codebase-models 1.0.2 → 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 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 './src/models/Environment';
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
- console.log("Connecting to the database on URI: ", uri);
137
- const mongooseConnection = yield mongoose_1.default.connect(uri, options);
138
- if (mongooseConnection.connection.readyState === 1) {
139
- yield seedRoles();
140
- console.log("Roles seeded successfully");
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: mongoose.Schema.Types.ObjectId;
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;
@@ -35,7 +35,7 @@ const AudienceSchema = new mongoose_1.Schema({
35
35
  client: {
36
36
  type: mongoose_1.default.Schema.Types.ObjectId,
37
37
  ref: "client",
38
- }
38
+ },
39
39
  }, {
40
40
  timestamps: true,
41
41
  });
@@ -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: mongoose.Schema.Types.Array;
51
+ audiences?: mongoose.Schema.Types.Array;
52
52
  variations: IVariations;
53
- environments: mongoose.Schema.Types.Array;
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: mongoose.Schema.Types.ObjectId[];
52
+ audiences?: mongoose.Schema.Types.ObjectId[];
53
53
  variations: IVariations[];
54
- environments: mongoose.Schema.Types.Array;
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: mongoose.Schema.Types.Mixed;
58
+ property?: mongoose.Schema.Types.Mixed;
59
59
  platform: string;
60
60
  viewId: string;
61
61
  goal?: mongoose.Schema.Types.ObjectId[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-models",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Common models for codebase",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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: mongoose.Schema.Types.ObjectId;
6
+ client?: mongoose.Schema.Types.ObjectId;
7
7
  }
8
8
 
9
- const AudienceSchema = new Schema<IAudience>({
10
- name: {
11
- type: String,
12
- required: true,
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
- rules_js: {
15
- type: String,
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
 
@@ -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: mongoose.Schema.Types.Array;
29
+ audiences?: mongoose.Schema.Types.Array;
30
30
  variations: IVariations;
31
- environments: mongoose.Schema.Types.Array;
31
+ environments?: mongoose.Schema.Types.Array;
32
32
  }
33
33
 
34
34
  const VariationsSchema = new Schema<IVariations>({
@@ -26,14 +26,14 @@ export interface ITest extends Document {
26
26
  jscode: string;
27
27
  reset_js: string;
28
28
  csscode: string;
29
- audiences: mongoose.Schema.Types.ObjectId[];
29
+ audiences?: mongoose.Schema.Types.ObjectId[];
30
30
  variations: IVariations[];
31
- environments: mongoose.Schema.Types.Array;
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: mongoose.Schema.Types.Mixed;
36
+ property?: mongoose.Schema.Types.Mixed;
37
37
  platform: string;
38
38
  viewId: string;
39
39
  goal?: mongoose.Schema.Types.ObjectId[];