codebase-models 2.0.5 → 2.0.6
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/dist/index.d.ts +3 -1
- package/dist/index.js +6 -1
- package/dist/src/constant.d.ts +7 -0
- package/dist/src/constant.js +17 -0
- package/dist/src/models/Announcement.d.ts +1 -0
- package/dist/src/models/Announcement.js +31 -0
- package/dist/src/models/Audience.d.ts +1 -0
- package/dist/src/models/Audience.js +31 -0
- package/dist/src/models/BqPreCompiledData.d.ts +1 -0
- package/dist/src/models/BqPreCompiledData.js +31 -0
- package/dist/src/models/Client.d.ts +1 -0
- package/dist/src/models/Client.js +31 -0
- package/dist/src/models/ClientAdditionalRevenue.d.ts +3 -1
- package/dist/src/models/ClientAdditionalRevenue.js +48 -0
- package/dist/src/models/ClientLearning.d.ts +1 -0
- package/dist/src/models/ClientLearning.js +31 -0
- package/dist/src/models/ClientLinks.d.ts +1 -0
- package/dist/src/models/ClientLinks.js +31 -0
- package/dist/src/models/ClientNextSteps.d.ts +1 -0
- package/dist/src/models/ClientNextSteps.js +30 -0
- package/dist/src/models/ClientNote.d.ts +1 -0
- package/dist/src/models/ClientNote.js +31 -0
- package/dist/src/models/ClientScript.d.ts +12 -11
- package/dist/src/models/ClientScript.js +54 -8
- package/dist/src/models/ClientStrategy.d.ts +1 -0
- package/dist/src/models/ClientStrategy.js +31 -0
- package/dist/src/models/CustomQuery.d.ts +1 -0
- package/dist/src/models/CustomQuery.js +30 -1
- package/dist/src/models/Environment.d.ts +2 -0
- package/dist/src/models/Environment.js +34 -0
- package/dist/src/models/Goal.d.ts +1 -0
- package/dist/src/models/Goal.js +31 -1
- package/dist/src/models/Page.d.ts +2 -0
- package/dist/src/models/Page.js +48 -0
- package/dist/src/models/Report.d.ts +1 -0
- package/dist/src/models/Report.js +30 -0
- package/dist/src/models/StageInCustomerJourney.d.ts +1 -0
- package/dist/src/models/StageInCustomerJourney.js +31 -0
- package/dist/src/models/Test.d.ts +2 -0
- package/dist/src/models/Test.js +46 -2
- package/dist/src/models/TestTimeline.d.ts +39 -0
- package/dist/src/models/TestTimeline.js +79 -0
- package/index.ts +4 -1
- package/package.json +3 -2
- package/src/constant.ts +17 -0
- package/src/models/Announcement.ts +22 -0
- package/src/models/Audience.ts +23 -0
- package/src/models/BqPreCompiledData.ts +22 -0
- package/src/models/Client.ts +22 -0
- package/src/models/ClientAdditionalRevenue.ts +42 -1
- package/src/models/ClientLearning.ts +22 -0
- package/src/models/ClientLinks.ts +23 -2
- package/src/models/ClientNextSteps.ts +20 -0
- package/src/models/ClientNote.ts +22 -1
- package/src/models/ClientScript.ts +56 -20
- package/src/models/ClientStrategy.ts +24 -0
- package/src/models/CustomQuery.ts +22 -2
- package/src/models/Environment.ts +27 -0
- package/src/models/Goal.ts +22 -2
- package/src/models/Page.ts +43 -0
- package/src/models/Report.ts +22 -0
- package/src/models/StageInCustomerJourney.ts +22 -0
- package/src/models/Test.ts +40 -3
- 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
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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",
|
|
@@ -84,10 +98,6 @@ const ClientScriptSchema = new mongoose_1.Schema({
|
|
|
84
98
|
default: "return true;",
|
|
85
99
|
trim: true,
|
|
86
100
|
},
|
|
87
|
-
tracker_url: {
|
|
88
|
-
type: String,
|
|
89
|
-
trim: true,
|
|
90
|
-
},
|
|
91
101
|
asset_url: {
|
|
92
102
|
type: String,
|
|
93
103
|
trim: true,
|
|
@@ -110,7 +120,7 @@ const ClientScriptSchema = new mongoose_1.Schema({
|
|
|
110
120
|
metadata_key_var_3: {
|
|
111
121
|
type: mongoose_1.default.Schema.Types.Mixed,
|
|
112
122
|
},
|
|
113
|
-
|
|
123
|
+
logDomain: {
|
|
114
124
|
type: String,
|
|
115
125
|
trim: true,
|
|
116
126
|
},
|
|
@@ -133,11 +143,15 @@ const ClientScriptSchema = new mongoose_1.Schema({
|
|
|
133
143
|
visual_editor_version: {
|
|
134
144
|
type: Number,
|
|
135
145
|
},
|
|
136
|
-
|
|
146
|
+
js: {
|
|
147
|
+
type: String,
|
|
148
|
+
trim: true,
|
|
149
|
+
},
|
|
150
|
+
css: {
|
|
137
151
|
type: String,
|
|
138
152
|
trim: true,
|
|
139
153
|
},
|
|
140
|
-
|
|
154
|
+
helper_js: {
|
|
141
155
|
type: String,
|
|
142
156
|
trim: true,
|
|
143
157
|
},
|
|
@@ -145,14 +159,46 @@ const ClientScriptSchema = new mongoose_1.Schema({
|
|
|
145
159
|
type: Boolean,
|
|
146
160
|
default: false,
|
|
147
161
|
},
|
|
162
|
+
isPreview: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
default: false,
|
|
165
|
+
},
|
|
166
|
+
goalsEnabled: {
|
|
167
|
+
type: Boolean,
|
|
168
|
+
default: false,
|
|
169
|
+
},
|
|
170
|
+
optedOut: {
|
|
171
|
+
type: Boolean,
|
|
172
|
+
default: false,
|
|
173
|
+
},
|
|
174
|
+
liveEventListenersSet: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: false,
|
|
177
|
+
},
|
|
148
178
|
}, {
|
|
149
179
|
timestamps: true,
|
|
150
180
|
});
|
|
181
|
+
ClientScriptSchema.pre('save', function (next) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
if (!this.iid) {
|
|
184
|
+
let unique = false;
|
|
185
|
+
while (!unique) {
|
|
186
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
187
|
+
const existing = yield mongoose_1.default.models.clientscript.findOne({ iid: id });
|
|
188
|
+
if (!existing) {
|
|
189
|
+
this.iid = id;
|
|
190
|
+
unique = true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
next();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
ClientScriptSchema.index({ iid: 1 }, { unique: true });
|
|
151
198
|
// Compound indexes for common query patterns
|
|
152
199
|
ClientScriptSchema.index({ client: 1 });
|
|
153
200
|
// Sparse indexes for optional fields
|
|
154
201
|
ClientScriptSchema.index({ organisationId: 1 }, { sparse: true });
|
|
155
|
-
ClientScriptSchema.index({ tracker_url: 1 }, { sparse: true });
|
|
156
202
|
ClientScriptSchema.index({ asset_url: 1 }, { sparse: true });
|
|
157
203
|
const ClientScript = mongoose_1.default.models.clientscript || (0, mongoose_1.model)("clientscript", ClientScriptSchema);
|
|
158
204
|
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,
|
|
@@ -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.
|
|
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,13 @@
|
|
|
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;
|
|
32
34
|
}
|
|
33
35
|
declare const Environment: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
34
36
|
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",
|
|
@@ -52,6 +70,22 @@ const EnvironmentSchema = new mongoose_1.Schema({
|
|
|
52
70
|
}, {
|
|
53
71
|
timestamps: true
|
|
54
72
|
});
|
|
73
|
+
EnvironmentSchema.pre('save', function (next) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
if (!this.iid) {
|
|
76
|
+
let unique = false;
|
|
77
|
+
while (!unique) {
|
|
78
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
79
|
+
const existing = yield mongoose_1.default.models.environment.findOne({ iid: id });
|
|
80
|
+
if (!existing) {
|
|
81
|
+
this.iid = id;
|
|
82
|
+
unique = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
next();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
55
89
|
// Compound indexes for common query patterns
|
|
56
90
|
EnvironmentSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
57
91
|
EnvironmentSchema.index({ client: 1, isActive: 1 });
|
package/dist/src/models/Goal.js
CHANGED
|
@@ -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 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,
|
|
@@ -85,10 +99,26 @@ const GoalSchema = new mongoose_1.Schema({
|
|
|
85
99
|
}, {
|
|
86
100
|
timestamps: true
|
|
87
101
|
});
|
|
88
|
-
|
|
102
|
+
GoalSchema.pre('save', function (next) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
if (!this.iid) {
|
|
105
|
+
let unique = false;
|
|
106
|
+
while (!unique) {
|
|
107
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
108
|
+
const existing = yield mongoose_1.default.models.goal.findOne({ iid: id });
|
|
109
|
+
if (!existing) {
|
|
110
|
+
this.iid = id;
|
|
111
|
+
unique = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
next();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
89
118
|
GoalSchema.index({ client: 1 });
|
|
90
119
|
GoalSchema.index({ client: 1, isActive: 1 });
|
|
91
120
|
GoalSchema.index({ organizationId: 1, client: 1 });
|
|
92
121
|
GoalSchema.index({ client: 1, name: 1 }, { unique: true });
|
|
122
|
+
GoalSchema.index({ iid: 1 }, { unique: true });
|
|
93
123
|
const Goal = mongoose_1.default.models.goal || (0, mongoose_1.model)("goal", GoalSchema);
|
|
94
124
|
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;
|
package/dist/src/models/Page.js
CHANGED
|
@@ -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 });
|
|
@@ -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
|
|
@@ -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 StageInCustomerJourneySchema = new mongoose_1.Schema({
|
|
43
|
+
iid: {
|
|
44
|
+
type: String,
|
|
45
|
+
unique: true,
|
|
46
|
+
},
|
|
33
47
|
name: {
|
|
34
48
|
type: String,
|
|
35
49
|
required: true,
|
|
@@ -67,6 +81,23 @@ const StageInCustomerJourneySchema = new mongoose_1.Schema({
|
|
|
67
81
|
}, {
|
|
68
82
|
timestamps: true,
|
|
69
83
|
});
|
|
84
|
+
StageInCustomerJourneySchema.pre('save', function (next) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (!this.iid) {
|
|
87
|
+
let unique = false;
|
|
88
|
+
while (!unique) {
|
|
89
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
90
|
+
const existing = yield mongoose_1.default.models.stageincustomerjourney.findOne({ iid: id });
|
|
91
|
+
if (!existing) {
|
|
92
|
+
this.iid = id;
|
|
93
|
+
unique = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
next();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
StageInCustomerJourneySchema.index({ iid: 1 }, { unique: true });
|
|
70
101
|
// Compound indexes for common query patterns
|
|
71
102
|
// StageInCustomerJourneySchema.index({ client: 1, slug: 1 });
|
|
72
103
|
const StageInCustomerJourney = mongoose_1.default.models.stageincustomerjourney || (0, mongoose_1.model)("stageincustomerjourney", StageInCustomerJourneySchema);
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IVariations extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
name: string;
|
|
28
29
|
css_code: string;
|
|
29
30
|
baseline: boolean;
|
|
@@ -38,6 +39,7 @@ export interface IVariations extends Document {
|
|
|
38
39
|
}
|
|
39
40
|
export interface ITest extends Document {
|
|
40
41
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
42
|
+
iid: string;
|
|
41
43
|
status: string;
|
|
42
44
|
name: string;
|
|
43
45
|
traffic_allocation: number;
|