codebase-models 1.0.6 → 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 +5 -4
- package/dist/index.js +20 -11
- package/dist/src/models/Announcement.d.ts +6 -5
- package/dist/src/models/Announcement.js +29 -9
- package/dist/src/models/Audience.d.ts +2 -1
- package/dist/src/models/Audience.js +6 -1
- 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 +3 -1
- package/dist/src/models/Client.js +31 -45
- 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 +25 -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 -0
- package/dist/src/models/Report.js +35 -47
- 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 +18 -17
- 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
|
@@ -1,7 +1,35 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mongoose_1 = require("mongoose");
|
|
26
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
4
27
|
const TriggerSchema = new mongoose_1.Schema({
|
|
28
|
+
organizationId: {
|
|
29
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
30
|
+
ref: "organization",
|
|
31
|
+
default: null,
|
|
32
|
+
},
|
|
5
33
|
name: {
|
|
6
34
|
type: String,
|
|
7
35
|
},
|
|
@@ -35,6 +35,7 @@ export interface IUser extends Document {
|
|
|
35
35
|
createdAt: Date;
|
|
36
36
|
updatedAt: Date;
|
|
37
37
|
resetLink: string;
|
|
38
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
38
39
|
}
|
|
39
40
|
declare const User: mongoose.Model<IUser, {}, {}, {}, mongoose.Document<unknown, {}, IUser> & IUser & {
|
|
40
41
|
_id: mongoose.Types.ObjectId;
|
package/dist/src/models/User.js
CHANGED
|
@@ -53,18 +53,17 @@ const UserSchema = new mongoose_1.Schema({
|
|
|
53
53
|
type: Boolean,
|
|
54
54
|
default: false,
|
|
55
55
|
},
|
|
56
|
-
|
|
57
|
-
type:
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
updatedAt: {
|
|
61
|
-
type: Date,
|
|
62
|
-
default: new Date(),
|
|
63
|
-
},
|
|
64
|
-
resetLink: {
|
|
65
|
-
type: String,
|
|
56
|
+
organizationId: {
|
|
57
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
58
|
+
ref: "organization",
|
|
66
59
|
default: null,
|
|
67
60
|
},
|
|
61
|
+
}, {
|
|
62
|
+
timestamps: true
|
|
68
63
|
});
|
|
64
|
+
// Add compound indexes for common query patterns
|
|
65
|
+
UserSchema.index({ organizationId: 1, role: 1 });
|
|
66
|
+
UserSchema.index({ organizationId: 1, client: 1 });
|
|
67
|
+
UserSchema.index({ email: 1 }, { unique: true });
|
|
69
68
|
const User = (0, mongoose_1.model)("user", UserSchema);
|
|
70
69
|
exports.default = User;
|
package/index.ts
CHANGED
|
@@ -18,7 +18,6 @@ import ClientRetention from "./src/models/ClientRetention";
|
|
|
18
18
|
import ClientStrategy from "./src/models/ClientStrategy";
|
|
19
19
|
import ClientSurvey from "./src/models/ClientSurvay";
|
|
20
20
|
import CVRReport from "./src/models/CVRReport";
|
|
21
|
-
import Experiments from "./src/models/Experiments";
|
|
22
21
|
import Faq from "./src/models/Faqs";
|
|
23
22
|
import Feedback from "./src/models/Feedback";
|
|
24
23
|
import Goal from "./src/models/Goal";
|
|
@@ -32,6 +31,7 @@ import PageElement from "./src/models/PageElement";
|
|
|
32
31
|
import PageTestType from "./src/models/PageTestType";
|
|
33
32
|
import Portfolio from "./src/models/Portfolio";
|
|
34
33
|
import ReadNotification from "./src/models/ReadNotification";
|
|
34
|
+
import Organization from "./src/models/Organization";
|
|
35
35
|
import Role from "./src/models/Role";
|
|
36
36
|
import SavedSegment from "./src/models/SavedSegment";
|
|
37
37
|
import Segment from "./src/models/Segment";
|
|
@@ -43,9 +43,10 @@ import Temp from "./src/models/Temp";
|
|
|
43
43
|
import Tier from "./src/models/Tier";
|
|
44
44
|
import Trigger from "./src/models/Trigger";
|
|
45
45
|
import ClientScript from "./src/models/ClientScript";
|
|
46
|
-
import ClientExperiment from "./src/models/ClientExperiment";
|
|
47
46
|
import Audience from "./src/models/Audience";
|
|
48
47
|
import Environment from "./src/models/Environment";
|
|
48
|
+
import PrecalculationFilters from "./src/models/PrecalculationFilters";
|
|
49
|
+
import BqPreCompiledData from "./src/models/BqPreCompiledData";
|
|
49
50
|
|
|
50
51
|
async function seedRoles() {
|
|
51
52
|
const checkRoles = await Role.countDocuments();
|
|
@@ -113,7 +114,6 @@ export {
|
|
|
113
114
|
ClientStrategy,
|
|
114
115
|
ClientSurvey,
|
|
115
116
|
CVRReport,
|
|
116
|
-
Experiments,
|
|
117
117
|
Faq,
|
|
118
118
|
Feedback,
|
|
119
119
|
Goal,
|
|
@@ -138,7 +138,9 @@ export {
|
|
|
138
138
|
Tier,
|
|
139
139
|
Trigger,
|
|
140
140
|
ClientScript,
|
|
141
|
-
ClientExperiment,
|
|
142
141
|
Audience,
|
|
143
142
|
Environment,
|
|
143
|
+
Organization,
|
|
144
|
+
PrecalculationFilters,
|
|
145
|
+
BqPreCompiledData,
|
|
144
146
|
};
|
package/package.json
CHANGED
|
@@ -2,48 +2,71 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
export interface IAnnouncement extends Document {
|
|
4
4
|
title: string;
|
|
5
|
-
description?:
|
|
6
|
-
active?:
|
|
7
|
-
forRoles?: mongoose.Schema.Types.ObjectId;
|
|
8
|
-
forUsers?: mongoose.Schema.Types.ObjectId;
|
|
9
|
-
readBy?: mongoose.Schema.Types.ObjectId;
|
|
5
|
+
description?: string;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
forRoles?: mongoose.Schema.Types.ObjectId[];
|
|
8
|
+
forUsers?: mongoose.Schema.Types.ObjectId[];
|
|
9
|
+
readBy?: mongoose.Schema.Types.ObjectId[];
|
|
10
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const AnnouncementSchema = new Schema<IAnnouncement>(
|
|
13
14
|
{
|
|
14
|
-
|
|
15
|
-
type:
|
|
16
|
-
|
|
15
|
+
organizationId: {
|
|
16
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
+
ref: "organization",
|
|
18
|
+
default: null,
|
|
17
19
|
},
|
|
18
|
-
|
|
19
|
-
type: String,
|
|
20
|
-
required:
|
|
20
|
+
title: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
trim: true
|
|
21
24
|
},
|
|
22
|
-
|
|
23
|
-
type:
|
|
24
|
-
|
|
25
|
+
description: {
|
|
26
|
+
type: String,
|
|
27
|
+
trim: true
|
|
25
28
|
},
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
|
|
29
|
-
ref: "role",
|
|
29
|
+
active: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
33
|
-
required:
|
|
34
|
-
ref: "
|
|
33
|
+
forRoles: {
|
|
34
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
35
|
+
required: true,
|
|
36
|
+
ref: "role"
|
|
35
37
|
},
|
|
36
|
-
|
|
37
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
38
|
-
|
|
39
|
-
ref: "user",
|
|
38
|
+
forUsers: {
|
|
39
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
40
|
+
ref: "user"
|
|
40
41
|
},
|
|
42
|
+
readBy: {
|
|
43
|
+
type: [mongoose.Schema.Types.ObjectId],
|
|
44
|
+
ref: "user"
|
|
45
|
+
}
|
|
41
46
|
},
|
|
42
47
|
{
|
|
43
|
-
timestamps: true
|
|
48
|
+
timestamps: true
|
|
44
49
|
}
|
|
45
50
|
);
|
|
46
51
|
|
|
52
|
+
// Add compound indexes for better query performance
|
|
53
|
+
AnnouncementSchema.index({ active: 1, createdAt: -1 }); // For active announcements sorted by date
|
|
54
|
+
AnnouncementSchema.index({ forRoles: 1, active: 1 }); // For role-based announcements
|
|
55
|
+
AnnouncementSchema.index({ forUsers: 1, active: 1 }); // For user-specific announcements
|
|
56
|
+
AnnouncementSchema.index({ readBy: 1 }); // For tracking read status
|
|
57
|
+
AnnouncementSchema.index({ title: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive title search
|
|
58
|
+
|
|
59
|
+
// Add text index for full-text search
|
|
60
|
+
// AnnouncementSchema.index({
|
|
61
|
+
// title: 'text',
|
|
62
|
+
// description: 'text'
|
|
63
|
+
// }, {
|
|
64
|
+
// weights: {
|
|
65
|
+
// title: 10,
|
|
66
|
+
// description: 5
|
|
67
|
+
// }
|
|
68
|
+
// });
|
|
69
|
+
|
|
47
70
|
const Announcement = model<IAnnouncement>("announcement", AnnouncementSchema);
|
|
48
71
|
|
|
49
72
|
export default Announcement;
|
package/src/models/Audience.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IAudience extends Document {
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
4
5
|
name: string;
|
|
5
6
|
rules_js?: string;
|
|
6
7
|
client?: mongoose.Schema.Types.ObjectId;
|
|
@@ -8,6 +9,11 @@ export interface IAudience extends Document {
|
|
|
8
9
|
|
|
9
10
|
const AudienceSchema = new Schema<IAudience>(
|
|
10
11
|
{
|
|
12
|
+
organizationId: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: "organization",
|
|
15
|
+
default: null,
|
|
16
|
+
},
|
|
11
17
|
name: {
|
|
12
18
|
type: String,
|
|
13
19
|
required: true,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
|
|
3
|
+
export interface IBqPreCompiledData extends Document {
|
|
4
|
+
title: string;
|
|
5
|
+
organizationId: mongoose.Schema.Types.ObjectId;
|
|
6
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
test: mongoose.Schema.Types.ObjectId;
|
|
8
|
+
from: Date;
|
|
9
|
+
to: Date;
|
|
10
|
+
filters: any;
|
|
11
|
+
otherFilters: any;
|
|
12
|
+
cloudurl: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const BqPreCompiledDataSchema = new Schema<IBqPreCompiledData>({
|
|
16
|
+
title: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: null,
|
|
19
|
+
},
|
|
20
|
+
organizationId: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: "organization",
|
|
23
|
+
default: null,
|
|
24
|
+
},
|
|
25
|
+
client: {
|
|
26
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
+
ref: "client",
|
|
28
|
+
default: null,
|
|
29
|
+
},
|
|
30
|
+
test: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "test",
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
from: {
|
|
36
|
+
type: Date,
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
filters: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: null,
|
|
42
|
+
},
|
|
43
|
+
to: {
|
|
44
|
+
type: Date,
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
otherFilters: {
|
|
48
|
+
type: Object,
|
|
49
|
+
default: null,
|
|
50
|
+
},
|
|
51
|
+
cloudurl: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: null,
|
|
54
|
+
},
|
|
55
|
+
}, {
|
|
56
|
+
timestamps: true
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
BqPreCompiledDataSchema.index({ organizationId: 1, client: 1 });
|
|
60
|
+
const BqPreCompiledData = model<IBqPreCompiledData>("bqprecompileddata", BqPreCompiledDataSchema);
|
|
61
|
+
|
|
62
|
+
export default BqPreCompiledData;
|
package/src/models/CVRReport.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface ICVRReport extends Document {
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
4
5
|
reportLink?: string;
|
|
5
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const CVRReportSchema = new Schema<ICVRReport>(
|
|
9
10
|
{
|
|
11
|
+
organizationId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: "organization",
|
|
14
|
+
default: null,
|
|
15
|
+
},
|
|
10
16
|
reportLink: {
|
|
11
17
|
type: String,
|
|
12
18
|
default: null,
|
|
19
|
+
trim: true,
|
|
13
20
|
},
|
|
14
21
|
client: {
|
|
15
22
|
type: mongoose.Schema.Types.ObjectId,
|
|
16
23
|
ref: "client",
|
|
24
|
+
index: true,
|
|
17
25
|
},
|
|
18
26
|
},
|
|
19
27
|
{
|
|
@@ -21,5 +29,14 @@ const CVRReportSchema = new Schema<ICVRReport>(
|
|
|
21
29
|
}
|
|
22
30
|
);
|
|
23
31
|
|
|
32
|
+
// Compound index for client and reportLink
|
|
33
|
+
CVRReportSchema.index({ client: 1 });
|
|
34
|
+
|
|
35
|
+
// Sparse index for reportLink
|
|
36
|
+
CVRReportSchema.index({ reportLink: 1 }, { sparse: true });
|
|
37
|
+
|
|
38
|
+
// TTL index for automatic cleanup of old reports (1 year)
|
|
39
|
+
CVRReportSchema.index({ createdAt: 1 }, { expireAfterSeconds: 31536000 });
|
|
40
|
+
|
|
24
41
|
const CVRReport = model<ICVRReport>("cvrreport", CVRReportSchema);
|
|
25
42
|
export default CVRReport;
|
package/src/models/Client.ts
CHANGED
|
@@ -12,11 +12,11 @@ export interface IProperty extends Document {
|
|
|
12
12
|
const PropertySchema: Schema = new Schema<IProperty>({
|
|
13
13
|
propertyname: { type: String, required: true },
|
|
14
14
|
viewId: { type: String, required: true },
|
|
15
|
-
platform: { type: String,
|
|
15
|
+
platform: { type: String, default: "GA4" }
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
export interface IClient extends Document {
|
|
19
|
-
|
|
19
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
20
20
|
name: string;
|
|
21
21
|
slug?: string;
|
|
22
22
|
viewId?: string;
|
|
@@ -37,71 +37,51 @@ export interface IClient extends Document {
|
|
|
37
37
|
|
|
38
38
|
const ClientSchema: Schema = new Schema<IClient>(
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
default: null,
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
type: String,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
viewId: {
|
|
50
|
-
type: String,
|
|
51
|
-
},
|
|
52
|
-
portfolioClient: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false,
|
|
40
|
+
organizationId: { type: mongoose.Schema.Types.ObjectId,
|
|
41
|
+
ref: "organization",
|
|
42
|
+
default: null },
|
|
43
|
+
name: { type: String, required: true },
|
|
44
|
+
slug: {
|
|
45
|
+
type: String,
|
|
46
|
+
slug: ["name"],
|
|
47
|
+
slugPaddingSize: 4,
|
|
48
|
+
unique: true
|
|
55
49
|
},
|
|
50
|
+
viewId: { type: String },
|
|
51
|
+
portfolioClient: { type: Boolean, default: false },
|
|
56
52
|
gaproperties: [PropertySchema],
|
|
57
|
-
tier: {
|
|
58
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
59
|
-
ref: "tier",
|
|
60
|
-
default: null
|
|
61
|
-
},
|
|
62
|
-
active: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
default: true,
|
|
65
|
-
},
|
|
66
|
-
currency: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: "USD",
|
|
69
|
-
},
|
|
70
|
-
logo: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: "",
|
|
73
|
-
},
|
|
74
|
-
createdBy: {
|
|
75
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
76
|
-
ref: "user",
|
|
77
|
-
default: null,
|
|
78
|
-
},
|
|
79
|
-
onboardDate: {
|
|
80
|
-
type: Date,
|
|
81
|
-
default: new Date(),
|
|
82
|
-
},
|
|
83
|
-
bqClientId: {
|
|
84
|
-
type: String,
|
|
85
|
-
default: null,
|
|
86
|
-
},
|
|
87
|
-
defaultDataSet: {
|
|
88
|
-
type: String,
|
|
89
|
-
},
|
|
90
|
-
NDAStatus: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: false,
|
|
93
|
-
},
|
|
94
|
-
retainerValue: {
|
|
95
|
-
type: Number,
|
|
53
|
+
tier: {
|
|
54
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
+
ref: "tier",
|
|
56
|
+
default: null
|
|
96
57
|
},
|
|
97
|
-
|
|
98
|
-
|
|
58
|
+
active: { type: Boolean, default: true },
|
|
59
|
+
currency: { type: String, default: "USD" },
|
|
60
|
+
logo: { type: String, default: "" },
|
|
61
|
+
createdBy: {
|
|
62
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
63
|
+
ref: "user",
|
|
64
|
+
default: null
|
|
99
65
|
},
|
|
66
|
+
onboardDate: { type: Date, default: Date.now },
|
|
67
|
+
bqClientId: { type: String, default: null },
|
|
68
|
+
defaultDataSet: { type: String },
|
|
69
|
+
NDAStatus: { type: Boolean, default: false },
|
|
70
|
+
retainerValue: { type: Number },
|
|
71
|
+
useIntraDayTable: { type: Boolean }
|
|
100
72
|
},
|
|
101
|
-
{
|
|
73
|
+
{
|
|
74
|
+
timestamps: true
|
|
75
|
+
}
|
|
102
76
|
);
|
|
103
77
|
|
|
78
|
+
// Add compound indexes for better query performance
|
|
104
79
|
ClientSchema.index({ active: 1 });
|
|
80
|
+
ClientSchema.index({ organizationId: 1, active: 1 });
|
|
81
|
+
ClientSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
|
|
82
|
+
ClientSchema.index({ tier: 1, active: 1 }); // For tier-based queries
|
|
83
|
+
ClientSchema.index({ onboardDate: 1 }); // For date-based queries
|
|
84
|
+
ClientSchema.index({ portfolioClient: 1, active: 1 }); // For portfolio client queries
|
|
105
85
|
|
|
106
86
|
const Client = model<IClient>("client", ClientSchema);
|
|
107
87
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IClientAdditionalRevenue extends Document {
|
|
4
|
-
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
client?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
additionalRevenueForTests: IAdditionalRevenue;
|
|
7
7
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
@@ -36,8 +36,9 @@ const AdditionalRevenueSchema = new Schema<IAdditionalRevenue>({
|
|
|
36
36
|
|
|
37
37
|
const ClientAdditionalRevenueSchema = new Schema<IClientAdditionalRevenue>(
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
type:
|
|
39
|
+
organizationId: {
|
|
40
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
41
|
+
ref: "organization",
|
|
41
42
|
default: null,
|
|
42
43
|
},
|
|
43
44
|
client: {
|
|
@@ -2,7 +2,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
export interface IClientLearning extends Document {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
viewId?: string;
|
|
8
8
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
@@ -13,9 +13,11 @@ const ClientLearningSchema = new Schema<IClientLearning>(
|
|
|
13
13
|
name: {
|
|
14
14
|
type: String,
|
|
15
15
|
required: true,
|
|
16
|
+
trim: true,
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
-
type:
|
|
18
|
+
organizationId: {
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
ref: "organization",
|
|
19
21
|
default: null,
|
|
20
22
|
},
|
|
21
23
|
client: {
|
|
@@ -35,10 +37,12 @@ const ClientLearningSchema = new Schema<IClientLearning>(
|
|
|
35
37
|
}
|
|
36
38
|
);
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
40
|
+
// Compound indexes for common query patterns
|
|
41
|
+
ClientLearningSchema.index({ client: 1 });
|
|
42
|
+
// Sparse indexes for optional fields
|
|
43
|
+
ClientLearningSchema.index({ organisationId: 1 }, { sparse: true });
|
|
44
|
+
// Case-insensitive index for name
|
|
45
|
+
ClientLearningSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } });
|
|
42
46
|
|
|
43
47
|
const ClientLearning = model<IClientLearning>(
|
|
44
48
|
"clientlearning",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IClientLinks extends Document {
|
|
4
|
-
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
title: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
link?: string;
|
|
@@ -13,20 +13,24 @@ export interface IClientLinks extends Document {
|
|
|
13
13
|
|
|
14
14
|
const ClientLinksSchema = new Schema<IClientLinks>(
|
|
15
15
|
{
|
|
16
|
-
|
|
17
|
-
type:
|
|
16
|
+
organizationId: {
|
|
17
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
18
|
+
ref: "organization",
|
|
18
19
|
default: null,
|
|
19
20
|
},
|
|
20
21
|
title: {
|
|
21
22
|
type: String,
|
|
22
23
|
required: true,
|
|
24
|
+
trim: true,
|
|
23
25
|
},
|
|
24
26
|
description: {
|
|
25
27
|
type: String,
|
|
28
|
+
trim: true,
|
|
26
29
|
},
|
|
27
30
|
link: {
|
|
28
31
|
type: String,
|
|
29
32
|
required: true,
|
|
33
|
+
trim: true,
|
|
30
34
|
},
|
|
31
35
|
client: {
|
|
32
36
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -49,10 +53,17 @@ const ClientLinksSchema = new Schema<IClientLinks>(
|
|
|
49
53
|
}
|
|
50
54
|
);
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
+
// Compound indexes for common query patterns
|
|
57
|
+
ClientLinksSchema.index({ client: 1 });
|
|
58
|
+
ClientLinksSchema.index({ client: 1, private: 1 });
|
|
59
|
+
ClientLinksSchema.index({ client: 1, createdAt: -1 });
|
|
60
|
+
|
|
61
|
+
// Sparse indexes for optional fields
|
|
62
|
+
ClientLinksSchema.index({ viewId: 1 }, { sparse: true });
|
|
63
|
+
ClientLinksSchema.index({ organisationId: 1 }, { sparse: true });
|
|
64
|
+
|
|
65
|
+
// Case-insensitive indexes
|
|
66
|
+
ClientLinksSchema.index({ title: 1 }, { collation: { locale: 'en', strength: 2 } });
|
|
56
67
|
|
|
57
68
|
const ClientLinks = model<IClientLinks>("clientlink", ClientLinksSchema);
|
|
58
69
|
export default ClientLinks;
|
|
@@ -2,7 +2,7 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
export interface IClientNextSteps extends Document {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
viewId?: string;
|
|
8
8
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
@@ -14,8 +14,9 @@ const ClientNextStepsSchema = new Schema<IClientNextSteps>(
|
|
|
14
14
|
type: String,
|
|
15
15
|
required: true,
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
type:
|
|
17
|
+
organizationId: {
|
|
18
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
+
ref: "organization",
|
|
19
20
|
default: null,
|
|
20
21
|
},
|
|
21
22
|
client: {
|
package/src/models/ClientNote.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
2
|
|
|
3
3
|
export interface IClientNote extends Document {
|
|
4
|
-
|
|
4
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
5
|
client?: mongoose.Schema.Types.ObjectId;
|
|
6
6
|
viewId?: string;
|
|
7
7
|
pageType?: mongoose.Schema.Types.ObjectId;
|
|
@@ -14,8 +14,9 @@ export interface IClientNote extends Document {
|
|
|
14
14
|
|
|
15
15
|
const ClientNoteSchema = new Schema<IClientNote>(
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
type:
|
|
17
|
+
organizationId: {
|
|
18
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
+
ref: "organization",
|
|
19
20
|
default: null,
|
|
20
21
|
},
|
|
21
22
|
client: {
|