codebase-models 3.1.2 → 3.1.4

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
@@ -81,6 +81,6 @@ import ThreadMessage from "./src/models/ThreadMessage";
81
81
  import Provider from "./src/models/Provider";
82
82
  import ApiLog from "./src/models/ApiLog";
83
83
  import { ProviderType } from "./src/models/Provider";
84
- import Log from "./src/models/Log";
84
+ import OldReport from "./src/models/OldReport";
85
85
  export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
86
- export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, 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, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, Log, };
86
+ export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Provider, 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, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserOrganization, Package, Invitation, Thread, ThreadMessage, ApiLog, ProviderType, OldReport, };
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.BqPreCompiledData = exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = 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.Provider = exports.Report = exports.ClientReportsTemp = exports.Client = exports.RolesConstants = exports.generateRandomIID = exports.connect = void 0;
16
- exports.Log = exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = void 0;
16
+ exports.OldReport = exports.ProviderType = exports.ApiLog = exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserPermission = exports.CronConfig = exports.CronData = 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;
@@ -132,8 +132,8 @@ const ApiLog_1 = __importDefault(require("./src/models/ApiLog"));
132
132
  exports.ApiLog = ApiLog_1.default;
133
133
  const Provider_2 = require("./src/models/Provider");
134
134
  Object.defineProperty(exports, "ProviderType", { enumerable: true, get: function () { return Provider_2.ProviderType; } });
135
- const Log_1 = __importDefault(require("./src/models/Log"));
136
- exports.Log = Log_1.default;
135
+ const OldReport_1 = __importDefault(require("./src/models/OldReport"));
136
+ exports.OldReport = OldReport_1.default;
137
137
  function seedRoles() {
138
138
  return __awaiter(this, void 0, void 0, function* () {
139
139
  const checkRoles = yield Role_1.default.countDocuments();
@@ -32,6 +32,7 @@ export interface IClient extends Document {
32
32
  iid: string;
33
33
  organization: mongoose.Schema.Types.ObjectId;
34
34
  name: string;
35
+ url: string;
35
36
  slug?: string;
36
37
  viewId?: string;
37
38
  portfolioClient?: boolean;
@@ -51,6 +51,7 @@ const ClientSchema = new mongoose_1.Schema({
51
51
  unique: true,
52
52
  default: () => (0, constant_1.generateRandomIID)(),
53
53
  },
54
+ url: { type: String, required: true },
54
55
  organization: {
55
56
  type: mongoose_1.default.Schema.Types.ObjectId,
56
57
  ref: "organization",
@@ -22,26 +22,27 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import { Document } from "mongoose";
26
- export interface ILogMeta {
27
- operationType?: string;
28
- operationName?: string;
29
- rootFields?: string[];
30
- userId?: string;
31
- ip?: string;
32
- clientFullUrl?: string;
33
- clientId?: string;
34
- organizationId?: string;
35
- timestamp?: string;
36
- [key: string]: any;
25
+ import mongoose, { Document } from "mongoose";
26
+ export interface IOldReport extends Document {
27
+ iid: string;
28
+ name: string;
29
+ segmentName?: string;
30
+ reportLink?: string;
31
+ conclusion?: string;
32
+ variant?: string;
33
+ client?: mongoose.Schema.Types.ObjectId;
34
+ viewId?: string;
35
+ test?: mongoose.Schema.Types.ObjectId;
36
+ gaTestId?: string;
37
+ reportDetails?: mongoose.Schema.Types.Mixed;
38
+ learnings?: mongoose.Schema.Types.Mixed;
39
+ from?: Date;
40
+ to?: Date;
41
+ createdBy?: mongoose.Schema.Types.ObjectId;
42
+ excludedFromCalculations?: boolean;
43
+ createdAt?: Date;
44
+ updatedAt?: Date;
45
+ organizationId?: mongoose.Schema.Types.ObjectId;
37
46
  }
38
- export interface ILog extends Document {
39
- level: string;
40
- message: string;
41
- meta: ILogMeta;
42
- timestamp: Date;
43
- }
44
- declare const Log: import("mongoose").Model<ILog, {}, {}, {}, Document<unknown, {}, ILog> & ILog & {
45
- _id: import("mongoose").Types.ObjectId;
46
- }, any>;
47
- export default Log;
47
+ declare const OldReport: mongoose.Model<any, {}, {}, {}, any, any>;
48
+ export default OldReport;
@@ -0,0 +1,107 @@
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 OldReportSchema = new mongoose_1.Schema({
38
+ iid: {
39
+ type: String,
40
+ trim: true,
41
+ },
42
+ organizationId: {
43
+ type: mongoose_1.default.Schema.Types.ObjectId,
44
+ ref: "organization",
45
+ default: null,
46
+ },
47
+ name: { type: String, required: true },
48
+ segmentName: { type: String },
49
+ reportLink: { type: String },
50
+ conclusion: { type: String },
51
+ variant: { type: String },
52
+ client: {
53
+ type: mongoose_1.default.Schema.Types.ObjectId,
54
+ ref: "client"
55
+ },
56
+ viewId: { type: String },
57
+ test: {
58
+ type: mongoose_1.default.Schema.Types.ObjectId,
59
+ ref: "test"
60
+ },
61
+ gaTestId: { type: String },
62
+ reportDetails: { type: mongoose_1.default.Schema.Types.Mixed },
63
+ learnings: {
64
+ type: mongoose_1.default.Schema.Types.Mixed,
65
+ default: []
66
+ },
67
+ from: { type: Date },
68
+ to: { type: Date },
69
+ createdBy: {
70
+ type: mongoose_1.default.Schema.Types.ObjectId,
71
+ ref: "user"
72
+ },
73
+ excludedFromCalculations: {
74
+ type: Boolean,
75
+ default: false
76
+ }
77
+ }, {
78
+ timestamps: true
79
+ });
80
+ OldReportSchema.pre('save', function (next) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (!this.iid) {
83
+ let unique = false;
84
+ while (!unique) {
85
+ const id = (0, constant_1.generateRandomIID)();
86
+ const existing = yield mongoose_1.default.models.report.findOne({ iid: id });
87
+ if (!existing) {
88
+ this.iid = id;
89
+ unique = true;
90
+ }
91
+ }
92
+ }
93
+ next();
94
+ });
95
+ });
96
+ // Add compound indexes for better query performance
97
+ OldReportSchema.index({ client: 1, conclusion: 1 });
98
+ // ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
99
+ // OldReportSchema.index({ client: 1, test: 1 }); // For client-specific test reports
100
+ // OldReportSchema.index({ from: 1, to: 1 }); // For date range queries
101
+ // OldReportSchema.index({ client: 1, "reportDetails.implementedStatus": 1 }); // For implemented status queries
102
+ // ReportsSchema.index({ client: 1, "reportDetails.conclusionFactorStatusAll": 1 }); // For conclusion factor queries
103
+ // ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
104
+ // ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
105
+ // ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
106
+ const OldReport = mongoose_1.default.models.oldreport || (0, mongoose_1.model)("oldreport", OldReportSchema);
107
+ exports.default = OldReport;
@@ -25,16 +25,7 @@
25
25
  import mongoose, { Document } from "mongoose";
26
26
  export declare enum ProviderType {
27
27
  SHOPIFY = "shopify",
28
- BIGQUERY = "bigquery",
29
- GOOGLE_ANALYTICS = "google_analytics",
30
- GOOGLE_TAG_MANAGER = "google_tag_manager",
31
- GOOGLE_ADS = "google_ads",
32
- GOOGLE_SEARCH_CONSOLE = "google_search_console",
33
- GOOGLE_SHEETS = "google_sheets",
34
- GOOGLE_DOCS = "google_docs",
35
- GOOGLE_DRIVE = "google_drive",
36
- GOOGLE_MAIL = "google_mail",
37
- GOOGLE_CALENDAR = "google_calendar"
28
+ BIGQUERY = "bigquery"
38
29
  }
39
30
  export interface IShopifyMetadata {
40
31
  apiKey: string;
@@ -31,15 +31,15 @@ var ProviderType;
31
31
  (function (ProviderType) {
32
32
  ProviderType["SHOPIFY"] = "shopify";
33
33
  ProviderType["BIGQUERY"] = "bigquery";
34
- ProviderType["GOOGLE_ANALYTICS"] = "google_analytics";
35
- ProviderType["GOOGLE_TAG_MANAGER"] = "google_tag_manager";
36
- ProviderType["GOOGLE_ADS"] = "google_ads";
37
- ProviderType["GOOGLE_SEARCH_CONSOLE"] = "google_search_console";
38
- ProviderType["GOOGLE_SHEETS"] = "google_sheets";
39
- ProviderType["GOOGLE_DOCS"] = "google_docs";
40
- ProviderType["GOOGLE_DRIVE"] = "google_drive";
41
- ProviderType["GOOGLE_MAIL"] = "google_mail";
42
- ProviderType["GOOGLE_CALENDAR"] = "google_calendar";
34
+ // GOOGLE_ANALYTICS = "google_analytics",
35
+ // GOOGLE_TAG_MANAGER = "google_tag_manager",
36
+ // GOOGLE_ADS = "google_ads",
37
+ // GOOGLE_SEARCH_CONSOLE = "google_search_console",
38
+ // GOOGLE_SHEETS = "google_sheets",
39
+ // GOOGLE_DOCS = "google_docs",
40
+ // GOOGLE_DRIVE = "google_drive",
41
+ // GOOGLE_MAIL = "google_mail",
42
+ // GOOGLE_CALENDAR = "google_calendar",
43
43
  // Add more provider types as needed
44
44
  })(ProviderType || (exports.ProviderType = ProviderType = {}));
45
45
  const ProviderSchema = new mongoose_1.Schema({
package/index.ts CHANGED
@@ -58,8 +58,7 @@ import ThreadMessage from "./src/models/ThreadMessage";
58
58
  import Provider from "./src/models/Provider";
59
59
  import ApiLog from "./src/models/ApiLog";
60
60
  import { ProviderType } from "./src/models/Provider";
61
- import Log from "./src/models/Log";
62
-
61
+ import OldReport from "./src/models/OldReport";
63
62
  async function seedRoles() {
64
63
  const checkRoles = await Role.countDocuments();
65
64
  if (checkRoles < RolesConstants.length) {
@@ -167,5 +166,5 @@ export {
167
166
  ThreadMessage,
168
167
  ApiLog,
169
168
  ProviderType,
170
- Log,
169
+ OldReport,
171
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-models",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "Common models for codebase",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,6 +19,7 @@ export interface IClient extends Document {
19
19
  iid: string;
20
20
  organization: mongoose.Schema.Types.ObjectId;
21
21
  name: string;
22
+ url: string;
22
23
  slug?: string;
23
24
  viewId?: string;
24
25
  portfolioClient?: boolean;
@@ -44,6 +45,7 @@ const ClientSchema: Schema = new Schema<IClient>(
44
45
  unique: true,
45
46
  default: () => generateRandomIID(),
46
47
  },
48
+ url: { type: String, required: true },
47
49
  organization: {
48
50
  type: mongoose.Schema.Types.ObjectId,
49
51
  ref: "organization",
@@ -0,0 +1,102 @@
1
+ import mongoose, { Document, Schema, model } from "mongoose";
2
+ import { generateRandomIID } from "../constant";
3
+
4
+ export interface IOldReport extends Document {
5
+ iid: string;
6
+ name: string;
7
+ segmentName?: string;
8
+ reportLink?: string;
9
+ conclusion?: string;
10
+ variant?: string;
11
+ client?: mongoose.Schema.Types.ObjectId;
12
+ viewId?: string;
13
+ test?: mongoose.Schema.Types.ObjectId;
14
+ gaTestId?: string;
15
+ reportDetails?: mongoose.Schema.Types.Mixed;
16
+ learnings?: mongoose.Schema.Types.Mixed;
17
+ from?: Date;
18
+ to?: Date;
19
+ createdBy?: mongoose.Schema.Types.ObjectId;
20
+ excludedFromCalculations?: boolean;
21
+ createdAt?: Date;
22
+ updatedAt?: Date;
23
+ organizationId?: mongoose.Schema.Types.ObjectId;
24
+ }
25
+
26
+ const OldReportSchema = new Schema<IOldReport>(
27
+ {
28
+ iid: {
29
+ type: String,
30
+ trim: true,
31
+ },
32
+ organizationId: {
33
+ type: mongoose.Schema.Types.ObjectId,
34
+ ref: "organization",
35
+ default: null,
36
+ },
37
+ name: { type: String, required: true },
38
+ segmentName: { type: String },
39
+ reportLink: { type: String },
40
+ conclusion: { type: String },
41
+ variant: { type: String },
42
+ client: {
43
+ type: mongoose.Schema.Types.ObjectId,
44
+ ref: "client"
45
+ },
46
+ viewId: { type: String },
47
+ test: {
48
+ type: mongoose.Schema.Types.ObjectId,
49
+ ref: "test"
50
+ },
51
+ gaTestId: { type: String },
52
+ reportDetails: { type: mongoose.Schema.Types.Mixed },
53
+ learnings: {
54
+ type: mongoose.Schema.Types.Mixed,
55
+ default: []
56
+ },
57
+ from: { type: Date },
58
+ to: { type: Date },
59
+ createdBy: {
60
+ type: mongoose.Schema.Types.ObjectId,
61
+ ref: "user"
62
+ },
63
+ excludedFromCalculations: {
64
+ type: Boolean,
65
+ default: false
66
+ }
67
+ },
68
+ {
69
+ timestamps: true
70
+ }
71
+ );
72
+
73
+ OldReportSchema.pre('save', async function(next) {
74
+ if (!this.iid) {
75
+ let unique = false;
76
+ while (!unique) {
77
+ const id = generateRandomIID();
78
+ const existing = await mongoose.models.report.findOne({ iid: id });
79
+ if (!existing) {
80
+ this.iid = id;
81
+ unique = true;
82
+ }
83
+ }
84
+ }
85
+ next();
86
+ });
87
+
88
+
89
+ // Add compound indexes for better query performance
90
+ OldReportSchema.index({ client: 1, conclusion: 1 });
91
+ // ReportsSchema.index({ test: 1, to: -1 }); // For sorting reports by date
92
+ // OldReportSchema.index({ client: 1, test: 1 }); // For client-specific test reports
93
+ // OldReportSchema.index({ from: 1, to: 1 }); // For date range queries
94
+ // OldReportSchema.index({ client: 1, "reportDetails.implementedStatus": 1 }); // For implemented status queries
95
+ // ReportsSchema.index({ client: 1, "reportDetails.conclusionFactorStatusAll": 1 }); // For conclusion factor queries
96
+ // ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
97
+ // ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
98
+ // ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
99
+
100
+ const OldReport = mongoose.models.oldreport || model<IOldReport>("oldreport", OldReportSchema);
101
+
102
+ export default OldReport;
@@ -5,15 +5,15 @@ import { generateRandomIID } from "../constant";
5
5
  export enum ProviderType {
6
6
  SHOPIFY = "shopify",
7
7
  BIGQUERY = "bigquery",
8
- GOOGLE_ANALYTICS = "google_analytics",
9
- GOOGLE_TAG_MANAGER = "google_tag_manager",
10
- GOOGLE_ADS = "google_ads",
11
- GOOGLE_SEARCH_CONSOLE = "google_search_console",
12
- GOOGLE_SHEETS = "google_sheets",
13
- GOOGLE_DOCS = "google_docs",
14
- GOOGLE_DRIVE = "google_drive",
15
- GOOGLE_MAIL = "google_mail",
16
- GOOGLE_CALENDAR = "google_calendar",
8
+ // GOOGLE_ANALYTICS = "google_analytics",
9
+ // GOOGLE_TAG_MANAGER = "google_tag_manager",
10
+ // GOOGLE_ADS = "google_ads",
11
+ // GOOGLE_SEARCH_CONSOLE = "google_search_console",
12
+ // GOOGLE_SHEETS = "google_sheets",
13
+ // GOOGLE_DOCS = "google_docs",
14
+ // GOOGLE_DRIVE = "google_drive",
15
+ // GOOGLE_MAIL = "google_mail",
16
+ // GOOGLE_CALENDAR = "google_calendar",
17
17
  // Add more provider types as needed
18
18
  }
19
19
 
@@ -84,7 +84,7 @@ const ProviderSchema = new Schema<IProvider>(
84
84
  ref: "client",
85
85
  required: true,
86
86
  },
87
- user: {
87
+ user: {
88
88
  type: mongoose.Schema.Types.ObjectId,
89
89
  ref: "user",
90
90
  required: true,
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mongoose_1 = require("mongoose");
4
- const LogSchema = new mongoose_1.Schema({
5
- level: {
6
- type: String,
7
- required: true,
8
- trim: true,
9
- },
10
- message: {
11
- type: String,
12
- required: true,
13
- },
14
- meta: {
15
- type: mongoose_1.Schema.Types.Mixed,
16
- default: {},
17
- },
18
- timestamp: {
19
- type: Date,
20
- default: Date.now,
21
- },
22
- }, {
23
- collection: "logs",
24
- timestamps: false,
25
- });
26
- LogSchema.index({
27
- "meta.rootFields": 1,
28
- "meta.userId": 1,
29
- "meta.clientId": 1,
30
- "meta.timestamp": -1,
31
- });
32
- LogSchema.index({ "meta.operationType": 1 });
33
- const Log = (0, mongoose_1.model)("Log", LogSchema);
34
- exports.default = Log;
package/src/models/Log.ts DELETED
@@ -1,59 +0,0 @@
1
- import { Document, Schema, model } from "mongoose";
2
-
3
- export interface ILogMeta {
4
- operationType?: string;
5
- operationName?: string;
6
- rootFields?: string[];
7
- userId?: string;
8
- ip?: string;
9
- clientFullUrl?: string;
10
- clientId?: string;
11
- organizationId?: string;
12
- timestamp?: string;
13
- [key: string]: any;
14
- }
15
-
16
- export interface ILog extends Document {
17
- level: string;
18
- message: string;
19
- meta: ILogMeta;
20
- timestamp: Date;
21
- }
22
-
23
- const LogSchema = new Schema<ILog>(
24
- {
25
- level: {
26
- type: String,
27
- required: true,
28
- trim: true,
29
- },
30
- message: {
31
- type: String,
32
- required: true,
33
- },
34
- meta: {
35
- type: Schema.Types.Mixed,
36
- default: {},
37
- },
38
- timestamp: {
39
- type: Date,
40
- default: Date.now,
41
- },
42
- },
43
- {
44
- collection: "logs",
45
- timestamps: false,
46
- }
47
- );
48
-
49
- LogSchema.index({
50
- "meta.rootFields": 1,
51
- "meta.userId": 1,
52
- "meta.clientId": 1,
53
- "meta.timestamp": -1,
54
- });
55
- LogSchema.index({ "meta.operationType": 1 });
56
-
57
- const Log = model<ILog>("Log", LogSchema);
58
-
59
- export default Log;