codebase-models 1.0.7 → 2.0.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/.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 +7 -8
- package/dist/src/models/Announcement.js +30 -10
- package/dist/src/models/AppEvent.d.ts +1 -3
- package/dist/src/models/AppEvent.js +1 -1
- package/dist/src/models/Audience.d.ts +2 -3
- package/dist/src/models/Audience.js +6 -1
- package/dist/src/models/{Experiments.d.ts → BqPreCompiledData.d.ts} +12 -32
- package/dist/src/models/{ClientExperiment.js → BqPreCompiledData.js} +26 -46
- package/dist/src/models/CVRReport.d.ts +2 -3
- package/dist/src/models/CVRReport.js +14 -1
- package/dist/src/models/Client.d.ts +2 -4
- package/dist/src/models/Client.js +32 -52
- package/dist/src/models/ClientAdditionalRevenue.d.ts +2 -4
- package/dist/src/models/ClientAdditionalRevenue.js +4 -3
- package/dist/src/models/ClientLearning.d.ts +2 -4
- package/dist/src/models/ClientLearning.js +11 -7
- package/dist/src/models/ClientLinks.d.ts +2 -4
- package/dist/src/models/ClientLinks.js +16 -7
- package/dist/src/models/ClientNextSteps.d.ts +2 -4
- package/dist/src/models/ClientNextSteps.js +4 -3
- package/dist/src/models/ClientNote.d.ts +2 -4
- package/dist/src/models/ClientNote.js +4 -3
- package/dist/src/models/ClientReportsTemp.d.ts +2 -4
- package/dist/src/models/ClientReportsTemp.js +21 -3
- package/dist/src/models/ClientRetention.d.ts +2 -3
- package/dist/src/models/ClientRetention.js +19 -1
- package/dist/src/models/ClientScript.d.ts +2 -4
- package/dist/src/models/ClientScript.js +25 -9
- package/dist/src/models/ClientStrategy.d.ts +2 -4
- package/dist/src/models/ClientStrategy.js +4 -3
- package/dist/src/models/ClientSurvay.d.ts +2 -7
- package/dist/src/models/ClientSurvay.js +6 -1
- package/dist/src/models/Environment.d.ts +3 -3
- package/dist/src/models/Environment.js +27 -3
- package/dist/src/models/Faqs.d.ts +2 -3
- package/dist/src/models/Faqs.js +6 -1
- package/dist/src/models/Feedback.d.ts +2 -4
- package/dist/src/models/Feedback.js +4 -3
- package/dist/src/models/Goal.d.ts +3 -4
- package/dist/src/models/Goal.js +34 -12
- package/dist/src/models/Hypothesis.d.ts +3 -3
- package/dist/src/models/Hypothesis.js +50 -10
- package/dist/src/models/HypothesisSheet.d.ts +2 -4
- package/dist/src/models/HypothesisSheet.js +27 -3
- package/dist/src/models/LandingPages.d.ts +4 -3
- package/dist/src/models/LandingPages.js +30 -1
- package/dist/src/models/NewIdeas.d.ts +2 -4
- package/dist/src/models/NewIdeas.js +4 -3
- package/dist/src/models/Notification.d.ts +2 -3
- package/dist/src/models/Notification.js +30 -2
- package/dist/src/models/{ClientExperiment.d.ts → Organization.d.ts} +18 -31
- package/dist/src/models/{Experiments.js → Organization.js} +36 -54
- package/dist/src/models/Page.d.ts +4 -4
- package/dist/src/models/Page.js +57 -5
- package/dist/src/models/PageElement.d.ts +4 -3
- package/dist/src/models/PageElement.js +60 -8
- package/dist/src/models/PageTestType.d.ts +3 -3
- package/dist/src/models/PageTestType.js +42 -6
- package/dist/src/models/Portfolio.d.ts +2 -3
- package/dist/src/models/Portfolio.js +6 -1
- package/dist/src/models/PrecalculationFilters.d.ts +34 -0
- package/dist/src/models/PrecalculationFilters.js +78 -0
- package/dist/src/models/QueryLog.d.ts +2 -4
- package/dist/src/models/QueryLog.js +4 -3
- package/dist/src/models/ReadNotification.d.ts +2 -3
- package/dist/src/models/ReadNotification.js +30 -2
- package/dist/src/models/Report.d.ts +3 -4
- package/dist/src/models/Report.js +33 -49
- package/dist/src/models/Role.d.ts +4 -3
- package/dist/src/models/Role.js +51 -8
- package/dist/src/models/SavedSegment.d.ts +2 -3
- package/dist/src/models/SavedSegment.js +6 -1
- package/dist/src/models/Segment.d.ts +2 -3
- package/dist/src/models/Segment.js +6 -1
- package/dist/src/models/SegmentCombination.d.ts +2 -3
- package/dist/src/models/SegmentCombination.js +6 -1
- package/dist/src/models/Snippet.d.ts +3 -4
- package/dist/src/models/Snippet.js +29 -4
- package/dist/src/models/StageInCustomerJourney.d.ts +4 -4
- package/dist/src/models/StageInCustomerJourney.js +56 -4
- package/dist/src/models/Tag.d.ts +2 -3
- package/dist/src/models/Tag.js +30 -2
- package/dist/src/models/Temp.d.ts +2 -3
- package/dist/src/models/Temp.js +30 -2
- package/dist/src/models/Test.d.ts +17 -18
- package/dist/src/models/Test.js +83 -186
- package/dist/src/models/TestSequentialValue.d.ts +2 -3
- package/dist/src/models/TestSequentialValue.js +6 -1
- package/dist/src/models/Tier.d.ts +2 -3
- package/dist/src/models/Tier.js +30 -2
- package/dist/src/models/Trigger.d.ts +2 -3
- package/dist/src/models/Trigger.js +30 -2
- package/dist/src/models/User.d.ts +2 -3
- package/dist/src/models/User.js +10 -11
- package/index.ts +6 -4
- package/package.json +1 -1
- package/src/models/Announcement.ts +51 -28
- package/src/models/AppEvent.ts +1 -1
- package/src/models/Audience.ts +7 -1
- package/src/models/BqPreCompiledData.ts +62 -0
- package/src/models/CVRReport.ts +18 -1
- package/src/models/Client.ts +40 -60
- package/src/models/ClientAdditionalRevenue.ts +5 -4
- package/src/models/ClientLearning.ts +12 -8
- package/src/models/ClientLinks.ts +19 -8
- package/src/models/ClientNextSteps.ts +5 -4
- package/src/models/ClientNote.ts +5 -4
- package/src/models/ClientReportsTemp.ts +25 -4
- package/src/models/ClientRetention.ts +28 -2
- package/src/models/ClientScript.ts +27 -10
- package/src/models/ClientStrategy.ts +5 -4
- package/src/models/ClientSurvay.ts +7 -1
- package/src/models/Environment.ts +32 -4
- package/src/models/Faqs.ts +7 -1
- package/src/models/Feedback.ts +5 -4
- package/src/models/Goal.ts +37 -13
- package/src/models/Hypothesis.ts +30 -9
- package/src/models/HypothesisSheet.ts +4 -3
- package/src/models/LandingPages.ts +35 -1
- package/src/models/NewIdeas.ts +5 -4
- package/src/models/Notification.ts +7 -1
- package/src/models/Organization.ts +86 -0
- package/src/models/Page.ts +63 -6
- package/src/models/PageElement.ts +39 -8
- package/src/models/PageTestType.ts +22 -5
- package/src/models/Portfolio.ts +7 -1
- package/src/models/PrecalculationFilters.ts +68 -0
- package/src/models/QueryLog.ts +5 -4
- package/src/models/ReadNotification.ts +7 -1
- package/src/models/Report.ts +55 -67
- package/src/models/Role.ts +32 -7
- package/src/models/SavedSegment.ts +7 -1
- package/src/models/Segment.ts +7 -1
- package/src/models/SegmentCombination.ts +7 -1
- package/src/models/Snippet.ts +33 -5
- package/src/models/StageInCustomerJourney.ts +34 -6
- package/src/models/Tag.ts +7 -1
- package/src/models/Temp.ts +7 -1
- package/src/models/Test.ts +156 -244
- package/src/models/TestSequentialValue.ts +7 -1
- package/src/models/Tier.ts +7 -1
- package/src/models/Trigger.ts +7 -1
- package/src/models/User.ts +12 -11
- package/src/models/ClientExperiment.ts +0 -113
- package/src/models/Experiments.ts +0 -118
|
@@ -6,7 +6,7 @@ export interface IClientScriptSchema extends Document {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface IClientScript extends Document {
|
|
9
|
-
|
|
9
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
10
|
client?: mongoose.Schema.Types.ObjectId;
|
|
11
11
|
viewId?: string;
|
|
12
12
|
clientScriptURL: string;
|
|
@@ -41,23 +41,28 @@ export interface IClientScript extends Document {
|
|
|
41
41
|
|
|
42
42
|
const ClientScriptSchema = new Schema<IClientScript>(
|
|
43
43
|
{
|
|
44
|
-
|
|
45
|
-
type:
|
|
44
|
+
organizationId: {
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: "organization",
|
|
46
47
|
default: null,
|
|
47
48
|
},
|
|
48
49
|
client: {
|
|
49
50
|
type: mongoose.Schema.Types.ObjectId,
|
|
50
51
|
ref: "client",
|
|
52
|
+
index: true,
|
|
51
53
|
},
|
|
52
54
|
viewId: {
|
|
53
55
|
type: String,
|
|
56
|
+
index: true,
|
|
54
57
|
},
|
|
55
58
|
clientScriptURL: {
|
|
56
59
|
type: String,
|
|
60
|
+
trim: true,
|
|
57
61
|
},
|
|
58
62
|
jquery_include: {
|
|
59
63
|
type: String,
|
|
60
64
|
default: "false",
|
|
65
|
+
trim: true,
|
|
61
66
|
},
|
|
62
67
|
debug: {
|
|
63
68
|
type: Boolean,
|
|
@@ -76,6 +81,7 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
76
81
|
},
|
|
77
82
|
activation_mode: {
|
|
78
83
|
type: String,
|
|
84
|
+
trim: true,
|
|
79
85
|
},
|
|
80
86
|
use_antiflicker: {
|
|
81
87
|
type: Boolean,
|
|
@@ -87,17 +93,21 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
87
93
|
},
|
|
88
94
|
rules: {
|
|
89
95
|
type: String,
|
|
90
|
-
default: "return true;"
|
|
96
|
+
default: "return true;",
|
|
97
|
+
trim: true,
|
|
91
98
|
},
|
|
92
99
|
rules_tracking: {
|
|
93
100
|
type: String,
|
|
94
|
-
default: "return true;"
|
|
101
|
+
default: "return true;",
|
|
102
|
+
trim: true,
|
|
95
103
|
},
|
|
96
104
|
tracker_url: {
|
|
97
105
|
type: String,
|
|
106
|
+
trim: true,
|
|
98
107
|
},
|
|
99
108
|
asset_url: {
|
|
100
109
|
type: String,
|
|
110
|
+
trim: true,
|
|
101
111
|
},
|
|
102
112
|
metadata_key_exp_1: {
|
|
103
113
|
type: mongoose.Schema.Types.Mixed,
|
|
@@ -119,6 +129,7 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
119
129
|
},
|
|
120
130
|
cookie_domain: {
|
|
121
131
|
type: String,
|
|
132
|
+
trim: true,
|
|
122
133
|
},
|
|
123
134
|
snippet_version: {
|
|
124
135
|
type: Number,
|
|
@@ -126,6 +137,7 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
126
137
|
storage: {
|
|
127
138
|
type: String,
|
|
128
139
|
default: "default",
|
|
140
|
+
trim: true,
|
|
129
141
|
},
|
|
130
142
|
run_only_on_reinit: {
|
|
131
143
|
type: Boolean,
|
|
@@ -140,9 +152,11 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
140
152
|
},
|
|
141
153
|
jscode: {
|
|
142
154
|
type: String,
|
|
155
|
+
trim: true,
|
|
143
156
|
},
|
|
144
157
|
csscode: {
|
|
145
158
|
type: String,
|
|
159
|
+
trim: true,
|
|
146
160
|
},
|
|
147
161
|
is_spa: {
|
|
148
162
|
type: Boolean,
|
|
@@ -154,11 +168,14 @@ const ClientScriptSchema = new Schema<IClientScript>(
|
|
|
154
168
|
}
|
|
155
169
|
);
|
|
156
170
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
171
|
+
// Compound indexes for common query patterns
|
|
172
|
+
ClientScriptSchema.index({ client: 1 });
|
|
173
|
+
// Sparse indexes for optional fields
|
|
174
|
+
ClientScriptSchema.index({ organisationId: 1 }, { sparse: true });
|
|
175
|
+
ClientScriptSchema.index({ tracker_url: 1 }, { sparse: true });
|
|
176
|
+
ClientScriptSchema.index({ asset_url: 1 }, { sparse: true });
|
|
177
|
+
|
|
161
178
|
|
|
162
|
-
const ClientScript = model<IClientScript>("clientscript", ClientScriptSchema);
|
|
179
|
+
const ClientScript = mongoose.models.clientscript || model<IClientScript>("clientscript", ClientScriptSchema);
|
|
163
180
|
|
|
164
181
|
export default ClientScript;
|
|
@@ -6,7 +6,7 @@ export interface IClientStrategy extends Document {
|
|
|
6
6
|
startDate?: Date;
|
|
7
7
|
endDate?: Date;
|
|
8
8
|
strategies?: mongoose.Schema.Types.Mixed;
|
|
9
|
-
|
|
9
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
10
|
client?: mongoose.Schema.Types.ObjectId;
|
|
11
11
|
learningsoftime?: mongoose.Schema.Types.Mixed;
|
|
12
12
|
viewId?: string;
|
|
@@ -32,8 +32,9 @@ const ClientStrategySchema = new Schema<IClientStrategy>(
|
|
|
32
32
|
strategies: {
|
|
33
33
|
type: mongoose.Schema.Types.Mixed,
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
type:
|
|
35
|
+
organizationId: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: "organization",
|
|
37
38
|
default: null,
|
|
38
39
|
},
|
|
39
40
|
client: {
|
|
@@ -63,7 +64,7 @@ ClientStrategySchema.index({
|
|
|
63
64
|
viewId: 1,
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
const ClientStrategy = model<IClientStrategy>(
|
|
67
|
+
const ClientStrategy = mongoose.models.clientstrategy || model<IClientStrategy>(
|
|
67
68
|
"clientstrategy",
|
|
68
69
|
ClientStrategySchema
|
|
69
70
|
);
|
|
@@ -3,6 +3,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
3
3
|
export interface IClientSurvay extends Document {
|
|
4
4
|
responses: IResponce;
|
|
5
5
|
user?: mongoose.Schema.Types.ObjectId;
|
|
6
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export interface IResponce extends Document {
|
|
@@ -26,11 +27,16 @@ const ClientSurveySchema = new Schema<IClientSurvay>(
|
|
|
26
27
|
type: mongoose.Schema.Types.ObjectId,
|
|
27
28
|
ref: "user",
|
|
28
29
|
},
|
|
30
|
+
organizationId: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "organization",
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
29
35
|
},
|
|
30
36
|
{
|
|
31
37
|
timestamps: true,
|
|
32
38
|
}
|
|
33
39
|
);
|
|
34
40
|
|
|
35
|
-
const ClientSurvey = model("clientsurvey", ClientSurveySchema);
|
|
41
|
+
const ClientSurvey = mongoose.models.clientsurvey || model("clientsurvey", ClientSurveySchema);
|
|
36
42
|
export default ClientSurvey;
|
|
@@ -4,26 +4,54 @@ export interface IEnvironment extends Document {
|
|
|
4
4
|
name: string;
|
|
5
5
|
rules_js?: string;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
8
|
+
isActive?: boolean;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
const EnvironmentSchema = new Schema<IEnvironment>({
|
|
10
12
|
name: {
|
|
11
13
|
type: String,
|
|
12
14
|
required: true,
|
|
13
|
-
default: 'Default'
|
|
15
|
+
default: 'Default',
|
|
16
|
+
trim: true,
|
|
17
|
+
index: true,
|
|
14
18
|
},
|
|
15
19
|
client: {
|
|
16
20
|
type: mongoose.Schema.Types.ObjectId,
|
|
17
21
|
ref: "client",
|
|
22
|
+
required: true,
|
|
23
|
+
index: true,
|
|
24
|
+
},
|
|
25
|
+
organizationId: {
|
|
26
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
+
ref: "organization",
|
|
28
|
+
index: true,
|
|
18
29
|
},
|
|
19
30
|
rules_js: {
|
|
20
31
|
type: String,
|
|
21
|
-
default: "return true"
|
|
32
|
+
default: "return true",
|
|
33
|
+
trim: true,
|
|
22
34
|
},
|
|
23
|
-
|
|
35
|
+
isActive: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: true,
|
|
38
|
+
index: true,
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
24
41
|
timestamps: true
|
|
25
42
|
});
|
|
26
43
|
|
|
27
|
-
|
|
44
|
+
// Compound indexes for common query patterns
|
|
45
|
+
EnvironmentSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
46
|
+
EnvironmentSchema.index({ client: 1, isActive: 1 });
|
|
47
|
+
EnvironmentSchema.index({ organizationId: 1, client: 1 });
|
|
48
|
+
EnvironmentSchema.index({ organizationId: 1, name: 1 }, {
|
|
49
|
+
sparse: true,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Text index for full-text search
|
|
53
|
+
EnvironmentSchema.index({ name: 'text' });
|
|
54
|
+
|
|
55
|
+
const Environment = mongoose.models.environment || model<IEnvironment>("environment", EnvironmentSchema);
|
|
28
56
|
|
|
29
57
|
export default Environment;
|
package/src/models/Faqs.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface IFaqs extends Document {
|
|
|
6
6
|
keywords?: mongoose.Schema.Types.Array;
|
|
7
7
|
createdAt?: Date;
|
|
8
8
|
updatedAt?: Date;
|
|
9
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const FaqSchema = new Schema<IFaqs>({
|
|
@@ -26,7 +27,12 @@ const FaqSchema = new Schema<IFaqs>({
|
|
|
26
27
|
type: Date,
|
|
27
28
|
default: new Date(),
|
|
28
29
|
},
|
|
30
|
+
organizationId: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "organization",
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
29
35
|
});
|
|
30
36
|
|
|
31
|
-
const Faq = model<IFaqs>("faq", FaqSchema);
|
|
37
|
+
const Faq = mongoose.models.faq || model<IFaqs>("faq", FaqSchema);
|
|
32
38
|
export default Faq;
|
package/src/models/Feedback.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface IFeedback extends Document {
|
|
|
5
5
|
details?: string;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
thread?: mongoose.Schema.Types.Mixed;
|
|
8
|
-
|
|
8
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
9
9
|
createdAt?: Date;
|
|
10
10
|
updatedAt?: Date;
|
|
11
11
|
}
|
|
@@ -27,8 +27,9 @@ const FeedbackSchema = new Schema<IFeedback>({
|
|
|
27
27
|
type: mongoose.Schema.Types.Mixed,
|
|
28
28
|
default: [],
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
type:
|
|
30
|
+
organizationId: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "organization",
|
|
32
33
|
default: null,
|
|
33
34
|
},
|
|
34
35
|
createdAt: {
|
|
@@ -41,6 +42,6 @@ const FeedbackSchema = new Schema<IFeedback>({
|
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
|
|
44
|
-
const Feedback = model<IFeedback>("feedback", FeedbackSchema);
|
|
45
|
+
const Feedback = mongoose.models.feedback || model<IFeedback>("feedback", FeedbackSchema);
|
|
45
46
|
|
|
46
47
|
export default Feedback;
|
package/src/models/Goal.ts
CHANGED
|
@@ -6,13 +6,14 @@ export interface IGoal extends Document {
|
|
|
6
6
|
name: string;
|
|
7
7
|
details?: string;
|
|
8
8
|
slug?: string;
|
|
9
|
-
|
|
9
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
10
|
client?: mongoose.Schema.Types.ObjectId;
|
|
11
11
|
type: string;
|
|
12
12
|
counting_method: string;
|
|
13
13
|
css_selector: string;
|
|
14
14
|
api_name: string;
|
|
15
15
|
rules_js: string;
|
|
16
|
+
isActive?: boolean;
|
|
16
17
|
createdAt?: Date;
|
|
17
18
|
updatedAt?: Date;
|
|
18
19
|
}
|
|
@@ -21,45 +22,68 @@ const GoalSchema = new Schema<IGoal>({
|
|
|
21
22
|
name: {
|
|
22
23
|
type: String,
|
|
23
24
|
required: true,
|
|
25
|
+
trim: true,
|
|
26
|
+
index: true,
|
|
24
27
|
},
|
|
25
28
|
details: {
|
|
26
29
|
type: String,
|
|
27
30
|
default: "",
|
|
31
|
+
trim: true,
|
|
28
32
|
},
|
|
29
33
|
slug: {
|
|
30
34
|
type: String,
|
|
35
|
+
unique: true,
|
|
36
|
+
sparse: true,
|
|
31
37
|
},
|
|
32
|
-
|
|
33
|
-
type:
|
|
38
|
+
organizationId: {
|
|
39
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
40
|
+
ref: "organization",
|
|
34
41
|
default: null,
|
|
42
|
+
index: true,
|
|
35
43
|
},
|
|
36
44
|
client: {
|
|
37
45
|
type: mongoose.Schema.Types.ObjectId,
|
|
38
46
|
ref: "client",
|
|
47
|
+
index: true,
|
|
39
48
|
},
|
|
40
49
|
type: {
|
|
41
50
|
type: String,
|
|
51
|
+
trim: true,
|
|
42
52
|
},
|
|
43
53
|
counting_method: {
|
|
44
54
|
type: String,
|
|
55
|
+
trim: true,
|
|
45
56
|
},
|
|
46
57
|
css_selector: {
|
|
47
58
|
type: String,
|
|
59
|
+
trim: true,
|
|
60
|
+
},
|
|
61
|
+
api_name: {
|
|
62
|
+
type: String,
|
|
63
|
+
slug: ["name"],
|
|
64
|
+
slugPaddingSize: 4,
|
|
65
|
+
unique: true,
|
|
66
|
+
trim: true,
|
|
48
67
|
},
|
|
49
|
-
api_name: { type: String, slug: ["name"], slugPaddingSize: 4, unique: true },
|
|
50
68
|
rules_js: {
|
|
51
69
|
type: String,
|
|
70
|
+
trim: true,
|
|
52
71
|
},
|
|
53
|
-
|
|
54
|
-
type:
|
|
55
|
-
default:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
72
|
+
isActive: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true,
|
|
75
|
+
index: true,
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
timestamps: true
|
|
61
79
|
});
|
|
62
80
|
|
|
63
|
-
|
|
81
|
+
// Compound indexes for common query patterns
|
|
82
|
+
GoalSchema.index({ client: 1});
|
|
83
|
+
GoalSchema.index({ client: 1, isActive: 1 });
|
|
84
|
+
GoalSchema.index({ organizationId: 1, client: 1 });
|
|
85
|
+
GoalSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
86
|
+
|
|
87
|
+
const Goal = mongoose.models.goal || model<IGoal>("goal", GoalSchema);
|
|
64
88
|
|
|
65
89
|
export default Goal;
|
package/src/models/Hypothesis.ts
CHANGED
|
@@ -1,50 +1,71 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IHypothesis extends Document {
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
4
5
|
hypothesisNumber?: string;
|
|
5
6
|
name: string;
|
|
6
7
|
action: string;
|
|
7
8
|
result: string;
|
|
8
9
|
expectation: string;
|
|
9
10
|
tagged?: string;
|
|
11
|
+
isActive?: boolean;
|
|
10
12
|
createdAt?: Date;
|
|
11
13
|
updatedAt?: Date;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const HypothesisSchema = new Schema<IHypothesis>({
|
|
17
|
+
organizationId: {
|
|
18
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
+
ref: "organization",
|
|
20
|
+
default: null,
|
|
21
|
+
},
|
|
15
22
|
hypothesisNumber: {
|
|
16
23
|
type: String,
|
|
24
|
+
trim: true,
|
|
25
|
+
index: true,
|
|
17
26
|
},
|
|
18
27
|
name: {
|
|
19
28
|
type: String,
|
|
20
29
|
required: true,
|
|
30
|
+
trim: true,
|
|
31
|
+
index: true,
|
|
21
32
|
},
|
|
22
33
|
action: {
|
|
23
34
|
type: String,
|
|
24
35
|
required: true,
|
|
36
|
+
trim: true,
|
|
25
37
|
},
|
|
26
38
|
result: {
|
|
27
39
|
type: String,
|
|
28
40
|
required: true,
|
|
41
|
+
trim: true,
|
|
29
42
|
},
|
|
30
43
|
expectation: {
|
|
31
44
|
type: String,
|
|
32
45
|
required: true,
|
|
46
|
+
trim: true,
|
|
33
47
|
},
|
|
34
48
|
tagged: {
|
|
35
49
|
type: String,
|
|
36
50
|
default: "General Purpose",
|
|
51
|
+
trim: true,
|
|
52
|
+
index: true,
|
|
37
53
|
},
|
|
38
|
-
|
|
39
|
-
type:
|
|
40
|
-
default:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
54
|
+
isActive: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true,
|
|
57
|
+
index: true,
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
timestamps: true
|
|
46
61
|
});
|
|
47
62
|
|
|
48
|
-
|
|
63
|
+
// Compound indexes for common query patterns
|
|
64
|
+
HypothesisSchema.index({ hypothesisNumber: 1, isActive: 1 });
|
|
65
|
+
HypothesisSchema.index({ tagged: 1, isActive: 1 });
|
|
66
|
+
HypothesisSchema.index({ name: 1, isActive: 1 });
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const Hypothesis = mongoose.models.hypothesis || model<IHypothesis>("hypothesis", HypothesisSchema);
|
|
49
70
|
|
|
50
71
|
export default Hypothesis;
|
|
@@ -2,7 +2,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
import HypothesisSheetConstants from "../constant";
|
|
3
3
|
|
|
4
4
|
export interface IHypothesisSheet extends Document {
|
|
5
|
-
organizationId?:
|
|
5
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
viewId?: string;
|
|
8
8
|
pageelement?: mongoose.Schema.Types.ObjectId;
|
|
@@ -25,8 +25,9 @@ export interface IHypothesisSheet extends Document {
|
|
|
25
25
|
const HypothesisSheetSchema = new Schema<IHypothesisSheet>(
|
|
26
26
|
{
|
|
27
27
|
organizationId: {
|
|
28
|
-
type:
|
|
28
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
29
29
|
default: null,
|
|
30
|
+
ref: "organization",
|
|
30
31
|
},
|
|
31
32
|
client: {
|
|
32
33
|
type: Schema.Types.ObjectId,
|
|
@@ -106,7 +107,7 @@ const HypothesisSheetSchema = new Schema<IHypothesisSheet>(
|
|
|
106
107
|
}
|
|
107
108
|
);
|
|
108
109
|
|
|
109
|
-
const HypothesisSheet = model<IHypothesisSheet>(
|
|
110
|
+
const HypothesisSheet = mongoose.models.hypothesissheet || model<IHypothesisSheet>(
|
|
110
111
|
"hypothesisSheet",
|
|
111
112
|
HypothesisSheetSchema
|
|
112
113
|
);
|
|
@@ -2,19 +2,29 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
export interface ILandingPagesData extends Document {
|
|
4
4
|
conversionRate?: Number;
|
|
5
|
+
lastUpdated?: Date;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
const LandingPageDataSchema = new Schema<ILandingPagesData>({
|
|
8
9
|
conversionRate: {
|
|
9
10
|
type: Number,
|
|
11
|
+
min: 0,
|
|
12
|
+
max: 100,
|
|
13
|
+
index: true,
|
|
10
14
|
},
|
|
15
|
+
lastUpdated: {
|
|
16
|
+
type: Date,
|
|
17
|
+
default: Date.now,
|
|
18
|
+
}
|
|
11
19
|
});
|
|
12
20
|
|
|
13
21
|
export interface ILandingPages extends Document {
|
|
14
22
|
title: string;
|
|
15
23
|
client?: mongoose.Schema.Types.ObjectId;
|
|
24
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
16
25
|
screenshot?: string;
|
|
17
26
|
dataPoints?: ILandingPagesData;
|
|
27
|
+
isActive?: boolean;
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
const LandingPagesSchema = new Schema<ILandingPages>(
|
|
@@ -22,25 +32,49 @@ const LandingPagesSchema = new Schema<ILandingPages>(
|
|
|
22
32
|
title: {
|
|
23
33
|
type: String,
|
|
24
34
|
required: true,
|
|
35
|
+
trim: true,
|
|
36
|
+
index: true,
|
|
25
37
|
},
|
|
26
38
|
client: {
|
|
27
39
|
type: mongoose.Schema.Types.ObjectId,
|
|
28
40
|
ref: "client",
|
|
29
41
|
required: true,
|
|
42
|
+
index: true,
|
|
43
|
+
},
|
|
44
|
+
organizationId: {
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: "organization",
|
|
47
|
+
index: true,
|
|
30
48
|
},
|
|
31
49
|
screenshot: {
|
|
32
50
|
type: String,
|
|
33
51
|
default: null,
|
|
52
|
+
trim: true,
|
|
34
53
|
},
|
|
35
54
|
dataPoints: {
|
|
36
55
|
type: LandingPageDataSchema,
|
|
37
56
|
default: {},
|
|
38
57
|
},
|
|
58
|
+
isActive: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true,
|
|
61
|
+
index: true,
|
|
62
|
+
}
|
|
39
63
|
},
|
|
40
64
|
{
|
|
41
65
|
timestamps: true,
|
|
42
66
|
}
|
|
43
67
|
);
|
|
44
68
|
|
|
45
|
-
|
|
69
|
+
// Compound indexes for common query patterns
|
|
70
|
+
LandingPagesSchema.index({ client: 1, title: 1 }, { unique: true });
|
|
71
|
+
LandingPagesSchema.index({ client: 1, isActive: 1 });
|
|
72
|
+
LandingPagesSchema.index({ organizationId: 1, client: 1 });
|
|
73
|
+
LandingPagesSchema.index({ organizationId: 1, title: 1 });
|
|
74
|
+
LandingPagesSchema.index({ client: 1, 'dataPoints.conversionRate': -1 });
|
|
75
|
+
|
|
76
|
+
// Text index for full-text search
|
|
77
|
+
LandingPagesSchema.index({ title: 'text' });
|
|
78
|
+
|
|
79
|
+
const LandingPages = mongoose.models.landingpages || model<ILandingPages>("landingpages", LandingPagesSchema);
|
|
46
80
|
export default LandingPages;
|
package/src/models/NewIdeas.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface INewIdeas extends Document {
|
|
4
|
-
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
ideaName: string;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
hypothesis?: mongoose.Schema.Types.ObjectId;
|
|
@@ -14,8 +14,9 @@ export interface INewIdeas extends Document {
|
|
|
14
14
|
|
|
15
15
|
const NewIdeasSchema = new Schema<INewIdeas>(
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
type:
|
|
17
|
+
organizationId: {
|
|
18
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
+
ref: "organization",
|
|
19
20
|
default: null,
|
|
20
21
|
},
|
|
21
22
|
ideaName: {
|
|
@@ -59,5 +60,5 @@ NewIdeasSchema.index({
|
|
|
59
60
|
viewId: 1,
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
const NewIdeas = model<INewIdeas>("
|
|
63
|
+
const NewIdeas = mongoose.models.newideas || model<INewIdeas>("newideas", NewIdeasSchema);
|
|
63
64
|
export default NewIdeas;
|
|
@@ -8,10 +8,16 @@ export interface INotification extends Document {
|
|
|
8
8
|
archive?: boolean;
|
|
9
9
|
module?: string;
|
|
10
10
|
moduleData?: string;
|
|
11
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const NotificationSchema = new Schema<INotification>(
|
|
14
15
|
{
|
|
16
|
+
organizationId: {
|
|
17
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
18
|
+
ref: "organization",
|
|
19
|
+
default: null,
|
|
20
|
+
},
|
|
15
21
|
title: {
|
|
16
22
|
type: String,
|
|
17
23
|
},
|
|
@@ -42,6 +48,6 @@ const NotificationSchema = new Schema<INotification>(
|
|
|
42
48
|
}
|
|
43
49
|
);
|
|
44
50
|
|
|
45
|
-
const Notification = model<INotification>("notification", NotificationSchema);
|
|
51
|
+
const Notification = mongoose.models.notification || model<INotification>("notification", NotificationSchema);
|
|
46
52
|
|
|
47
53
|
export default Notification;
|