mobioffice-cli 1.0.0 → 1.0.2
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/{src/index.ts → lib/index.d.ts} +1 -45
- package/lib/models/Feed-Details-Screen.model.d.ts +6 -0
- package/lib/models/Feed-Details-Screen.model.js +27 -0
- package/lib/models/action.model.d.ts +58 -0
- package/lib/models/action.model.js +315 -0
- package/lib/models/actions/doffing.d.ts +6 -0
- package/lib/models/actions/doffing.js +64 -0
- package/lib/models/actions/folding.d.ts +7 -0
- package/lib/models/actions/folding.js +37 -0
- package/lib/models/attendance.model.d.ts +44 -0
- package/lib/models/attendance.model.js +446 -0
- package/lib/models/cicoPost.model.d.ts +9 -0
- package/lib/models/cicoPost.model.js +19 -0
- package/lib/models/company.model.d.ts +67 -0
- package/lib/models/company.model.js +725 -0
- package/lib/models/contact-us/resquest.model.d.ts +30 -0
- package/lib/models/contact-us/resquest.model.js +73 -0
- package/lib/models/crud/crud.d.ts +7 -0
- package/lib/models/crud/crud.js +27 -0
- package/lib/models/customCollection.model.d.ts +9 -0
- package/lib/models/customCollection.model.js +40 -0
- package/lib/models/customer/customer.model.d.ts +32 -0
- package/lib/models/customer/customer.model.js +62 -0
- package/lib/models/deviceChangeReq.d.ts +10 -0
- package/lib/models/deviceChangeReq.js +138 -0
- package/lib/models/dispatch.model.d.ts +14 -0
- package/lib/models/dispatch.model.js +93 -0
- package/lib/models/feed.models.d.ts +8 -0
- package/lib/models/feed.models.js +97 -0
- package/lib/models/geofence.model.d.ts +7 -0
- package/lib/models/geofence.model.js +61 -0
- package/lib/models/leaveApplicationPost.model.d.ts +12 -0
- package/lib/models/leaveApplicationPost.model.js +72 -0
- package/lib/models/license.model.d.ts +25 -0
- package/lib/models/license.model.js +198 -0
- package/lib/models/log.model.d.ts +6 -0
- package/{src/models/log.model.ts → lib/models/log.model.js} +11 -11
- package/lib/models/meeting.model.d.ts +11 -0
- package/lib/models/meeting.model.js +79 -0
- package/lib/models/meter.model.d.ts +18 -0
- package/lib/models/meter.model.js +54 -0
- package/lib/models/missingPunchPost.model.d.ts +15 -0
- package/lib/models/missingPunchPost.model.js +69 -0
- package/lib/models/offline.model.d.ts +70 -0
- package/lib/models/offline.model.js +831 -0
- package/lib/models/post.model.d.ts +38 -0
- package/lib/models/post.model.js +94 -0
- package/lib/models/printDetailsScreen.model.d.ts +6 -0
- package/lib/models/printDetailsScreen.model.js +27 -0
- package/lib/models/pushNotifications/pushNotification.model.d.ts +4 -0
- package/lib/models/pushNotifications/pushNotification.model.js +17 -0
- package/lib/models/report-actions.model.d.ts +26 -0
- package/lib/models/report-actions.model.js +56 -0
- package/lib/models/report-definition-details.model.d.ts +13 -0
- package/lib/models/report-definition-details.model.js +85 -0
- package/lib/models/report-definition.model.d.ts +23 -0
- package/lib/models/report-definition.model.js +26 -0
- package/lib/models/report-definitions-summary.model.d.ts +8 -0
- package/lib/models/report-definitions-summary.model.js +59 -0
- package/lib/models/report-detail-data.model.d.ts +46 -0
- package/lib/models/report-detail-data.model.js +49 -0
- package/lib/models/report-visibility.model.d.ts +7 -0
- package/lib/models/report-visibility.model.js +42 -0
- package/lib/models/report.model.d.ts +19 -0
- package/lib/models/report.model.js +138 -0
- package/lib/models/reportGenerator.model.d.ts +164 -0
- package/lib/models/reportGenerator.model.js +642 -0
- package/lib/models/response.model.d.ts +18 -0
- package/lib/models/response.model.js +30 -0
- package/lib/models/steps.factory.model.d.ts +172 -0
- package/lib/models/steps.factory.model.js +187 -0
- package/lib/models/storeGupShupLog.model.d.ts +6 -0
- package/lib/models/storeGupShupLog.model.js +51 -0
- package/lib/models/summary.model.d.ts +10 -0
- package/{src/models/summary.model.ts → lib/models/summary.model.js} +28 -27
- package/lib/models/tasks/sub-task-group.model.d.ts +42 -0
- package/lib/models/tasks/sub-task-group.model.js +154 -0
- package/lib/models/tasks/tags.model.d.ts +29 -0
- package/lib/models/tasks/tags.model.js +70 -0
- package/lib/models/tasks/task-group.model.d.ts +53 -0
- package/lib/models/tasks/task-group.model.js +156 -0
- package/lib/models/tasks/task.model.d.ts +163 -0
- package/lib/models/tasks/task.model.js +603 -0
- package/lib/models/tempCollection.model.d.ts +40 -0
- package/{src/models/tempCollection.model.ts → lib/models/tempCollection.model.js} +114 -130
- package/lib/models/user.model.d.ts +42 -0
- package/lib/models/user.model.js +272 -0
- package/lib/models/utility.model.d.ts +13 -0
- package/lib/models/utility.model.js +93 -0
- package/lib/models/visitorManagement/acknowledgement.model.d.ts +9 -0
- package/lib/models/visitorManagement/acknowledgement.model.js +55 -0
- package/lib/models/visitorManagement/invite.model.d.ts +32 -0
- package/lib/models/visitorManagement/invite.model.js +326 -0
- package/lib/models/visitorManagement/newIn.model.d.ts +19 -0
- package/lib/models/visitorManagement/newIn.model.js +67 -0
- package/lib/models/visitorManagement/selfServe.model.d.ts +13 -0
- package/lib/models/visitorManagement/selfServe.model.js +46 -0
- package/lib/models/worklogPost.model.d.ts +6 -0
- package/lib/models/worklogPost.model.js +9 -0
- package/lib/services/customer.d.ts +30 -0
- package/lib/services/customer.js +354 -0
- package/lib/services/meeting.d.ts +19 -0
- package/lib/services/meeting.js +109 -0
- package/package.json +4 -1
- package/.prettierrc +0 -4
- package/a.js +0 -3
- package/scripts/1.ts +0 -1300
- package/scripts/GCloudPubSub/pub-sub-config.json +0 -12
- package/scripts/GCloudPubSub/visitorAutoRejection.ts +0 -86
- package/scripts/actions/assignUsersFromOneActionToOther.ts +0 -64
- package/scripts/actions/assignUsersListToAction.ts +0 -81
- package/scripts/actions/getActionsListOfUser.ts +0 -42
- package/scripts/actions/getCompanyUserDetails.ts +0 -49
- package/scripts/actions/giveActionToUser.ts +0 -41
- package/scripts/actions/giveUsersToActivitySelector.ts +0 -56
- package/scripts/actions/groupActionsInActivitySelector.ts +0 -101
- package/scripts/actions/modifySummaryReportDB.ts +0 -42
- package/scripts/actions/setUrlToActionStep.ts +0 -18
- package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +0 -93
- package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +0 -103
- package/scripts/actions/test.ts +0 -29
- package/scripts/actions/transferFeedsOldIdToNew.ts +0 -40
- package/scripts/actions/transformUserIntoManager.ts +0 -89
- package/scripts/argvConfig.js +0 -9
- package/scripts/backUpData/testCode.ts +0 -131
- package/scripts/benaraScripts/addWorkAreaMap.ts +0 -46
- package/scripts/benaraScripts/add_customers.ts +0 -26
- package/scripts/benaraScripts/add_customers_contact.ts +0 -27
- package/scripts/benaraScripts/add_empty_work_area.ts +0 -17
- package/scripts/benaraScripts/assignManagers.ts +0 -35
- package/scripts/benaraScripts/changeCheckInFlag.ts +0 -45
- package/scripts/benaraScripts/createCustomerContactsList.ts +0 -170
- package/scripts/benaraScripts/createUserByDeletingOldUser.ts +0 -70
- package/scripts/benaraScripts/createUsersAreaMapCollection.ts +0 -23
- package/scripts/benaraScripts/createWorkAreaMap.ts +0 -24
- package/scripts/benaraScripts/mapWorkAreasToUsers.ts +0 -112
- package/scripts/companies_data.json +0 -2496
- package/scripts/create_or_update_users.ts +0 -31
- package/scripts/csvToJson/csvToJson.ts +0 -90
- package/scripts/csvToJson/users.json +0 -3896
- package/scripts/db.js +0 -27
- package/scripts/db.json +0 -13
- package/scripts/dbMySql.ts +0 -63
- package/scripts/delete_action_steps.ts +0 -11
- package/scripts/delete_user.ts +0 -71
- package/scripts/dev_companies_data.json +0 -613
- package/scripts/enroll.xlsx +0 -0
- package/scripts/export_users.ts +0 -72
- package/scripts/files/visitorManagementFiles/displayScreen.json +0 -70
- package/scripts/files/visitorManagementFiles/init_report_visibility.ts +0 -79
- package/scripts/firebaseConfig.js +0 -12
- package/scripts/firebaseDocs/deleteIncommingCollection.ts +0 -47
- package/scripts/firebaseDocs/updateDoc.ts +0 -43
- package/scripts/getActionDataIntoJSON/getActionData.ts +0 -68
- package/scripts/get_attendance_by_any_date.ts +0 -14
- package/scripts/get_attendance_by_month.ts +0 -12
- package/scripts/get_attendance_monthly_by_team.ts +0 -11
- package/scripts/get_daily_report.ts +0 -10
- package/scripts/get_mangers.ts +0 -13
- package/scripts/grant_user_license.ts +0 -18
- package/scripts/init_CustomCollection.ts +0 -16
- package/scripts/init_action_steps.ts +0 -28
- package/scripts/init_actions.ts +0 -31
- package/scripts/init_company.ts +0 -18
- package/scripts/init_customer_mysql.ts +0 -12
- package/scripts/init_feed.ts +0 -4
- package/scripts/init_feed_details_screen.ts +0 -14
- package/scripts/init_geofence.ts +0 -26
- package/scripts/init_print_details_screen.ts +0 -14
- package/scripts/init_report_actions.ts +0 -24
- package/scripts/init_report_definition_detail.ts +0 -26
- package/scripts/init_report_definition_summary.ts +0 -16
- package/scripts/init_report_visibility.ts +0 -46
- package/scripts/init_user_customcollection.ts +0 -16
- package/scripts/json/action.json +0 -21
- package/scripts/json/company.json +0 -24
- package/scripts/json/report-action.json +0 -13
- package/scripts/json/report-def-deet.json +0 -43
- package/scripts/json/resp.json +0 -784
- package/scripts/json/steps.json +0 -24
- package/scripts/json/test.ts +0 -49
- package/scripts/mysqlConfig.ts +0 -9
- package/scripts/revoke_or_extend_license.ts +0 -14
- package/scripts/stream.js +0 -4
- package/scripts/testing1.ts +0 -35
- package/scripts/update/doc.json +0 -20
- package/scripts/update/getDocByPath.ts +0 -34
- package/scripts/update/updateDocByPath.ts +0 -47
- package/scripts/update/updateUsersOfCompanies.ts +0 -58
- package/scripts/update_actions.ts +0 -19
- package/scripts/update_actions_steps.ts +0 -19
- package/scripts/update_company.ts +0 -19
- package/scripts/update_geofence.ts +0 -20
- package/scripts/update_managers.ts +0 -16
- package/scripts/visitorMgmt/createArea.ts +0 -68
- package/scripts/visitorMgmt/createArea.txt +0 -3
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +0 -130
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +0 -18
- package/scripts/visitorMgmt/encryptDateString.ts +0 -71
- package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +0 -117
- package/scripts/whatsapp_gupshup/sendMessage.ts +0 -97
- package/src/models/Feed-Details-Screen.model.ts +0 -29
- package/src/models/action.model.ts +0 -355
- package/src/models/actions/doffing.ts +0 -71
- package/src/models/actions/folding.ts +0 -39
- package/src/models/attendance.model.ts +0 -615
- package/src/models/cicoPost.model.ts +0 -20
- package/src/models/company.model.ts +0 -975
- package/src/models/contact-us/resquest.model.ts +0 -87
- package/src/models/crud/crud.ts +0 -30
- package/src/models/customCollection.model.ts +0 -47
- package/src/models/customer/customer.model.ts +0 -85
- package/src/models/deviceChangeReq.ts +0 -150
- package/src/models/dispatch.model.ts +0 -99
- package/src/models/feed.models.ts +0 -104
- package/src/models/geofence.model.ts +0 -61
- package/src/models/leaveApplicationPost.model.ts +0 -79
- package/src/models/license.model.ts +0 -215
- package/src/models/meeting.model.ts +0 -80
- package/src/models/meter.model.ts +0 -62
- package/src/models/missingPunchPost.model.ts +0 -84
- package/src/models/offline.model.ts +0 -1133
- package/src/models/post.model.ts +0 -105
- package/src/models/printDetailsScreen.model.ts +0 -30
- package/src/models/pushNotifications/pushNotification.model.ts +0 -17
- package/src/models/report-actions.model.ts +0 -57
- package/src/models/report-definition-details.model.ts +0 -89
- package/src/models/report-definition.model.ts +0 -26
- package/src/models/report-definitions-summary.model.ts +0 -59
- package/src/models/report-detail-data.model.ts +0 -49
- package/src/models/report-visibility.model.ts +0 -44
- package/src/models/report.model.ts +0 -179
- package/src/models/reportGenerator.model.ts +0 -883
- package/src/models/response.model.ts +0 -31
- package/src/models/steps.factory.model.ts +0 -195
- package/src/models/storeGupShupLog.model.ts +0 -49
- package/src/models/tasks/sub-task-group.model.ts +0 -173
- package/src/models/tasks/tags.model.ts +0 -113
- package/src/models/tasks/task-group.model.ts +0 -172
- package/src/models/tasks/task.model.ts +0 -681
- package/src/models/user.model.ts +0 -319
- package/src/models/utility.model.ts +0 -100
- package/src/models/visitorManagement/acknowledgement.model.ts +0 -71
- package/src/models/visitorManagement/invite.model.ts +0 -406
- package/src/models/visitorManagement/newIn.model.ts +0 -82
- package/src/models/visitorManagement/selfServe.model.ts +0 -58
- package/src/models/worklogPost.model.ts +0 -8
- package/src/services/customer.ts +0 -382
- package/src/services/meeting.ts +0 -123
- package/test/1.ts +0 -13
- package/test/db.js +0 -19
- package/test/firebaseConfig.js +0 -1
- package/tsconfig.json +0 -16
@@ -0,0 +1,272 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.User = void 0;
|
4
|
+
// import * as stream from "getstream";
|
5
|
+
const company_model_1 = require("./company.model");
|
6
|
+
class User {
|
7
|
+
reportingTo = null;
|
8
|
+
managers = [];
|
9
|
+
bio = null;
|
10
|
+
fcmToken = null;
|
11
|
+
email = null;
|
12
|
+
avatarUrl = null;
|
13
|
+
satOff = null;
|
14
|
+
id = "";
|
15
|
+
designation = null;
|
16
|
+
roles = "";
|
17
|
+
roamId = null;
|
18
|
+
birthDate = 0;
|
19
|
+
name = "";
|
20
|
+
hasCheckedIn = false;
|
21
|
+
department = null;
|
22
|
+
empCode = null;
|
23
|
+
phone = "";
|
24
|
+
constructor(reportingTo, managers, bio, fcmToken, email, avatarUrl, satOff, id, designation, roles, roamId, birthdate, name, hasCheckedIn, department, empCode, phone) {
|
25
|
+
this.reportingTo = reportingTo;
|
26
|
+
this.managers = managers;
|
27
|
+
this.bio = bio;
|
28
|
+
this.fcmToken = fcmToken;
|
29
|
+
this.email = email;
|
30
|
+
this.avatarUrl = avatarUrl;
|
31
|
+
this.satOff = satOff;
|
32
|
+
this.id = id;
|
33
|
+
this.designation = designation;
|
34
|
+
this.roles = roles;
|
35
|
+
this.roamId = roamId;
|
36
|
+
this.birthDate = birthdate;
|
37
|
+
this.name = name;
|
38
|
+
this.hasCheckedIn = hasCheckedIn;
|
39
|
+
this.department = department;
|
40
|
+
this.empCode = empCode;
|
41
|
+
this.phone = phone;
|
42
|
+
}
|
43
|
+
// async initByPhone(phone:string) {
|
44
|
+
// var d = await User.getUserDocByPhone(phone);
|
45
|
+
// this.initViaSnapshotDoc(d);
|
46
|
+
// }
|
47
|
+
// initViaSnapshotDoc(doc) {
|
48
|
+
// var _data = doc.data();
|
49
|
+
// this.id = _data.id;
|
50
|
+
// this.phone = _data.phone;
|
51
|
+
// this.companies = _data.companies;
|
52
|
+
// }
|
53
|
+
// static async getUserDocByPhone(phone) {
|
54
|
+
// const coRef = db.collection("Users");
|
55
|
+
// const snapshot = await coRef.where("phone", "==", phone).limit(1).get();
|
56
|
+
// if (snapshot.empty) {
|
57
|
+
// throw "Phone " + phone + " not found";
|
58
|
+
// } else {
|
59
|
+
// var rdoc;
|
60
|
+
// snapshot.forEach((doc) => {
|
61
|
+
// console.log(doc.id, "=>", doc.data());
|
62
|
+
// rdoc = doc;
|
63
|
+
// });
|
64
|
+
// return rdoc;
|
65
|
+
// }
|
66
|
+
// }
|
67
|
+
// async getUserLocation() {
|
68
|
+
// const coRef = db.collection("Users/" + this.id + "/location");
|
69
|
+
// const snapshot = await coRef.limit(10).get();
|
70
|
+
// if (snapshot.empty) {
|
71
|
+
// throw "Location " + this.id + " not found";
|
72
|
+
// } else {
|
73
|
+
// var rdoc;
|
74
|
+
// snapshot.forEach((doc) => {
|
75
|
+
// console.log(doc.id, "=>", doc.data());
|
76
|
+
// rdoc = doc;
|
77
|
+
// });
|
78
|
+
// return rdoc;
|
79
|
+
// }
|
80
|
+
// }
|
81
|
+
static async initUsers(firestore) {
|
82
|
+
let document = firestore.collection("Users").doc();
|
83
|
+
await document.set({
|
84
|
+
id: document.id,
|
85
|
+
});
|
86
|
+
return "success";
|
87
|
+
}
|
88
|
+
static async getUsersListByManger(firestore, nickName) {
|
89
|
+
let companyId = await company_model_1.Company.getCompanyIdbyNickname(firestore, nickName);
|
90
|
+
let snapshot = await firestore
|
91
|
+
.collection("Companies")
|
92
|
+
.doc(companyId)
|
93
|
+
.collection("Users")
|
94
|
+
.get();
|
95
|
+
let map = new Map();
|
96
|
+
for (let element of snapshot.docs) {
|
97
|
+
if (element.data().reportingTo) {
|
98
|
+
for (let data of element.data().reportingTo) {
|
99
|
+
if (map.has(data)) {
|
100
|
+
let newId = map.get(data);
|
101
|
+
newId.push(element.data().id);
|
102
|
+
map.set(data, newId);
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
map.set(data, [element.data().id]);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return map;
|
111
|
+
}
|
112
|
+
static async getUserPhonebyUserId(firestore, userId) {
|
113
|
+
const queryForNumber = await firestore.collection("Users")
|
114
|
+
.where("id", "==", userId)
|
115
|
+
.get();
|
116
|
+
const phoneFetchingDocData = queryForNumber.docs.map((doc) => doc.data());
|
117
|
+
var number = phoneFetchingDocData[0]["phone"];
|
118
|
+
return number;
|
119
|
+
}
|
120
|
+
static async getUserIdByPhone(firestore, phone) {
|
121
|
+
if (phone[0] != "+") {
|
122
|
+
phone = `+${phone}`;
|
123
|
+
}
|
124
|
+
const userInfo = await firestore.collection("Users")
|
125
|
+
.where("phone", "==", phone)
|
126
|
+
.get();
|
127
|
+
let userId = "";
|
128
|
+
userInfo.docs.forEach(info => {
|
129
|
+
userId = info.data().id;
|
130
|
+
});
|
131
|
+
return userId;
|
132
|
+
}
|
133
|
+
static async getUserInfoById(firestore, userId, companyId) {
|
134
|
+
const userInfoDoc = await firestore.collection("Companies")
|
135
|
+
.doc(companyId)
|
136
|
+
.collection("Users")
|
137
|
+
.doc(userId)
|
138
|
+
.get();
|
139
|
+
const userInfo = userInfoDoc.data();
|
140
|
+
return userInfo;
|
141
|
+
}
|
142
|
+
static async getUsersListByCompanyNickName(firestore, nickName) {
|
143
|
+
console.log("Getting users list");
|
144
|
+
const companyId = await company_model_1.Company.getCompanyIdbyNickname(firestore, nickName);
|
145
|
+
const usersList_snapshot = await firestore.collection("Companies")
|
146
|
+
.doc(companyId)
|
147
|
+
.collection("Users")
|
148
|
+
.select("name", "id", "phone")
|
149
|
+
.get();
|
150
|
+
let usersList = [];
|
151
|
+
usersList_snapshot.forEach((doc) => {
|
152
|
+
usersList.push(doc.data());
|
153
|
+
});
|
154
|
+
return usersList;
|
155
|
+
}
|
156
|
+
static async deleteUser(firebase, auth, arrayRemove, nickName, phone) {
|
157
|
+
let userId = await User.getUserIdByPhone(firebase, phone);
|
158
|
+
console.log(phone);
|
159
|
+
let companyId = await company_model_1.Company.getCompanyIdByNickName(firebase, nickName);
|
160
|
+
await firebase.collection("Companies")
|
161
|
+
.doc(companyId)
|
162
|
+
.collection("Users")
|
163
|
+
.doc(userId)
|
164
|
+
.delete();
|
165
|
+
console.log("deleted user doc from company");
|
166
|
+
await firebase.collection("Companies")
|
167
|
+
.doc(companyId)
|
168
|
+
.collection("Report-Visibility")
|
169
|
+
.doc(userId)
|
170
|
+
.delete();
|
171
|
+
console.log("deleted user report visibility");
|
172
|
+
let companyDoc = await firebase.collection("Companies")
|
173
|
+
.doc(companyId)
|
174
|
+
.get();
|
175
|
+
companyDoc.ref.update({
|
176
|
+
users: arrayRemove(userId)
|
177
|
+
});
|
178
|
+
let actionDoc = await firebase.collection("Companies")
|
179
|
+
.doc(companyId)
|
180
|
+
.collection("Actions")
|
181
|
+
.where("users", "array-contains", userId)
|
182
|
+
.get();
|
183
|
+
actionDoc.forEach((doc) => {
|
184
|
+
doc.ref.update({
|
185
|
+
users: arrayRemove(userId)
|
186
|
+
});
|
187
|
+
});
|
188
|
+
let userLicenseDoc = await firebase.collection("Licenses")
|
189
|
+
.where("user", "==", phone)
|
190
|
+
.get();
|
191
|
+
if (!userLicenseDoc.empty) {
|
192
|
+
userLicenseDoc.forEach((doc) => {
|
193
|
+
doc.ref.delete();
|
194
|
+
});
|
195
|
+
}
|
196
|
+
await firebase.collection("Feeds")
|
197
|
+
.doc(userId)
|
198
|
+
.delete();
|
199
|
+
// await firebase.collection("Feeds").doc(userId).delete()
|
200
|
+
await auth.deleteUser(userId);
|
201
|
+
await firebase.collection("Users").doc(userId).delete();
|
202
|
+
return `${userId} Deleted successfully`;
|
203
|
+
}
|
204
|
+
static async getApps(firestore, phone, nickName) {
|
205
|
+
const userId = await User.getUserIdByPhone(firestore, phone);
|
206
|
+
const companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, nickName);
|
207
|
+
const userAppsInfo = await firestore.collection("Companies")
|
208
|
+
.doc(companyId)
|
209
|
+
.collection("Actions")
|
210
|
+
.where("actionType", "==", "activitySelector")
|
211
|
+
.where("users", "array-contains", userId)
|
212
|
+
.get();
|
213
|
+
const userApps = userAppsInfo.docs.map((doc) => {
|
214
|
+
const app = doc.data();
|
215
|
+
return {
|
216
|
+
id: app.id,
|
217
|
+
name: app.name,
|
218
|
+
displayName: app.displayName,
|
219
|
+
icon: app.icon
|
220
|
+
};
|
221
|
+
});
|
222
|
+
return userApps;
|
223
|
+
}
|
224
|
+
static async getActionsByUserApp(firestore, phone, nickName, actionId) {
|
225
|
+
const companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, nickName);
|
226
|
+
const actionList = await firestore.collection("Companies")
|
227
|
+
.doc(companyId)
|
228
|
+
.collection("Report-Actions")
|
229
|
+
.where("activityFor", "==", actionId)
|
230
|
+
.get();
|
231
|
+
const actionIdsList = actionList.docs.map((doc) => {
|
232
|
+
return doc.id;
|
233
|
+
});
|
234
|
+
const userId = await User.getUserIdByPhone(firestore, phone);
|
235
|
+
const actionsInfo = await firestore.collection("Companies")
|
236
|
+
.doc(companyId)
|
237
|
+
.collection("Actions")
|
238
|
+
.where("id", "in", actionIdsList)
|
239
|
+
.where("users", "array-contains", userId)
|
240
|
+
.get();
|
241
|
+
const actions = actionsInfo.docs.map((doc) => {
|
242
|
+
const actionInfo = doc.data();
|
243
|
+
return {
|
244
|
+
name: actionInfo.name,
|
245
|
+
displayName: actionInfo.displayName,
|
246
|
+
icon: actionInfo.icon,
|
247
|
+
id: actionInfo.id
|
248
|
+
};
|
249
|
+
});
|
250
|
+
console.log(actions);
|
251
|
+
return actions;
|
252
|
+
}
|
253
|
+
static async getHostsPhoneList(firestore, companyId) {
|
254
|
+
try {
|
255
|
+
const hostsList = await firestore.collection("Companies")
|
256
|
+
.doc(companyId)
|
257
|
+
.collection("Users")
|
258
|
+
.where("roles", "array-contains", "host")
|
259
|
+
.get();
|
260
|
+
const hostPhoneList = hostsList.docs.map((hostDoc) => {
|
261
|
+
console.log(hostDoc.data());
|
262
|
+
return hostDoc.data().phone;
|
263
|
+
});
|
264
|
+
return hostPhoneList;
|
265
|
+
}
|
266
|
+
catch (error) {
|
267
|
+
console.log(error);
|
268
|
+
return [];
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
exports.User = User;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
declare class Utilities {
|
2
|
+
static formatTimeTo12hr(epochTime: number): string;
|
3
|
+
static padWithZero(str: string): string;
|
4
|
+
static getTimeFromEpoch(time: number): Promise<string>;
|
5
|
+
static dateFromEpochTime(epochTime: number): string;
|
6
|
+
static epochToMySqlDateTime(epochTime: number): Promise<string>;
|
7
|
+
static readLineAsync(msg: string, readLineInterface: any): Promise<unknown>;
|
8
|
+
static readLineClose(readLineInterface: any): void;
|
9
|
+
static hold(readline: any): Promise<void>;
|
10
|
+
static encryptAString(secretText: string): Promise<string>;
|
11
|
+
static decryptEncryptedStr(encryptedString: string): Promise<string>;
|
12
|
+
}
|
13
|
+
export { Utilities };
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Utilities = void 0;
|
4
|
+
const crypto_1 = require("crypto");
|
5
|
+
class Utilities {
|
6
|
+
static formatTimeTo12hr(epochTime) {
|
7
|
+
const dateObj = new Date(epochTime);
|
8
|
+
let hrs = dateObj.getHours();
|
9
|
+
const amOrPm = hrs >= 12 ? "pm" : "am";
|
10
|
+
hrs = (hrs % 12) || 12;
|
11
|
+
const formattedTime = `${this.padWithZero(String(hrs))}:${this.padWithZero(String(dateObj.getMinutes()))} ${amOrPm}`;
|
12
|
+
return formattedTime;
|
13
|
+
}
|
14
|
+
static padWithZero(str) {
|
15
|
+
return str.padStart(2, "0");
|
16
|
+
}
|
17
|
+
static async getTimeFromEpoch(time) {
|
18
|
+
return new Date(time).toLocaleTimeString("en-GB", { timeZone: "asia/kolkata", hour: '2-digit', minute: '2-digit', hourCycle: "h12" });
|
19
|
+
}
|
20
|
+
static dateFromEpochTime(epochTime) {
|
21
|
+
const dateObj = new Date(epochTime);
|
22
|
+
const date = `${this.padWithZero(String(dateObj.getDate()))}/`;
|
23
|
+
const month = `${this.padWithZero(String(dateObj.getMonth()))}/`;
|
24
|
+
const year = `${dateObj.getFullYear()}`;
|
25
|
+
return date + month + year;
|
26
|
+
}
|
27
|
+
static async epochToMySqlDateTime(epochTime) {
|
28
|
+
const date = new Date(epochTime);
|
29
|
+
const dateTimeInfo = date.toISOString().split("T");
|
30
|
+
const result = dateTimeInfo[0] + " " + dateTimeInfo[1].split(".")[0];
|
31
|
+
return result;
|
32
|
+
}
|
33
|
+
static async readLineAsync(msg, readLineInterface) {
|
34
|
+
return new Promise((resolve) => {
|
35
|
+
readLineInterface.question(msg, (userRes) => {
|
36
|
+
resolve(userRes);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
}
|
40
|
+
static readLineClose(readLineInterface) {
|
41
|
+
readLineInterface.close();
|
42
|
+
}
|
43
|
+
static async hold(readline) {
|
44
|
+
const response = await this.readLineAsync("is wait over: ", readline);
|
45
|
+
console.log("response: ", response);
|
46
|
+
if (response.toLowerCase() === "yes") {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
await this.hold(readline);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
static async encryptAString(secretText) {
|
54
|
+
try {
|
55
|
+
// Encryption
|
56
|
+
const algorithm = 'aes-256-cbc';
|
57
|
+
// const key = randomBytes(32);
|
58
|
+
const key = "wearethebestoneswearethebestones"; // Replace with your secret key
|
59
|
+
// const iv = randomBytes(16); // Initialization Vector
|
60
|
+
const iv = "wearethebestones"; // Initialization Vector
|
61
|
+
const cipher = (0, crypto_1.createCipheriv)(algorithm, key, iv);
|
62
|
+
let encryptedString = cipher.update(secretText, 'utf8', 'hex');
|
63
|
+
encryptedString += cipher.final('hex');
|
64
|
+
return encryptedString;
|
65
|
+
}
|
66
|
+
catch (error) {
|
67
|
+
console.log(error.message);
|
68
|
+
throw {
|
69
|
+
message: error.message
|
70
|
+
};
|
71
|
+
}
|
72
|
+
}
|
73
|
+
static async decryptEncryptedStr(encryptedString) {
|
74
|
+
try {
|
75
|
+
const algorithm = 'aes-256-cbc';
|
76
|
+
const key = "wearethebestoneswearethebestones"; // Replace with your secret key
|
77
|
+
// const iv = randomBytes(16); // Initialization Vector
|
78
|
+
const iv = "wearethebestones"; // Initialization Vector
|
79
|
+
// Decryption
|
80
|
+
const decipher = (0, crypto_1.createDecipheriv)(algorithm, key, iv);
|
81
|
+
let decryptedString = decipher.update(encryptedString, 'hex', 'utf8');
|
82
|
+
decryptedString += decipher.final('utf8');
|
83
|
+
return decryptedString;
|
84
|
+
}
|
85
|
+
catch (error) {
|
86
|
+
console.log(error.message);
|
87
|
+
throw {
|
88
|
+
message: error.message
|
89
|
+
};
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
exports.Utilities = Utilities;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Post } from "../post.model";
|
2
|
+
import { Pool } from "mysql2";
|
3
|
+
declare class Acknowledgement extends Post {
|
4
|
+
static setIncomingInfoToAcknowledgement(invitationInfo: any, post: Acknowledgement, toBeUpdatedDoc: any): Promise<Acknowledgement>;
|
5
|
+
static modifyExtraDAtaForAcknowledgement(toBeUpdatedDoc: any): Promise<any>;
|
6
|
+
static updateVisitEntryOnAck(connection: Pool, visitId: string, acknowledgedTime: string, approverPhone: string): Promise<void>;
|
7
|
+
static updateVisitEntryOnCheckout(connection: Pool, visitId: string, checkOutTime: string): Promise<void>;
|
8
|
+
}
|
9
|
+
export { Acknowledgement };
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.Acknowledgement = void 0;
|
7
|
+
const post_model_1 = require("../post.model");
|
8
|
+
const crud_1 = __importDefault(require("../crud/crud"));
|
9
|
+
class Acknowledgement extends post_model_1.Post {
|
10
|
+
static async setIncomingInfoToAcknowledgement(invitationInfo, post, toBeUpdatedDoc) {
|
11
|
+
post.actionEvent = invitationInfo.extra.actionEvent;
|
12
|
+
post.actionId = invitationInfo.extra.actionId;
|
13
|
+
post.actionName = invitationInfo.extra.actionName;
|
14
|
+
post.actionType = invitationInfo.extra.actionType;
|
15
|
+
post.companyId = invitationInfo.extra.companyId;
|
16
|
+
post.createdAt = invitationInfo.extra.createdAt;
|
17
|
+
post.description = "Meeting Completed";
|
18
|
+
post.eventId = invitationInfo.extra.eventId;
|
19
|
+
post.isGeofence = invitationInfo.extra.isGeofence;
|
20
|
+
post.userId = invitationInfo.userId;
|
21
|
+
const newExtraData = await this.modifyExtraDAtaForAcknowledgement(toBeUpdatedDoc);
|
22
|
+
post.extraData = newExtraData;
|
23
|
+
post.time = invitationInfo.extra.time;
|
24
|
+
return post;
|
25
|
+
}
|
26
|
+
static async modifyExtraDAtaForAcknowledgement(toBeUpdatedDoc) {
|
27
|
+
return toBeUpdatedDoc;
|
28
|
+
}
|
29
|
+
static async updateVisitEntryOnAck(connection, visitId, acknowledgedTime, approverPhone) {
|
30
|
+
const crudServicce = new crud_1.default(connection);
|
31
|
+
try {
|
32
|
+
const qryString = `UPDATE visits SET
|
33
|
+
meetingTime = '${acknowledgedTime}',
|
34
|
+
approvedBy = '${approverPhone}'
|
35
|
+
WHERE visitId='${visitId}'`;
|
36
|
+
await crudServicce.query(qryString);
|
37
|
+
}
|
38
|
+
catch (error) {
|
39
|
+
console.log(error.message);
|
40
|
+
throw new Error(error.message);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
static async updateVisitEntryOnCheckout(connection, visitId, checkOutTime) {
|
44
|
+
const crudServicce = new crud_1.default(connection);
|
45
|
+
try {
|
46
|
+
const qryString = `UPDATE visits SET checkOutTime = '${checkOutTime}' WHERE visitId = '${visitId}'`;
|
47
|
+
await crudServicce.query(qryString);
|
48
|
+
}
|
49
|
+
catch (error) {
|
50
|
+
console.log(error.message);
|
51
|
+
throw new Error(error.message);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
exports.Acknowledgement = Acknowledgement;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Post } from "../post.model";
|
2
|
+
import * as admin from "firebase-admin";
|
3
|
+
import { Pool } from "mysql2/typings/mysql/lib/Pool";
|
4
|
+
declare class Invitation extends Post {
|
5
|
+
isProcessed: boolean;
|
6
|
+
static setIncomingInfoToInvitation(firestore: admin.firestore.Firestore, invitationInfo: any, post: Invitation, nickName: string): Promise<any>;
|
7
|
+
static modifyExtraDAtaForInvitation(invitationInfo: any, whomToMeet: string): Promise<{
|
8
|
+
visitorName: any;
|
9
|
+
personToMeet: string;
|
10
|
+
visitorPhoneNumber: any;
|
11
|
+
status: string;
|
12
|
+
acknowledgedTime: null;
|
13
|
+
time: number;
|
14
|
+
date: any;
|
15
|
+
checkInTimeOfVisitor: null;
|
16
|
+
checkInDateOfVisitor: string;
|
17
|
+
checkOutTimeOfVisitor: null;
|
18
|
+
}>;
|
19
|
+
static uploadEntryToMySql(connection: Pool, info: any): Promise<void>;
|
20
|
+
static updateInvitationEntryOnReception(connection: Pool, visitId: string, redId: string, inGateKeeperId: string, checkInTime: string): Promise<void>;
|
21
|
+
static updateInvitationOnApproval(connection: Pool, visitId: string, isApproved: boolean): Promise<void>;
|
22
|
+
static updateInvitationWithCardColor(connection: Pool, visitId: string, cardColor: string): Promise<void>;
|
23
|
+
static updateInvitationWithIdProof(connection: Pool, visitId: string, proofType: string, proofImage: string): Promise<void>;
|
24
|
+
static updateInvitationWithVisitorsLeaving(connection: Pool, visitId: string, outGateKeeperId: string, visitorsLeaving: string): Promise<void>;
|
25
|
+
static updateInvitationWithImage(connection: Pool, visitId: string, imageBase64: string, additionalVisitors: string, assets: string): Promise<void>;
|
26
|
+
static updateInvitationWithApprovedAt(connection: Pool, visitId: string, approvedAt: string): Promise<void>;
|
27
|
+
static fetchHostMeetingsForTheDay(connection: Pool, hostPhone: string, companyId: string): Promise<any>;
|
28
|
+
static checkUserIsExist(connection: Pool, Phone: string, companyId: string): Promise<import("mysql2/typings/mysql/lib/protocol/packets/ResultSetHeader").ResultSetHeader | import("mysql2/typings/mysql/lib/protocol/packets/OkPacket").OkPacket | import("mysql2/typings/mysql/lib/protocol/packets/RowDataPacket").RowDataPacket[]>;
|
29
|
+
static createGatePass(connection: Pool, companyId: string, phone: string, from: string, to: string, name: string, createdBy: string, faceJpg: string): Promise<import("mysql2/typings/mysql/lib/protocol/packets/ResultSetHeader").ResultSetHeader | import("mysql2/typings/mysql/lib/protocol/packets/OkPacket").OkPacket | import("mysql2/typings/mysql/lib/protocol/packets/RowDataPacket").RowDataPacket[]>;
|
30
|
+
static updateUserGatePassData(connection: Pool, id: number, to: string): Promise<import("mysql2/typings/mysql/lib/protocol/packets/ResultSetHeader").ResultSetHeader | import("mysql2/typings/mysql/lib/protocol/packets/OkPacket").OkPacket | import("mysql2/typings/mysql/lib/protocol/packets/RowDataPacket").RowDataPacket[]>;
|
31
|
+
}
|
32
|
+
export { Invitation };
|