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
@@ -1,45 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import { Company } from "../../src/models/company.model";
|
3
|
-
import { createInterface } from "readline";
|
4
|
-
|
5
|
-
const firestore = admin.firestore();
|
6
|
-
|
7
|
-
const readline = createInterface({
|
8
|
-
input: process.stdin,
|
9
|
-
output: process.stdout,
|
10
|
-
});
|
11
|
-
|
12
|
-
const readLineAsync: any = (msg: string) => {
|
13
|
-
return new Promise((resolve) => {
|
14
|
-
readline.question(msg, (userRes: string) => {
|
15
|
-
resolve(userRes);
|
16
|
-
});
|
17
|
-
});
|
18
|
-
};
|
19
|
-
async function deleteIncommingDoc(firestore) {
|
20
|
-
const nickName: string = await readLineAsync("Enter company nickName: ");
|
21
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
22
|
-
if (!companyId) {
|
23
|
-
throw {
|
24
|
-
message: "invalid company nickname."
|
25
|
-
}
|
26
|
-
}
|
27
|
-
console.log("companyId =>", companyId)
|
28
|
-
|
29
|
-
const querySnapshot = await firestore.collection("Companies").doc(companyId).collection("Users").get();
|
30
|
-
|
31
|
-
querySnapshot.forEach(async (doc) => {
|
32
|
-
try {
|
33
|
-
await firestore.collection("Companies").doc(companyId).collection("Users").doc(doc.id).update({hasCheckedIn:false,checkInTime:null});
|
34
|
-
console.log(`Update Document With Doc Id ===> ${doc.id}.`);
|
35
|
-
} catch (error) {
|
36
|
-
console.error(`Error Updating document with ID ${doc.id}:`, error);
|
37
|
-
}
|
38
|
-
});
|
39
|
-
}
|
40
|
-
|
41
|
-
async function main() {
|
42
|
-
await deleteIncommingDoc(firestore);
|
43
|
-
}
|
44
|
-
|
45
|
-
main();
|
@@ -1,170 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import * as csvToJson from "convert-csv-to-json";
|
3
|
-
import fs from "fs";
|
4
|
-
import { options } from "../argvConfig";
|
5
|
-
|
6
|
-
const designations = {
|
7
|
-
1: {
|
8
|
-
name: "Managing Director",
|
9
|
-
priority: 1
|
10
|
-
},
|
11
|
-
2: {
|
12
|
-
name: "Zonal Manager",
|
13
|
-
priority: 2
|
14
|
-
},
|
15
|
-
3: {
|
16
|
-
name: "Ast. Sales Manager",
|
17
|
-
priority: 3
|
18
|
-
},
|
19
|
-
4: {
|
20
|
-
name: "Sales Officer",
|
21
|
-
priority: 4
|
22
|
-
},
|
23
|
-
9: {
|
24
|
-
name: "Customer Contact",
|
25
|
-
priority: 5
|
26
|
-
},
|
27
|
-
10: {
|
28
|
-
name: "Vice President",
|
29
|
-
priority: 6
|
30
|
-
},
|
31
|
-
11: {
|
32
|
-
name: "Production Manager",
|
33
|
-
priority: 7
|
34
|
-
},
|
35
|
-
12: {
|
36
|
-
name: "Accounts Manager",
|
37
|
-
priority: 8
|
38
|
-
},
|
39
|
-
13: {
|
40
|
-
name: "Dispatch Manager",
|
41
|
-
priority: 9
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
const argv = options.args;
|
46
|
-
const customersFilePath = "/home/atishae/Downloads/1/customer.csv";
|
47
|
-
const usersFilePath = "/home/atishae/Downloads/1/users.csv";
|
48
|
-
const customerContactFilePath = "/home/atishae/Downloads/1/customerContact.csv";
|
49
|
-
const firestore = admin.firestore();
|
50
|
-
const customersArr = csvToJson.fieldDelimiter(",").getJsonFromCsv(customersFilePath);
|
51
|
-
const usersArr = csvToJson.fieldDelimiter(",").getJsonFromCsv(usersFilePath);
|
52
|
-
const linksArr = csvToJson.fieldDelimiter(",").getJsonFromCsv(customerContactFilePath);
|
53
|
-
let count = 0;
|
54
|
-
const filteredUsers: any = [];
|
55
|
-
for (const user of usersArr) {
|
56
|
-
let pushFlag = true;
|
57
|
-
for (const fUser of filteredUsers) {
|
58
|
-
if (fUser.name === user.name) {
|
59
|
-
pushFlag = false;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
if (pushFlag) {
|
63
|
-
filteredUsers.push(user);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
console.log(filteredUsers.length);
|
67
|
-
// customerContacts = customerContacts.reduce((accumulator, currentVal) => {
|
68
|
-
// if (accumulator.hasOwnProperty(currentVal.contactInfoToSave.designation)) {
|
69
|
-
// accumulator[currentVal.contactInfoToSave.designation].push(currentVal)
|
70
|
-
// } else {
|
71
|
-
// accumulator[currentVal.contactInfoToSave.designation] = [ currentVal ]
|
72
|
-
// }
|
73
|
-
// return accumulator;
|
74
|
-
// }, {})
|
75
|
-
|
76
|
-
// const designationDetails = filteredUsers.reduce((accumulator, currentVal) => {
|
77
|
-
// let checkFlag = designations[currentVal.refDesignationId];
|
78
|
-
// if (checkFlag) {
|
79
|
-
// if (accumulator.hasOwnProperty(designations[currentVal.refDesignationId].name)) {
|
80
|
-
// accumulator[designations[currentVal.refDesignationId].name] += 1;
|
81
|
-
// } else {
|
82
|
-
// accumulator[designations[currentVal.refDesignationId].name] = 1;
|
83
|
-
// }
|
84
|
-
// } else {
|
85
|
-
// accumulator.noDesignation += 1;
|
86
|
-
// }
|
87
|
-
// return accumulator;
|
88
|
-
// }, {
|
89
|
-
// noDesignation: 0
|
90
|
-
// })
|
91
|
-
|
92
|
-
const designationWiseContactDetails = filteredUsers.reduce((accumulator, currentVal) => {
|
93
|
-
let checkFlag = designations[currentVal.refDesignationId];
|
94
|
-
if (checkFlag) {
|
95
|
-
if (accumulator.hasOwnProperty(designations[currentVal.refDesignationId].name)) {
|
96
|
-
accumulator[designations[currentVal.refDesignationId].name].push(currentVal);
|
97
|
-
} else {
|
98
|
-
accumulator[designations[currentVal.refDesignationId].name] = [currentVal];
|
99
|
-
}
|
100
|
-
} else {
|
101
|
-
accumulator.noDesignation.push(currentVal);
|
102
|
-
}
|
103
|
-
return accumulator;
|
104
|
-
}, {
|
105
|
-
noDesignation: []
|
106
|
-
})
|
107
|
-
|
108
|
-
let usersList = [
|
109
|
-
...designationWiseContactDetails["Managing Director"],
|
110
|
-
...designationWiseContactDetails["Ast. Sales Manager"],
|
111
|
-
...designationWiseContactDetails["Dispatch Manager"],
|
112
|
-
...designationWiseContactDetails["Sales Officer"],
|
113
|
-
...designationWiseContactDetails["Zonal Manager"],
|
114
|
-
...designationWiseContactDetails["Production Manager"],
|
115
|
-
...designationWiseContactDetails["Vice President"]
|
116
|
-
]
|
117
|
-
usersList = usersList.map(user => {
|
118
|
-
return {
|
119
|
-
...user,
|
120
|
-
name: user.name.trim().replaceAll('"', '')
|
121
|
-
};
|
122
|
-
})
|
123
|
-
const usersInfoToWrite = JSON.stringify(usersList);
|
124
|
-
|
125
|
-
let customerContacts = [
|
126
|
-
...designationWiseContactDetails["noDesignation"],
|
127
|
-
...designationWiseContactDetails["Customer Contact"]
|
128
|
-
]
|
129
|
-
|
130
|
-
|
131
|
-
const contacts: any = []
|
132
|
-
for (let link of linksArr) {
|
133
|
-
for (let user of customerContacts) {
|
134
|
-
const designationId = user.refDesignationId;
|
135
|
-
if (link.refUserId === user.id) {
|
136
|
-
const customerContact = {
|
137
|
-
contactInfoToSave: {
|
138
|
-
contactName: user.name.trim().replaceAll('"', ""),
|
139
|
-
contactNo: user.username,
|
140
|
-
// designation: designationId ? (designations[designationId] ? designations[designationId].name: null): null,
|
141
|
-
alternateContactNo: link.contactNo2
|
142
|
-
},
|
143
|
-
refCustomerId: link.refCustomerId
|
144
|
-
}
|
145
|
-
contacts.push(customerContact);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
let formattedCustomerContacts: any = [];
|
151
|
-
for (let contact of contacts) {
|
152
|
-
for (let customer of customersArr) {
|
153
|
-
if (contact.refCustomerId === customer.id) {
|
154
|
-
contact.customerName = customer.customerName;
|
155
|
-
delete contact.refCustomerId;
|
156
|
-
formattedCustomerContacts.push(contact);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
console.log(formattedCustomerContacts.length);
|
161
|
-
console.log(usersList.length);
|
162
|
-
const customersContactsToWrite = JSON.stringify(formattedCustomerContacts);
|
163
|
-
|
164
|
-
// for (let key of Object.keys(contactDetails)) {
|
165
|
-
// console.log(key, contactDetails[key].length);
|
166
|
-
// }
|
167
|
-
|
168
|
-
const infoToWrite = JSON.stringify(customerContacts);
|
169
|
-
fs.writeFileSync("./usersList.json", usersInfoToWrite, { flag: "w" });
|
170
|
-
fs.writeFileSync("./customerContacts.json", customersContactsToWrite, { flag: "w" })
|
@@ -1,70 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import admin from "../db";
|
3
|
-
import {Company} from '../../src/models/company.model'
|
4
|
-
import * as csvToJson from 'convert-csv-to-json'
|
5
|
-
import { options } from "../argvConfig.js";
|
6
|
-
import { Action } from "../../src/models/action.model";
|
7
|
-
|
8
|
-
// let argv = options.args[0].split(',')
|
9
|
-
let firestore = admin.firestore();
|
10
|
-
let auth = admin.auth()
|
11
|
-
// let arrayUnion = admin.firestore.FieldValue.arrayUnion
|
12
|
-
// let usersList = csvToJson.fieldDelimiter(',').getJsonFromCsv(argv[0]);
|
13
|
-
let oldUserPhone = "+919425006833"
|
14
|
-
let userDetailsInFireStore = await firestore.collection("Companies")
|
15
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
16
|
-
.collection("Users")
|
17
|
-
.where("phone","==",oldUserPhone)
|
18
|
-
.get()
|
19
|
-
|
20
|
-
let newNumber = "+917000447688"
|
21
|
-
let userDetails = userDetailsInFireStore.docs[0].data()
|
22
|
-
let oldUserId = JSON.parse(JSON.stringify(userDetails.id))
|
23
|
-
let newUser = await auth.createUser({ phoneNumber: newNumber });
|
24
|
-
userDetails.id = newUser.uid;
|
25
|
-
userDetails.phone = newNumber
|
26
|
-
await firestore
|
27
|
-
.collection("Users")
|
28
|
-
.doc(newUser.uid)
|
29
|
-
.create({ id: newUser.uid, phone: newNumber });
|
30
|
-
await firestore
|
31
|
-
.collection("Companies")
|
32
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
33
|
-
.collection("Users")
|
34
|
-
.doc(newUser.uid)
|
35
|
-
.create(userDetails);
|
36
|
-
|
37
|
-
|
38
|
-
let actionNameList = ["check_in_out","requestForm","mp","Meeting"]
|
39
|
-
await firestore
|
40
|
-
.collection("Companies")
|
41
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
42
|
-
.update({
|
43
|
-
users: admin.firestore.FieldValue.arrayUnion(newUser.uid)
|
44
|
-
});
|
45
|
-
await firestore
|
46
|
-
.collection("Companies")
|
47
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
48
|
-
.update({
|
49
|
-
users: admin.firestore.FieldValue.arrayRemove(oldUserId)
|
50
|
-
});
|
51
|
-
for(let actionName of actionNameList){
|
52
|
-
let action = await Action.getActionByName(firestore,actionName,"benara")
|
53
|
-
await firestore.collection('Companies').doc("GC5BOfo2Ibma9CJ4NRpM").collection('Actions').doc(action.id).update({
|
54
|
-
users:admin.firestore.FieldValue.arrayUnion(newUser.uid)
|
55
|
-
})
|
56
|
-
await firestore.collection('Companies').doc("GC5BOfo2Ibma9CJ4NRpM").collection('Actions').doc(action.id).update({
|
57
|
-
users:admin.firestore.FieldValue.arrayRemove(oldUserId)
|
58
|
-
})
|
59
|
-
}
|
60
|
-
let license = {
|
61
|
-
company:"benara",
|
62
|
-
device_id:1,
|
63
|
-
from_date:1669919400000,
|
64
|
-
license_type:"employee",
|
65
|
-
nickname:"benara",
|
66
|
-
to_date:2506185000000,
|
67
|
-
user:newNumber
|
68
|
-
}
|
69
|
-
await firestore.collection('Licenses').add(license)
|
70
|
-
console.log(newUser.uid)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import fs from "fs";
|
3
|
-
|
4
|
-
const firestore = admin.firestore();
|
5
|
-
|
6
|
-
const file = fs.readFileSync("/home/atishae/atishae/mobiOffice_web/mobioffice-cli/scripts/benaraScripts/userAreaMap.json", "utf-8");
|
7
|
-
const mapInfo = JSON.parse(file);
|
8
|
-
let count = 0;
|
9
|
-
for (let key of Object.keys(mapInfo)) {
|
10
|
-
let objToSet = {
|
11
|
-
id: mapInfo[key].id,
|
12
|
-
workAreas: mapInfo[key].workAreas
|
13
|
-
}
|
14
|
-
await firestore.collection("CustomCollections")
|
15
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
16
|
-
.collection("Users")
|
17
|
-
.doc(mapInfo[key].id)
|
18
|
-
.set(objToSet);
|
19
|
-
console.log(objToSet);
|
20
|
-
count++;
|
21
|
-
console.log(count);
|
22
|
-
}
|
23
|
-
console.log("done");
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import * as csvToJson from "convert-csv-to-json";
|
3
|
-
import fs from "fs";
|
4
|
-
|
5
|
-
const workAreaFilePath = "/home/atishae/Downloads/1/workarea.csv";
|
6
|
-
const workAreaMapArr = csvToJson.fieldDelimiter(",").getJsonFromCsv(workAreaFilePath);
|
7
|
-
const firestore = admin.firestore();
|
8
|
-
const mapToStore = workAreaMapArr.map((mapObj) => {
|
9
|
-
return {
|
10
|
-
workAreaId: mapObj.id,
|
11
|
-
areaName: mapObj.name
|
12
|
-
}
|
13
|
-
})
|
14
|
-
for (let i = 0; i < mapToStore.length; i++) {
|
15
|
-
let obj = mapToStore[i];
|
16
|
-
const doc = await firestore.collection("CustomCollections")
|
17
|
-
.doc("GsEmZfg6TUO0KMKmnJxq")
|
18
|
-
.collection("WorkAreaMap")
|
19
|
-
.doc()
|
20
|
-
.get();
|
21
|
-
obj.id = doc.id;
|
22
|
-
await doc.ref.set(obj);
|
23
|
-
console.log(obj);
|
24
|
-
}
|
@@ -1,112 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import * as csvToJson from "convert-csv-to-json";
|
3
|
-
import fs from "fs";
|
4
|
-
import { options } from "../argvConfig";
|
5
|
-
import { Company } from "../../src/models/company.model";
|
6
|
-
|
7
|
-
const workAreaFilePath = "/home/atishae/Downloads/1/workarea.csv";
|
8
|
-
const usersFilePath = "/home/atishae/Downloads/1/users.csv";
|
9
|
-
const userWorkAreaMapPath = "/home/atishae/Downloads/1/userworkarea.csv";
|
10
|
-
const firestore = admin.firestore();
|
11
|
-
const previousUsers = await firestore.collection("Companies")
|
12
|
-
.doc("GC5BOfo2Ibma9CJ4NRpM")
|
13
|
-
.collection("Users")
|
14
|
-
.get();
|
15
|
-
|
16
|
-
// const previousUsers = await Company.getUsersListbyCompany(firestore, "benara");
|
17
|
-
const addedUsers: any = []
|
18
|
-
previousUsers.forEach((doc) => {
|
19
|
-
addedUsers.push(doc.data());
|
20
|
-
})
|
21
|
-
|
22
|
-
const workAreaArr = csvToJson.fieldDelimiter(",").getJsonFromCsv(workAreaFilePath);
|
23
|
-
const wholeUsers = csvToJson.fieldDelimiter(",").getJsonFromCsv(usersFilePath);
|
24
|
-
console.log(wholeUsers.length);
|
25
|
-
const filteredUsers = await filterOutDuplicateUsersData(wholeUsers);
|
26
|
-
console.log(filteredUsers.length);
|
27
|
-
const userWorkAreaMap = csvToJson.fieldDelimiter(",").getJsonFromCsv(userWorkAreaMapPath);
|
28
|
-
const userWorkAreaMapWithName = await addAreaNameToWorkAreaMap(userWorkAreaMap, workAreaArr);
|
29
|
-
const usersWithWorkArea = await getUsersWithWorkingArea(filteredUsers, userWorkAreaMapWithName);
|
30
|
-
const usersWorkAreasFormatted = await filterOutMapObj(usersWithWorkArea, addedUsers);
|
31
|
-
// const userWorkAreaNameMap = await replaceAreaIdWithNames(usersWorkAreasFormatted, workAreaFilePath);
|
32
|
-
const infoToWrite = JSON.stringify(usersWorkAreasFormatted);
|
33
|
-
fs.writeFileSync("./userAreaMap.json", infoToWrite, {flag: "w"});
|
34
|
-
|
35
|
-
|
36
|
-
async function filterOutDuplicateUsersData(usersArr) {
|
37
|
-
const filteredUsers: any = [];
|
38
|
-
for (let user of usersArr) {
|
39
|
-
let pushFlag = true;
|
40
|
-
for (let userD of filteredUsers) {
|
41
|
-
if (user.name === userD.name) {
|
42
|
-
pushFlag = false;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
if (pushFlag) {
|
46
|
-
filteredUsers.push(user);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
return filteredUsers;
|
50
|
-
}
|
51
|
-
|
52
|
-
async function addAreaNameToWorkAreaMap(userWorkAreaMap, workAreaArr) {
|
53
|
-
let result: any = [];
|
54
|
-
for (let obj of userWorkAreaMap) {
|
55
|
-
for (let obj1 of workAreaArr) {
|
56
|
-
if (obj1.id === obj.workAreaId) {
|
57
|
-
obj.workAreaName = obj1.name;
|
58
|
-
result.push(obj);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
return result;
|
63
|
-
}
|
64
|
-
|
65
|
-
async function getUsersWithWorkingArea(filteredUsers, userWorkAreaMapWithName) {
|
66
|
-
const userWorkAreaArr: any = [];
|
67
|
-
for (let user of filteredUsers) {
|
68
|
-
for (let mapObj of userWorkAreaMapWithName) {
|
69
|
-
if (user.id === mapObj.userId) {
|
70
|
-
userWorkAreaArr.push({
|
71
|
-
userName: user.name,
|
72
|
-
workAreaName: mapObj.workAreaName
|
73
|
-
})
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
console.log(userWorkAreaArr.length);
|
78
|
-
return userWorkAreaArr;
|
79
|
-
}
|
80
|
-
|
81
|
-
async function filterOutMapObj(usersWithWorkArea, addedUsers) {
|
82
|
-
const result = addedUsers.reduce((accumulator, user) => {
|
83
|
-
if (!accumulator.hasOwnProperty(user.name)) {
|
84
|
-
accumulator[user.name] = {
|
85
|
-
id: user.id,
|
86
|
-
workAreas: []
|
87
|
-
};
|
88
|
-
}
|
89
|
-
return accumulator;
|
90
|
-
}, {})
|
91
|
-
for (let mapObj of usersWithWorkArea) {
|
92
|
-
for (let user of addedUsers) {
|
93
|
-
if (user.name === mapObj.userName) {
|
94
|
-
result[user.name].workAreas.push(mapObj.workAreaName);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
return result;
|
99
|
-
}
|
100
|
-
|
101
|
-
// async function replaceAreaIdWithNames(usersWorkAreasFormatted, workAreaArr) {
|
102
|
-
// const result: any = [];
|
103
|
-
// for (let key of Object.keys(usersWorkAreasFormatted)){
|
104
|
-
// for (let id of usersWorkAreasFormatted[key].workArea) {
|
105
|
-
// for (let obj of workAreaArr) {
|
106
|
-
// if (workAreaArr.id === id) {
|
107
|
-
// result.push()
|
108
|
-
// }
|
109
|
-
// }
|
110
|
-
// }
|
111
|
-
// }
|
112
|
-
// }
|