codebase-models 1.0.1 → 1.0.3
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 +2 -2
- package/dist/index.js +13 -6
- package/dist/src/models/Audience.d.ts +1 -1
- package/dist/src/models/Audience.js +1 -1
- package/dist/src/models/Client.d.ts +2 -0
- package/dist/src/models/Client.js +6 -0
- package/dist/src/models/Experiments.d.ts +2 -2
- package/dist/src/models/Test.d.ts +3 -3
- package/index.ts +14 -8
- package/package.json +1 -1
- package/src/models/Audience.ts +17 -14
- package/src/models/Client.ts +8 -0
- package/src/models/Experiments.ts +2 -2
- package/src/models/Test.ts +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,6 @@ import Trigger from "./src/models/Trigger";
|
|
|
68
68
|
import ClientScript from "./src/models/ClientScript";
|
|
69
69
|
import ClientExperiment from "./src/models/ClientExperiment";
|
|
70
70
|
import Audience from "./src/models/Audience";
|
|
71
|
-
import Environment from
|
|
71
|
+
import Environment from "./src/models/Environment";
|
|
72
72
|
export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
|
|
73
|
-
export { Client, ClientReportsTemp, QueryLog, Report, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Experiments, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, SavedSegment, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, ClientExperiment, Audience, Environment };
|
|
73
|
+
export { Client, ClientReportsTemp, QueryLog, Report, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Experiments, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, SavedSegment, Segment, SegmentCombination, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, ClientExperiment, Audience, Environment, };
|
package/dist/index.js
CHANGED
|
@@ -127,19 +127,26 @@ function seedRoles() {
|
|
|
127
127
|
},
|
|
128
128
|
]);
|
|
129
129
|
}));
|
|
130
|
+
console.log("Roles seeded successfully");
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
function connect(uri, options) {
|
|
134
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
136
|
if (uri) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (mongoose_1.default.connection.readyState === 1) {
|
|
138
|
+
// Already connected
|
|
139
|
+
console.log("Already connected to the database");
|
|
140
|
+
return mongoose_1.default;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
console.log("Connecting to the database on URI: ", uri);
|
|
144
|
+
const mongooseConnection = yield mongoose_1.default.connect(uri, options);
|
|
145
|
+
if (mongooseConnection.connection.readyState === 1) {
|
|
146
|
+
yield seedRoles();
|
|
147
|
+
}
|
|
148
|
+
return mongooseConnection;
|
|
141
149
|
}
|
|
142
|
-
return mongooseConnection;
|
|
143
150
|
}
|
|
144
151
|
throw new Error("URI is required to connect to the database");
|
|
145
152
|
});
|
|
@@ -26,7 +26,7 @@ import mongoose, { Document } from "mongoose";
|
|
|
26
26
|
export interface IAudience extends Document {
|
|
27
27
|
name: string;
|
|
28
28
|
rules_js?: string;
|
|
29
|
-
client
|
|
29
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
30
30
|
}
|
|
31
31
|
declare const Audience: mongoose.Model<IAudience, {}, {}, {}, mongoose.Document<unknown, {}, IAudience> & IAudience & {
|
|
32
32
|
_id: mongoose.Types.ObjectId;
|
|
@@ -44,6 +44,8 @@ export interface IClient extends Document {
|
|
|
44
44
|
bqClientId?: string;
|
|
45
45
|
defaultDataSet?: string;
|
|
46
46
|
NDAStatus?: boolean;
|
|
47
|
+
retainerValue: number;
|
|
48
|
+
useIntraDayTable: boolean;
|
|
47
49
|
}
|
|
48
50
|
declare const Client: mongoose.Model<IClient, {}, {}, {}, mongoose.Document<unknown, {}, IClient> & IClient & {
|
|
49
51
|
_id: mongoose.Types.ObjectId;
|
|
@@ -89,6 +89,12 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
89
89
|
type: Boolean,
|
|
90
90
|
default: false,
|
|
91
91
|
},
|
|
92
|
+
retainerValue: {
|
|
93
|
+
type: Number,
|
|
94
|
+
},
|
|
95
|
+
useIntraDayTable: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
},
|
|
92
98
|
}, { timestamps: true });
|
|
93
99
|
ClientSchema.index({ active: 1 });
|
|
94
100
|
const Client = (0, mongoose_1.model)("client", ClientSchema);
|
|
@@ -48,9 +48,9 @@ export interface IExperiments extends Document {
|
|
|
48
48
|
js: string;
|
|
49
49
|
reset_js: string;
|
|
50
50
|
csscode: string;
|
|
51
|
-
audiences
|
|
51
|
+
audiences?: mongoose.Schema.Types.Array;
|
|
52
52
|
variations: IVariations;
|
|
53
|
-
environments
|
|
53
|
+
environments?: mongoose.Schema.Types.Array;
|
|
54
54
|
}
|
|
55
55
|
declare const Experiments: mongoose.Model<IExperiments, {}, {}, {}, mongoose.Document<unknown, {}, IExperiments> & IExperiments & {
|
|
56
56
|
_id: mongoose.Types.ObjectId;
|
|
@@ -49,13 +49,13 @@ export interface ITest extends Document {
|
|
|
49
49
|
jscode: string;
|
|
50
50
|
reset_js: string;
|
|
51
51
|
csscode: string;
|
|
52
|
-
audiences
|
|
52
|
+
audiences?: mongoose.Schema.Types.ObjectId[];
|
|
53
53
|
variations: IVariations[];
|
|
54
|
-
environments
|
|
54
|
+
environments?: mongoose.Schema.Types.Array;
|
|
55
55
|
pages?: mongoose.Schema.Types.ObjectId[];
|
|
56
56
|
pageelement?: mongoose.Schema.Types.ObjectId[];
|
|
57
57
|
client?: mongoose.Schema.Types.ObjectId;
|
|
58
|
-
property
|
|
58
|
+
property?: mongoose.Schema.Types.Mixed;
|
|
59
59
|
platform: string;
|
|
60
60
|
viewId: string;
|
|
61
61
|
goal?: mongoose.Schema.Types.ObjectId[];
|
package/index.ts
CHANGED
|
@@ -45,7 +45,7 @@ import Trigger from "./src/models/Trigger";
|
|
|
45
45
|
import ClientScript from "./src/models/ClientScript";
|
|
46
46
|
import ClientExperiment from "./src/models/ClientExperiment";
|
|
47
47
|
import Audience from "./src/models/Audience";
|
|
48
|
-
import Environment from
|
|
48
|
+
import Environment from "./src/models/Environment";
|
|
49
49
|
|
|
50
50
|
async function seedRoles() {
|
|
51
51
|
const checkRoles = await Role.countDocuments();
|
|
@@ -69,6 +69,7 @@ async function seedRoles() {
|
|
|
69
69
|
]);
|
|
70
70
|
})
|
|
71
71
|
);
|
|
72
|
+
console.log("Roles seeded successfully");
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -77,13 +78,18 @@ export async function connect(
|
|
|
77
78
|
options?: mongoose.ConnectOptions | undefined
|
|
78
79
|
): Promise<typeof mongoose> {
|
|
79
80
|
if (uri) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
if (mongoose.connection.readyState === 1) {
|
|
82
|
+
// Already connected
|
|
83
|
+
console.log("Already connected to the database");
|
|
84
|
+
return mongoose;
|
|
85
|
+
} else {
|
|
86
|
+
console.log("Connecting to the database on URI: ", uri);
|
|
87
|
+
const mongooseConnection = await mongoose.connect(uri, options);
|
|
88
|
+
if (mongooseConnection.connection.readyState === 1) {
|
|
89
|
+
await seedRoles();
|
|
90
|
+
}
|
|
91
|
+
return mongooseConnection;
|
|
85
92
|
}
|
|
86
|
-
return mongooseConnection;
|
|
87
93
|
}
|
|
88
94
|
throw new Error("URI is required to connect to the database");
|
|
89
95
|
}
|
|
@@ -134,5 +140,5 @@ export {
|
|
|
134
140
|
ClientScript,
|
|
135
141
|
ClientExperiment,
|
|
136
142
|
Audience,
|
|
137
|
-
Environment
|
|
143
|
+
Environment,
|
|
138
144
|
};
|
package/package.json
CHANGED
package/src/models/Audience.ts
CHANGED
|
@@ -3,24 +3,27 @@ import mongoose, { Document, Schema, model } from "mongoose";
|
|
|
3
3
|
export interface IAudience extends Document {
|
|
4
4
|
name: string;
|
|
5
5
|
rules_js?: string;
|
|
6
|
-
client
|
|
6
|
+
client?: mongoose.Schema.Types.ObjectId;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const AudienceSchema = new Schema<IAudience>(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const AudienceSchema = new Schema<IAudience>(
|
|
10
|
+
{
|
|
11
|
+
name: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
rules_js: {
|
|
16
|
+
type: String,
|
|
17
|
+
},
|
|
18
|
+
client: {
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
ref: "client",
|
|
21
|
+
},
|
|
13
22
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
client: {
|
|
18
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
-
ref: "client",
|
|
23
|
+
{
|
|
24
|
+
timestamps: true,
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
timestamps: true,
|
|
23
|
-
});
|
|
26
|
+
);
|
|
24
27
|
|
|
25
28
|
const Audience = model<IAudience>("audience", AudienceSchema);
|
|
26
29
|
|
package/src/models/Client.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface IClient extends Document {
|
|
|
31
31
|
bqClientId?: string;
|
|
32
32
|
defaultDataSet?: string;
|
|
33
33
|
NDAStatus?: boolean;
|
|
34
|
+
retainerValue: number;
|
|
35
|
+
useIntraDayTable: boolean;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const ClientSchema: Schema = new Schema<IClient>(
|
|
@@ -89,6 +91,12 @@ const ClientSchema: Schema = new Schema<IClient>(
|
|
|
89
91
|
type: Boolean,
|
|
90
92
|
default: false,
|
|
91
93
|
},
|
|
94
|
+
retainerValue: {
|
|
95
|
+
type: Number,
|
|
96
|
+
},
|
|
97
|
+
useIntraDayTable: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
},
|
|
92
100
|
},
|
|
93
101
|
{ timestamps: true }
|
|
94
102
|
);
|
|
@@ -26,9 +26,9 @@ export interface IExperiments extends Document {
|
|
|
26
26
|
js: string;
|
|
27
27
|
reset_js: string;
|
|
28
28
|
csscode: string;
|
|
29
|
-
audiences
|
|
29
|
+
audiences?: mongoose.Schema.Types.Array;
|
|
30
30
|
variations: IVariations;
|
|
31
|
-
environments
|
|
31
|
+
environments?: mongoose.Schema.Types.Array;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const VariationsSchema = new Schema<IVariations>({
|
package/src/models/Test.ts
CHANGED
|
@@ -26,14 +26,14 @@ export interface ITest extends Document {
|
|
|
26
26
|
jscode: string;
|
|
27
27
|
reset_js: string;
|
|
28
28
|
csscode: string;
|
|
29
|
-
audiences
|
|
29
|
+
audiences?: mongoose.Schema.Types.ObjectId[];
|
|
30
30
|
variations: IVariations[];
|
|
31
|
-
environments
|
|
31
|
+
environments?: mongoose.Schema.Types.Array;
|
|
32
32
|
pages?: mongoose.Schema.Types.ObjectId[];
|
|
33
|
-
// OLD SCHEMA VARIABLES
|
|
33
|
+
// OLD SCHEMA VARIABLES
|
|
34
34
|
pageelement?: mongoose.Schema.Types.ObjectId[];
|
|
35
35
|
client?: mongoose.Schema.Types.ObjectId;
|
|
36
|
-
property
|
|
36
|
+
property?: mongoose.Schema.Types.Mixed;
|
|
37
37
|
platform: string;
|
|
38
38
|
viewId: string;
|
|
39
39
|
goal?: mongoose.Schema.Types.ObjectId[];
|