codebase-models 1.0.0 → 1.0.2

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.
@@ -0,0 +1,118 @@
1
+ import mongoose, { Document, Schema, model } from "mongoose";
2
+
3
+ export interface IVariations extends Document {
4
+ name: string;
5
+ css_code: string;
6
+ baseline: Boolean;
7
+ traffic_allocation: Number;
8
+ metadata_1: mongoose.Schema.Types.Mixed;
9
+ metadata_2: mongoose.Schema.Types.Mixed;
10
+ metadata_3: mongoose.Schema.Types.Mixed;
11
+ js: string;
12
+ reset_js: string;
13
+ css: string;
14
+ changesets: string;
15
+ }
16
+
17
+ export interface IExperiments extends Document {
18
+ status: string;
19
+ name: string;
20
+ traffic_allocation: Number;
21
+ audiences_match_type: string;
22
+ metadata_1: mongoose.Schema.Types.Mixed;
23
+ metadata_2: mongoose.Schema.Types.Mixed;
24
+ metadata_3: mongoose.Schema.Types.Mixed;
25
+ integrations_run_mode: mongoose.Schema.Types.Mixed;
26
+ js: string;
27
+ reset_js: string;
28
+ csscode: string;
29
+ audiences: mongoose.Schema.Types.Array;
30
+ variations: IVariations;
31
+ environments: mongoose.Schema.Types.Array;
32
+ }
33
+
34
+ const VariationsSchema = new Schema<IVariations>({
35
+ name: {
36
+ type: String,
37
+ },
38
+ css_code: {
39
+ type: String,
40
+ },
41
+ baseline: {
42
+ type: Boolean,
43
+ },
44
+ traffic_allocation: {
45
+ type: Number,
46
+ },
47
+ metadata_1: {
48
+ type: mongoose.Schema.Types.Mixed,
49
+ },
50
+ metadata_2: {
51
+ type: mongoose.Schema.Types.Mixed,
52
+ },
53
+ metadata_3: {
54
+ type: mongoose.Schema.Types.Mixed,
55
+ },
56
+ js: {
57
+ type: String,
58
+ },
59
+ reset_js: {
60
+ type: String,
61
+ },
62
+ css: {
63
+ type: String,
64
+ },
65
+ changesets: {
66
+ type: String,
67
+ },
68
+ });
69
+
70
+ const ExperimentsSchema = new Schema<IExperiments>({
71
+ status: {
72
+ type: String,
73
+ },
74
+ name: {
75
+ type: String,
76
+ required: true,
77
+ },
78
+ traffic_allocation: {
79
+ type: Number,
80
+ default: 100,
81
+ },
82
+ audiences_match_type: {
83
+ type: String,
84
+ default: "all",
85
+ },
86
+ metadata_1: {
87
+ type: mongoose.Schema.Types.Mixed,
88
+ },
89
+ metadata_2: {
90
+ type: mongoose.Schema.Types.Mixed,
91
+ },
92
+ metadata_3: {
93
+ type: mongoose.Schema.Types.Mixed,
94
+ },
95
+ integrations_run_mode: {
96
+ type: mongoose.Schema.Types.Mixed,
97
+ },
98
+ js: {
99
+ type: String,
100
+ },
101
+ reset_js: {
102
+ type: String,
103
+ },
104
+ csscode: {
105
+ type: String,
106
+ },
107
+ audiences: {
108
+ type: mongoose.Schema.Types.Array,
109
+ },
110
+ variations: VariationsSchema,
111
+ environments: {
112
+ type: mongoose.Schema.Types.Array,
113
+ },
114
+ });
115
+
116
+ const Experiments = model<IExperiments>("experiments", ExperimentsSchema);
117
+
118
+ export default Experiments;
@@ -1,10 +1,18 @@
1
1
  import mongoose, { Document, Schema, model } from "mongoose";
2
+ import slug from "mongoose-slug-updater"
3
+ mongoose.plugin(slug)
2
4
 
3
5
  export interface IGoal extends Document {
4
6
  name: string;
5
7
  details?: string;
6
8
  slug?: string;
7
9
  organisationId?: string;
10
+ client?: mongoose.Schema.Types.ObjectId;
11
+ type: string;
12
+ counting_method: string;
13
+ css_selector: string;
14
+ api_name: string;
15
+ rules_js: string;
8
16
  createdAt?: Date;
9
17
  updatedAt?: Date;
10
18
  }
@@ -25,6 +33,23 @@ const GoalSchema = new Schema<IGoal>({
25
33
  type: String,
26
34
  default: null,
27
35
  },
36
+ client: {
37
+ type: mongoose.Schema.Types.ObjectId,
38
+ ref: "client",
39
+ },
40
+ type: {
41
+ type: String,
42
+ },
43
+ counting_method: {
44
+ type: String,
45
+ },
46
+ css_selector: {
47
+ type: String,
48
+ },
49
+ api_name: { type: String, slug: ["name"], slugPaddingSize: 4, unique: true },
50
+ rules_js: {
51
+ type: String,
52
+ },
28
53
  createdAt: {
29
54
  type: Date,
30
55
  default: new Date(),
@@ -0,0 +1,69 @@
1
+ import mongoose, { Document, Schema, model } from "mongoose";
2
+ import slug from "mongoose-slug-updater"
3
+ mongoose.plugin(slug)
4
+ export interface IUrltargetings extends Document {
5
+ type: string;
6
+ url: string;
7
+ url_type: string;
8
+ }
9
+
10
+ export interface IPage extends Document {
11
+ name: string;
12
+ client?: mongoose.Schema.Types.ObjectId;
13
+ trigger: string;
14
+ trigger_js: string;
15
+ api_name: string;
16
+ poll_on_rules: Boolean;
17
+ deactivation_mode: string;
18
+ rules_js: string;
19
+ urltargetings: IUrltargetings;
20
+ }
21
+
22
+ const UrltargetingsSchema = new Schema<IUrltargetings>({
23
+ type: {
24
+ type: String,
25
+ },
26
+ url: {
27
+ type: String,
28
+ },
29
+ url_type: {
30
+ type: String,
31
+ },
32
+ });
33
+
34
+ const PageSchema = new Schema<IPage>({
35
+ name: {
36
+ type: String,
37
+ required: true,
38
+ },
39
+ trigger: {
40
+ type: String,
41
+ default: "direct"
42
+ },
43
+ client: {
44
+ type: mongoose.Schema.Types.ObjectId,
45
+ ref: "client",
46
+ },
47
+ trigger_js: {
48
+ type: String,
49
+ default: ""
50
+ },
51
+ api_name: { type: String, slug: ["name"], slugPaddingSize: 4, unique: true },
52
+ poll_on_rules: {
53
+ type: Boolean,
54
+ default: false,
55
+ },
56
+ deactivation_mode: {
57
+ type: String,
58
+ default: "reset",
59
+ },
60
+ rules_js: {
61
+ type: String,
62
+ default:"return true"
63
+ },
64
+ urltargetings: [UrltargetingsSchema],
65
+ });
66
+
67
+ const Page = model<IPage>("page", PageSchema);
68
+
69
+ export default Page;
@@ -1,8 +1,36 @@
1
1
  import mongoose, { Document, Schema, model } from "mongoose";
2
2
 
3
- export interface ITest extends Document {
3
+ export interface IVariations extends Document {
4
4
  name: string;
5
+ css_code: string;
6
+ baseline: Boolean;
7
+ traffic_allocation: Number;
8
+ metadata_1: mongoose.Schema.Types.Mixed;
9
+ metadata_2: mongoose.Schema.Types.Mixed;
10
+ metadata_3: mongoose.Schema.Types.Mixed;
11
+ jscode: string;
12
+ reset_js: string;
13
+ csscode: string;
14
+ changesets: string;
15
+ }
16
+ export interface ITest extends Document {
5
17
  organisationId?: string;
18
+ status: string;
19
+ name: string;
20
+ traffic_allocation: Number;
21
+ audiences_match_type: string;
22
+ metadata_1: mongoose.Schema.Types.Mixed;
23
+ metadata_2: mongoose.Schema.Types.Mixed;
24
+ metadata_3: mongoose.Schema.Types.Mixed;
25
+ integrations_run_mode: mongoose.Schema.Types.Mixed;
26
+ jscode: string;
27
+ reset_js: string;
28
+ csscode: string;
29
+ audiences: mongoose.Schema.Types.ObjectId[];
30
+ variations: IVariations[];
31
+ environments: mongoose.Schema.Types.Array;
32
+ pages?: mongoose.Schema.Types.ObjectId[];
33
+ // OLD SCHEMA VARIABLES
6
34
  pageelement?: mongoose.Schema.Types.ObjectId[];
7
35
  client?: mongoose.Schema.Types.ObjectId;
8
36
  property: mongoose.Schema.Types.Mixed;
@@ -21,8 +49,6 @@ export interface ITest extends Document {
21
49
  pageNotContains: string;
22
50
  eventparameter: string;
23
51
  htmlcode: string;
24
- csscode: string;
25
- jscode: string;
26
52
  testid: string;
27
53
  testtool: string;
28
54
  kameleoontestdetails: mongoose.Schema.Types.Mixed;
@@ -34,21 +60,108 @@ export interface ITest extends Document {
34
60
  revenue?: [];
35
61
  significance: string;
36
62
  recommendedsamplesize: number;
37
- status: string;
38
63
  livedate: Date;
39
64
  defaultControl: string;
40
65
  enddate: Date;
41
66
  }
42
67
 
68
+ const VariationsSchema = new Schema<IVariations>({
69
+ name: {
70
+ type: String,
71
+ },
72
+ css_code: {
73
+ type: String,
74
+ },
75
+ baseline: {
76
+ type: Boolean,
77
+ },
78
+ traffic_allocation: {
79
+ type: Number,
80
+ },
81
+ metadata_1: {
82
+ type: mongoose.Schema.Types.Mixed,
83
+ },
84
+ metadata_2: {
85
+ type: mongoose.Schema.Types.Mixed,
86
+ },
87
+ metadata_3: {
88
+ type: mongoose.Schema.Types.Mixed,
89
+ },
90
+ jscode: {
91
+ type: String,
92
+ },
93
+ reset_js: {
94
+ type: String,
95
+ },
96
+ csscode: {
97
+ type: String,
98
+ },
99
+ changesets: {
100
+ type: String,
101
+ default: "[]",
102
+ },
103
+ });
104
+
43
105
  const TestSchema = new Schema<ITest>(
44
106
  {
107
+ organisationId: {
108
+ type: String,
109
+ default: null,
110
+ },
111
+ status: {
112
+ type: String,
113
+ default: "draft",
114
+ enum: ["live", "draft", "ended", "paused", "preview"], // running is live
115
+ },
45
116
  name: {
46
117
  type: String,
47
118
  required: true,
48
119
  },
49
- organisationId: {
120
+ traffic_allocation: {
121
+ type: Number,
122
+ default: 100,
123
+ },
124
+ audiences_match_type: {
50
125
  type: String,
51
- default: null,
126
+ default: "all",
127
+ },
128
+ metadata_1: {
129
+ type: mongoose.Schema.Types.Mixed,
130
+ },
131
+ metadata_2: {
132
+ type: mongoose.Schema.Types.Mixed,
133
+ },
134
+ metadata_3: {
135
+ type: mongoose.Schema.Types.Mixed,
136
+ },
137
+ integrations_run_mode: {
138
+ type: mongoose.Schema.Types.Mixed,
139
+ },
140
+ jscode: {
141
+ type: String,
142
+ default: "",
143
+ },
144
+ reset_js: {
145
+ type: String,
146
+ },
147
+ csscode: {
148
+ type: String,
149
+ },
150
+ audiences: {
151
+ type: [mongoose.Schema.Types.ObjectId],
152
+ ref: "audience",
153
+ default: [],
154
+ },
155
+ pages: {
156
+ type: [mongoose.Schema.Types.ObjectId],
157
+ ref: "page",
158
+ default: [],
159
+ },
160
+ variations: [VariationsSchema],
161
+ environments: {
162
+ type: [mongoose.Schema.Types.ObjectId],
163
+ ref: "environment",
164
+ default: [],
52
165
  },
53
166
  pageelement: {
54
167
  type: [mongoose.Schema.Types.ObjectId],
@@ -64,7 +177,7 @@ const TestSchema = new Schema<ITest>(
64
177
  },
65
178
  platform: {
66
179
  type: String,
67
- default: "UA",
180
+ default: "BQ",
68
181
  },
69
182
  viewId: {
70
183
  type: String,
@@ -98,10 +211,12 @@ const TestSchema = new Schema<ITest>(
98
211
  default: null,
99
212
  },
100
213
  // Action , Posibility, Hypothesis
214
+ // Check if we need anymore
101
215
  urltargeting: {
102
216
  type: [],
103
217
  default: [],
104
218
  },
219
+ // Check if we need anymore
105
220
  pageaudience: {
106
221
  type: String,
107
222
  default: null,
@@ -126,13 +241,6 @@ const TestSchema = new Schema<ITest>(
126
241
  type: String,
127
242
  default: "",
128
243
  },
129
- csscode: {
130
- type: String,
131
- },
132
- jscode: {
133
- type: String,
134
- default: "",
135
- },
136
244
  testid: {
137
245
  type: String,
138
246
  default: null,
@@ -179,11 +287,6 @@ const TestSchema = new Schema<ITest>(
179
287
  type: Number,
180
288
  default: null,
181
289
  },
182
- status: {
183
- type: String,
184
- default: "draft",
185
- enum: ["live", "draft", "ended"],
186
- },
187
290
  livedate: {
188
291
  type: Date,
189
292
  default: null,