mobioffice-cli 1.0.0 → 1.0.1
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
package/scripts/json/steps.json
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"submitUrl": "",
|
4
|
-
"nickname": "test",
|
5
|
-
"actionname": "in",
|
6
|
-
"field": {
|
7
|
-
"isRequired": true,
|
8
|
-
"keyForAPI": "proofImage",
|
9
|
-
"hint": "",
|
10
|
-
"label": "ID Photo",
|
11
|
-
"id": "",
|
12
|
-
"value": ""
|
13
|
-
},
|
14
|
-
"id": "RE611nQYHiRiMmvMmoEX",
|
15
|
-
"label": "ID Photo",
|
16
|
-
"type": "normal",
|
17
|
-
"nextRole": "",
|
18
|
-
"nextCollection": "",
|
19
|
-
"value": "",
|
20
|
-
"fieldType": "Selfie",
|
21
|
-
"buttonActionText": "Next",
|
22
|
-
"order": 5
|
23
|
-
}
|
24
|
-
]
|
package/scripts/json/test.ts
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import { options } from "../argvConfig";
|
3
|
-
import { Company } from "../../src/models/company.model";
|
4
|
-
import { User } from "../../src/models/user.model";
|
5
|
-
import * as csvToJson from "convert-csv-to-json";
|
6
|
-
|
7
|
-
async function main() {
|
8
|
-
let firestore = admin.firestore();
|
9
|
-
|
10
|
-
const path = "/Companies/85vRmuwXwrDAv4TEP2dn/Actions/yUEEHCUxePHGa7KPpu3T";
|
11
|
-
const doc = await firestore.doc(path).get();
|
12
|
-
|
13
|
-
console.log(doc.data());
|
14
|
-
|
15
|
-
// await firestore.doc("/Companies/GsEmZfg6TUO0KMKmnJxq");
|
16
|
-
// let args = options.args[0].split(",");
|
17
|
-
// let managerPhone = args[0];
|
18
|
-
// let subordinates = args.shift();
|
19
|
-
// console.log("managerPhone => ", managerPhone);
|
20
|
-
// console.log("args => ", args);
|
21
|
-
// const managerId = await User.getUserIdByPhone(firestore, managerPhone);
|
22
|
-
// const companyId = await Company.getCompanyIdByNickName(firestore, "kg");
|
23
|
-
// console.log("companyId => ", companyId);
|
24
|
-
// const doc = await firestore
|
25
|
-
// .doc(`Companies/${companyId}/Users/${managerId}`)
|
26
|
-
// .get();
|
27
|
-
// const managerName = doc.data()["name"];
|
28
|
-
// console.log("managerPhone => ", managerPhone);
|
29
|
-
// console.log("managerName => ", managerName);
|
30
|
-
// console.log("args => ", args);
|
31
|
-
// console.log("managerId => ", managerId);
|
32
|
-
// for (var subordinate of args) {
|
33
|
-
// const subordinateId = await User.getUserIdByPhone(firestore, subordinate);
|
34
|
-
// if (subordinateId != null) {
|
35
|
-
// firestore.doc(`Companies/${companyId}/Users/${subordinateId}`).update({
|
36
|
-
// reportingTo: admin.firestore.FieldValue.arrayUnion(managerId),
|
37
|
-
// managers: admin.firestore.FieldValue.arrayUnion(managerName),
|
38
|
-
// });
|
39
|
-
// console.log("added => ", subordinateId);
|
40
|
-
// }
|
41
|
-
// }
|
42
|
-
// console.log("Successfully Completed");
|
43
|
-
|
44
|
-
// let argv = options.args[0].split(",");
|
45
|
-
// let csv_to_Json = csvToJson.fieldDelimiter(",").getJsonFromCsv(argv[0]);
|
46
|
-
// console.log(csv_to_Json);
|
47
|
-
}
|
48
|
-
|
49
|
-
main();
|
package/scripts/mysqlConfig.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import admin from "./db.js";
|
2
|
-
import * as csvToJson from 'convert-csv-to-json'
|
3
|
-
import { License } from '../src/models/license.model';
|
4
|
-
import { options } from "./argvConfig.js";
|
5
|
-
|
6
|
-
let argv = options.args[0].split(',')
|
7
|
-
let extendeddetails = csvToJson.fieldDelimiter(',').getJsonFromCsv(argv[0]);
|
8
|
-
for(let element of extendeddetails){
|
9
|
-
let nickName:string = element.nickname
|
10
|
-
delete element.nickname
|
11
|
-
console.log(element)
|
12
|
-
let status = await License.extendLicense(admin.firestore(),nickName,element)
|
13
|
-
console.log(status)
|
14
|
-
}
|
package/scripts/stream.js
DELETED
package/scripts/testing1.ts
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
import admin from "./db";
|
2
|
-
|
3
|
-
async function main() {
|
4
|
-
const firestore = admin.firestore();
|
5
|
-
|
6
|
-
const userDoc = await firestore
|
7
|
-
.collection("Companies/Yhcat7d3X62NJBIu1Tek/Users")
|
8
|
-
.where("roles", "array-contains", "host")
|
9
|
-
.get();
|
10
|
-
|
11
|
-
const userData = userDoc.docs.map((doc) => doc.data());
|
12
|
-
|
13
|
-
const allIds = [];
|
14
|
-
|
15
|
-
for (var user of userData) {
|
16
|
-
allIds.push(user.id);
|
17
|
-
const gate_i_doc = firestore
|
18
|
-
.collection("Companies/Yhcat7d3X62NJBIu1Tek/Gate-Instructions")
|
19
|
-
.doc();
|
20
|
-
const gateInstruction = {
|
21
|
-
hostId: user.id,
|
22
|
-
nextStop: "",
|
23
|
-
nextStopType: "HOST",
|
24
|
-
qrScannedInArea: "12GVieuFnmaM6Tbpn30D",
|
25
|
-
id: gate_i_doc.id,
|
26
|
-
};
|
27
|
-
|
28
|
-
await gate_i_doc.set({ ...gateInstruction });
|
29
|
-
console.log(`${gate_i_doc.id} added`);
|
30
|
-
}
|
31
|
-
|
32
|
-
console.log({ message: "Done" });
|
33
|
-
}
|
34
|
-
|
35
|
-
main();
|
package/scripts/update/doc.json
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"require_selfie": false,
|
3
|
-
"isFaceDetected": false,
|
4
|
-
"startCollectionName": "team_attendance_report_steps",
|
5
|
-
"displayName": "Team Attendance Report",
|
6
|
-
"icon": "https://firebasestorage.googleapis.com/v0/b/mobioffice-dev.appspot.com/o/action_icon%2Fsummary.svg?alt=media&token=ee904ae8-fd14-400b-8da5-eaae1641dbc1",
|
7
|
-
"isHidden": true,
|
8
|
-
"start_label": "Report",
|
9
|
-
"actionType": "openReport",
|
10
|
-
"companyId": "aJzcmyKI84PyYwiJ0awx",
|
11
|
-
"name": "teamAttendanceReport",
|
12
|
-
"id": "nryKpTFqg65WhHPezX8e",
|
13
|
-
"actionHandlerAPI": "",
|
14
|
-
"forApproval": false,
|
15
|
-
"end_label": "",
|
16
|
-
"require_location": false,
|
17
|
-
"order": 0,
|
18
|
-
"idForReport": "nryKpTFqg65WhHPezX8e",
|
19
|
-
"users": []
|
20
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { options } from "../argvConfig";
|
2
|
-
import admin from "../db";
|
3
|
-
import fs from "fs";
|
4
|
-
|
5
|
-
const firestore = admin.firestore();
|
6
|
-
const argv = options.args;
|
7
|
-
getDocByPath(firestore, argv);
|
8
|
-
|
9
|
-
async function getDocByPath(firestore, argv) {
|
10
|
-
if (argv) {
|
11
|
-
// Path will be in this format
|
12
|
-
// collection/document/collection/document/id
|
13
|
-
const docPath = await getPathOfDoc(argv);
|
14
|
-
const doc_snapshot = await firestore.doc(docPath)
|
15
|
-
.get();
|
16
|
-
// console.log(doc_snapshot.data());
|
17
|
-
const dataToWrite = JSON.stringify(doc_snapshot.data());
|
18
|
-
await createJsonFile(dataToWrite);
|
19
|
-
console.log("Created the file");
|
20
|
-
} else {
|
21
|
-
console.log("Please provide a path for doc.")
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
async function createJsonFile(docInfo) {
|
27
|
-
fs.writeFileSync("./doc.json", docInfo, { flag: "w" })
|
28
|
-
}
|
29
|
-
|
30
|
-
async function getPathOfDoc(argv) {
|
31
|
-
return argv[0];
|
32
|
-
}
|
33
|
-
|
34
|
-
// Companies/GsEmZfg6TUO0KMKmnJxq/Users/89fIU1YkT5U8mOZAuzsXnRYCcoV2
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import { options } from "../argvConfig";
|
2
|
-
import admin from "../db";
|
3
|
-
import fs from "fs";
|
4
|
-
|
5
|
-
const firestore = admin.firestore();
|
6
|
-
const argv = options.args;
|
7
|
-
await updateDocByPath(firestore, argv);
|
8
|
-
|
9
|
-
async function updateDocByPath(firestore, argv) {
|
10
|
-
try {
|
11
|
-
if (argv) {
|
12
|
-
const docPath = await getPathOfDoc(argv);
|
13
|
-
const updatedDocPath = await getPathForUpdatedDoc(argv);
|
14
|
-
const updatedDocInfo = await getUpdatedInfoDoc(updatedDocPath);
|
15
|
-
console.log(updatedDocInfo);
|
16
|
-
await firestore.doc(docPath)
|
17
|
-
.set(updatedDocInfo)
|
18
|
-
console.log("Successfully updated the document");
|
19
|
-
} else {
|
20
|
-
console.log("Please provide a path for doc");
|
21
|
-
}
|
22
|
-
} catch (error: any) {
|
23
|
-
console.log(error.message);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
async function getPathOfDoc(argv) {
|
28
|
-
return argv[0];
|
29
|
-
}
|
30
|
-
|
31
|
-
async function getPathForUpdatedDoc(argv) {
|
32
|
-
if (argv[1]) {
|
33
|
-
return argv[1]
|
34
|
-
} else {
|
35
|
-
throw new Error("Please provide updated file docPath");
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
async function getUpdatedInfoDoc(filePath: string) {
|
40
|
-
if (filePath) {
|
41
|
-
const file = fs.readFileSync(filePath, "utf-8");
|
42
|
-
const updatedDoc = JSON.parse(file);
|
43
|
-
return updatedDoc;
|
44
|
-
} else {
|
45
|
-
throw new Error("Please provide valid file path");
|
46
|
-
}
|
47
|
-
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { createInterface } from "readline";
|
2
|
-
import { Utilities } from "../../src/models/utility.model";
|
3
|
-
import admin from "../db";
|
4
|
-
import { Company } from "../../src/models/company.model";
|
5
|
-
|
6
|
-
const readLine = Utilities.readLineAsync;
|
7
|
-
const readLineClose = Utilities.readLineClose;
|
8
|
-
const readLineInterface = createInterface({
|
9
|
-
input: process.stdin,
|
10
|
-
output: process.stdout
|
11
|
-
})
|
12
|
-
|
13
|
-
async function updateUsersOfCompanies() {
|
14
|
-
try {
|
15
|
-
const firestore = admin.firestore();
|
16
|
-
const companies: any = await readLine("Provide the CSVs of company nicknames of target companies: ", readLineInterface);
|
17
|
-
if(!companies) {
|
18
|
-
throw {
|
19
|
-
message: "Please provied Company nicknames."
|
20
|
-
}
|
21
|
-
}
|
22
|
-
const companiesArr = companies.split(",").map((nickName) => nickName.trim());
|
23
|
-
console.log(companiesArr);
|
24
|
-
const newInfo = {
|
25
|
-
key: "internalRoles",
|
26
|
-
values: []
|
27
|
-
}
|
28
|
-
for (let nickname of companiesArr) {
|
29
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickname);
|
30
|
-
const usersDocsList = await firestore.collection("Companies").doc(companyId).collection("Users").get();
|
31
|
-
if (usersDocsList.empty) {
|
32
|
-
throw {
|
33
|
-
message: `${nickname} has some error or there are no users`
|
34
|
-
}
|
35
|
-
}
|
36
|
-
const usersList = usersDocsList.docs.map((userDoc) => userDoc.data());
|
37
|
-
for (let user of usersList) {
|
38
|
-
const newUserInfo = {
|
39
|
-
...user
|
40
|
-
}
|
41
|
-
newInfo.values = user.roles;
|
42
|
-
newUserInfo[newInfo.key] = newInfo.values;
|
43
|
-
console.log(newUserInfo);
|
44
|
-
await firestore.collection("Companies").doc(companyId).collection("Users").doc(user.id).set(newUserInfo);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
readLineClose(readLineInterface);
|
48
|
-
} catch (error) {
|
49
|
-
readLineClose(readLineInterface);
|
50
|
-
console.log(error.message);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
async function main() {
|
55
|
-
await updateUsersOfCompanies();
|
56
|
-
}
|
57
|
-
|
58
|
-
main();
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import admin from "./db.js";
|
2
|
-
import { options } from "./argvConfig.js";
|
3
|
-
import { Action } from "../src/models/action.model.js";
|
4
|
-
import fs from "fs";
|
5
|
-
|
6
|
-
let argv = options.args;
|
7
|
-
let firestore = admin.firestore();
|
8
|
-
let arrayUnion = admin.firestore.FieldValue.arrayUnion
|
9
|
-
|
10
|
-
let nickNames = argv[0].split(",");
|
11
|
-
let actionName = argv[1];
|
12
|
-
const companyActionsInfo = fs.readFileSync(argv[2], "utf-8");
|
13
|
-
console.log(companyActionsInfo);
|
14
|
-
const companyActionsArr = await JSON.parse(companyActionsInfo);
|
15
|
-
for(let nickName of nickNames) {
|
16
|
-
console.log(nickName);
|
17
|
-
let status = await Action.updateActions(firestore,arrayUnion,nickName,actionName,companyActionsArr[0])
|
18
|
-
console.log(status);
|
19
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import admin from "./db.js";
|
2
|
-
import { options } from "./argvConfig.js";
|
3
|
-
import { Action } from "../src/models/action.model.js";
|
4
|
-
import fs from "fs";
|
5
|
-
|
6
|
-
let firestore = admin.firestore()
|
7
|
-
const actionStepsInfo = fs.readFileSync(options.args[0], "utf-8");
|
8
|
-
const actionStepsArr = await JSON.parse(actionStepsInfo);
|
9
|
-
|
10
|
-
for(let steps of actionStepsArr){
|
11
|
-
let nickName = steps.nickname
|
12
|
-
let actionName = steps.actionname
|
13
|
-
delete steps.actionname
|
14
|
-
delete steps.nickname
|
15
|
-
let actionStepsId = await Action.updateActionsStep(firestore,nickName,actionName,steps);
|
16
|
-
console.log(`${actionStepsId} updated successfully`)
|
17
|
-
}
|
18
|
-
|
19
|
-
console.log('added')
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { Company } from "../src/models/company.model";
|
2
|
-
import admin from "./db.js";
|
3
|
-
import { options } from "./argvConfig.js";
|
4
|
-
import fs from "fs";
|
5
|
-
|
6
|
-
let firestore = admin.firestore();
|
7
|
-
// let arrayUnion = admin.firestore.FieldValue.arrayUnion
|
8
|
-
// let jsonList = csvToJson.fieldDelimiter(',').getJsonFromCsv(argv[0]);
|
9
|
-
const companyActionsInfo = fs.readFileSync(options.args[0], "utf-8");
|
10
|
-
const companyActionsArr = await JSON.parse(companyActionsInfo);
|
11
|
-
console.log(companyActionsArr)
|
12
|
-
|
13
|
-
for(let companyDoc of companyActionsArr){
|
14
|
-
let nickName = companyDoc.nickname
|
15
|
-
delete companyDoc.nickname
|
16
|
-
let status = await Company.updateCompany(firestore,nickName,companyDoc)
|
17
|
-
console.log(status)
|
18
|
-
}
|
19
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import admin from "./db.js";
|
2
|
-
import { options } from "./argvConfig.js";
|
3
|
-
import { Geofence } from "../src/models/geofence.model.js";
|
4
|
-
import fs from "fs";
|
5
|
-
|
6
|
-
|
7
|
-
let firestore = admin.firestore();
|
8
|
-
let arrayUnion = admin.firestore.FieldValue.arrayUnion
|
9
|
-
let geofencefile = fs.readFileSync(options.args[0], "utf-8")
|
10
|
-
let jsonList = JSON.parse(geofencefile);
|
11
|
-
|
12
|
-
for(let geofenceDoc of jsonList){
|
13
|
-
for(let geofencepoints of geofenceDoc.geoFence){
|
14
|
-
let temp = new admin.firestore.GeoPoint(geofencepoints.geoPoint[0],geofencepoints.geoPoint[1])
|
15
|
-
geofencepoints.geoPoint = temp
|
16
|
-
}
|
17
|
-
// console.log(geofenceDoc.geoFence)
|
18
|
-
let status = await Geofence.updateGeofence(firestore,arrayUnion,geofenceDoc)
|
19
|
-
console.log(status)
|
20
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { Company } from "../src/models/company.model";
|
2
|
-
import admin from "./db.js";
|
3
|
-
import { options } from "./argvConfig.js";
|
4
|
-
import fs from "fs";
|
5
|
-
|
6
|
-
let firestore = admin.firestore();
|
7
|
-
let arrayUnion = admin.firestore.FieldValue.arrayUnion
|
8
|
-
let nickName = options.args[0]
|
9
|
-
const usersInfo = fs.readFileSync(options.args[1], "utf-8");
|
10
|
-
const usersInfoArr = await JSON.parse(usersInfo);
|
11
|
-
|
12
|
-
for(let user of usersInfoArr){
|
13
|
-
let status = await Company.updateReportingTo(firestore,arrayUnion,nickName,user)
|
14
|
-
console.log(status)
|
15
|
-
}
|
16
|
-
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { createInterface } from "readline";
|
2
|
-
import { Utilities } from "../../src/models/utility.model";
|
3
|
-
import admin from "../db";
|
4
|
-
import { Company } from "../../src/models/company.model";
|
5
|
-
|
6
|
-
const readLine = Utilities.readLineAsync;
|
7
|
-
const readLineClose = Utilities.readLineClose;
|
8
|
-
const readLineInterface = createInterface({
|
9
|
-
input: process.stdin,
|
10
|
-
output: process.stdout
|
11
|
-
})
|
12
|
-
|
13
|
-
interface Area {
|
14
|
-
nickname: string,
|
15
|
-
name: string,
|
16
|
-
entry: boolean,
|
17
|
-
id: string
|
18
|
-
}
|
19
|
-
|
20
|
-
async function createNewArea() {
|
21
|
-
try {
|
22
|
-
const firestore = admin.firestore();
|
23
|
-
const nickname: any = await readLine("Enter Company Nickname: ", readLineInterface);
|
24
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickname);
|
25
|
-
if (!companyId) {
|
26
|
-
throw new Error("Please provide correct company nickname.");
|
27
|
-
}
|
28
|
-
const newArea: Area = {
|
29
|
-
nickname: "",
|
30
|
-
name: "",
|
31
|
-
entry: false,
|
32
|
-
id: ""
|
33
|
-
};
|
34
|
-
console.log("Found company id: ", companyId);
|
35
|
-
const areaRef = firestore.collection("Companies").doc(companyId)
|
36
|
-
.collection("Area").doc();
|
37
|
-
if (!areaRef) {
|
38
|
-
throw new Error("Some error occurred while creating firebase doc");
|
39
|
-
}
|
40
|
-
newArea.id = areaRef.id;
|
41
|
-
const areaName: any = await readLine("Enter Area Name: ", readLineInterface);
|
42
|
-
newArea.name = areaName;
|
43
|
-
const areaNickname: any = await readLine("Enter Area Nickname: ", readLineInterface);
|
44
|
-
newArea.nickname = areaNickname;
|
45
|
-
let isEntryPossible: any = await readLine("Is Entry Possible (Yes/No): ", readLineInterface);
|
46
|
-
isEntryPossible = isEntryPossible.toLowerCase();
|
47
|
-
if (isEntryPossible === "yes") {
|
48
|
-
newArea.entry = true;
|
49
|
-
} else if(isEntryPossible === "no") {
|
50
|
-
newArea.entry = false;
|
51
|
-
} else {
|
52
|
-
throw new Error("Please give a valid response");
|
53
|
-
}
|
54
|
-
const res = await areaRef.set(JSON.parse(JSON.stringify(newArea)));
|
55
|
-
console.log(res);
|
56
|
-
console.log(newArea);
|
57
|
-
readLineClose(readLineInterface);
|
58
|
-
} catch (error) {
|
59
|
-
console.error(error);
|
60
|
-
readLineClose(readLineInterface);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
async function main() {
|
65
|
-
await createNewArea();
|
66
|
-
}
|
67
|
-
|
68
|
-
main();
|
@@ -1,130 +0,0 @@
|
|
1
|
-
import admin from "../db";
|
2
|
-
import { Utilities } from "../../src/models/utility.model";
|
3
|
-
import { createInterface } from "readline";
|
4
|
-
import { Company } from "../../src/models/company.model";
|
5
|
-
import { User } from "../../src/models/user.model";
|
6
|
-
|
7
|
-
const readLine = Utilities.readLineAsync;
|
8
|
-
const readLineClose = Utilities.readLineClose;
|
9
|
-
const readLineInterface = createInterface({
|
10
|
-
input: process.stdin,
|
11
|
-
output: process.stdout
|
12
|
-
});
|
13
|
-
|
14
|
-
interface InstructionObj {
|
15
|
-
hostId: string,
|
16
|
-
id: string,
|
17
|
-
nextStop: string,
|
18
|
-
nextStopType: string,
|
19
|
-
qrScannedInArea: string
|
20
|
-
}
|
21
|
-
|
22
|
-
async function createVisitorPathInstructionDocs () {
|
23
|
-
try {
|
24
|
-
const firestore = admin.firestore();
|
25
|
-
const companyNickname: any = await readLine("Enter company Nickname: ", readLineInterface);
|
26
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, companyNickname);
|
27
|
-
if (!companyId) {
|
28
|
-
throw "Error: Company Not Found!!!";
|
29
|
-
}
|
30
|
-
console.log("Found company: ", companyId);
|
31
|
-
const hostsPhonesCSV: any = await readLine("Enter comma separated 10-digit numbers of hosts: ", readLineInterface)
|
32
|
-
const phonesArr = hostsPhonesCSV.split(",").map((phoneNumber) => {
|
33
|
-
if (phoneNumber.length !== 10) {
|
34
|
-
throw new Error("Looks like a phone number is not having 10-digits");
|
35
|
-
}
|
36
|
-
return "+91" + phoneNumber.trim()
|
37
|
-
});
|
38
|
-
console.log(phonesArr);
|
39
|
-
const hostsIds = await Promise.all(phonesArr.map(async (phone: any) => {
|
40
|
-
const hostId = await User.getUserIdByPhone(firestore, phone);
|
41
|
-
if (!hostId) {
|
42
|
-
throw `Error: ---> (${phone}) Invalid Phone Number.`
|
43
|
-
}
|
44
|
-
console.log("Found User Id: ", hostId);
|
45
|
-
return hostId;
|
46
|
-
}));
|
47
|
-
const visitorInstructionObj: InstructionObj = {
|
48
|
-
hostId: "",
|
49
|
-
id: "",
|
50
|
-
nextStop: "",
|
51
|
-
nextStopType: "",
|
52
|
-
qrScannedInArea: ""
|
53
|
-
}
|
54
|
-
while (true) {
|
55
|
-
let nextStopType: any = await readLine("Please give the nextStopType(HOST/HA): ", readLineInterface);
|
56
|
-
let nextStop = "";
|
57
|
-
nextStopType = nextStopType.toUpperCase();
|
58
|
-
if (nextStopType.toUpperCase() === "HA") {
|
59
|
-
const nextStopNickname = await readLine("Please give next stop nickname: ", readLineInterface);
|
60
|
-
const nextStopDoc = await firestore.collection("Companies")
|
61
|
-
.doc(companyId)
|
62
|
-
.collection("Area")
|
63
|
-
.where("nickname", "==", nextStopNickname)
|
64
|
-
.get();
|
65
|
-
if (nextStopDoc.empty) {
|
66
|
-
throw "Error: ---> Next stop nickname was not valid."
|
67
|
-
}
|
68
|
-
const nextStopId = nextStopDoc.docs[0].data().id;
|
69
|
-
nextStop = nextStopId;
|
70
|
-
} else if (nextStopType.toUpperCase() === "HOST") {
|
71
|
-
nextStop = "";
|
72
|
-
} else {
|
73
|
-
throw "Error: ---> nextStopType was not valid";
|
74
|
-
}
|
75
|
-
visitorInstructionObj.nextStop = nextStop;
|
76
|
-
visitorInstructionObj.nextStopType = nextStopType;
|
77
|
-
const currArea = await readLine("Enter Scanning area nickname: ", readLineInterface);
|
78
|
-
const currAreaDoc = await firestore.collection("Companies")
|
79
|
-
.doc(companyId)
|
80
|
-
.collection("Area")
|
81
|
-
.where("nickname", "==", currArea)
|
82
|
-
.get();
|
83
|
-
const currAreaId = currAreaDoc.docs[0].data().id;
|
84
|
-
if (!currAreaId) {
|
85
|
-
throw "Error: ---> Scanning area nickname was not valid."
|
86
|
-
}
|
87
|
-
visitorInstructionObj.qrScannedInArea = currAreaId;
|
88
|
-
|
89
|
-
for (let id of hostsIds) {
|
90
|
-
const instructionDocRef = firestore.collection("Companies")
|
91
|
-
.doc(companyId)
|
92
|
-
.collection("Gate-Instructions")
|
93
|
-
.doc();
|
94
|
-
visitorInstructionObj.id = instructionDocRef.id;
|
95
|
-
visitorInstructionObj.hostId = id;
|
96
|
-
console.log(visitorInstructionObj);
|
97
|
-
await instructionDocRef.set(visitorInstructionObj)
|
98
|
-
}
|
99
|
-
// await Promise.all(hostsIds.map(async (id) => {
|
100
|
-
// const instructionDocRef = firestore.collection("Companies")
|
101
|
-
// .doc(companyId)
|
102
|
-
// .collection("Gate-Instructions")
|
103
|
-
// .doc();
|
104
|
-
// visitorInstructionObj.id = instructionDocRef.id;
|
105
|
-
// visitorInstructionObj.hostId = id;
|
106
|
-
// console.log(visitorInstructionObj);
|
107
|
-
// await instructionDocRef.set(visitorInstructionObj)
|
108
|
-
// }))
|
109
|
-
if (nextStopType === "HOST") {
|
110
|
-
break;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
// }))
|
114
|
-
readLineClose(readLineInterface);
|
115
|
-
} catch(error) {
|
116
|
-
readLineClose(readLineInterface);
|
117
|
-
console.error(error);
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
async function main() {
|
122
|
-
// try {
|
123
|
-
await createVisitorPathInstructionDocs();
|
124
|
-
// } catch(error) {
|
125
|
-
// readLineClose(readLineInterface);
|
126
|
-
// console.error(error);
|
127
|
-
// }
|
128
|
-
}
|
129
|
-
|
130
|
-
main();
|
@@ -1,18 +0,0 @@
|
|
1
|
-
in ...visitorMgmt$
|
2
|
-
run --> npx tsx createVisitorPathInstructionDocs.ts
|
3
|
-
|
4
|
-
enter comma separated 10-digit phone numbers
|
5
|
-
|
6
|
-
-> host is the last point of a path so program will keep asking
|
7
|
-
the details of nextStop till the nextStopType is not HOST.
|
8
|
-
|
9
|
-
provide nextStopType ---> there are only two nextStopType
|
10
|
-
host and ha(holding area)
|
11
|
-
|
12
|
-
provide nextStop nickname ---> it will be short form of stop nickname
|
13
|
-
(stored in the area doc)
|
14
|
-
|
15
|
-
enter scanning area nickname ---> similar to above step
|
16
|
-
|
17
|
-
if nextStopType was host then the script will stop, or it will again resume
|
18
|
-
asking from nextStopType.
|