codebase-models 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.js +6 -1
  3. package/dist/src/constant.d.ts +7 -0
  4. package/dist/src/constant.js +17 -0
  5. package/dist/src/models/Announcement.d.ts +1 -0
  6. package/dist/src/models/Announcement.js +31 -0
  7. package/dist/src/models/Audience.d.ts +1 -0
  8. package/dist/src/models/Audience.js +31 -0
  9. package/dist/src/models/BqPreCompiledData.d.ts +1 -0
  10. package/dist/src/models/BqPreCompiledData.js +31 -0
  11. package/dist/src/models/Client.d.ts +1 -0
  12. package/dist/src/models/Client.js +31 -0
  13. package/dist/src/models/ClientAdditionalRevenue.d.ts +3 -1
  14. package/dist/src/models/ClientAdditionalRevenue.js +48 -0
  15. package/dist/src/models/ClientLearning.d.ts +1 -0
  16. package/dist/src/models/ClientLearning.js +31 -0
  17. package/dist/src/models/ClientLinks.d.ts +1 -0
  18. package/dist/src/models/ClientLinks.js +31 -0
  19. package/dist/src/models/ClientNextSteps.d.ts +1 -0
  20. package/dist/src/models/ClientNextSteps.js +30 -0
  21. package/dist/src/models/ClientNote.d.ts +1 -0
  22. package/dist/src/models/ClientNote.js +31 -0
  23. package/dist/src/models/ClientScript.d.ts +12 -11
  24. package/dist/src/models/ClientScript.js +54 -9
  25. package/dist/src/models/ClientStrategy.d.ts +1 -0
  26. package/dist/src/models/ClientStrategy.js +31 -0
  27. package/dist/src/models/CustomQuery.d.ts +1 -0
  28. package/dist/src/models/CustomQuery.js +30 -1
  29. package/dist/src/models/Environment.d.ts +3 -0
  30. package/dist/src/models/Environment.js +38 -0
  31. package/dist/src/models/Goal.d.ts +1 -0
  32. package/dist/src/models/Goal.js +31 -2
  33. package/dist/src/models/Page.d.ts +2 -0
  34. package/dist/src/models/Page.js +48 -0
  35. package/dist/src/models/PageElement.js +0 -1
  36. package/dist/src/models/PageTestType.js +0 -2
  37. package/dist/src/models/Report.d.ts +1 -0
  38. package/dist/src/models/Report.js +30 -0
  39. package/dist/src/models/Role.js +0 -3
  40. package/dist/src/models/Snippet.js +0 -4
  41. package/dist/src/models/StageInCustomerJourney.d.ts +1 -0
  42. package/dist/src/models/StageInCustomerJourney.js +31 -4
  43. package/dist/src/models/Test.d.ts +3 -0
  44. package/dist/src/models/Test.js +47 -2
  45. package/dist/src/models/TestTimeline.d.ts +39 -0
  46. package/dist/src/models/TestTimeline.js +79 -0
  47. package/index.ts +4 -1
  48. package/package.json +3 -2
  49. package/src/constant.ts +17 -0
  50. package/src/models/Announcement.ts +22 -0
  51. package/src/models/Audience.ts +23 -0
  52. package/src/models/BqPreCompiledData.ts +22 -0
  53. package/src/models/Client.ts +22 -0
  54. package/src/models/ClientAdditionalRevenue.ts +42 -1
  55. package/src/models/ClientLearning.ts +22 -0
  56. package/src/models/ClientLinks.ts +23 -2
  57. package/src/models/ClientNextSteps.ts +20 -0
  58. package/src/models/ClientNote.ts +22 -1
  59. package/src/models/ClientScript.ts +56 -21
  60. package/src/models/ClientStrategy.ts +24 -0
  61. package/src/models/CustomQuery.ts +22 -2
  62. package/src/models/Environment.ts +33 -1
  63. package/src/models/Goal.ts +22 -3
  64. package/src/models/Page.ts +43 -0
  65. package/src/models/PageElement.ts +0 -1
  66. package/src/models/PageTestType.ts +0 -2
  67. package/src/models/Report.ts +22 -0
  68. package/src/models/Role.ts +1 -3
  69. package/src/models/Snippet.ts +1 -4
  70. package/src/models/StageInCustomerJourney.ts +22 -4
  71. package/src/models/Test.ts +42 -4
  72. package/src/models/TestTimeline.ts +61 -0
@@ -23,26 +23,24 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
- export interface IClientScriptSchema extends Document {
27
- scriptUrl: string;
28
- viewId: string;
29
- }
30
26
  export interface IClientScript extends Document {
27
+ iid: string;
31
28
  organizationId?: mongoose.Schema.Types.ObjectId;
32
29
  client?: mongoose.Schema.Types.ObjectId;
30
+ adhere_dnt: Boolean;
31
+ allow_in_iframes: Boolean;
33
32
  viewId?: string;
34
33
  clientScriptURL: string;
35
34
  jquery_include: string;
36
35
  debug: Boolean;
37
36
  restrict_debug: Boolean;
38
- adhere_dnt: Boolean;
39
37
  max_cookie_lifetime: Number;
40
38
  activation_mode: string;
41
39
  use_antiflicker: Boolean;
42
40
  snippet_revision: Number;
41
+ snippet_version: Number;
43
42
  rules: string;
44
43
  rules_tracking: string;
45
- tracker_url: string;
46
44
  asset_url: string;
47
45
  metadata_key_exp_1: mongoose.Schema.Types.Mixed;
48
46
  metadata_key_exp_2: mongoose.Schema.Types.Mixed;
@@ -50,15 +48,18 @@ export interface IClientScript extends Document {
50
48
  metadata_key_var_1: mongoose.Schema.Types.Mixed;
51
49
  metadata_key_var_2: mongoose.Schema.Types.Mixed;
52
50
  metadata_key_var_3: mongoose.Schema.Types.Mixed;
53
- cookie_domain: string;
54
- snippet_version: Number;
51
+ logDomain: string;
55
52
  storage: string;
56
53
  run_only_on_reinit: Boolean;
57
- allow_in_iframes: Boolean;
58
54
  visual_editor_version: Number;
59
- jscode: string;
60
- csscode: string;
55
+ js: string;
56
+ css: string;
57
+ helper_js: string;
61
58
  is_spa: Boolean;
59
+ isPreview: Boolean;
60
+ goalsEnabled: Boolean;
61
+ optedOut: Boolean;
62
+ liveEventListenersSet: Boolean;
62
63
  }
63
64
  declare const ClientScript: mongoose.Model<any, {}, {}, {}, any, any>;
64
65
  export default ClientScript;
@@ -22,9 +22,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
27
37
  const ClientScriptSchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
28
42
  organizationId: {
29
43
  type: mongoose_1.default.Schema.Types.ObjectId,
30
44
  ref: "organization",
@@ -36,7 +50,6 @@ const ClientScriptSchema = new mongoose_1.Schema({
36
50
  },
37
51
  viewId: {
38
52
  type: String,
39
- index: true,
40
53
  },
41
54
  clientScriptURL: {
42
55
  type: String,
@@ -84,10 +97,6 @@ const ClientScriptSchema = new mongoose_1.Schema({
84
97
  default: "return true;",
85
98
  trim: true,
86
99
  },
87
- tracker_url: {
88
- type: String,
89
- trim: true,
90
- },
91
100
  asset_url: {
92
101
  type: String,
93
102
  trim: true,
@@ -110,7 +119,7 @@ const ClientScriptSchema = new mongoose_1.Schema({
110
119
  metadata_key_var_3: {
111
120
  type: mongoose_1.default.Schema.Types.Mixed,
112
121
  },
113
- cookie_domain: {
122
+ logDomain: {
114
123
  type: String,
115
124
  trim: true,
116
125
  },
@@ -133,11 +142,15 @@ const ClientScriptSchema = new mongoose_1.Schema({
133
142
  visual_editor_version: {
134
143
  type: Number,
135
144
  },
136
- jscode: {
145
+ js: {
146
+ type: String,
147
+ trim: true,
148
+ },
149
+ css: {
137
150
  type: String,
138
151
  trim: true,
139
152
  },
140
- csscode: {
153
+ helper_js: {
141
154
  type: String,
142
155
  trim: true,
143
156
  },
@@ -145,14 +158,46 @@ const ClientScriptSchema = new mongoose_1.Schema({
145
158
  type: Boolean,
146
159
  default: false,
147
160
  },
161
+ isPreview: {
162
+ type: Boolean,
163
+ default: false,
164
+ },
165
+ goalsEnabled: {
166
+ type: Boolean,
167
+ default: false,
168
+ },
169
+ optedOut: {
170
+ type: Boolean,
171
+ default: false,
172
+ },
173
+ liveEventListenersSet: {
174
+ type: Boolean,
175
+ default: false,
176
+ },
148
177
  }, {
149
178
  timestamps: true,
150
179
  });
180
+ ClientScriptSchema.pre('save', function (next) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ if (!this.iid) {
183
+ let unique = false;
184
+ while (!unique) {
185
+ const id = (0, constant_1.generateRandomIID)();
186
+ const existing = yield mongoose_1.default.models.clientscript.findOne({ iid: id });
187
+ if (!existing) {
188
+ this.iid = id;
189
+ unique = true;
190
+ }
191
+ }
192
+ }
193
+ next();
194
+ });
195
+ });
196
+ ClientScriptSchema.index({ iid: 1 }, { unique: true });
151
197
  // Compound indexes for common query patterns
152
198
  ClientScriptSchema.index({ client: 1 });
153
199
  // Sparse indexes for optional fields
154
200
  ClientScriptSchema.index({ organisationId: 1 }, { sparse: true });
155
- ClientScriptSchema.index({ tracker_url: 1 }, { sparse: true });
156
201
  ClientScriptSchema.index({ asset_url: 1 }, { sparse: true });
157
202
  const ClientScript = mongoose_1.default.models.clientscript || (0, mongoose_1.model)("clientscript", ClientScriptSchema);
158
203
  exports.default = ClientScript;
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IClientStrategy extends Document {
27
+ iid: string;
27
28
  year: mongoose.Schema.Types.Mixed;
28
29
  month: mongoose.Schema.Types.Mixed;
29
30
  startDate?: Date;
@@ -22,9 +22,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
27
37
  const ClientStrategySchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
28
42
  year: {
29
43
  type: mongoose_1.default.Schema.Types.Mixed,
30
44
  required: true,
@@ -64,6 +78,23 @@ const ClientStrategySchema = new mongoose_1.Schema({
64
78
  }, {
65
79
  timestamps: true,
66
80
  });
81
+ ClientStrategySchema.pre('save', function (next) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ if (!this.iid) {
84
+ let unique = false;
85
+ while (!unique) {
86
+ const id = (0, constant_1.generateRandomIID)();
87
+ const existing = yield mongoose_1.default.models.clientstrategy.findOne({ iid: id });
88
+ if (!existing) {
89
+ this.iid = id;
90
+ unique = true;
91
+ }
92
+ }
93
+ }
94
+ next();
95
+ });
96
+ });
97
+ ClientStrategySchema.index({ iid: 1 }, { unique: true });
67
98
  ClientStrategySchema.index({
68
99
  year: 1,
69
100
  month: 1,
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from 'mongoose';
26
26
  interface ICustomQuery extends Document {
27
+ iid: string;
27
28
  organizationId?: mongoose.Schema.Types.ObjectId;
28
29
  title: string;
29
30
  module: string;
@@ -22,9 +22,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
27
37
  const CustomQuerySchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
28
42
  organizationId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "organization", default: null },
29
43
  title: { type: String, required: true },
30
44
  module: { type: String, required: true },
@@ -34,6 +48,21 @@ const CustomQuerySchema = new mongoose_1.Schema({
34
48
  }, {
35
49
  timestamps: true, // Automatically adds createdAt and updatedAt fields
36
50
  });
37
- CustomQuerySchema.index({ module: 1, client: 1 }, { unique: true });
51
+ CustomQuerySchema.pre('save', function (next) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ if (!this.iid) {
54
+ let unique = false;
55
+ while (!unique) {
56
+ const id = (0, constant_1.generateRandomIID)();
57
+ const existing = yield mongoose_1.default.models.customquery.findOne({ iid: id });
58
+ if (!existing) {
59
+ this.iid = id;
60
+ unique = true;
61
+ }
62
+ }
63
+ }
64
+ next();
65
+ });
66
+ });
38
67
  const CustomQuery = (0, mongoose_1.model)('CustomQuery', CustomQuerySchema);
39
68
  exports.default = CustomQuery;
@@ -24,11 +24,14 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IEnvironment extends Document {
27
+ iid: string;
27
28
  name: string;
28
29
  rules_js?: string;
29
30
  client?: mongoose.Schema.Types.ObjectId;
30
31
  organizationId?: mongoose.Schema.Types.ObjectId;
31
32
  isActive?: boolean;
33
+ default?: boolean;
34
+ qa?: boolean;
32
35
  }
33
36
  declare const Environment: mongoose.Model<any, {}, {}, {}, any, any>;
34
37
  export default Environment;
@@ -22,9 +22,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
27
37
  const EnvironmentSchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
28
42
  name: {
29
43
  type: String,
30
44
  required: true,
@@ -40,6 +54,10 @@ const EnvironmentSchema = new mongoose_1.Schema({
40
54
  type: mongoose_1.default.Schema.Types.ObjectId,
41
55
  ref: "organization",
42
56
  },
57
+ default: {
58
+ type: Boolean,
59
+ default: false,
60
+ },
43
61
  rules_js: {
44
62
  type: String,
45
63
  default: "return true",
@@ -48,10 +66,30 @@ const EnvironmentSchema = new mongoose_1.Schema({
48
66
  isActive: {
49
67
  type: Boolean,
50
68
  default: true,
69
+ },
70
+ qa: {
71
+ type: Boolean,
72
+ default: false,
51
73
  }
52
74
  }, {
53
75
  timestamps: true
54
76
  });
77
+ EnvironmentSchema.pre('save', function (next) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ if (!this.iid) {
80
+ let unique = false;
81
+ while (!unique) {
82
+ const id = (0, constant_1.generateRandomIID)();
83
+ const existing = yield mongoose_1.default.models.environment.findOne({ iid: id });
84
+ if (!existing) {
85
+ this.iid = id;
86
+ unique = true;
87
+ }
88
+ }
89
+ }
90
+ next();
91
+ });
92
+ });
55
93
  // Compound indexes for common query patterns
56
94
  EnvironmentSchema.index({ client: 1, name: 1 }, { unique: true });
57
95
  EnvironmentSchema.index({ client: 1, isActive: 1 });
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IGoal extends Document {
27
+ iid: string;
27
28
  name: string;
28
29
  details?: string;
29
30
  slug?: string;
@@ -22,19 +22,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
28
37
  Object.defineProperty(exports, "__esModule", { value: true });
29
38
  const mongoose_1 = __importStar(require("mongoose"));
30
39
  const mongoose_slug_updater_1 = __importDefault(require("mongoose-slug-updater"));
40
+ const constant_1 = require("../constant");
31
41
  mongoose_1.default.plugin(mongoose_slug_updater_1.default);
32
42
  const GoalSchema = new mongoose_1.Schema({
43
+ iid: {
44
+ type: String,
45
+ trim: true,
46
+ },
33
47
  name: {
34
48
  type: String,
35
49
  required: true,
36
50
  trim: true,
37
- index: true,
38
51
  },
39
52
  details: {
40
53
  type: String,
@@ -85,10 +98,26 @@ const GoalSchema = new mongoose_1.Schema({
85
98
  }, {
86
99
  timestamps: true
87
100
  });
88
- // Compound indexes for common query patterns
101
+ GoalSchema.pre('save', function (next) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ if (!this.iid) {
104
+ let unique = false;
105
+ while (!unique) {
106
+ const id = (0, constant_1.generateRandomIID)();
107
+ const existing = yield mongoose_1.default.models.goal.findOne({ iid: id });
108
+ if (!existing) {
109
+ this.iid = id;
110
+ unique = true;
111
+ }
112
+ }
113
+ }
114
+ next();
115
+ });
116
+ });
89
117
  GoalSchema.index({ client: 1 });
90
118
  GoalSchema.index({ client: 1, isActive: 1 });
91
119
  GoalSchema.index({ organizationId: 1, client: 1 });
92
120
  GoalSchema.index({ client: 1, name: 1 }, { unique: true });
121
+ GoalSchema.index({ iid: 1 }, { unique: true });
93
122
  const Goal = mongoose_1.default.models.goal || (0, mongoose_1.model)("goal", GoalSchema);
94
123
  exports.default = Goal;
@@ -24,11 +24,13 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IUrltargetings extends Document {
27
+ iid: string;
27
28
  type: string;
28
29
  url: string;
29
30
  url_type: string;
30
31
  }
31
32
  export interface IPage extends Document {
33
+ iid: string;
32
34
  name: string;
33
35
  client?: mongoose.Schema.Types.ObjectId;
34
36
  organizationId?: mongoose.Schema.Types.ObjectId;
@@ -22,14 +22,28 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
28
37
  Object.defineProperty(exports, "__esModule", { value: true });
29
38
  const mongoose_1 = __importStar(require("mongoose"));
30
39
  const mongoose_slug_updater_1 = __importDefault(require("mongoose-slug-updater"));
40
+ const constant_1 = require("../constant");
31
41
  mongoose_1.default.plugin(mongoose_slug_updater_1.default);
32
42
  const UrltargetingsSchema = new mongoose_1.Schema({
43
+ iid: {
44
+ type: String,
45
+ unique: true,
46
+ },
33
47
  type: {
34
48
  type: String,
35
49
  required: true,
@@ -47,6 +61,10 @@ const UrltargetingsSchema = new mongoose_1.Schema({
47
61
  },
48
62
  });
49
63
  const PageSchema = new mongoose_1.Schema({
64
+ iid: {
65
+ type: String,
66
+ unique: true,
67
+ },
50
68
  name: {
51
69
  type: String,
52
70
  required: true,
@@ -100,6 +118,36 @@ const PageSchema = new mongoose_1.Schema({
100
118
  }, {
101
119
  timestamps: true
102
120
  });
121
+ PageSchema.pre('save', function (next) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ if (!this.iid) {
124
+ let unique = false;
125
+ while (!unique) {
126
+ const id = (0, constant_1.generateRandomIID)();
127
+ const existing = yield mongoose_1.default.models.page.findOne({ iid: id });
128
+ if (!existing) {
129
+ this.iid = id;
130
+ unique = true;
131
+ }
132
+ }
133
+ }
134
+ for (const urltargeting of this.urltargetings) {
135
+ if (!urltargeting.iid) {
136
+ let uniqueVar = false;
137
+ while (!uniqueVar) {
138
+ const id = (0, constant_1.generateRandomIID)();
139
+ const existingVar = yield mongoose_1.default.models.page.findOne({ "urltargetings.iid": id });
140
+ if (!existingVar) {
141
+ urltargeting.iid = id;
142
+ uniqueVar = true;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ next();
148
+ });
149
+ });
150
+ PageSchema.index({ iid: 1 }, { unique: true });
103
151
  // Compound indexes for common query patterns
104
152
  PageSchema.index({ client: 1, name: 1 }, { unique: true });
105
153
  PageSchema.index({ client: 1, isActive: 1 });
@@ -45,7 +45,6 @@ const PageElementSchema = new mongoose_1.Schema({
45
45
  organizationId: {
46
46
  type: mongoose_1.default.Schema.Types.ObjectId,
47
47
  ref: "organization",
48
- index: true,
49
48
  default: null,
50
49
  },
51
50
  client: {
@@ -35,7 +35,6 @@ const PageTestTypeSchema = new mongoose_1.Schema({
35
35
  required: true,
36
36
  unique: true,
37
37
  trim: true,
38
- index: true,
39
38
  },
40
39
  details: {
41
40
  type: String,
@@ -49,7 +48,6 @@ const PageTestTypeSchema = new mongoose_1.Schema({
49
48
  isActive: {
50
49
  type: Boolean,
51
50
  default: true,
52
- index: true,
53
51
  }
54
52
  }, {
55
53
  timestamps: true
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IReports extends Document {
27
+ iid: string;
27
28
  name: string;
28
29
  segmentName?: string;
29
30
  reportLink?: string;
@@ -22,9 +22,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
27
37
  const ReportsSchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
28
42
  organizationId: {
29
43
  type: mongoose_1.default.Schema.Types.ObjectId,
30
44
  ref: "organization",
@@ -63,6 +77,22 @@ const ReportsSchema = new mongoose_1.Schema({
63
77
  }, {
64
78
  timestamps: true
65
79
  });
80
+ ReportsSchema.pre('save', function (next) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (!this.iid) {
83
+ let unique = false;
84
+ while (!unique) {
85
+ const id = (0, constant_1.generateRandomIID)();
86
+ const existing = yield mongoose_1.default.models.report.findOne({ iid: id });
87
+ if (!existing) {
88
+ this.iid = id;
89
+ unique = true;
90
+ }
91
+ }
92
+ }
93
+ next();
94
+ });
95
+ });
66
96
  // Add compound indexes for better query performance
67
97
  ReportsSchema.index({ client: 1, conclusion: 1 });
68
98
  ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
@@ -31,7 +31,6 @@ const RoleSchema = new mongoose_1.Schema({
31
31
  required: true,
32
32
  enum: ["USER", "ADMIN", "EDITOR", "COLLABORATOR", "CLIENT"],
33
33
  trim: true,
34
- index: true,
35
34
  uppercase: true,
36
35
  },
37
36
  description: {
@@ -41,13 +40,11 @@ const RoleSchema = new mongoose_1.Schema({
41
40
  organizationId: {
42
41
  type: mongoose_1.default.Schema.Types.ObjectId,
43
42
  ref: "organization",
44
- index: true,
45
43
  default: null,
46
44
  },
47
45
  isActive: {
48
46
  type: Boolean,
49
47
  default: true,
50
- index: true,
51
48
  }
52
49
  }, {
53
50
  timestamps: true
@@ -29,20 +29,17 @@ const SnippetSchema = new mongoose_1.Schema({
29
29
  type: mongoose_1.default.Schema.Types.ObjectId,
30
30
  ref: "organization",
31
31
  default: null,
32
- index: true,
33
32
  },
34
33
  name: {
35
34
  type: String,
36
35
  required: true,
37
36
  unique: true,
38
37
  trim: true,
39
- index: true,
40
38
  },
41
39
  pageelement: {
42
40
  type: [mongoose_1.default.Schema.Types.ObjectId],
43
41
  ref: "pageelement",
44
42
  default: [],
45
- index: true,
46
43
  },
47
44
  client: {
48
45
  type: mongoose_1.default.Schema.Types.ObjectId,
@@ -80,7 +77,6 @@ const SnippetSchema = new mongoose_1.Schema({
80
77
  test: {
81
78
  type: mongoose_1.default.Schema.Types.ObjectId,
82
79
  ref: "test",
83
- index: true,
84
80
  },
85
81
  status: {
86
82
  type: String,
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export interface IStageInCustomerJourney extends Document {
27
+ iid: string;
27
28
  name?: string;
28
29
  stages?: string;
29
30
  slug?: string;