codebase-models 2.1.20 → 2.1.22

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
@@ -75,5 +75,6 @@ import CustomQuery from "./src/models/CustomQuery";
75
75
  import { generateRandomIID } from "./src/constant";
76
76
  import TestTimeline from "./src/models/TestTimeline";
77
77
  import CronData from "./src/models/CronData";
78
+ import CronConfig from "./src/models/CronConfig";
78
79
  export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
79
- 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, CronData, UserPermission, };
80
+ 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, CronData, CronConfig, UserPermission };
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
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.UserPermission = exports.CronData = exports.BqPreCompiledData = void 0;
16
+ exports.UserPermission = exports.CronConfig = exports.CronData = exports.BqPreCompiledData = void 0;
17
17
  const mongoose_1 = __importDefault(require("mongoose"));
18
18
  const Client_1 = __importDefault(require("./src/models/Client"));
19
19
  exports.Client = Client_1.default;
@@ -119,6 +119,8 @@ const TestTimeline_1 = __importDefault(require("./src/models/TestTimeline"));
119
119
  exports.TestTimeline = TestTimeline_1.default;
120
120
  const CronData_1 = __importDefault(require("./src/models/CronData"));
121
121
  exports.CronData = CronData_1.default;
122
+ const CronConfig_1 = __importDefault(require("./src/models/CronConfig"));
123
+ exports.CronConfig = CronConfig_1.default;
122
124
  function seedRoles() {
123
125
  return __awaiter(this, void 0, void 0, function* () {
124
126
  const checkRoles = yield Role_1.default.countDocuments();
@@ -0,0 +1,41 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from "mongoose";
26
+ export interface ICronConfig extends Document {
27
+ iid: string;
28
+ organizationId?: mongoose.Schema.Types.ObjectId;
29
+ jobName: string;
30
+ description: string;
31
+ client: mongoose.Schema.Types.ObjectId;
32
+ test: mongoose.Schema.Types.ObjectId;
33
+ active: boolean;
34
+ lastRun: Date;
35
+ nextRun: Date;
36
+ schedule: string;
37
+ metadata: mongoose.Schema.Types.Mixed;
38
+ createdBy: mongoose.Schema.Types.ObjectId;
39
+ }
40
+ declare const CronConfig: mongoose.Model<any, {}, {}, {}, any, any>;
41
+ export default CronConfig;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
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
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const mongoose_1 = __importStar(require("mongoose"));
36
+ const constant_1 = require("../constant");
37
+ const CronConfigSchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ unique: true,
41
+ },
42
+ organizationId: {
43
+ type: mongoose_1.default.Schema.Types.ObjectId,
44
+ ref: "organization",
45
+ default: null,
46
+ },
47
+ jobName: {
48
+ type: String,
49
+ required: true,
50
+ },
51
+ description: {
52
+ type: String,
53
+ },
54
+ client: {
55
+ type: mongoose_1.default.Schema.Types.ObjectId,
56
+ ref: "client",
57
+ },
58
+ test: {
59
+ type: mongoose_1.default.Schema.Types.ObjectId,
60
+ ref: "test",
61
+ },
62
+ active: {
63
+ type: Boolean,
64
+ default: true,
65
+ },
66
+ lastRun: {
67
+ type: Date,
68
+ default: null,
69
+ },
70
+ nextRun: {
71
+ type: Date,
72
+ default: null,
73
+ },
74
+ schedule: {
75
+ type: String,
76
+ required: true,
77
+ },
78
+ metadata: {
79
+ type: mongoose_1.default.Schema.Types.Mixed,
80
+ default: null,
81
+ },
82
+ createdBy: {
83
+ type: mongoose_1.default.Schema.Types.ObjectId,
84
+ ref: "user",
85
+ default: null,
86
+ required: true,
87
+ },
88
+ }, {
89
+ timestamps: true
90
+ });
91
+ CronConfigSchema.pre("save", function (next) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ if (!this.iid) {
94
+ this.iid = (0, constant_1.generateRandomIID)();
95
+ }
96
+ next();
97
+ });
98
+ });
99
+ CronConfigSchema.index({ test: 1 });
100
+ CronConfigSchema.index({ client: 1 });
101
+ const CronConfig = mongoose_1.default.models.cronConfig || (0, mongoose_1.model)("cronConfig", CronConfigSchema);
102
+ exports.default = CronConfig;
@@ -30,6 +30,7 @@ interface ICustomQuery extends Document {
30
30
  module: string;
31
31
  client: mongoose.Schema.Types.ObjectId;
32
32
  query: string;
33
+ metadata: any;
33
34
  createdBy?: mongoose.Schema.Types.ObjectId;
34
35
  }
35
36
  declare const CustomQuery: mongoose.Model<ICustomQuery, {}, {}, {}, mongoose.Document<unknown, {}, ICustomQuery> & ICustomQuery & {
@@ -43,7 +43,8 @@ const CustomQuerySchema = new mongoose_1.Schema({
43
43
  title: { type: String, required: true },
44
44
  module: { type: String, required: true },
45
45
  client: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'client', required: true },
46
- query: { type: String, required: true },
46
+ query: { type: String },
47
+ metadata: { type: mongoose_1.default.Schema.Types.Mixed, default: null },
47
48
  createdBy: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'user', default: null },
48
49
  }, {
49
50
  timestamps: true, // Automatically adds createdAt and updatedAt fields
@@ -43,6 +43,7 @@ export interface ITest extends Document {
43
43
  iid: string;
44
44
  status: string;
45
45
  name: string;
46
+ traffic_allocation_type: string;
46
47
  traffic_allocation: number;
47
48
  audiences_match_type: string;
48
49
  metadata_1: mongoose.Schema.Types.Mixed;
@@ -65,6 +65,7 @@ const TestSchema = new mongoose_1.Schema({
65
65
  enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"]
66
66
  },
67
67
  name: { type: String, required: true },
68
+ traffic_allocation_type: { type: String, default: "manual", enum: ["manual", "multi-armed", "contextual"] },
68
69
  traffic_allocation: { type: Number, default: 100 },
69
70
  audiences_match_type: { type: String, default: "all" },
70
71
  // Metadata fields
@@ -41,7 +41,7 @@ const TestTimelineSchema = new mongoose_1.Schema({
41
41
  },
42
42
  event: {
43
43
  type: String,
44
- enum: ["test_created", "test_updated", "test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted"],
44
+ enum: ["test_created", "test_updated", "test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted", "traffic_allocation_changed"],
45
45
  },
46
46
  organizationId: {
47
47
  type: mongoose_1.default.Schema.Types.ObjectId,
package/index.ts CHANGED
@@ -52,6 +52,7 @@ import CustomQuery from "./src/models/CustomQuery";
52
52
  import { generateRandomIID } from "./src/constant";
53
53
  import TestTimeline from "./src/models/TestTimeline";
54
54
  import CronData from "./src/models/CronData";
55
+ import CronConfig from "./src/models/CronConfig";
55
56
  async function seedRoles() {
56
57
  const checkRoles = await Role.countDocuments();
57
58
  if (checkRoles < 5) {
@@ -151,5 +152,6 @@ export {
151
152
  PrecalculationFilters,
152
153
  BqPreCompiledData,
153
154
  CronData,
154
- UserPermission,
155
+ CronConfig,
156
+ UserPermission
155
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-models",
3
- "version": "2.1.20",
3
+ "version": "2.1.22",
4
4
  "description": "Common models for codebase",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,84 @@
1
+ import mongoose, { Document, Schema, model } from "mongoose";
2
+ import { generateRandomIID } from "../constant";
3
+
4
+ export interface ICronConfig extends Document {
5
+ iid: string;
6
+ organizationId?: mongoose.Schema.Types.ObjectId;
7
+ jobName: string;
8
+ description: string;
9
+ client: mongoose.Schema.Types.ObjectId;
10
+ test: mongoose.Schema.Types.ObjectId;
11
+ active: boolean;
12
+ lastRun: Date;
13
+ nextRun: Date;
14
+ schedule: string;
15
+ metadata: mongoose.Schema.Types.Mixed;
16
+ createdBy: mongoose.Schema.Types.ObjectId;
17
+ }
18
+ const CronConfigSchema = new Schema<ICronConfig>({
19
+ iid: {
20
+ type: String,
21
+ unique: true,
22
+ },
23
+ organizationId: {
24
+ type: mongoose.Schema.Types.ObjectId,
25
+ ref: "organization",
26
+ default: null,
27
+ },
28
+ jobName: {
29
+ type: String,
30
+ required: true,
31
+ },
32
+ description: {
33
+ type: String,
34
+ },
35
+ client: {
36
+ type: mongoose.Schema.Types.ObjectId,
37
+ ref: "client",
38
+ },
39
+ test: {
40
+ type: mongoose.Schema.Types.ObjectId,
41
+ ref: "test",
42
+ },
43
+ active: {
44
+ type: Boolean,
45
+ default: true,
46
+ },
47
+ lastRun: {
48
+ type: Date,
49
+ default: null,
50
+ },
51
+ nextRun: {
52
+ type: Date,
53
+ default: null,
54
+ },
55
+ schedule: {
56
+ type: String,
57
+ required: true,
58
+ },
59
+ metadata: {
60
+ type: mongoose.Schema.Types.Mixed,
61
+ default: null,
62
+ },
63
+ createdBy: {
64
+ type: mongoose.Schema.Types.ObjectId,
65
+ ref: "user",
66
+ default: null,
67
+ required: true,
68
+ },
69
+ }, {
70
+ timestamps: true
71
+ });
72
+
73
+ CronConfigSchema.pre("save", async function (next) {
74
+ if (!this.iid) {
75
+ this.iid = generateRandomIID();
76
+ }
77
+ next();
78
+ });
79
+
80
+ CronConfigSchema.index({ test: 1 });
81
+ CronConfigSchema.index({ client: 1 });
82
+
83
+ const CronConfig = mongoose.models.cronConfig || model<ICronConfig>("cronConfig", CronConfigSchema);
84
+ export default CronConfig;
@@ -8,6 +8,7 @@ interface ICustomQuery extends Document {
8
8
  module: string;
9
9
  client: mongoose.Schema.Types.ObjectId;
10
10
  query: string;
11
+ metadata: any;
11
12
  createdBy?: mongoose.Schema.Types.ObjectId;
12
13
  }
13
14
 
@@ -21,7 +22,8 @@ const CustomQuerySchema = new Schema<ICustomQuery>(
21
22
  title: { type: String, required: true },
22
23
  module: { type: String, required: true },
23
24
  client: { type: mongoose.Schema.Types.ObjectId, ref: 'client', required: true },
24
- query: { type: String, required: true },
25
+ query: { type: String },
26
+ metadata: { type: mongoose.Schema.Types.Mixed, default: null },
25
27
  createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'user', default: null },
26
28
  },
27
29
  {
@@ -23,6 +23,7 @@ export interface ITest extends Document {
23
23
  iid: string;
24
24
  status: string;
25
25
  name: string;
26
+ traffic_allocation_type: string;
26
27
  traffic_allocation: number;
27
28
  audiences_match_type: string;
28
29
  // Metadata fields
@@ -113,9 +114,9 @@ const TestSchema = new Schema<ITest>(
113
114
  enum: ["live", "draft", "ended", "paused", "preview", "running", "archive"]
114
115
  },
115
116
  name: { type: String, required: true },
117
+ traffic_allocation_type: { type: String, default: "manual", enum: ["manual", "multi-armed", "contextual"] },
116
118
  traffic_allocation: { type: Number, default: 100 },
117
119
  audiences_match_type: { type: String, default: "all" },
118
-
119
120
  // Metadata fields
120
121
  metadata_1: { type: mongoose.Schema.Types.Mixed, default: null },
121
122
  metadata_2: { type: mongoose.Schema.Types.Mixed, default: null },
@@ -20,7 +20,7 @@ const TestTimelineSchema = new Schema<ITestTimeline>({
20
20
  },
21
21
  event: {
22
22
  type: String,
23
- enum: ["test_created", "test_updated","test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted"],
23
+ enum: ["test_created", "test_updated","test_status_changed", "test_deleted", "variant_created", "variant_updated", "variant_deleted", "traffic_allocation_changed"],
24
24
  },
25
25
  organizationId: {
26
26
  type: mongoose.Schema.Types.ObjectId,