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
package/dist/index.d.ts
CHANGED
|
@@ -71,5 +71,7 @@ import Environment from "./src/models/Environment";
|
|
|
71
71
|
import PrecalculationFilters from "./src/models/PrecalculationFilters";
|
|
72
72
|
import BqPreCompiledData from "./src/models/BqPreCompiledData";
|
|
73
73
|
import CustomQuery from "./src/models/CustomQuery";
|
|
74
|
+
import { generateRandomIID } from "./src/constant";
|
|
75
|
+
import TestTimeline from "./src/models/TestTimeline";
|
|
74
76
|
export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
|
|
75
|
-
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, CustomQuery, SavedSegment, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, };
|
|
77
|
+
export { generateRandomIID, 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, CustomQuery, SavedSegment, TestTimeline, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, };
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,8 @@ 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.
|
|
15
|
+
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.TestTimeline = exports.SavedSegment = exports.CustomQuery = 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.generateRandomIID = exports.connect = void 0;
|
|
16
|
+
exports.BqPreCompiledData = void 0;
|
|
16
17
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
17
18
|
const Client_1 = __importDefault(require("./src/models/Client"));
|
|
18
19
|
exports.Client = Client_1.default;
|
|
@@ -110,6 +111,10 @@ const BqPreCompiledData_1 = __importDefault(require("./src/models/BqPreCompiledD
|
|
|
110
111
|
exports.BqPreCompiledData = BqPreCompiledData_1.default;
|
|
111
112
|
const CustomQuery_1 = __importDefault(require("./src/models/CustomQuery"));
|
|
112
113
|
exports.CustomQuery = CustomQuery_1.default;
|
|
114
|
+
const constant_1 = require("./src/constant");
|
|
115
|
+
Object.defineProperty(exports, "generateRandomIID", { enumerable: true, get: function () { return constant_1.generateRandomIID; } });
|
|
116
|
+
const TestTimeline_1 = __importDefault(require("./src/models/TestTimeline"));
|
|
117
|
+
exports.TestTimeline = TestTimeline_1.default;
|
|
113
118
|
function seedRoles() {
|
|
114
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
120
|
const checkRoles = yield Role_1.default.countDocuments();
|
package/dist/src/constant.d.ts
CHANGED
|
@@ -8,4 +8,11 @@ declare const HypothesisSheetConstants: {
|
|
|
8
8
|
MEDIUM: number;
|
|
9
9
|
GOOD: number;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Generates a random unique identifier
|
|
13
|
+
* @returns A 12-character uppercase string (increased from 8 for better uniqueness)
|
|
14
|
+
* @throws Error if UUID generation fails
|
|
15
|
+
*/
|
|
16
|
+
declare const generateRandomIID: () => string;
|
|
17
|
+
export { generateRandomIID };
|
|
11
18
|
export default HypothesisSheetConstants;
|
package/dist/src/constant.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateRandomIID = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
3
5
|
const HypothesisSheetConstants = {
|
|
4
6
|
NO: 0,
|
|
5
7
|
YES: 1,
|
|
@@ -12,4 +14,19 @@ const HypothesisSheetConstants = {
|
|
|
12
14
|
MEDIUM: 1,
|
|
13
15
|
GOOD: 2,
|
|
14
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Generates a random unique identifier
|
|
19
|
+
* @returns A 12-character uppercase string (increased from 8 for better uniqueness)
|
|
20
|
+
* @throws Error if UUID generation fails
|
|
21
|
+
*/
|
|
22
|
+
const generateRandomIID = () => {
|
|
23
|
+
try {
|
|
24
|
+
// Take first 12 characters instead of 8 for better uniqueness
|
|
25
|
+
return (0, uuid_1.v4)().replace(/-/g, '').substring(0, 12).toUpperCase();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Failed to generate random IID: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.generateRandomIID = generateRandomIID;
|
|
15
32
|
exports.default = HypothesisSheetConstants;
|
|
@@ -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 AnnouncementSchema = 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",
|
|
@@ -59,6 +73,23 @@ const AnnouncementSchema = new mongoose_1.Schema({
|
|
|
59
73
|
}, {
|
|
60
74
|
timestamps: true
|
|
61
75
|
});
|
|
76
|
+
AnnouncementSchema.pre('save', function (next) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
if (!this.iid) {
|
|
79
|
+
let unique = false;
|
|
80
|
+
while (!unique) {
|
|
81
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
82
|
+
const existing = yield mongoose_1.default.models.announcement.findOne({ iid: id });
|
|
83
|
+
if (!existing) {
|
|
84
|
+
this.iid = id;
|
|
85
|
+
unique = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
AnnouncementSchema.index({ iid: 1 }, { unique: true });
|
|
62
93
|
// Add compound indexes for better query performance
|
|
63
94
|
AnnouncementSchema.index({ active: 1, createdAt: -1 }); // For active announcements sorted by date
|
|
64
95
|
AnnouncementSchema.index({ forRoles: 1, active: 1 }); // For role-based announcements
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IAudience extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
28
29
|
name: string;
|
|
29
30
|
rules_js?: 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 AudienceSchema = 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",
|
|
@@ -44,5 +58,22 @@ const AudienceSchema = new mongoose_1.Schema({
|
|
|
44
58
|
}, {
|
|
45
59
|
timestamps: true,
|
|
46
60
|
});
|
|
61
|
+
AudienceSchema.pre('save', function (next) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (!this.iid) {
|
|
64
|
+
let unique = false;
|
|
65
|
+
while (!unique) {
|
|
66
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
67
|
+
const existing = yield mongoose_1.default.models.audience.findOne({ iid: id });
|
|
68
|
+
if (!existing) {
|
|
69
|
+
this.iid = id;
|
|
70
|
+
unique = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
next();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
AudienceSchema.index({ iid: 1 }, { unique: true });
|
|
47
78
|
const Audience = mongoose_1.default.models.audience || (0, mongoose_1.model)("audience", AudienceSchema);
|
|
48
79
|
exports.default = Audience;
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IBqPreCompiledData extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
title: string;
|
|
28
29
|
organizationId: mongoose.Schema.Types.ObjectId;
|
|
29
30
|
client: mongoose.Schema.Types.ObjectId;
|
|
@@ -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 BqPreCompiledDataSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
28
42
|
title: {
|
|
29
43
|
type: String,
|
|
30
44
|
default: null,
|
|
@@ -67,6 +81,23 @@ const BqPreCompiledDataSchema = new mongoose_1.Schema({
|
|
|
67
81
|
}, {
|
|
68
82
|
timestamps: true
|
|
69
83
|
});
|
|
84
|
+
BqPreCompiledDataSchema.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.bqprecompileddata.findOne({ iid: id });
|
|
91
|
+
if (!existing) {
|
|
92
|
+
this.iid = id;
|
|
93
|
+
unique = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
next();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
BqPreCompiledDataSchema.index({ iid: 1 }, { unique: true });
|
|
70
101
|
BqPreCompiledDataSchema.index({ organizationId: 1, client: 1 });
|
|
71
102
|
const BqPreCompiledData = mongoose_1.default.models.bqprecompileddata || (0, mongoose_1.model)("bqprecompileddata", BqPreCompiledDataSchema);
|
|
72
103
|
exports.default = BqPreCompiledData;
|
|
@@ -22,12 +22,22 @@ 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 PropertySchema = new mongoose_1.Schema({
|
|
33
43
|
propertyname: { type: String, required: true },
|
|
@@ -35,6 +45,10 @@ const PropertySchema = new mongoose_1.Schema({
|
|
|
35
45
|
platform: { type: String, default: "GA4" }
|
|
36
46
|
});
|
|
37
47
|
const ClientSchema = new mongoose_1.Schema({
|
|
48
|
+
iid: {
|
|
49
|
+
type: String,
|
|
50
|
+
trim: true,
|
|
51
|
+
},
|
|
38
52
|
organizationId: { type: mongoose_1.default.Schema.Types.ObjectId,
|
|
39
53
|
ref: "organization",
|
|
40
54
|
default: null },
|
|
@@ -70,6 +84,23 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
70
84
|
}, {
|
|
71
85
|
timestamps: true
|
|
72
86
|
});
|
|
87
|
+
ClientSchema.pre('save', function (next) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (!this.iid) {
|
|
90
|
+
let unique = false;
|
|
91
|
+
while (!unique) {
|
|
92
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
93
|
+
const existing = yield mongoose_1.default.models.client.findOne({ iid: id });
|
|
94
|
+
if (!existing) {
|
|
95
|
+
this.iid = id;
|
|
96
|
+
unique = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
ClientSchema.index({ iid: 1 }, { unique: true });
|
|
73
104
|
// Add compound indexes for better query performance
|
|
74
105
|
ClientSchema.index({ active: 1 });
|
|
75
106
|
ClientSchema.index({ organizationId: 1, active: 1 });
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IClientAdditionalRevenue extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
28
29
|
client?: mongoose.Schema.Types.ObjectId;
|
|
29
|
-
additionalRevenueForTests: IAdditionalRevenue;
|
|
30
|
+
additionalRevenueForTests: IAdditionalRevenue[];
|
|
30
31
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
31
32
|
}
|
|
32
33
|
export interface IAdditionalRevenue extends Document {
|
|
34
|
+
iid: string;
|
|
33
35
|
segmentName: string;
|
|
34
36
|
lastDate?: Date;
|
|
35
37
|
test?: mongoose.Schema.Types.ObjectId;
|
|
@@ -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 AdditionalRevenueSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
28
42
|
// add_rev: {
|
|
29
43
|
// type: Number,
|
|
30
44
|
// },
|
|
@@ -44,6 +58,10 @@ const AdditionalRevenueSchema = new mongoose_1.Schema({
|
|
|
44
58
|
},
|
|
45
59
|
});
|
|
46
60
|
const ClientAdditionalRevenueSchema = new mongoose_1.Schema({
|
|
61
|
+
iid: {
|
|
62
|
+
type: String,
|
|
63
|
+
trim: true,
|
|
64
|
+
},
|
|
47
65
|
organizationId: {
|
|
48
66
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
49
67
|
ref: "organization",
|
|
@@ -62,6 +80,36 @@ const ClientAdditionalRevenueSchema = new mongoose_1.Schema({
|
|
|
62
80
|
}, {
|
|
63
81
|
timestamps: true,
|
|
64
82
|
});
|
|
83
|
+
ClientAdditionalRevenueSchema.pre('save', function (next) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (!this.iid) {
|
|
86
|
+
let unique = false;
|
|
87
|
+
while (!unique) {
|
|
88
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
89
|
+
const existing = yield mongoose_1.default.models.clientadditionalrevenue.findOne({ iid: id });
|
|
90
|
+
if (!existing) {
|
|
91
|
+
this.iid = id;
|
|
92
|
+
unique = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// For each Variation inside Test
|
|
97
|
+
for (const additionalRevenue of this.additionalRevenueForTests) {
|
|
98
|
+
if (!additionalRevenue.iid) {
|
|
99
|
+
let uniqueVar = false;
|
|
100
|
+
while (!uniqueVar) {
|
|
101
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
102
|
+
const existingVar = yield mongoose_1.default.models.clientadditionalrevenue.findOne({ "additionalRevenueForTests.iid": id });
|
|
103
|
+
if (!existingVar) {
|
|
104
|
+
additionalRevenue.iid = id;
|
|
105
|
+
uniqueVar = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
next();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
65
113
|
ClientAdditionalRevenueSchema.index({
|
|
66
114
|
client: 1,
|
|
67
115
|
});
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IClientLearning extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
name: string;
|
|
28
29
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
29
30
|
client?: mongoose.Schema.Types.ObjectId;
|
|
@@ -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 ClientLearningSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
28
42
|
name: {
|
|
29
43
|
type: String,
|
|
30
44
|
required: true,
|
|
@@ -49,6 +63,23 @@ const ClientLearningSchema = new mongoose_1.Schema({
|
|
|
49
63
|
}, {
|
|
50
64
|
timestamps: true,
|
|
51
65
|
});
|
|
66
|
+
ClientLearningSchema.pre('save', function (next) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (!this.iid) {
|
|
69
|
+
let unique = false;
|
|
70
|
+
while (!unique) {
|
|
71
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
72
|
+
const existing = yield mongoose_1.default.models.clientlearning.findOne({ iid: id });
|
|
73
|
+
if (!existing) {
|
|
74
|
+
this.iid = id;
|
|
75
|
+
unique = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
next();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
ClientLearningSchema.index({ iid: 1 }, { unique: true });
|
|
52
83
|
// Compound indexes for common query patterns
|
|
53
84
|
ClientLearningSchema.index({ client: 1 });
|
|
54
85
|
// Sparse indexes for optional fields
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IClientLinks extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
28
29
|
title: string;
|
|
29
30
|
description?: 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 ClientLinksSchema = 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",
|
|
@@ -62,6 +76,23 @@ const ClientLinksSchema = new mongoose_1.Schema({
|
|
|
62
76
|
}, {
|
|
63
77
|
timestamps: true,
|
|
64
78
|
});
|
|
79
|
+
ClientLinksSchema.pre('save', function (next) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!this.iid) {
|
|
82
|
+
let unique = false;
|
|
83
|
+
while (!unique) {
|
|
84
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
85
|
+
const existing = yield mongoose_1.default.models.clientlink.findOne({ iid: id });
|
|
86
|
+
if (!existing) {
|
|
87
|
+
this.iid = id;
|
|
88
|
+
unique = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
next();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
ClientLinksSchema.index({ iid: 1 }, { unique: true });
|
|
65
96
|
// Compound indexes for common query patterns
|
|
66
97
|
ClientLinksSchema.index({ client: 1 });
|
|
67
98
|
ClientLinksSchema.index({ client: 1, private: 1 });
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IClientNextSteps extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
name: string;
|
|
28
29
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
29
30
|
client?: mongoose.Schema.Types.ObjectId;
|
|
@@ -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 ClientNextStepsSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
28
42
|
name: {
|
|
29
43
|
type: String,
|
|
30
44
|
required: true,
|
|
@@ -48,6 +62,22 @@ const ClientNextStepsSchema = new mongoose_1.Schema({
|
|
|
48
62
|
}, {
|
|
49
63
|
timestamps: true,
|
|
50
64
|
});
|
|
65
|
+
ClientNextStepsSchema.pre('save', function (next) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (!this.iid) {
|
|
68
|
+
let unique = false;
|
|
69
|
+
while (!unique) {
|
|
70
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
71
|
+
const existing = yield mongoose_1.default.models.clientnextstep.findOne({ iid: id });
|
|
72
|
+
if (!existing) {
|
|
73
|
+
this.iid = id;
|
|
74
|
+
unique = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
next();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
51
81
|
ClientNextStepsSchema.index({
|
|
52
82
|
client: 1,
|
|
53
83
|
viewId: 1,
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IClientNote extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
28
29
|
client?: mongoose.Schema.Types.ObjectId;
|
|
29
30
|
viewId?: 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 ClientNoteSchema = 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",
|
|
@@ -61,7 +75,24 @@ const ClientNoteSchema = new mongoose_1.Schema({
|
|
|
61
75
|
}, {
|
|
62
76
|
timestamps: true,
|
|
63
77
|
});
|
|
78
|
+
ClientNoteSchema.pre('save', function (next) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
if (!this.iid) {
|
|
81
|
+
let unique = false;
|
|
82
|
+
while (!unique) {
|
|
83
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
84
|
+
const existing = yield mongoose_1.default.models.clientnote.findOne({ iid: id });
|
|
85
|
+
if (!existing) {
|
|
86
|
+
this.iid = id;
|
|
87
|
+
unique = true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
next();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
64
94
|
ClientNoteSchema.index({
|
|
95
|
+
iid: 1,
|
|
65
96
|
client: 1,
|
|
66
97
|
viewId: 1,
|
|
67
98
|
});
|