shuttlepro-shared 1.3.10 → 1.3.12

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.
@@ -13,7 +13,6 @@ const userPermissionRepository = require("./userPermission.repository");
13
13
  const userRolePermissionRepository = require("./userRolePermission.repository");
14
14
  const notificationSettingsRepository = require("./notificationSettings.repository");
15
15
  const customerProfileRepository = require("./customerProfile.repository");
16
- const customerTimelineRepository = require("./customerTimeline.repository");
17
16
  exports.module = {
18
17
  workspaceRepository,
19
18
  integrationRepository,
@@ -30,5 +29,4 @@ exports.module = {
30
29
  userPermissionRepository,
31
30
  userRolePermissionRepository,
32
31
  customerProfileRepository,
33
- customerTimelineRepository,
34
32
  };
@@ -8,11 +8,18 @@ const CACHE_KEY_ALL = "integrations_all";
8
8
  */
9
9
  const getCachedAllIntegrations = async () => {
10
10
  let integrations = await getRedisData(CACHE_KEY_ALL);
11
+ console.log(integrations, "integrations");
11
12
  if (!integrations) {
12
13
  integrations = await Integration.find({}).lean().exec();
13
14
  await setRedisData(CACHE_KEY_ALL, integrations);
14
15
  }
15
- return integrations;
16
+ console.log(integrations, "after integrations");
17
+ return integrations?.map((x) => {
18
+ return {
19
+ ...x,
20
+ _id: x?._id?.toString(),
21
+ };
22
+ });
16
23
  };
17
24
 
18
25
  /**
@@ -75,6 +82,8 @@ const findIntegrationByFilter = async (
75
82
  ) => {
76
83
  const allIntegrations = await getCachedAllIntegrations();
77
84
 
85
+ console.log(allIntegrations, "allIntegrations");
86
+
78
87
  let filteredIntegrations = allIntegrations;
79
88
  if (workspaceId) {
80
89
  filteredIntegrations = allIntegrations.filter(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,78 +0,0 @@
1
- const CustomerTimeline = require("../../models/CustomerTimeline");
2
-
3
- const createCustomerTimeline = async (data) => {
4
- const newTimeline = new CustomerTimeline(data);
5
- return await newTimeline.save();
6
- };
7
-
8
- const findCustomerTimelinesByWorkspaceId = async (workspaceId) => {
9
- return await CustomerTimeline.find({ workspaceId }).lean().exec();
10
- };
11
-
12
- const findCustomerTimelinesByWorkspace = async (workspaceId, filter = {}) => {
13
- return await CustomerTimeline.find({ workspaceId, ...filter })
14
- .lean()
15
- .exec();
16
- };
17
-
18
- const findCustomerTimelineByFilter = async (filter = {}, bodyFilter = {}) => {
19
- const all = await CustomerTimeline.find(filter).lean().exec();
20
-
21
- return (
22
- all.find((item) =>
23
- Object.entries(bodyFilter).every(
24
- ([key, value]) => item.body?.[key] === value
25
- )
26
- ) || null
27
- );
28
- };
29
-
30
- const findAllCustomerTimelinesByFilter = async (
31
- filter = {},
32
- bodyFilter = {}
33
- ) => {
34
- const all = await CustomerTimeline.find(filter).lean().exec();
35
- return all.filter((item) =>
36
- Object.entries(bodyFilter).every(
37
- ([key, value]) => item.body?.[key] === value
38
- )
39
- );
40
- };
41
-
42
- const updateCustomerTimeline = async (id, data) => {
43
- return await CustomerTimeline.findByIdAndUpdate(id, data, {
44
- new: true,
45
- }).exec();
46
- };
47
- const updateManyCustomerTimelinesByFilter = async (filter = {}, data = {}) => {
48
- await CustomerTimeline.updateMany(filter, data).exec();
49
- const updatedDocs = await CustomerTimeline.find(query).lean().exec();
50
- return updatedDocs;
51
- };
52
-
53
- const updateCustomerTimelineByFilter = async (filter, data) => {
54
- return await CustomerTimeline.findOneAndUpdate(filter, data, {
55
- new: true,
56
- }).exec();
57
- };
58
-
59
- const deleteCustomerTimeline = async (id) => {
60
- return await CustomerTimeline.findByIdAndDelete(id).exec();
61
- };
62
-
63
- const deleteAllCustomerTimelinesByWorkspace = async (workspaceId) => {
64
- return await CustomerTimeline.deleteMany({ workspaceId }).exec();
65
- };
66
-
67
- module.exports = {
68
- createCustomerTimeline,
69
- findCustomerTimelinesByWorkspaceId,
70
- findCustomerTimelinesByWorkspace,
71
- findCustomerTimelineByFilter,
72
- updateCustomerTimeline,
73
- updateCustomerTimelineByFilter,
74
- deleteCustomerTimeline,
75
- deleteAllCustomerTimelinesByWorkspace,
76
- findAllCustomerTimelinesByFilter,
77
- updateManyCustomerTimelinesByFilter,
78
- };
@@ -1,28 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const CustomerTimelineSchema = new Schema(
4
- {
5
- type: { type: String, default: "" },
6
- referenceId: { type: String, default: "" },
7
- timestamp: { type: String, default: "" },
8
- platformId: {
9
- type: Schema.Types.ObjectId,
10
- ref: "Integration",
11
- default: null,
12
- },
13
- workspaceId: {
14
- type: Schema.Types.ObjectId,
15
- ref: "Workspace",
16
- default: null,
17
- },
18
- profileId: {
19
- type: Schema.Types.ObjectId,
20
- ref: "CustomerProfile",
21
- default: null,
22
- },
23
- body: {},
24
- },
25
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
26
- );
27
-
28
- module.exports = mongoose.model("CustomerTimeline", CustomerTimelineSchema);