shuttlepro-shared 1.3.13 → 1.3.14

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.
Files changed (64) hide show
  1. package/constants/index.js +0 -15
  2. package/index.js +0 -8
  3. package/models/UserRole.js +119 -1
  4. package/models/Website.js +1 -0
  5. package/models.js +1 -62
  6. package/package.json +2 -13
  7. package/common/repositories/chatMember.repository.js +0 -9
  8. package/common/repositories/customerProfile.repository.js +0 -147
  9. package/common/repositories/descriptionTemplates.repository.js +0 -229
  10. package/common/repositories/index.js +0 -32
  11. package/common/repositories/integration.repository.js +0 -210
  12. package/common/repositories/label.repository.js +0 -95
  13. package/common/repositories/notificationSettings.repository.js +0 -95
  14. package/common/repositories/role.repository.js +0 -333
  15. package/common/repositories/settings.repository.js +0 -32
  16. package/common/repositories/shipper.repository.js +0 -77
  17. package/common/repositories/socialMediaSetting.repository.js +0 -33
  18. package/common/repositories/user.repository.js +0 -150
  19. package/common/repositories/userPermission.repository.js +0 -228
  20. package/common/repositories/userRepository.js +0 -31
  21. package/common/repositories/userRole.repository.js +0 -235
  22. package/common/repositories/userRolePermission.repository.js +0 -59
  23. package/common/repositories/workspace.repository.js +0 -147
  24. package/config/bull.js +0 -78
  25. package/config/config.js +0 -14
  26. package/config/database.js +0 -4
  27. package/config/index.js +0 -13
  28. package/config/redis.js +0 -196
  29. package/config/socket.js +0 -172
  30. package/models/AgentActivity.js +0 -192
  31. package/models/Assignment.js +0 -23
  32. package/models/BusinessDistribution.js +0 -23
  33. package/models/Card.js +0 -144
  34. package/models/CardComments.js +0 -33
  35. package/models/ChatMember.js +0 -17
  36. package/models/Chatbot.js +0 -20
  37. package/models/Checkpoint.js +0 -50
  38. package/models/City.js +0 -17
  39. package/models/Column.js +0 -28
  40. package/models/Conversation.js +0 -87
  41. package/models/Customer.js +0 -36
  42. package/models/CustomerProfile.js +0 -27
  43. package/models/DefaultRolePermission.js +0 -34
  44. package/models/DescriptionTemplate.js +0 -22
  45. package/models/Integration.js +0 -51
  46. package/models/Label.js +0 -42
  47. package/models/Message.js +0 -47
  48. package/models/NewProduct.js +0 -71
  49. package/models/NotificationSettings.js +0 -130
  50. package/models/Order.js +0 -236
  51. package/models/OrderProduct.js +0 -37
  52. package/models/Profile.js +0 -127
  53. package/models/Report.js +0 -27
  54. package/models/Setting.js +0 -18
  55. package/models/Shipper.js +0 -62
  56. package/models/SocialMediaSetting.js +0 -28
  57. package/models/Status.js +0 -58
  58. package/models/StatusType.js +0 -10
  59. package/models/Step.js +0 -50
  60. package/models/Type.js +0 -25
  61. package/models/UserWorkflow.js +0 -46
  62. package/models/Workspace.js +0 -308
  63. package/utils/decorator-factory.js +0 -264
  64. package/utils/logger.js +0 -41
@@ -1,71 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
-
4
- const NewProductSchema = new Schema(
5
- {
6
- id: {
7
- type: Schema.Types.ObjectId,
8
- ref: "Product",
9
- default: null,
10
- },
11
- name: { type: String, default: "" },
12
- description: { type: String, default: "" },
13
- sku: { type: String, default: "" },
14
- price: { type: String, default: 0 },
15
- quantity: { type: Number, default: 0 },
16
- imageUrl: { type: String, default: "" },
17
- costPrice: { type: String, default: 0 },
18
- salePrice: { type: String, default: 0 },
19
- webProductId: { type: Number, default: null },
20
- variants: [],
21
- attachments: [],
22
- workspaceId: {
23
- type: Schema.Types.ObjectId,
24
- ref: "Workspace",
25
- default: null,
26
- },
27
- },
28
- {
29
- timestamps: true,
30
- toJSON: { virtuals: true },
31
- toObject: { virtuals: true },
32
- }
33
- );
34
-
35
- // Adding compound text index for name, sku, and variants
36
- NewProductSchema.index({
37
- name: "text",
38
- sku: "text",
39
- "variants.name": "text",
40
- "variants.sku": "text",
41
- });
42
-
43
- // Adding separate indexes for frequent query conditions
44
- NewProductSchema.index({
45
- workspaceId: 1,
46
- name: 1,
47
- });
48
-
49
- NewProductSchema.index({
50
- workspaceId: 1,
51
- sku: 1,
52
- });
53
-
54
- NewProductSchema.index({
55
- workspaceId: 1,
56
- "variants.name": 1,
57
- });
58
-
59
- NewProductSchema.index({
60
- workspaceId: 1,
61
- "variants.sku": 1,
62
- });
63
-
64
- // Index for attachments existence check
65
- NewProductSchema.index({
66
- attachments: 1,
67
- });
68
-
69
- const NewProduct = mongoose.model("NewProduct", NewProductSchema);
70
-
71
- module.exports = NewProduct;
@@ -1,130 +0,0 @@
1
- const { model, Schema } = require("mongoose");
2
-
3
- const NotificationSettingsSchema = new Schema(
4
- {
5
- workspaceId: {
6
- type: Schema.Types.ObjectId,
7
- ref: "Workspace",
8
- default: null,
9
- },
10
-
11
- orders: {
12
- type: {
13
- createOrder: {
14
- type: Boolean,
15
- default: false,
16
- },
17
- orderAssign: {
18
- type: Boolean,
19
- default: false,
20
- },
21
- orderComment: {
22
- type: Boolean,
23
- default: false,
24
- },
25
- },
26
- default: {
27
- createOrder: false,
28
- orderAssign: false,
29
- orderComment: false,
30
- },
31
- },
32
-
33
- products: {
34
- type: Boolean,
35
- default: false,
36
- },
37
-
38
- socialProfiles: {
39
- type: {
40
- socialProfileComment: {
41
- type: Boolean,
42
- default: false,
43
- },
44
- story: {
45
- type: Boolean,
46
- default: false,
47
- },
48
- },
49
- default: {
50
- socialProfileComment: false,
51
- story: false,
52
- },
53
- },
54
-
55
- conversation: {
56
- type: {
57
- instaMessage: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- fbMessage: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- whatsapp: {
66
- type: Boolean,
67
- default: false,
68
- },
69
- instaComment: {
70
- type: Boolean,
71
- default: false,
72
- },
73
- fbComment: {
74
- type: Boolean,
75
- default: false,
76
- },
77
- email: {
78
- type: Boolean,
79
- default: false,
80
- },
81
- },
82
- default: {
83
- instaMessage: false,
84
- fbMessage: false,
85
- instaComment: false,
86
- fbComment: false,
87
- email: false,
88
- whatsapp: false,
89
- },
90
- },
91
-
92
- taskManager: {
93
- type: {
94
- cardAssign: {
95
- type: Boolean,
96
- default: false,
97
- },
98
- cardMove: {
99
- type: Boolean,
100
- default: false,
101
- },
102
- },
103
- default: {
104
- cardAssign: false,
105
- cardMove: false,
106
- },
107
- },
108
-
109
- sound: {
110
- type: {
111
- play: {
112
- type: Boolean,
113
- default: true,
114
- },
115
- },
116
- default: {
117
- play: true,
118
- },
119
- },
120
-
121
- default: {
122
- type: Boolean,
123
- default: true,
124
- },
125
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
126
- },
127
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
128
- );
129
-
130
- module.exports = model("NotificationSettings", NotificationSettingsSchema);
package/models/Order.js DELETED
@@ -1,236 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const normalizePhoneNumber = (phone) => {
4
- let normalized = phone.replace(/[^\d]/g, "");
5
- if (normalized.startsWith("92")) {
6
- normalized = normalized.replace(/^92/, "");
7
- }
8
- if (normalized.startsWith("0")) {
9
- normalized = normalized.substring(1);
10
- }
11
- return normalized;
12
- };
13
- const getPhoneRegex = (phone) => {
14
- const normalizedPhone = normalizePhoneNumber(phone);
15
- return new RegExp(
16
- `^0?${normalizedPhone}$|^\\+92${normalizedPhone}$|^${normalizedPhone}$`,
17
- "i"
18
- );
19
- };
20
- const _ = require("lodash");
21
-
22
- const ShipperInformation = new Schema({
23
- _id: false,
24
- shipperType: { type: String, default: "" },
25
- weight: { type: Number, default: 0 }, //M&P, TRAX, INSTA, RIDER, TCS, CC
26
- fragile: { type: Boolean, default: false }, //M&P, TRAX, INSTA, RIDER, TCS, CC
27
- serviceType: { type: String, default: "" }, //M&P, TRAX, INSTA, RIDER, TCS, CC
28
- serviceTypeId: { type: String, default: 1 }, //M&P, TRAX, INSTA, RIDER, TCS, CC
29
- pieces: { type: Number, default: 0 }, //M&P, TRAX, INSTA, RIDER, TCS, CC
30
- originCityName: { type: String, default: "" }, //M&P, TRAX, INSTA, RIDER, TCS, CC
31
- remarks: { type: String, default: "" },
32
- customer_note: { type: String, default: "" },
33
- orderId: { type: Schema.Types.ObjectId, ref: "Order", default: null },
34
- return_branch: { type: String, default: "" },
35
- cityData: { type: String, default: "" }, //M&P, TRAX, INSTA, RIDER, TCS, CC
36
- //TRAX
37
- paymentMode: { type: Number, default: 0 },
38
- addressId: { type: Number, default: 0 },
39
- itemProductType: { type: Number, default: 0 },
40
- shippingMode: { type: Number, default: 0 },
41
- itemInsurance: { type: Boolean, default: false },
42
- informationDisplay: { type: String, default: "" },
43
- //Call Courier (CC)
44
- shipperName: { type: String, default: "" },
45
- shipperEmail: { type: String, default: "" },
46
- shipperCellNo: { type: String, default: "" },
47
- shipperLandlineNo: { type: String, default: "" },
48
- shipperAddress: { type: String, default: "" },
49
- shipperCityId: { type: Number, default: 0 },
50
- shipperAreaId: { type: Number, default: 0 },
51
- });
52
-
53
- const OrderSchema = new Schema(
54
- {
55
- webOrderId: { type: String, default: "" },
56
- webOrderNumber: { type: String, default: "" },
57
- orderNumber: { type: String, default: "" },
58
- customerId: { type: Schema.Types.ObjectId, ref: "Customer", default: null },
59
- customerName: { type: String, default: "" },
60
- customerPhone: { type: String, default: "" },
61
- customerAddress: { type: String, default: "" },
62
- cityName: { type: String, default: "" },
63
- trackingId: { type: String, default: "" },
64
- shipperInformation: ShipperInformation,
65
- isCnGenerated: { type: Boolean, default: false },
66
- swap: { type: String, default: "" },
67
- status: { type: String, default: "" },
68
- lastStatusTime: { type: String, default: "" },
69
- statusType: { type: String, default: "" },
70
- returnOrder: {
71
- received: { type: Boolean, default: false },
72
- restocked: { type: Boolean, default: false },
73
- remarks: { type: String, default: "" },
74
- },
75
- statusTypeId: {
76
- type: Schema.Types.ObjectId,
77
- ref: "StatusType",
78
- default: null,
79
- },
80
- statusId: {
81
- type: Schema.Types.ObjectId,
82
- ref: "Status",
83
- default: null,
84
- },
85
- totalAmount: { type: Number, default: 0 },
86
- payableAmount: { type: Number, default: 0 },
87
- parcelValue: { type: Number, default: 0 },
88
- payableAmount: { type: Number, default: 0 },
89
- discountPercentage: { type: Number, default: 0 },
90
- discountValue: { type: Number, default: 0 },
91
- productDetails: { type: String, default: "" },
92
- webOrderId: { type: String, default: "" },
93
- parentOrderId: { type: Schema.Types.ObjectId, ref: "Order", default: null },
94
- webOrderNumber: { type: String, default: "" },
95
- fulfillmentStatus: { type: String, default: "" },
96
- webFulfillmentId: { type: String, default: "" },
97
- platformFinancialStatus: { type: String, default: "pending" },
98
- pinLocation: { type: String, default: "" },
99
- deliveryCharges: { type: Number, default: 0 },
100
- tax: { type: Number, default: 0 },
101
- workspaceId: {
102
- type: Schema.Types.ObjectId,
103
- ref: "Workspace",
104
- default: null,
105
- },
106
- orderType: { type: String, default: "" },
107
- barCode: { type: String, default: "" },
108
- quantity: { type: Number, default: 0 },
109
- assignTo: { type: Schema.Types.ObjectId, ref: "User", default: null },
110
- isLoadSheetGenerated: { type: Boolean, default: false },
111
- orderDate: { type: String, default: "" },
112
- returnDate: { type: String, default: "" },
113
- receivedDate: { type: String, default: "" },
114
- published: { type: Boolean, default: false },
115
- isFlagged: { type: Boolean, default: false },
116
- publishedTime: { type: String, default: "" },
117
- paymentType: { type: String, default: "COD" },
118
- isDeleted: { type: Boolean, default: false },
119
- isFake: { type: Boolean, default: false },
120
- statusUpdatedAt: { type: String, default: "" },
121
- invalidCity: { type: Boolean, default: false },
122
- invalidCredentials: { type: Boolean, default: false },
123
- isConfirmed: { type: Boolean, default: false },
124
- confirmedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
125
- priority: { type: String, default: "" },
126
- isBulk: { type: String, default: "" },
127
- conversationId: { type: String, default: "" },
128
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
129
- updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
130
- publishedStatus: { type: String, default: "pending" },
131
- isDuplicate: { type: Boolean, default: false },
132
- ivrGenerated: { type: Boolean, default: false },
133
- isActivityGenerated: { type: Boolean, default: false },
134
- payment: {
135
- isPaid: { type: Boolean, default: false },
136
- paymentDate: { type: String, default: "" },
137
- paymentDetails: {},
138
- },
139
- credentials: {},
140
- ticketId: { type: String, default: "" },
141
- sender: { type: String, default: "" },
142
- orderName: { type: String, default: "" },
143
- totalWeight: { type: String, default: "" },
144
- },
145
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
146
- );
147
-
148
- OrderSchema.virtual("checkPoints", {
149
- ref: "Checkpoint",
150
- localField: "_id",
151
- foreignField: "orderId",
152
- });
153
-
154
- OrderSchema.virtual("orderProducts", {
155
- ref: "OrderProduct",
156
- localField: "_id",
157
- foreignField: "orderId",
158
- });
159
-
160
- OrderSchema.post("save", async function (doc) {
161
- try {
162
- if (doc) {
163
- markOrUnMarkOrderAsDuplicate(doc);
164
- }
165
- return { code: 200 };
166
- } catch (err) {
167
- console.log("err", err);
168
- return { code: 400 };
169
- }
170
- });
171
-
172
- OrderSchema.post("findOneAndUpdate", async function (doc) {
173
- try {
174
- if (doc) {
175
- markOrUnMarkOrderAsDuplicate(doc);
176
- }
177
- return { code: 200 };
178
- } catch (err) {
179
- console.log("err", err);
180
- return { code: 400 };
181
- }
182
- });
183
-
184
- const markOrUnMarkOrderAsDuplicate = async (doc) => {
185
- try {
186
- if (["pending", "cancelled", "published"].includes(doc?.statusType)) {
187
- if (["cancelled"].includes(doc?.statusType)) {
188
- await Order.updateOne(
189
- { _id: doc?._id },
190
- { $set: { isDuplicate: false } }
191
- );
192
- }
193
- const phoneRegex = getPhoneRegex(doc?.customerPhone);
194
- let orders = await Order.find({
195
- workspaceId: doc?.workspaceId,
196
- isDeleted: false,
197
- statusType: "pending",
198
- customerPhone: phoneRegex,
199
- })
200
- .lean()
201
- .exec();
202
- if (orders?.length > 1) {
203
- const ordersByCity = _.groupBy(orders, "cityName");
204
- const bulkOps = [];
205
- for (const cityName in ordersByCity) {
206
- const cityOrders = ordersByCity[cityName];
207
- const isDuplicate = cityOrders.length > 1;
208
- const orderIds = cityOrders.map((order) => order?._id);
209
- bulkOps.push({
210
- updateMany: {
211
- filter: { _id: { $in: orderIds } },
212
- update: { $set: { isDuplicate } },
213
- },
214
- });
215
- }
216
- if (bulkOps.length > 0) {
217
- await Order.bulkWrite(bulkOps);
218
- }
219
- } else {
220
- await Order.updateMany(
221
- { _id: { $in: orders.map((d) => d?._id?.toString()) } },
222
- { $set: { isDuplicate: false } }
223
- );
224
- }
225
- return { code: 200 };
226
- }
227
- return { code: 200 };
228
- } catch (err) {
229
- console.log("err", err);
230
- return { code: 400 };
231
- }
232
- };
233
-
234
- const Order = mongoose.model("Order", OrderSchema);
235
-
236
- module.exports = Order;
@@ -1,37 +0,0 @@
1
- const { Schema, model } = require("mongoose");
2
- const OrderProductSchema = new Schema(
3
- {
4
- orderId: { type: Schema.Types.ObjectId, ref: "Order", default: null },
5
- productId: { type: Schema.Types.ObjectId, ref: "Product", default: null },
6
- variantId: {
7
- type: Schema.Types.ObjectId,
8
- ref: "ProductVariant",
9
- default: null,
10
- },
11
- locationId: {
12
- type: Schema.Types.ObjectId,
13
- ref: "Location",
14
- default: null,
15
- },
16
- quantity: { type: Number, default: 0 },
17
- price: { type: Number, default: 0 },
18
- totalAmount: { type: Number, default: 0 },
19
- discountPercentage: { type: Number, default: 0 },
20
- webFulfillmentOrderId: { type: String, default: "" },
21
- webFulfillmentId: { type: String, default: "" },
22
- isFullfilled: { type: Boolean, default: false },
23
- isDeleted: { type: Boolean, default: false },
24
- discountValue: { type: Number, default: 0 },
25
- webLineItemId: { type: String, default: "" },
26
- status: { type: String, default: "open" },
27
- hyperLink: { type: String, default: "" },
28
- parentOrderProductId: { type: Schema.Types.ObjectId, default: null },
29
- workspaceId: {
30
- type: Schema.Types.ObjectId,
31
- ref: "Workspace",
32
- default: null,
33
- },
34
- },
35
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
36
- );
37
- module.exports = model("OrderProduct", OrderProductSchema);
package/models/Profile.js DELETED
@@ -1,127 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const { setRedisData, getRedisData } = require("../config/redis");
4
-
5
- const ProfileSchema = new Schema(
6
- {
7
- name: { type: String, default: "" },
8
- userName: { type: String, default: "" },
9
- profilePicture: { type: String, default: "" },
10
- profileId: { type: String, default: "" },
11
- isSpam: { type: Boolean, default: false },
12
- workspaceId: { type: String, default: "" },
13
- email: { type: String, default: "" },
14
- phoneNo: { type: String, default: "" },
15
- },
16
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
17
- );
18
- const Profile = mongoose.model("Profile", ProfileSchema);
19
-
20
- const addOrUpdateProfilesInRedis = async (profile) => {
21
- try {
22
- const docId = profile?._id.toString();
23
- let profiles = await fetchProfiles(profile?.workspaceId);
24
- const profilesMap = profiles.reduce((map, p) => {
25
- map[p._id.toString()] = p;
26
- return map;
27
- }, {});
28
- profilesMap[docId] = profile.toObject();
29
- profiles = Object.values(profilesMap);
30
- setRedisData(`${profile?.workspaceId}-profiles`, profiles);
31
- return { code: 200 };
32
- } catch (err) {
33
- return { code: 400 };
34
- }
35
- };
36
-
37
- const fetchProfiles = async (workspaceId) => {
38
- try {
39
- let profiles = await getRedisData(`${workspaceId}-profiles`);
40
- if (!profiles || profiles.length === 0) {
41
- profiles = await Profile.find({ workspaceId }).lean().exec();
42
- setRedisData(`${workspaceId}-profiles`, profiles);
43
- }
44
- return profiles;
45
- } catch (err) {
46
- return [];
47
- }
48
- };
49
-
50
- const fetchByProfileIdAndWorkspaceId = async (id, workspaceId) => {
51
- try {
52
- let profiles = await fetchProfiles(workspaceId);
53
- let profile = profiles.find(
54
- (p) =>
55
- (p?.profileId === id || p._id.toString() === id.toString()) &&
56
- p?.workspaceId.toString() === workspaceId.toString()
57
- );
58
- return profile || null;
59
- } catch (err) {
60
- return null;
61
- }
62
- };
63
-
64
- const fetchProfileByEmailAndWorkspaceId = async (
65
- workspaceId,
66
- userName = ""
67
- ) => {
68
- try {
69
- let profiles = await fetchProfiles(workspaceId);
70
- let profile = profiles.find(
71
- (p) => p?.userName === userName && p?.workspaceId === workspaceId
72
- );
73
- return profile || null;
74
- } catch (err) {
75
- console.log(err, "err");
76
- return null;
77
- }
78
- };
79
-
80
- const createProfile = async (obj) => {
81
- try {
82
- let profile = await Profile.create(obj);
83
- await addOrUpdateProfilesInRedis(profile);
84
- return profile;
85
- } catch (err) {
86
- console.log(err, "err");
87
- return null;
88
- }
89
- };
90
- const createUpdateProfileModified = async (filter, obj) => {
91
- try {
92
- let profile = await Profile.findOneAndUpdate(
93
- filter,
94
- { ...obj, ...filter },
95
- {
96
- new: true,
97
- upsert: true,
98
- }
99
- );
100
- await addOrUpdateProfilesInRedis(profile);
101
- return profile;
102
- } catch (err) {
103
- console.log(err, "err");
104
- return null;
105
- }
106
- };
107
- const updateProfile = async (query, payload) => {
108
- try {
109
- const profile = await Profile.findOneAndUpdate(query, payload, {
110
- new: true,
111
- });
112
- await addOrUpdateProfilesInRedis(profile);
113
- return profile;
114
- } catch (err) {
115
- return null;
116
- }
117
- };
118
-
119
- module.exports = {
120
- fetchByProfileIdAndWorkspaceId,
121
- fetchProfileByEmailAndWorkspaceId,
122
- createProfile,
123
- updateProfile,
124
- fetchProfiles,
125
- Profile,
126
- createUpdateProfileModified,
127
- };
package/models/Report.js DELETED
@@ -1,27 +0,0 @@
1
- const mongoose = require("mongoose");
2
-
3
- const reportSchema = new mongoose.Schema(
4
- {
5
- workspaceId: { type: String, default: "" },
6
- type: {
7
- type: String,
8
- default: "",
9
- },
10
- title: { type: String, default: "" },
11
- mode: { type: String, default: "combined" },
12
- displayType: { type: String, default: "table" },
13
- filter: {},
14
- dateRange: {
15
- startDate: { type: String, default: "" },
16
- endDate: { type: String, default: "" },
17
- },
18
- actions: [],
19
- processedData: [],
20
- },
21
- { timestamps: true }
22
- );
23
-
24
- reportSchema.index({ type: 1, workspaceId: 1 });
25
- reportSchema.index({ type: 1, workspaceId: 1, title: 1 });
26
-
27
- module.exports = mongoose.model("Report", reportSchema);
package/models/Setting.js DELETED
@@ -1,18 +0,0 @@
1
- const { model, Schema } = require("mongoose");
2
-
3
- const SettingSchema = new Schema(
4
- {
5
- workspaceId: {
6
- type: Schema.Types.ObjectId,
7
- ref: "Workspace",
8
- default: null,
9
- },
10
- settings: [{ module: { type: String, default: "" }, options: {} }],
11
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
12
- updateBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
13
- isDeleted: { type: Boolean, default: false },
14
- },
15
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
16
- );
17
-
18
- module.exports = model("Setting", SettingSchema);