joye-backend-utility 5.0.33 → 5.0.35
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/database.js +1 -1
- package/dist/jwt.d.ts +1 -0
- package/dist/jwt.js +15 -1
- package/dist/schema/organization.js +2 -0
- package/dist/schema/user.js +18 -0
- package/dist/schema/userMessagesLog.js +2 -0
- package/package.json +1 -1
package/dist/database.js
CHANGED
|
@@ -65,7 +65,7 @@ class database {
|
|
|
65
65
|
}
|
|
66
66
|
this.modelSchemaInConnection(dbConnection);
|
|
67
67
|
database.connections[`${config_1.DB_KEY}`] = dbConnection;
|
|
68
|
-
console.log('Connected to database');
|
|
68
|
+
console.log('Connected to database 111');
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
this.connectionFactory = async (key, url) => {
|
package/dist/jwt.d.ts
CHANGED
package/dist/jwt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtVerify = exports.createToken = void 0;
|
|
3
|
+
exports.decodeToken = exports.jwtVerify = exports.createToken = void 0;
|
|
4
4
|
const jwt = require('jsonwebtoken');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
@@ -24,3 +24,17 @@ const jwtVerify = async (token) => new Promise(resolve => {
|
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
exports.jwtVerify = jwtVerify;
|
|
27
|
+
const decodeToken = (token) => {
|
|
28
|
+
try {
|
|
29
|
+
const decodedHeader = jwt.decode(token, { complete: true });
|
|
30
|
+
if (!decodedHeader) {
|
|
31
|
+
console.log('Invalid token Error');
|
|
32
|
+
}
|
|
33
|
+
return decodedHeader;
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.log('Token decode failed: ', err);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.decodeToken = decodeToken;
|
|
@@ -6,6 +6,7 @@ const Organization = new mongoose_1.Schema({
|
|
|
6
6
|
platformKey: {
|
|
7
7
|
type: String,
|
|
8
8
|
required: true,
|
|
9
|
+
index: true,
|
|
9
10
|
},
|
|
10
11
|
key: {
|
|
11
12
|
type: String,
|
|
@@ -74,4 +75,5 @@ const Organization = new mongoose_1.Schema({
|
|
|
74
75
|
required: false,
|
|
75
76
|
},
|
|
76
77
|
});
|
|
78
|
+
Organization.index({ platformKey: 1, timezone: -1, inactive: -1 });
|
|
77
79
|
exports.OrganizationSchema = Organization;
|
package/dist/schema/user.js
CHANGED
|
@@ -6,6 +6,7 @@ const User = new mongoose_1.Schema({
|
|
|
6
6
|
organizationId: {
|
|
7
7
|
type: String,
|
|
8
8
|
required: true,
|
|
9
|
+
index: true,
|
|
9
10
|
},
|
|
10
11
|
employeeId: {
|
|
11
12
|
type: String,
|
|
@@ -164,6 +165,14 @@ const User = new mongoose_1.Schema({
|
|
|
164
165
|
type: String,
|
|
165
166
|
required: false,
|
|
166
167
|
},
|
|
168
|
+
consentVia: {
|
|
169
|
+
type: String,
|
|
170
|
+
required: false,
|
|
171
|
+
},
|
|
172
|
+
loginTime: {
|
|
173
|
+
type: Number,
|
|
174
|
+
required: false,
|
|
175
|
+
},
|
|
167
176
|
lastRecommendationDate: {
|
|
168
177
|
type: String,
|
|
169
178
|
required: false,
|
|
@@ -200,4 +209,13 @@ const User = new mongoose_1.Schema({
|
|
|
200
209
|
required: false,
|
|
201
210
|
},
|
|
202
211
|
});
|
|
212
|
+
User.index({ botDetails: 1, preferredTimezone: -1 }, {
|
|
213
|
+
unique: false,
|
|
214
|
+
});
|
|
215
|
+
User.index({ organizationId: 1, botDetails: -1 }, {
|
|
216
|
+
unique: false,
|
|
217
|
+
});
|
|
218
|
+
User.index({ botDetails: 1, organizationId: -1, preferredTimezone: -1 }, {
|
|
219
|
+
unique: false,
|
|
220
|
+
});
|
|
203
221
|
exports.UserSchema = User;
|
|
@@ -64,4 +64,6 @@ const UserMessageLog = new mongoose_1.Schema({
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
UserMessageLog.index({ employeeId: 1, activityId: -1 });
|
|
67
|
+
UserMessageLog.index({ employeeId: 1, date: -1 });
|
|
68
|
+
UserMessageLog.index({ employeeId: 1, messageType: -1, status: -1, date: -1 });
|
|
67
69
|
exports.UserMessageLogSchema = UserMessageLog;
|