shuttlepro-shared 1.1.91 → 1.1.93

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 (45) hide show
  1. package/constants/index.js +0 -15
  2. package/index.js +0 -8
  3. package/models/Role.js +40 -0
  4. package/models/UserPermission.js +5 -0
  5. package/models/UserRole.js +10 -3
  6. package/models.js +3 -50
  7. package/package.json +2 -13
  8. package/common/repositories/descriptionTemplates.repository.js +0 -186
  9. package/common/repositories/index.js +0 -10
  10. package/common/repositories/integration.repository.js +0 -197
  11. package/common/repositories/shipper.repository.js +0 -77
  12. package/common/repositories/workspace.repository.js +0 -95
  13. package/config/bull.js +0 -78
  14. package/config/config.js +0 -14
  15. package/config/database.js +0 -7
  16. package/config/index.js +0 -13
  17. package/config/redis.js +0 -160
  18. package/config/socket.js +0 -172
  19. package/models/AgentActivity.js +0 -189
  20. package/models/Assignment.js +0 -23
  21. package/models/BusinessDistribution.js +0 -23
  22. package/models/Card.js +0 -144
  23. package/models/CardComments.js +0 -33
  24. package/models/Chatbot.js +0 -16
  25. package/models/Checkpoint.js +0 -50
  26. package/models/City.js +0 -17
  27. package/models/Column.js +0 -28
  28. package/models/Conversation.js +0 -84
  29. package/models/Customer.js +0 -35
  30. package/models/DescriptionTemplate.js +0 -22
  31. package/models/Integration.js +0 -53
  32. package/models/Label.js +0 -42
  33. package/models/Message.js +0 -47
  34. package/models/Order.js +0 -131
  35. package/models/OrderProduct.js +0 -37
  36. package/models/Profile.js +0 -127
  37. package/models/Report.js +0 -27
  38. package/models/Shipper.js +0 -52
  39. package/models/Status.js +0 -58
  40. package/models/StatusType.js +0 -10
  41. package/models/Step.js +0 -50
  42. package/models/Type.js +0 -25
  43. package/models/Workspace.js +0 -190
  44. package/utils/decorator-factory.js +0 -264
  45. package/utils/logger.js +0 -41
@@ -23,18 +23,3 @@ exports.GenericMessages = {
23
23
  URL_FETCH_SUCCESS: "Url Fetched successfully!",
24
24
  WORKSPACE_NOT_FOUND: "Workspace not found!",
25
25
  };
26
-
27
- exports.DYNAMIC_FIELD_TYPES = [
28
- "text",
29
- "autocomplete",
30
- "radio",
31
- "text area",
32
- "number",
33
- "date",
34
- "time",
35
- "email",
36
- "range",
37
- "url",
38
- "colour",
39
- "file",
40
- ];
package/index.js CHANGED
@@ -1,15 +1,7 @@
1
1
  const sharedModels = require("./models");
2
2
  const sharedFunctions = require("./functions");
3
- const logger = require("./utils/logger");
4
- const shuttlePro = require("./utils/decorator-factory");
5
- const configs = require("./config");
6
- const repositories = require("./common/repositories");
7
3
 
8
4
  module.exports = {
9
5
  sharedModels,
10
6
  sharedFunctions,
11
- logger,
12
- shuttlePro,
13
- configs,
14
- repositories,
15
7
  };
package/models/Role.js ADDED
@@ -0,0 +1,40 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const RoleSchema = new Schema(
5
+ {
6
+ name: {
7
+ type: String,
8
+ default: "",
9
+ },
10
+ workspaceId: {
11
+ type: Schema.Types.ObjectId,
12
+ ref: "Workspace",
13
+ default: null,
14
+ },
15
+ description: {
16
+ type: String,
17
+ default: "",
18
+ },
19
+ status: {
20
+ type: String,
21
+ default: "active",
22
+ enum: ["active", "inactive"],
23
+ },
24
+ permissionId: {
25
+ type: Schema.Types.ObjectId,
26
+ ref: "Role",
27
+ default: null,
28
+ },
29
+ defaultModule: {
30
+ type: String,
31
+ default: "conversation",
32
+ },
33
+ modulePermissions: {},
34
+ permissions: [],
35
+ logs: [],
36
+ },
37
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
38
+ );
39
+
40
+ module.exports = mongoose.model("Role", RoleSchema);
@@ -16,6 +16,11 @@ const UserPermissionsSchema = new Schema(
16
16
  type: String,
17
17
  default: "",
18
18
  },
19
+ roleId: {
20
+ type: Schema.Types.ObjectId,
21
+ ref: "Role",
22
+ default: null,
23
+ },
19
24
  },
20
25
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
21
26
  );
@@ -1,6 +1,7 @@
1
1
  const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
2
3
 
3
- const daySchema = new mongoose.Schema({
4
+ const daySchema = new Schema({
4
5
  day: { type: String, required: true },
5
6
  startTime: { type: String, required: false },
6
7
  endTime: { type: String, required: false },
@@ -9,7 +10,7 @@ const daySchema = new mongoose.Schema({
9
10
  lateThreshold: { type: String, required: false },
10
11
  });
11
12
 
12
- const userRoleSchema = new mongoose.Schema(
13
+ const userRoleSchema = new Schema(
13
14
  {
14
15
  userId: {
15
16
  type: mongoose.Schema.Types.ObjectId,
@@ -23,7 +24,12 @@ const userRoleSchema = new mongoose.Schema(
23
24
  },
24
25
  role: {
25
26
  type: String,
26
- enum: ["admin", "agent", "storeManager", "socialMediaManager"],
27
+ default: "",
28
+ },
29
+ roleId: {
30
+ type: Schema.Types.ObjectId,
31
+ ref: "Role",
32
+ default: null,
27
33
  },
28
34
  isOwner: { type: Boolean, default: false },
29
35
  userShift: {
@@ -45,6 +51,7 @@ const userRoleSchema = new mongoose.Schema(
45
51
  );
46
52
 
47
53
  const UserRole = mongoose.model("UserRole", userRoleSchema);
54
+
48
55
  module.exports = {
49
56
  UserRole,
50
57
  };
package/models.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const Website = require("./models/Website");
2
- const DescriptionTemplate = require("./models/DescriptionTemplate");
3
2
  const ProductQueue = require("./models/ProductQueue");
4
3
  const ColumnPreference = require("./models/ColumnPreference");
5
4
  const UserPermission = require("./models/UserPermission");
@@ -13,30 +12,8 @@ const AutoSchedulerSchema = require("./models/AutoScheduler");
13
12
  const ActivityLogs = require("./models/ActivityLogs");
14
13
  const UserRole = require("./models/UserRole");
15
14
  const OrderQueue = require("./models/OrderQueue");
16
- const AgentActivity = require("./models/AgentActivity");
17
- const Assignment = require("./models/Assignment");
18
- const BusinessDistribution = require("./models/BusinessDistribution");
19
- const CardComments = require("./models/CardComments");
20
- const Checkpoint = require("./models/Checkpoint");
21
- const City = require("./models/City");
22
- const Column = require("./models/Column");
23
- const Conversation = require("./models/Conversation");
24
- const Customer = require("./models/Customer");
25
- const Integration = require("./models/Integration");
26
- const Label = require("./models/Label");
27
- const Message = require("./models/Message");
28
- const Order = require("./models/Order");
29
- const OrderProduct = require("./models/OrderProduct");
30
- const Report = require("./models/Report");
31
- const Shipper = require("./models/Shipper");
32
- const Status = require("./models/Status");
33
- const StatusType = require("./models/StatusType");
34
- const Type = require("./models/Type");
35
- const Workspace = require("./models/Workspace");
36
- const Card = require("./models/Card");
37
- const Profile = require("./models/Profile");
38
- const Chatbot = require("./models/Chatbot");
39
- const Step = require("./models/Step");
15
+ const Role = require("./models/Role");
16
+
40
17
  module.exports = {
41
18
  Website,
42
19
  ProductQueue,
@@ -52,29 +29,5 @@ module.exports = {
52
29
  ActivityLogs,
53
30
  UserRole,
54
31
  OrderQueue,
55
- AgentActivity,
56
- Assignment,
57
- BusinessDistribution,
58
- CardComments,
59
- Checkpoint,
60
- Column,
61
- Conversation,
62
- City,
63
- Customer,
64
- Integration,
65
- Label,
66
- Message,
67
- Order,
68
- OrderProduct,
69
- Report,
70
- Shipper,
71
- Status,
72
- Type,
73
- Workspace,
74
- StatusType,
75
- Card,
76
- DescriptionTemplate,
77
- Profile,
78
- Chatbot,
79
- Step,
32
+ Role,
80
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.1.91",
3
+ "version": "1.1.93",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,18 +11,7 @@
11
11
  "license": "ISC",
12
12
  "access": "restricted",
13
13
  "dependencies": {
14
- "@babel/core": "^7.22.5",
15
- "@babel/plugin-proposal-class-properties": "^7.18.6",
16
- "@babel/plugin-proposal-decorators": "^7.22.5",
17
- "@babel/preset-env": "^7.22.5",
18
- "@babel/register": "^7.22.5",
19
- "redis": "^4.6.14",
20
- "express": "^4.17.1",
21
14
  "jsonwebtoken": "^9.0.2",
22
- "mongoose": "^8.7.1",
23
- "cors": "^2.8.5",
24
- "helmet": "^8.0.0",
25
- "bull": "^4.10.4",
26
- "socket.io": "^4.8.1"
15
+ "mongoose": "^8.7.1"
27
16
  }
28
17
  }
@@ -1,186 +0,0 @@
1
- const { getRedisData, setRedisData } = require("../../config/redis");
2
- // const DescriptionTemplate = require("../../../models/DescriptionTemplate");
3
- const DescriptionTemplate = require("../../models/DescriptionTemplate");
4
-
5
- const CACHE_KEY_ALL = "description_templates_all";
6
-
7
- /**
8
- * Get cached descriptionTemplates for all workspaces.
9
- */
10
- const getCachedAllDescriptionTemplates = async () => {
11
- let descriptionTemplates = await getRedisData(CACHE_KEY_ALL);
12
- if (!descriptionTemplates) {
13
- descriptionTemplates = await DescriptionTemplate.find({}).lean().exec();
14
- await setRedisData(CACHE_KEY_ALL, descriptionTemplates);
15
- }
16
- return descriptionTemplates;
17
- };
18
-
19
- /**
20
- * Update cached descriptionTemplates for all workspaces.
21
- */
22
- const updateCachedAllDescriptionTemplates = async () => {
23
- const descriptionTemplates = await DescriptionTemplate.find({}).lean().exec();
24
- await setRedisData(CACHE_KEY_ALL, descriptionTemplates);
25
- };
26
-
27
- /**
28
- * Get cached descriptionTemplates for a specific workspace.
29
- * Now uses the all descriptionTemplates cache and filters by workspaceId.
30
- */
31
-
32
- /**
33
- * Create a new DescriptionTemplate and update cache.
34
- */
35
- const createTemplate = async (data) => {
36
- const newTemplate = new DescriptionTemplate(data);
37
- const saveDescriptionTemplate = await newTemplate.save();
38
-
39
- // Update only the main cache
40
- await updateCachedAllDescriptionTemplates();
41
-
42
- return saveDescriptionTemplate;
43
- };
44
-
45
- /**
46
- * Find an DescriptionTemplate by ID.
47
- */
48
- const findTemplatesByWorkspaceId = async (workspaceId) => {
49
- const allDescriptionTemplates = await getCachedAllDescriptionTemplates();
50
- return allDescriptionTemplates.filter(
51
- (desc) => desc.workspaceId === workspaceId
52
- );
53
- };
54
-
55
- /**
56
- * Find DescriptionTemplate by filter (supports both workspace & non-workspace).
57
- */
58
- const findTemplateByFilter = async (
59
- filter,
60
- bodyFilter = {},
61
- workspaceId = null
62
- ) => {
63
- const allTemplates = await getCachedAllDescriptionTemplates();
64
-
65
- // Filter by workspaceId if provided
66
- let filteredTemplates = workspaceId
67
- ? allTemplates.filter((desc) => desc.workspaceId === workspaceId)
68
- : allTemplates;
69
-
70
- return (
71
- filteredTemplates.find(
72
- (item) =>
73
- // Check direct properties of item
74
- Object.entries(filter).every(([key, value]) => item[key] === value) &&
75
- // If bodyFilter is provided, check inside item.body
76
- Object.entries(bodyFilter).every(
77
- ([key, value]) => item.body?.[key] === value
78
- )
79
- ) || null
80
- );
81
- };
82
- const createOrUpdateTemplate = async (filter, data) => {
83
- const template = await DescriptionTemplate.findOneAndUpdate(filter, data, {
84
- upsert: true,
85
- new: true,
86
- });
87
- if (template) {
88
- // Update only the main cache
89
- await updateCachedAllDescriptionTemplates();
90
- }
91
- return template;
92
- };
93
- const updateTemplateById = async (id, data) => {
94
- const updatedTemplate = await DescriptionTemplate.findByIdAndUpdate(
95
- id,
96
- data,
97
- {
98
- new: true,
99
- }
100
- ).exec();
101
-
102
- if (updatedTemplate) {
103
- // Update only the main cache
104
- await updateCachedAllDescriptionTemplates();
105
- }
106
-
107
- return updatedTemplate;
108
- };
109
-
110
- /**
111
- * Update an DescriptionTemplate by filter.
112
- */
113
- const updateTemplateByFilter = async (filter, data, workspaceId = null) => {
114
- // Add workspace filter if provided
115
- const queryFilter = workspaceId ? { ...filter, workspaceId } : filter;
116
-
117
- const updatedTemplate = await DescriptionTemplate.findOneAndUpdate(
118
- queryFilter,
119
- data,
120
- {
121
- new: true,
122
- }
123
- ).exec();
124
-
125
- if (updatedTemplate) {
126
- // Update only the main cache
127
- await updateCachedAllDescriptionTemplates();
128
- }
129
-
130
- return updatedTemplate;
131
- };
132
- const updateManyTemplates = async (filter, data) => {
133
- const queryFilter = workspaceId ? { ...filter, workspaceId } : filter;
134
-
135
- const updatedTemplate = await DescriptionTemplate.updateMany(
136
- queryFilter,
137
- { $set: { ...data } },
138
- {
139
- new: true,
140
- }
141
- ).exec();
142
-
143
- if (updatedTemplate) {
144
- // Update only the main cache
145
- await updateCachedAllDescriptionTemplates();
146
- }
147
-
148
- return updatedTemplate;
149
- };
150
- /**
151
- * Delete an DescriptionTemplate by ID.
152
- */
153
- const deleteTemplate = async (id) => {
154
- const deletedTemplate = await DescriptionTemplate.findByIdAndDelete(
155
- id
156
- ).exec();
157
-
158
- if (deletedTemplate) {
159
- // Update only the main cache
160
- await updateCachedAllDescriptionTemplates();
161
- }
162
-
163
- return deletedTemplate;
164
- };
165
-
166
- /**
167
- * Delete all descriptionTemplates for a specific workspace.
168
- */
169
- const deleteAllTemplatesByWorkspace = async (workspaceId) => {
170
- await DescriptionTemplate.deleteMany({ workspaceId }).exec();
171
-
172
- // Update only the main cache
173
- await updateCachedAllDescriptionTemplates();
174
- };
175
-
176
- module.exports = {
177
- createTemplate,
178
- createOrUpdateTemplate,
179
- findTemplateByFilter,
180
- findTemplatesByWorkspaceId,
181
- updateTemplateById,
182
- updateTemplateByFilter,
183
- updateManyTemplates,
184
- deleteTemplate,
185
- deleteAllTemplatesByWorkspace,
186
- };
@@ -1,10 +0,0 @@
1
- const workspaceRepository = require("./workspace.repository");
2
- const integrationRepository = require("./integration.repository");
3
- const descriptionTemplateRepository = require("./descriptionTemplates.repository");
4
- const shipperRepository = require("./shipper.repository");
5
- exports.module = {
6
- workspaceRepository,
7
- integrationRepository,
8
- descriptionTemplateRepository,
9
- shipperRepository,
10
- };
@@ -1,197 +0,0 @@
1
- const { getRedisData, setRedisData } = require("../../config/redis");
2
- const Integration = require("../../models/Integration");
3
-
4
- const CACHE_KEY_ALL = "integrations_all";
5
-
6
- /**
7
- * Get cached integrations for all workspaces.
8
- */
9
- const getCachedAllIntegrations = async () => {
10
- let integrations = await getRedisData(CACHE_KEY_ALL);
11
- if (!integrations) {
12
- integrations = await Integration.find({}).lean().exec();
13
- await setRedisData(CACHE_KEY_ALL, integrations);
14
- }
15
- return integrations;
16
- };
17
-
18
- /**
19
- * Update cached integrations for all workspaces.
20
- */
21
- const updateCachedAllIntegrations = async () => {
22
- const integrations = await Integration.find({}).lean().exec();
23
- await setRedisData(CACHE_KEY_ALL, integrations);
24
- };
25
-
26
- /**
27
- * Get cached integrations for a specific workspace.
28
- * Now uses the all integrations cache and filters by workspaceId.
29
- */
30
- const getCachedIntegrations = async (workspaceId) => {
31
- const allIntegrations = await getCachedAllIntegrations();
32
- return allIntegrations.filter((intg) => intg.workspaceId === workspaceId);
33
- };
34
-
35
- /**
36
- * Create a new integration and update cache.
37
- */
38
- const createIntegration = async (data) => {
39
- const newIntegration = new Integration(data);
40
- const savedIntegration = await newIntegration.save();
41
-
42
- // Update only the main cache
43
- await updateCachedAllIntegrations();
44
-
45
- return savedIntegration;
46
- };
47
-
48
- /**
49
- * Find an integration by ID.
50
- */
51
- const findIntegrationsByWorkspaceId = async (workspaceId) => {
52
- return await getCachedIntegrations(workspaceId);
53
- };
54
-
55
- /**
56
- * Find integrations by workspace.
57
- */
58
- const findIntegrationsByWorkspace = async (workspaceId, filter = {}) => {
59
- const allIntegrations = await getCachedIntegrations(workspaceId);
60
-
61
- return allIntegrations.filter(
62
- (intg) =>
63
- intg.workspaceId === workspaceId &&
64
- Object.entries(filter).every(([key, value]) => intg[key] === value)
65
- );
66
- };
67
-
68
- /**
69
- * Find integration by filter (supports both workspace & non-workspace).
70
- */
71
- const findIntegrationByFilter = async (filter, workspaceId = null) => {
72
- const allIntegrations = await getCachedAllIntegrations();
73
-
74
- let filteredIntegrations = allIntegrations;
75
- if (workspaceId) {
76
- filteredIntegrations = allIntegrations.filter(
77
- (intg) => intg.workspaceId === workspaceId
78
- );
79
- }
80
-
81
- return (
82
- filteredIntegrations.find((item) =>
83
- Object.entries(filter).every(([key, value]) => item.body?.[key] === value)
84
- ) || null
85
- );
86
- };
87
- const findAllIntegrationByFilter = async (
88
- filter = {},
89
- bodyFilter = {},
90
- workspaceId = null
91
- ) => {
92
- const allIntegrations = await getCachedAllIntegrations();
93
-
94
- let filteredIntegrations = allIntegrations;
95
- if (workspaceId) {
96
- filteredIntegrations = allIntegrations.filter(
97
- (intg) => intg.workspaceId === workspaceId
98
- );
99
- }
100
- return (
101
- filteredIntegrations.filter(
102
- (item) =>
103
- Object.entries(filter).every(([key, value]) => item[key] === value) &&
104
- Object.entries(bodyFilter).every(
105
- ([key, value]) => item.body?.[key] === value
106
- )
107
- ) || []
108
- );
109
- };
110
- const bulkCreateAndUpdateIntegrations = async (operations) => {
111
- await Integration.bulkWrite(operations);
112
- await updateCachedAllIntegrations();
113
- return operations;
114
- };
115
- /**
116
- * Find all integrations (without workspace filtering).
117
- */
118
- const findAllIntegrations = async () => {
119
- return await getCachedAllIntegrations();
120
- };
121
-
122
- /**
123
- * Update an integration by ID.
124
- */
125
- const updateIntegration = async (id, data) => {
126
- const updatedIntegration = await Integration.findByIdAndUpdate(id, data, {
127
- new: true,
128
- }).exec();
129
-
130
- if (updatedIntegration) {
131
- // Update only the main cache
132
- await updateCachedAllIntegrations();
133
- }
134
-
135
- return updatedIntegration;
136
- };
137
-
138
- /**
139
- * Update an integration by filter.
140
- */
141
- const updateIntegrationByFilter = async (filter, data, workspaceId = null) => {
142
- // Add workspace filter if provided
143
- const queryFilter = workspaceId ? { ...filter, workspaceId } : filter;
144
-
145
- const updatedIntegration = await Integration.findOneAndUpdate(
146
- queryFilter,
147
- data,
148
- {
149
- new: true,
150
- }
151
- ).exec();
152
-
153
- if (updatedIntegration) {
154
- // Update only the main cache
155
- await updateCachedAllIntegrations();
156
- }
157
-
158
- return updatedIntegration;
159
- };
160
-
161
- /**
162
- * Delete an integration by ID.
163
- */
164
- const deleteIntegration = async (id) => {
165
- const deletedIntegration = await Integration.findByIdAndDelete(id).exec();
166
-
167
- if (deletedIntegration) {
168
- // Update only the main cache
169
- await updateCachedAllIntegrations();
170
- }
171
-
172
- return deletedIntegration;
173
- };
174
-
175
- /**
176
- * Delete all integrations for a specific workspace.
177
- */
178
- const deleteAllIntegrationsByWorkspace = async (workspaceId) => {
179
- await Integration.deleteMany({ workspaceId }).exec();
180
-
181
- // Update only the main cache
182
- await updateCachedAllIntegrations();
183
- };
184
-
185
- module.exports = {
186
- createIntegration,
187
- findIntegrationsByWorkspaceId,
188
- findIntegrationsByWorkspace,
189
- findIntegrationByFilter,
190
- findAllIntegrations,
191
- updateIntegration,
192
- updateIntegrationByFilter,
193
- deleteIntegration,
194
- deleteAllIntegrationsByWorkspace,
195
- findAllIntegrationByFilter,
196
- bulkCreateAndUpdateIntegrations,
197
- };
@@ -1,77 +0,0 @@
1
- const { getRedisData, setRedisData } = require("../../config/redis");
2
- const Shipper = require("../../models/Shipper");
3
-
4
- const CACHE_KEY_ALL = "shippers_all";
5
-
6
- const getCachedShippers = async () => {
7
- let shippers = await getRedisData(CACHE_KEY_ALL);
8
- if (!shippers) {
9
- shippers = await Shipper.find().lean().exec();
10
- await setRedisData(CACHE_KEY_ALL, JSON.stringify(shippers));
11
- } else {
12
- shippers = JSON.parse(shippers);
13
- }
14
- return shippers;
15
- };
16
-
17
- const updateCachedShippers = async () => {
18
- const shippers = await Shipper.find().lean().exec();
19
- await setRedisData(CACHE_KEY_ALL, JSON.stringify(shippers));
20
- };
21
-
22
- const createShipper = async (data) => {
23
- const newShipper = new Shipper(data);
24
- const savedShipper = await newShipper.save();
25
- await updateCachedShippers();
26
- return savedShipper;
27
- };
28
-
29
- const findShipperById = async (id) => {
30
- const shippers = await getCachedShippers();
31
- const shipper = shippers.find((s) => s._id.toString() === id) || null;
32
-
33
- return shipper;
34
- };
35
-
36
- const findShipper = async (filter) => {
37
- const shippers = await getCachedShippers();
38
- return (
39
- shippers.find((s) =>
40
- Object.entries(filter).every(([key, value]) => s[key] === value)
41
- ) || null
42
- );
43
- };
44
-
45
- const findAllShippers = async (filter = {}) => {
46
- const shippers = await getCachedShippers();
47
- return shippers.filter((s) =>
48
- Object.entries(filter).every(([key, value]) => s[key] === value)
49
- );
50
- };
51
-
52
- const updateShipper = async (id, data) => {
53
- const updatedShipper = await Shipper.findByIdAndUpdate(id, data, {
54
- new: true,
55
- }).exec();
56
- if (updatedShipper) {
57
- await updateCachedShippers();
58
- }
59
- return updatedShipper;
60
- };
61
-
62
- const deleteShipper = async (id) => {
63
- const deletedShipper = await Shipper.findByIdAndDelete(id).exec();
64
- if (deletedShipper) {
65
- await updateCachedShippers();
66
- }
67
- return deletedShipper;
68
- };
69
-
70
- module.exports = {
71
- createShipper,
72
- findShipperById,
73
- findShipper,
74
- findAllShippers,
75
- updateShipper,
76
- deleteShipper,
77
- };