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.
Files changed (145) hide show
  1. package/.github/workflows/npm-publish.yml +33 -0
  2. package/dist/index.d.ts +5 -4
  3. package/dist/index.js +20 -11
  4. package/dist/src/models/Announcement.d.ts +6 -5
  5. package/dist/src/models/Announcement.js +29 -9
  6. package/dist/src/models/Audience.d.ts +2 -1
  7. package/dist/src/models/Audience.js +6 -1
  8. package/dist/src/models/{Experiments.d.ts → BqPreCompiledData.d.ts} +12 -30
  9. package/dist/src/models/{ClientExperiment.js → BqPreCompiledData.js} +26 -46
  10. package/dist/src/models/CVRReport.d.ts +1 -0
  11. package/dist/src/models/CVRReport.js +13 -0
  12. package/dist/src/models/Client.d.ts +3 -1
  13. package/dist/src/models/Client.js +31 -45
  14. package/dist/src/models/ClientAdditionalRevenue.d.ts +1 -1
  15. package/dist/src/models/ClientAdditionalRevenue.js +3 -2
  16. package/dist/src/models/ClientLearning.d.ts +1 -1
  17. package/dist/src/models/ClientLearning.js +10 -6
  18. package/dist/src/models/ClientLinks.d.ts +1 -1
  19. package/dist/src/models/ClientLinks.js +15 -6
  20. package/dist/src/models/ClientNextSteps.d.ts +1 -1
  21. package/dist/src/models/ClientNextSteps.js +3 -2
  22. package/dist/src/models/ClientNote.d.ts +1 -1
  23. package/dist/src/models/ClientNote.js +3 -2
  24. package/dist/src/models/ClientReportsTemp.d.ts +1 -1
  25. package/dist/src/models/ClientReportsTemp.js +20 -2
  26. package/dist/src/models/ClientRetention.d.ts +1 -0
  27. package/dist/src/models/ClientRetention.js +25 -0
  28. package/dist/src/models/ClientScript.d.ts +1 -1
  29. package/dist/src/models/ClientScript.js +24 -8
  30. package/dist/src/models/ClientStrategy.d.ts +1 -1
  31. package/dist/src/models/ClientStrategy.js +3 -2
  32. package/dist/src/models/ClientSurvay.d.ts +1 -0
  33. package/dist/src/models/ClientSurvay.js +5 -0
  34. package/dist/src/models/Environment.d.ts +2 -0
  35. package/dist/src/models/Environment.js +26 -2
  36. package/dist/src/models/Faqs.d.ts +1 -0
  37. package/dist/src/models/Faqs.js +5 -0
  38. package/dist/src/models/Feedback.d.ts +1 -1
  39. package/dist/src/models/Feedback.js +3 -2
  40. package/dist/src/models/Goal.d.ts +2 -1
  41. package/dist/src/models/Goal.js +33 -11
  42. package/dist/src/models/Hypothesis.d.ts +2 -0
  43. package/dist/src/models/Hypothesis.js +49 -9
  44. package/dist/src/models/HypothesisSheet.d.ts +1 -1
  45. package/dist/src/models/HypothesisSheet.js +26 -2
  46. package/dist/src/models/LandingPages.d.ts +3 -0
  47. package/dist/src/models/LandingPages.js +29 -0
  48. package/dist/src/models/NewIdeas.d.ts +1 -1
  49. package/dist/src/models/NewIdeas.js +3 -2
  50. package/dist/src/models/Notification.d.ts +1 -0
  51. package/dist/src/models/Notification.js +29 -1
  52. package/dist/src/models/{ClientExperiment.d.ts → Organization.d.ts} +18 -29
  53. package/dist/src/models/{Experiments.js → Organization.js} +36 -54
  54. package/dist/src/models/Page.d.ts +3 -1
  55. package/dist/src/models/Page.js +56 -4
  56. package/dist/src/models/PageElement.d.ts +3 -0
  57. package/dist/src/models/PageElement.js +59 -7
  58. package/dist/src/models/PageTestType.d.ts +2 -0
  59. package/dist/src/models/PageTestType.js +41 -5
  60. package/dist/src/models/Portfolio.d.ts +1 -0
  61. package/dist/src/models/Portfolio.js +5 -0
  62. package/dist/src/models/PrecalculationFilters.d.ts +36 -0
  63. package/dist/src/models/PrecalculationFilters.js +77 -0
  64. package/dist/src/models/QueryLog.d.ts +1 -1
  65. package/dist/src/models/QueryLog.js +3 -2
  66. package/dist/src/models/ReadNotification.d.ts +1 -0
  67. package/dist/src/models/ReadNotification.js +29 -1
  68. package/dist/src/models/Report.d.ts +2 -0
  69. package/dist/src/models/Report.js +35 -47
  70. package/dist/src/models/Role.d.ts +3 -0
  71. package/dist/src/models/Role.js +50 -7
  72. package/dist/src/models/SavedSegment.d.ts +1 -0
  73. package/dist/src/models/SavedSegment.js +5 -0
  74. package/dist/src/models/Segment.d.ts +1 -0
  75. package/dist/src/models/Segment.js +5 -0
  76. package/dist/src/models/SegmentCombination.d.ts +1 -0
  77. package/dist/src/models/SegmentCombination.js +5 -0
  78. package/dist/src/models/Snippet.d.ts +2 -1
  79. package/dist/src/models/Snippet.js +28 -3
  80. package/dist/src/models/StageInCustomerJourney.d.ts +3 -1
  81. package/dist/src/models/StageInCustomerJourney.js +56 -4
  82. package/dist/src/models/Tag.d.ts +1 -0
  83. package/dist/src/models/Tag.js +29 -1
  84. package/dist/src/models/Temp.d.ts +1 -0
  85. package/dist/src/models/Temp.js +29 -1
  86. package/dist/src/models/Test.d.ts +18 -17
  87. package/dist/src/models/Test.js +82 -185
  88. package/dist/src/models/TestSequentialValue.d.ts +1 -0
  89. package/dist/src/models/TestSequentialValue.js +5 -0
  90. package/dist/src/models/Tier.d.ts +1 -0
  91. package/dist/src/models/Tier.js +29 -1
  92. package/dist/src/models/Trigger.d.ts +1 -0
  93. package/dist/src/models/Trigger.js +29 -1
  94. package/dist/src/models/User.d.ts +1 -0
  95. package/dist/src/models/User.js +9 -10
  96. package/index.ts +6 -4
  97. package/package.json +1 -1
  98. package/src/models/Announcement.ts +50 -27
  99. package/src/models/Audience.ts +6 -0
  100. package/src/models/BqPreCompiledData.ts +62 -0
  101. package/src/models/CVRReport.ts +17 -0
  102. package/src/models/Client.ts +39 -59
  103. package/src/models/ClientAdditionalRevenue.ts +4 -3
  104. package/src/models/ClientLearning.ts +11 -7
  105. package/src/models/ClientLinks.ts +18 -7
  106. package/src/models/ClientNextSteps.ts +4 -3
  107. package/src/models/ClientNote.ts +4 -3
  108. package/src/models/ClientReportsTemp.ts +24 -3
  109. package/src/models/ClientRetention.ts +27 -1
  110. package/src/models/ClientScript.ts +26 -9
  111. package/src/models/ClientStrategy.ts +4 -3
  112. package/src/models/ClientSurvay.ts +6 -0
  113. package/src/models/Environment.ts +31 -3
  114. package/src/models/Faqs.ts +6 -0
  115. package/src/models/Feedback.ts +4 -3
  116. package/src/models/Goal.ts +36 -12
  117. package/src/models/Hypothesis.ts +29 -8
  118. package/src/models/HypothesisSheet.ts +3 -2
  119. package/src/models/LandingPages.ts +34 -0
  120. package/src/models/NewIdeas.ts +4 -3
  121. package/src/models/Notification.ts +6 -0
  122. package/src/models/Organization.ts +86 -0
  123. package/src/models/Page.ts +62 -5
  124. package/src/models/PageElement.ts +38 -7
  125. package/src/models/PageTestType.ts +21 -4
  126. package/src/models/Portfolio.ts +6 -0
  127. package/src/models/PrecalculationFilters.ts +67 -0
  128. package/src/models/QueryLog.ts +4 -3
  129. package/src/models/ReadNotification.ts +6 -0
  130. package/src/models/Report.ts +54 -66
  131. package/src/models/Role.ts +31 -6
  132. package/src/models/SavedSegment.ts +6 -0
  133. package/src/models/Segment.ts +6 -0
  134. package/src/models/SegmentCombination.ts +6 -0
  135. package/src/models/Snippet.ts +32 -4
  136. package/src/models/StageInCustomerJourney.ts +33 -5
  137. package/src/models/Tag.ts +6 -0
  138. package/src/models/Temp.ts +6 -0
  139. package/src/models/Test.ts +155 -243
  140. package/src/models/TestSequentialValue.ts +6 -0
  141. package/src/models/Tier.ts +6 -0
  142. package/src/models/Trigger.ts +6 -0
  143. package/src/models/User.ts +11 -10
  144. package/src/models/ClientExperiment.ts +0 -113
  145. package/src/models/Experiments.ts +0 -118
@@ -0,0 +1,33 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Publish Codebase Shared Models on NPM
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 20
19
+ - run: npm ci
20
+
21
+ publish-npm:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version: 20
29
+ registry-url: https://registry.npmjs.org/
30
+ - run: npm ci
31
+ - run: npm publish
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/dist/index.d.ts CHANGED
@@ -41,7 +41,6 @@ import ClientRetention from "./src/models/ClientRetention";
41
41
  import ClientStrategy from "./src/models/ClientStrategy";
42
42
  import ClientSurvey from "./src/models/ClientSurvay";
43
43
  import CVRReport from "./src/models/CVRReport";
44
- import Experiments from "./src/models/Experiments";
45
44
  import Faq from "./src/models/Faqs";
46
45
  import Feedback from "./src/models/Feedback";
47
46
  import Goal from "./src/models/Goal";
@@ -55,6 +54,7 @@ import PageElement from "./src/models/PageElement";
55
54
  import PageTestType from "./src/models/PageTestType";
56
55
  import Portfolio from "./src/models/Portfolio";
57
56
  import ReadNotification from "./src/models/ReadNotification";
57
+ import Organization from "./src/models/Organization";
58
58
  import Role from "./src/models/Role";
59
59
  import SavedSegment from "./src/models/SavedSegment";
60
60
  import Segment from "./src/models/Segment";
@@ -66,8 +66,9 @@ import Temp from "./src/models/Temp";
66
66
  import Tier from "./src/models/Tier";
67
67
  import Trigger from "./src/models/Trigger";
68
68
  import ClientScript from "./src/models/ClientScript";
69
- import ClientExperiment from "./src/models/ClientExperiment";
70
69
  import Audience from "./src/models/Audience";
71
- import Environment from './src/models/Environment';
70
+ import Environment from "./src/models/Environment";
71
+ import PrecalculationFilters from "./src/models/PrecalculationFilters";
72
+ import BqPreCompiledData from "./src/models/BqPreCompiledData";
72
73
  export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
73
- export { Client, ClientReportsTemp, QueryLog, Report, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Experiments, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, SavedSegment, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, ClientExperiment, Audience, Environment };
74
+ export { Client, ClientReportsTemp, QueryLog, Report, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, SavedSegment, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, };
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Environment = exports.Audience = exports.ClientExperiment = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.SegmentCombination = exports.Segment = exports.SavedSegment = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.Experiments = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Report = exports.QueryLog = exports.ClientReportsTemp = exports.Client = exports.connect = void 0;
15
+ exports.BqPreCompiledData = exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.SegmentCombination = exports.Segment = exports.SavedSegment = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Report = exports.QueryLog = exports.ClientReportsTemp = exports.Client = exports.connect = void 0;
16
16
  const mongoose_1 = __importDefault(require("mongoose"));
17
17
  const Client_1 = __importDefault(require("./src/models/Client"));
18
18
  exports.Client = Client_1.default;
@@ -50,8 +50,6 @@ const ClientSurvay_1 = __importDefault(require("./src/models/ClientSurvay"));
50
50
  exports.ClientSurvey = ClientSurvay_1.default;
51
51
  const CVRReport_1 = __importDefault(require("./src/models/CVRReport"));
52
52
  exports.CVRReport = CVRReport_1.default;
53
- const Experiments_1 = __importDefault(require("./src/models/Experiments"));
54
- exports.Experiments = Experiments_1.default;
55
53
  const Faqs_1 = __importDefault(require("./src/models/Faqs"));
56
54
  exports.Faq = Faqs_1.default;
57
55
  const Feedback_1 = __importDefault(require("./src/models/Feedback"));
@@ -78,6 +76,8 @@ const Portfolio_1 = __importDefault(require("./src/models/Portfolio"));
78
76
  exports.Portfolio = Portfolio_1.default;
79
77
  const ReadNotification_1 = __importDefault(require("./src/models/ReadNotification"));
80
78
  exports.ReadNotification = ReadNotification_1.default;
79
+ const Organization_1 = __importDefault(require("./src/models/Organization"));
80
+ exports.Organization = Organization_1.default;
81
81
  const Role_1 = __importDefault(require("./src/models/Role"));
82
82
  exports.Role = Role_1.default;
83
83
  const SavedSegment_1 = __importDefault(require("./src/models/SavedSegment"));
@@ -100,12 +100,14 @@ const Trigger_1 = __importDefault(require("./src/models/Trigger"));
100
100
  exports.Trigger = Trigger_1.default;
101
101
  const ClientScript_1 = __importDefault(require("./src/models/ClientScript"));
102
102
  exports.ClientScript = ClientScript_1.default;
103
- const ClientExperiment_1 = __importDefault(require("./src/models/ClientExperiment"));
104
- exports.ClientExperiment = ClientExperiment_1.default;
105
103
  const Audience_1 = __importDefault(require("./src/models/Audience"));
106
104
  exports.Audience = Audience_1.default;
107
105
  const Environment_1 = __importDefault(require("./src/models/Environment"));
108
106
  exports.Environment = Environment_1.default;
107
+ const PrecalculationFilters_1 = __importDefault(require("./src/models/PrecalculationFilters"));
108
+ exports.PrecalculationFilters = PrecalculationFilters_1.default;
109
+ const BqPreCompiledData_1 = __importDefault(require("./src/models/BqPreCompiledData"));
110
+ exports.BqPreCompiledData = BqPreCompiledData_1.default;
109
111
  function seedRoles() {
110
112
  return __awaiter(this, void 0, void 0, function* () {
111
113
  const checkRoles = yield Role_1.default.countDocuments();
@@ -127,19 +129,26 @@ function seedRoles() {
127
129
  },
128
130
  ]);
129
131
  }));
132
+ console.log("Roles seeded successfully");
130
133
  }
131
134
  });
132
135
  }
133
136
  function connect(uri, options) {
134
137
  return __awaiter(this, void 0, void 0, function* () {
135
138
  if (uri) {
136
- console.log("Connecting to the database on URI: ", uri);
137
- const mongooseConnection = yield mongoose_1.default.connect(uri, options);
138
- if (mongooseConnection.connection.readyState === 1) {
139
- yield seedRoles();
140
- console.log("Roles seeded successfully");
139
+ if (mongoose_1.default.connection.readyState === 1) {
140
+ // Already connected
141
+ console.log("Already connected to the database");
142
+ return mongoose_1.default;
143
+ }
144
+ else {
145
+ console.log("Connecting to the database on URI: ", uri);
146
+ const mongooseConnection = yield mongoose_1.default.connect(uri, options);
147
+ if (mongooseConnection.connection.readyState === 1) {
148
+ yield seedRoles();
149
+ }
150
+ return mongooseConnection;
141
151
  }
142
- return mongooseConnection;
143
152
  }
144
153
  throw new Error("URI is required to connect to the database");
145
154
  });
@@ -25,11 +25,12 @@
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IAnnouncement extends Document {
27
27
  title: string;
28
- description?: String;
29
- active?: Boolean;
30
- forRoles?: mongoose.Schema.Types.ObjectId;
31
- forUsers?: mongoose.Schema.Types.ObjectId;
32
- readBy?: mongoose.Schema.Types.ObjectId;
28
+ description?: string;
29
+ active?: boolean;
30
+ forRoles?: mongoose.Schema.Types.ObjectId[];
31
+ forUsers?: mongoose.Schema.Types.ObjectId[];
32
+ readBy?: mongoose.Schema.Types.ObjectId[];
33
+ organizationId?: mongoose.Schema.Types.ObjectId;
33
34
  }
34
35
  declare const Announcement: mongoose.Model<IAnnouncement, {}, {}, {}, mongoose.Document<unknown, {}, IAnnouncement> & IAnnouncement & {
35
36
  _id: mongoose.Types.ObjectId;
@@ -25,35 +25,55 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const mongoose_1 = __importStar(require("mongoose"));
27
27
  const AnnouncementSchema = new mongoose_1.Schema({
28
+ organizationId: {
29
+ type: mongoose_1.default.Schema.Types.ObjectId,
30
+ ref: "organization",
31
+ default: null,
32
+ },
28
33
  title: {
29
34
  type: String,
30
35
  required: true,
36
+ trim: true
31
37
  },
32
38
  description: {
33
39
  type: String,
34
- required: false,
40
+ trim: true
35
41
  },
36
42
  active: {
37
43
  type: Boolean,
38
- default: true,
44
+ default: true
39
45
  },
40
46
  forRoles: {
41
47
  type: [mongoose_1.default.Schema.Types.ObjectId],
42
48
  required: true,
43
- ref: "role",
49
+ ref: "role"
44
50
  },
45
51
  forUsers: {
46
52
  type: [mongoose_1.default.Schema.Types.ObjectId],
47
- required: false,
48
- ref: "user",
53
+ ref: "user"
49
54
  },
50
55
  readBy: {
51
56
  type: [mongoose_1.default.Schema.Types.ObjectId],
52
- required: false,
53
- ref: "user",
54
- },
57
+ ref: "user"
58
+ }
55
59
  }, {
56
- timestamps: true,
60
+ timestamps: true
57
61
  });
62
+ // Add compound indexes for better query performance
63
+ AnnouncementSchema.index({ active: 1, createdAt: -1 }); // For active announcements sorted by date
64
+ AnnouncementSchema.index({ forRoles: 1, active: 1 }); // For role-based announcements
65
+ AnnouncementSchema.index({ forUsers: 1, active: 1 }); // For user-specific announcements
66
+ AnnouncementSchema.index({ readBy: 1 }); // For tracking read status
67
+ AnnouncementSchema.index({ title: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive title search
68
+ // Add text index for full-text search
69
+ // AnnouncementSchema.index({
70
+ // title: 'text',
71
+ // description: 'text'
72
+ // }, {
73
+ // weights: {
74
+ // title: 10,
75
+ // description: 5
76
+ // }
77
+ // });
58
78
  const Announcement = (0, mongoose_1.model)("announcement", AnnouncementSchema);
59
79
  exports.default = Announcement;
@@ -24,9 +24,10 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IAudience extends Document {
27
+ organizationId?: mongoose.Schema.Types.ObjectId;
27
28
  name: string;
28
29
  rules_js?: string;
29
- client: mongoose.Schema.Types.ObjectId;
30
+ client?: mongoose.Schema.Types.ObjectId;
30
31
  }
31
32
  declare const Audience: mongoose.Model<IAudience, {}, {}, {}, mongoose.Document<unknown, {}, IAudience> & IAudience & {
32
33
  _id: mongoose.Types.ObjectId;
@@ -25,6 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const mongoose_1 = __importStar(require("mongoose"));
27
27
  const AudienceSchema = new mongoose_1.Schema({
28
+ organizationId: {
29
+ type: mongoose_1.default.Schema.Types.ObjectId,
30
+ ref: "organization",
31
+ default: null,
32
+ },
28
33
  name: {
29
34
  type: String,
30
35
  required: true,
@@ -35,7 +40,7 @@ const AudienceSchema = new mongoose_1.Schema({
35
40
  client: {
36
41
  type: mongoose_1.default.Schema.Types.ObjectId,
37
42
  ref: "client",
38
- }
43
+ },
39
44
  }, {
40
45
  timestamps: true,
41
46
  });
@@ -23,36 +23,18 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
- export interface IVariations extends Document {
27
- name: string;
28
- css_code: string;
29
- baseline: Boolean;
30
- traffic_allocation: Number;
31
- metadata_1: mongoose.Schema.Types.Mixed;
32
- metadata_2: mongoose.Schema.Types.Mixed;
33
- metadata_3: mongoose.Schema.Types.Mixed;
34
- js: string;
35
- reset_js: string;
36
- css: string;
37
- changesets: string;
26
+ export interface IBqPreCompiledData extends Document {
27
+ title: string;
28
+ organizationId: mongoose.Schema.Types.ObjectId;
29
+ client: mongoose.Schema.Types.ObjectId;
30
+ test: mongoose.Schema.Types.ObjectId;
31
+ from: Date;
32
+ to: Date;
33
+ filters: any;
34
+ otherFilters: any;
35
+ cloudurl: string;
38
36
  }
39
- export interface IExperiments extends Document {
40
- status: string;
41
- name: string;
42
- traffic_allocation: Number;
43
- audiences_match_type: string;
44
- metadata_1: mongoose.Schema.Types.Mixed;
45
- metadata_2: mongoose.Schema.Types.Mixed;
46
- metadata_3: mongoose.Schema.Types.Mixed;
47
- integrations_run_mode: mongoose.Schema.Types.Mixed;
48
- js: string;
49
- reset_js: string;
50
- csscode: string;
51
- audiences: mongoose.Schema.Types.Array;
52
- variations: IVariations;
53
- environments: mongoose.Schema.Types.Array;
54
- }
55
- declare const Experiments: mongoose.Model<IExperiments, {}, {}, {}, mongoose.Document<unknown, {}, IExperiments> & IExperiments & {
37
+ declare const BqPreCompiledData: mongoose.Model<IBqPreCompiledData, {}, {}, {}, mongoose.Document<unknown, {}, IBqPreCompiledData> & IBqPreCompiledData & {
56
38
  _id: mongoose.Types.ObjectId;
57
39
  }, any>;
58
- export default Experiments;
40
+ export default BqPreCompiledData;
@@ -24,69 +24,49 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const mongoose_1 = __importStar(require("mongoose"));
27
- const PageTargetingSchema = new mongoose_1.Schema({
28
- condition: {
27
+ const BqPreCompiledDataSchema = new mongoose_1.Schema({
28
+ title: {
29
29
  type: String,
30
30
  default: null,
31
31
  },
32
- routes: {
33
- type: mongoose_1.default.Schema.Types.Mixed,
34
- },
35
- });
36
- const AudienceTargetingSchema = new mongoose_1.Schema({
37
- javascript: {
38
- type: String,
39
- default: "return true",
40
- },
41
- });
42
- const VariantsSchema = new mongoose_1.Schema({
43
- name: {
44
- type: String,
32
+ organizationId: {
33
+ type: mongoose_1.default.Schema.Types.ObjectId,
34
+ ref: "organization",
45
35
  default: null,
46
36
  },
47
- traffic_allocation: {
48
- type: Number,
37
+ client: {
38
+ type: mongoose_1.default.Schema.Types.ObjectId,
39
+ ref: "client",
49
40
  default: null,
50
41
  },
51
- javascript: {
52
- type: String,
42
+ test: {
43
+ type: mongoose_1.default.Schema.Types.ObjectId,
44
+ ref: "test",
53
45
  default: null,
54
46
  },
55
- css: {
56
- type: String,
47
+ from: {
48
+ type: Date,
57
49
  default: null,
58
50
  },
59
- slug: {
60
- type: String,
51
+ filters: {
52
+ type: Object,
61
53
  default: null,
62
54
  },
63
- });
64
- const ClientExperimentSchema = new mongoose_1.Schema({
65
- organisationId: {
66
- type: String,
55
+ to: {
56
+ type: Date,
67
57
  default: null,
68
58
  },
69
- name: String,
70
- status: {
71
- type: String,
72
- default: "draft",
73
- },
74
- experimentUrl: String,
75
- client: {
76
- type: mongoose_1.default.Schema.Types.ObjectId,
77
- ref: "client",
59
+ otherFilters: {
60
+ type: Object,
61
+ default: null,
78
62
  },
79
- viewId: {
63
+ cloudurl: {
80
64
  type: String,
65
+ default: null,
81
66
  },
82
- pageTargeting: [PageTargetingSchema],
83
- audienceTargeting: AudienceTargetingSchema,
84
- variants: [VariantsSchema],
85
67
  }, {
86
- timestamps: true,
87
- });
88
- ClientExperimentSchema.index({
89
- client: 1,
68
+ timestamps: true
90
69
  });
91
- const ClientExperiment = (0, mongoose_1.model)("clientexperiment", ClientExperimentSchema);
92
- exports.default = ClientExperiment;
70
+ BqPreCompiledDataSchema.index({ organizationId: 1, client: 1 });
71
+ const BqPreCompiledData = (0, mongoose_1.model)("bqprecompileddata", BqPreCompiledDataSchema);
72
+ exports.default = BqPreCompiledData;
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface ICVRReport extends Document {
27
+ organizationId?: mongoose.Schema.Types.ObjectId;
27
28
  reportLink?: string;
28
29
  client?: mongoose.Schema.Types.ObjectId;
29
30
  }
@@ -25,16 +25,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const mongoose_1 = __importStar(require("mongoose"));
27
27
  const CVRReportSchema = new mongoose_1.Schema({
28
+ organizationId: {
29
+ type: mongoose_1.default.Schema.Types.ObjectId,
30
+ ref: "organization",
31
+ default: null,
32
+ },
28
33
  reportLink: {
29
34
  type: String,
30
35
  default: null,
36
+ trim: true,
31
37
  },
32
38
  client: {
33
39
  type: mongoose_1.default.Schema.Types.ObjectId,
34
40
  ref: "client",
41
+ index: true,
35
42
  },
36
43
  }, {
37
44
  timestamps: true,
38
45
  });
46
+ // Compound index for client and reportLink
47
+ CVRReportSchema.index({ client: 1 });
48
+ // Sparse index for reportLink
49
+ CVRReportSchema.index({ reportLink: 1 }, { sparse: true });
50
+ // TTL index for automatic cleanup of old reports (1 year)
51
+ CVRReportSchema.index({ createdAt: 1 }, { expireAfterSeconds: 31536000 });
39
52
  const CVRReport = (0, mongoose_1.model)("cvrreport", CVRReportSchema);
40
53
  exports.default = CVRReport;
@@ -29,7 +29,7 @@ export interface IProperty extends Document {
29
29
  platform?: string;
30
30
  }
31
31
  export interface IClient extends Document {
32
- organisationId?: string;
32
+ organizationId?: mongoose.Schema.Types.ObjectId;
33
33
  name: string;
34
34
  slug?: string;
35
35
  viewId?: string;
@@ -44,6 +44,8 @@ export interface IClient extends Document {
44
44
  bqClientId?: string;
45
45
  defaultDataSet?: string;
46
46
  NDAStatus?: boolean;
47
+ retainerValue: number;
48
+ useIntraDayTable: boolean;
47
49
  }
48
50
  declare const Client: mongoose.Model<IClient, {}, {}, {}, mongoose.Document<unknown, {}, IClient> & IClient & {
49
51
  _id: mongoose.Types.ObjectId;
@@ -32,64 +32,50 @@ mongoose_1.default.plugin(mongoose_slug_updater_1.default);
32
32
  const PropertySchema = new mongoose_1.Schema({
33
33
  propertyname: { type: String, required: true },
34
34
  viewId: { type: String, required: true },
35
- platform: { type: String, required: false, default: "UA" },
35
+ platform: { type: String, default: "GA4" }
36
36
  });
37
37
  const ClientSchema = new mongoose_1.Schema({
38
- organisationId: {
38
+ organizationId: { type: mongoose_1.default.Schema.Types.ObjectId,
39
+ ref: "organization",
40
+ default: null },
41
+ name: { type: String, required: true },
42
+ slug: {
39
43
  type: String,
40
- default: null,
41
- },
42
- name: {
43
- type: String,
44
- required: true,
45
- },
46
- slug: { type: String, slug: ["name"], slugPaddingSize: 4, unique: true },
47
- viewId: {
48
- type: String,
49
- },
50
- portfolioClient: {
51
- type: Boolean,
52
- default: false,
44
+ slug: ["name"],
45
+ slugPaddingSize: 4,
46
+ unique: true
53
47
  },
48
+ viewId: { type: String },
49
+ portfolioClient: { type: Boolean, default: false },
54
50
  gaproperties: [PropertySchema],
55
51
  tier: {
56
52
  type: mongoose_1.default.Schema.Types.ObjectId,
57
53
  ref: "tier",
58
- default: null,
59
- },
60
- active: {
61
- type: Boolean,
62
- default: true,
63
- },
64
- currency: {
65
- type: String,
66
- default: "USD",
67
- },
68
- logo: {
69
- type: String,
70
- default: "",
54
+ default: null
71
55
  },
56
+ active: { type: Boolean, default: true },
57
+ currency: { type: String, default: "USD" },
58
+ logo: { type: String, default: "" },
72
59
  createdBy: {
73
60
  type: mongoose_1.default.Schema.Types.ObjectId,
74
61
  ref: "user",
75
- default: null,
76
- },
77
- onboardDate: {
78
- type: Date,
79
- default: new Date(),
80
- },
81
- bqClientId: {
82
- type: String,
83
- default: null,
62
+ default: null
84
63
  },
85
- defaultDataSet: {
86
- type: String,
87
- },
88
- NDAStatus: {
89
- type: Boolean,
90
- default: false,
91
- },
92
- }, { timestamps: true });
64
+ onboardDate: { type: Date, default: Date.now },
65
+ bqClientId: { type: String, default: null },
66
+ defaultDataSet: { type: String },
67
+ NDAStatus: { type: Boolean, default: false },
68
+ retainerValue: { type: Number },
69
+ useIntraDayTable: { type: Boolean }
70
+ }, {
71
+ timestamps: true
72
+ });
73
+ // Add compound indexes for better query performance
93
74
  ClientSchema.index({ active: 1 });
75
+ ClientSchema.index({ organizationId: 1, active: 1 });
76
+ ClientSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
77
+ ClientSchema.index({ tier: 1, active: 1 }); // For tier-based queries
78
+ ClientSchema.index({ onboardDate: 1 }); // For date-based queries
79
+ ClientSchema.index({ portfolioClient: 1, active: 1 }); // For portfolio client queries
94
80
  const Client = (0, mongoose_1.model)("client", ClientSchema);
95
81
  exports.default = Client;
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IClientAdditionalRevenue extends Document {
27
- organisationId?: string;
27
+ organizationId?: mongoose.Schema.Types.ObjectId;
28
28
  client?: mongoose.Schema.Types.ObjectId;
29
29
  additionalRevenueForTests: IAdditionalRevenue;
30
30
  createdBy?: mongoose.Schema.Types.ObjectId;
@@ -44,8 +44,9 @@ const AdditionalRevenueSchema = new mongoose_1.Schema({
44
44
  },
45
45
  });
46
46
  const ClientAdditionalRevenueSchema = new mongoose_1.Schema({
47
- organisationId: {
48
- type: String,
47
+ organizationId: {
48
+ type: mongoose_1.default.Schema.Types.ObjectId,
49
+ ref: "organization",
49
50
  default: null,
50
51
  },
51
52
  client: {
@@ -25,7 +25,7 @@
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IClientLearning extends Document {
27
27
  name: string;
28
- organisationId?: string;
28
+ organizationId?: mongoose.Schema.Types.ObjectId;
29
29
  client?: mongoose.Schema.Types.ObjectId;
30
30
  viewId?: string;
31
31
  createdBy?: mongoose.Schema.Types.ObjectId;
@@ -28,9 +28,11 @@ const ClientLearningSchema = new mongoose_1.Schema({
28
28
  name: {
29
29
  type: String,
30
30
  required: true,
31
+ trim: true,
31
32
  },
32
- organisationId: {
33
- type: String,
33
+ organizationId: {
34
+ type: mongoose_1.default.Schema.Types.ObjectId,
35
+ ref: "organization",
34
36
  default: null,
35
37
  },
36
38
  client: {
@@ -47,9 +49,11 @@ const ClientLearningSchema = new mongoose_1.Schema({
47
49
  }, {
48
50
  timestamps: true,
49
51
  });
50
- ClientLearningSchema.index({
51
- client: 1,
52
- viewId: 1,
53
- });
52
+ // Compound indexes for common query patterns
53
+ ClientLearningSchema.index({ client: 1 });
54
+ // Sparse indexes for optional fields
55
+ ClientLearningSchema.index({ organisationId: 1 }, { sparse: true });
56
+ // Case-insensitive index for name
57
+ ClientLearningSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } });
54
58
  const ClientLearning = (0, mongoose_1.model)("clientlearning", ClientLearningSchema);
55
59
  exports.default = ClientLearning;
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IClientLinks extends Document {
27
- organisationId?: string;
27
+ organizationId?: mongoose.Schema.Types.ObjectId;
28
28
  title: string;
29
29
  description?: string;
30
30
  link?: string;