shuttlepro-shared 1.2.19 → 1.2.20

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.
@@ -156,20 +156,15 @@ const deleteTemplate = async (id) => {
156
156
  ).exec();
157
157
 
158
158
  if (deletedTemplate) {
159
- // Update only the main cache
160
159
  await updateCachedAllDescriptionTemplates();
161
160
  }
162
161
 
163
162
  return deletedTemplate;
164
163
  };
165
164
 
166
- /**
167
- * Delete all descriptionTemplates for a specific workspace.
168
- */
169
165
  const deleteAllTemplatesByWorkspace = async (workspaceId) => {
170
166
  await DescriptionTemplate.deleteMany({ workspaceId }).exec();
171
167
 
172
- // Update only the main cache
173
168
  await updateCachedAllDescriptionTemplates();
174
169
  };
175
170
 
@@ -177,6 +172,22 @@ const findTemplateById = async (id) => {
177
172
  return await DescriptionTemplate.findById(id).lean().exec();
178
173
  };
179
174
 
175
+ const deleteTemplatesByFilter = async (filter) => {
176
+ await DescriptionTemplate.deleteMany(filter).exec();
177
+
178
+ await updateCachedAllDescriptionTemplates();
179
+ };
180
+
181
+ const insertManyTemplates = async (templates) => {
182
+ const insertedTemplates = await DescriptionTemplate.insertMany(templates);
183
+
184
+ if (insertedTemplates?.length > 0) {
185
+ await updateCachedAllDescriptionTemplates();
186
+ }
187
+
188
+ return insertedTemplates;
189
+ };
190
+
180
191
  module.exports = {
181
192
  createTemplate,
182
193
  createOrUpdateTemplate,
@@ -188,4 +199,6 @@ module.exports = {
188
199
  deleteTemplate,
189
200
  deleteAllTemplatesByWorkspace,
190
201
  findTemplateById,
202
+ deleteTemplatesByFilter,
203
+ insertManyTemplates,
191
204
  };
@@ -4,6 +4,7 @@ const descriptionTemplateRepository = require("./descriptionTemplates.repository
4
4
  const shipperRepository = require("./shipper.repository");
5
5
  const labelRepository = require("./label.repository");
6
6
  const userRepository = require("./user.repository");
7
+ const chatMemberRepository = require("./chatMember.repository");
7
8
 
8
9
  exports.module = {
9
10
  workspaceRepository,
@@ -12,4 +13,5 @@ exports.module = {
12
13
  shipperRepository,
13
14
  labelRepository,
14
15
  userRepository,
16
+ chatMemberRepository,
15
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.19",
3
+ "version": "1.2.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {