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
@@ -0,0 +1,30 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class Request {
|
3
|
+
id: string;
|
4
|
+
message: string;
|
5
|
+
phone: string;
|
6
|
+
firstName: string;
|
7
|
+
lastName: string;
|
8
|
+
email: string;
|
9
|
+
private _sendUpdates;
|
10
|
+
get sendUpdates(): boolean;
|
11
|
+
set sendUpdates(value: boolean);
|
12
|
+
constructor();
|
13
|
+
argConstructor(id: string, message: string, phone: string, firstName: string, lastName: string, email: string, _sendUpdates: boolean): void;
|
14
|
+
fromJSON(request: string): void;
|
15
|
+
toJSON(): {
|
16
|
+
id: string;
|
17
|
+
message: string;
|
18
|
+
phone: string;
|
19
|
+
firstName: string;
|
20
|
+
lastName: string;
|
21
|
+
email: string;
|
22
|
+
sendUpdates: boolean;
|
23
|
+
};
|
24
|
+
save(firestore: admin.firestore.Firestore): Promise<{
|
25
|
+
status: string;
|
26
|
+
message: string;
|
27
|
+
path: string;
|
28
|
+
}>;
|
29
|
+
}
|
30
|
+
export { Request };
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Request = void 0;
|
4
|
+
class Request {
|
5
|
+
id;
|
6
|
+
message;
|
7
|
+
phone;
|
8
|
+
firstName;
|
9
|
+
lastName;
|
10
|
+
email;
|
11
|
+
_sendUpdates;
|
12
|
+
get sendUpdates() {
|
13
|
+
return this._sendUpdates;
|
14
|
+
}
|
15
|
+
set sendUpdates(value) {
|
16
|
+
this._sendUpdates = value;
|
17
|
+
}
|
18
|
+
constructor() { }
|
19
|
+
argConstructor(id, message, phone, firstName, lastName, email, _sendUpdates) {
|
20
|
+
this.id = id;
|
21
|
+
this.message = message;
|
22
|
+
this.phone = phone;
|
23
|
+
this.firstName = firstName;
|
24
|
+
this.lastName = lastName;
|
25
|
+
this.email = email;
|
26
|
+
this._sendUpdates = _sendUpdates;
|
27
|
+
}
|
28
|
+
fromJSON(request) {
|
29
|
+
let requestJSON = JSON.parse(request);
|
30
|
+
this.id = requestJSON["phone"];
|
31
|
+
this.message = requestJSON["message"];
|
32
|
+
this.phone = requestJSON["phone"];
|
33
|
+
this.firstName = requestJSON["firstName"];
|
34
|
+
this.lastName = requestJSON["lastName"];
|
35
|
+
this.email = requestJSON["email"];
|
36
|
+
this._sendUpdates = requestJSON["sendUpdates"];
|
37
|
+
}
|
38
|
+
toJSON() {
|
39
|
+
return {
|
40
|
+
id: this.phone,
|
41
|
+
message: this.message,
|
42
|
+
phone: this.phone,
|
43
|
+
firstName: this.firstName,
|
44
|
+
lastName: this.lastName,
|
45
|
+
email: this.email,
|
46
|
+
sendUpdates: this._sendUpdates
|
47
|
+
};
|
48
|
+
}
|
49
|
+
async save(firestore) {
|
50
|
+
let requestDoc = firestore
|
51
|
+
.collection("Requests")
|
52
|
+
.doc(this.phone.toString());
|
53
|
+
const requestDocInfo = await requestDoc.get();
|
54
|
+
const reqsInfo = requestDocInfo.data();
|
55
|
+
if (reqsInfo) {
|
56
|
+
reqsInfo.requests.push(this.toJSON());
|
57
|
+
await requestDoc.set(reqsInfo);
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
const newRequest = {
|
61
|
+
id: this.phone,
|
62
|
+
requests: [this.toJSON()]
|
63
|
+
};
|
64
|
+
await requestDoc.set(newRequest);
|
65
|
+
}
|
66
|
+
return {
|
67
|
+
status: "OK",
|
68
|
+
message: "Request Added Successfully",
|
69
|
+
path: requestDoc.path,
|
70
|
+
};
|
71
|
+
}
|
72
|
+
}
|
73
|
+
exports.Request = Request;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
class CurdService {
|
4
|
+
pool;
|
5
|
+
constructor(pool) {
|
6
|
+
this.pool = pool;
|
7
|
+
}
|
8
|
+
async query(queryString) {
|
9
|
+
return new Promise((resolve, reject) => {
|
10
|
+
this.pool.getConnection((err, connection) => {
|
11
|
+
if (err) {
|
12
|
+
reject(err);
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
connection.query(queryString, (err, result) => {
|
16
|
+
connection.release();
|
17
|
+
if (err) {
|
18
|
+
reject(err);
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
resolve(result);
|
22
|
+
});
|
23
|
+
});
|
24
|
+
});
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.default = CurdService;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class CustomCollection {
|
3
|
+
id: string;
|
4
|
+
static createCustomCollection(firestore: admin.firestore.Firestore, collectionDetails: any): Promise<void>;
|
5
|
+
static createNewCollection(firestore: admin.firestore.Firestore, collectionDetails: any): Promise<any>;
|
6
|
+
static restructureDetails(collectionDetails: any): Promise<any>;
|
7
|
+
static getUserWorkAreaList(firestore: admin.firestore.Firestore, companyId: string, phone: string): Promise<admin.firestore.DocumentData | undefined>;
|
8
|
+
}
|
9
|
+
export { CustomCollection };
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CustomCollection = void 0;
|
4
|
+
const user_model_1 = require("./user.model");
|
5
|
+
class CustomCollection {
|
6
|
+
id = "";
|
7
|
+
static async createCustomCollection(firestore, collectionDetails) {
|
8
|
+
try {
|
9
|
+
let collection_snapshot = await firestore.collection("customCollection")
|
10
|
+
.get();
|
11
|
+
if (collection_snapshot.empty) {
|
12
|
+
console.log("no collection found: creating one...");
|
13
|
+
await CustomCollection.createNewCollection(firestore, collectionDetails);
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
throw new Error("there is already a collection with this name.");
|
17
|
+
}
|
18
|
+
}
|
19
|
+
catch (error) {
|
20
|
+
console.log(error);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
static async createNewCollection(firestore, collectionDetails) {
|
24
|
+
let restructuredDetails = await CustomCollection.restructureDetails(collectionDetails);
|
25
|
+
let docRef = firestore.collection("CustomCollections").doc();
|
26
|
+
restructuredDetails.id = docRef.id;
|
27
|
+
await docRef.set(restructuredDetails);
|
28
|
+
return restructuredDetails;
|
29
|
+
}
|
30
|
+
static async restructureDetails(collectionDetails) {
|
31
|
+
// for now collectionDetails remain unaltered
|
32
|
+
return collectionDetails;
|
33
|
+
}
|
34
|
+
static async getUserWorkAreaList(firestore, companyId, phone) {
|
35
|
+
let userId = await user_model_1.User.getUserIdByPhone(firestore, phone);
|
36
|
+
let workAreaSnapShot = await firestore.collection("CustomCollections").doc(companyId).collection("Users").doc(userId).get();
|
37
|
+
return workAreaSnapShot.data();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
exports.CustomCollection = CustomCollection;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
declare class Customer {
|
2
|
+
customerName: string;
|
3
|
+
address: string;
|
4
|
+
zipcode: string;
|
5
|
+
city: string;
|
6
|
+
state: string;
|
7
|
+
GSTNo: string;
|
8
|
+
contactName: string;
|
9
|
+
contactNo: string;
|
10
|
+
constructor(customerName: string, address: string, zipcode: string, city: string, state: string, GSTNo: string, contactName: string, contactNo: string);
|
11
|
+
}
|
12
|
+
declare class CustomerContact {
|
13
|
+
customerId: number;
|
14
|
+
contactName: string;
|
15
|
+
contactNo: string;
|
16
|
+
alternateContactNo: string;
|
17
|
+
designation: string;
|
18
|
+
constructor(customerId: number, contactName: string, contactNo: string, alternateContactNo: string, designation: string);
|
19
|
+
}
|
20
|
+
declare class CustomerCard {
|
21
|
+
companyId: string;
|
22
|
+
userId: string;
|
23
|
+
createdAt: string;
|
24
|
+
actionName: string;
|
25
|
+
actionType: string;
|
26
|
+
actionId: string;
|
27
|
+
actionEvent: string;
|
28
|
+
extraData: any;
|
29
|
+
id: string;
|
30
|
+
constructor(companyId: string, userId: string, createdAt: string, actionName: string, actionType: string, actionId: string, actionEvent: string, extraData: any, id: string);
|
31
|
+
}
|
32
|
+
export { Customer, CustomerContact, CustomerCard };
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CustomerCard = exports.CustomerContact = exports.Customer = void 0;
|
4
|
+
class Customer {
|
5
|
+
customerName;
|
6
|
+
address;
|
7
|
+
zipcode;
|
8
|
+
city;
|
9
|
+
state;
|
10
|
+
GSTNo;
|
11
|
+
contactName;
|
12
|
+
contactNo;
|
13
|
+
constructor(customerName, address, zipcode, city, state, GSTNo, contactName, contactNo) {
|
14
|
+
this.customerName = customerName;
|
15
|
+
this.address = address;
|
16
|
+
this.zipcode = zipcode;
|
17
|
+
this.city = city;
|
18
|
+
this.state = state;
|
19
|
+
this.GSTNo = GSTNo;
|
20
|
+
this.contactName = contactName;
|
21
|
+
this.contactNo = contactNo;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
exports.Customer = Customer;
|
25
|
+
class CustomerContact {
|
26
|
+
customerId;
|
27
|
+
contactName;
|
28
|
+
contactNo;
|
29
|
+
alternateContactNo;
|
30
|
+
designation;
|
31
|
+
constructor(customerId, contactName, contactNo, alternateContactNo, designation) {
|
32
|
+
this.customerId = customerId;
|
33
|
+
this.contactName = contactName;
|
34
|
+
this.contactNo = contactNo;
|
35
|
+
this.alternateContactNo = alternateContactNo;
|
36
|
+
this.designation = designation;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
exports.CustomerContact = CustomerContact;
|
40
|
+
class CustomerCard {
|
41
|
+
companyId;
|
42
|
+
userId;
|
43
|
+
createdAt;
|
44
|
+
actionName;
|
45
|
+
actionType;
|
46
|
+
actionId;
|
47
|
+
actionEvent;
|
48
|
+
extraData;
|
49
|
+
id;
|
50
|
+
constructor(companyId, userId, createdAt, actionName, actionType, actionId, actionEvent, extraData, id) {
|
51
|
+
this.companyId = companyId;
|
52
|
+
this.userId = userId;
|
53
|
+
this.createdAt = createdAt;
|
54
|
+
this.actionName = actionName;
|
55
|
+
this.actionType = actionType;
|
56
|
+
this.actionId = actionId;
|
57
|
+
this.actionEvent = actionEvent;
|
58
|
+
this.extraData = extraData;
|
59
|
+
this.id = id;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
exports.CustomerCard = CustomerCard;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class DeviceChangeReq {
|
3
|
+
static checkIsReqPending(firestore: admin.firestore.Firestore, deviceChangeInfo: any, company: string): Promise<boolean>;
|
4
|
+
static fetchOpenReqs(firestore: admin.firestore.Firestore, companyId: string): Promise<admin.firestore.DocumentData[]>;
|
5
|
+
static approve(firestore: admin.firestore.Firestore, approvalDetails: any): Promise<void>;
|
6
|
+
static replaceOldDeviceWithNew(license: any, objToProcess: any): Promise<any>;
|
7
|
+
static getIndexToReplace(extraDevices: any, deviceId: string): Promise<number | "not found">;
|
8
|
+
static updateCompanyActionDoc(firestore: admin.firestore.Firestore, requestId: string, requestStatus: string): Promise<void>;
|
9
|
+
}
|
10
|
+
export { DeviceChangeReq };
|
@@ -0,0 +1,138 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DeviceChangeReq = void 0;
|
4
|
+
const action_model_1 = require("./action.model");
|
5
|
+
const company_model_1 = require("./company.model");
|
6
|
+
class DeviceChangeReq {
|
7
|
+
static async checkIsReqPending(firestore, deviceChangeInfo, company) {
|
8
|
+
const newDeviceId = deviceChangeInfo.extra.extraData.deviceId;
|
9
|
+
const nickName = "mobiOffice";
|
10
|
+
const requestCompanyId = await company_model_1.Company.getCompanyIdByNickName(firestore, company);
|
11
|
+
console.log("requestCompanyId", requestCompanyId);
|
12
|
+
const companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, nickName);
|
13
|
+
const actionName = deviceChangeInfo.actionName;
|
14
|
+
let isReqPending = false;
|
15
|
+
console.log("companyId", companyId, "actionName", actionName);
|
16
|
+
const actionId = await action_model_1.Action.getActionId(firestore, companyId, actionName);
|
17
|
+
console.log(companyId, requestCompanyId);
|
18
|
+
const deviceChangeReqs = await firestore.collection("Companies")
|
19
|
+
.doc(companyId)
|
20
|
+
.collection("Actions")
|
21
|
+
.doc(actionId)
|
22
|
+
.collection(actionName)
|
23
|
+
.where("reqCompanyId", "==", requestCompanyId)
|
24
|
+
.get();
|
25
|
+
deviceChangeReqs.forEach((doc) => {
|
26
|
+
console.log("compare", doc.data().extraData.deviceId, newDeviceId, doc.data().isProcessed);
|
27
|
+
if (doc.data().extraData.deviceId === newDeviceId
|
28
|
+
&& doc.data().isProcessed === false) {
|
29
|
+
isReqPending = true;
|
30
|
+
}
|
31
|
+
});
|
32
|
+
return isReqPending;
|
33
|
+
}
|
34
|
+
static async fetchOpenReqs(firestore, companyId) {
|
35
|
+
const nickName = "mobiOffice";
|
36
|
+
const supportCompanyId = await company_model_1.Company.getCompanyIdByNickName(firestore, nickName);
|
37
|
+
const actionName = "requestForm";
|
38
|
+
const actionId = await action_model_1.Action.getActionId(firestore, supportCompanyId, actionName);
|
39
|
+
const allRequestsDocs = await firestore.collection("Companies")
|
40
|
+
.doc(supportCompanyId)
|
41
|
+
.collection("Actions")
|
42
|
+
.doc(actionId)
|
43
|
+
.collection(actionName)
|
44
|
+
.get();
|
45
|
+
let allRequestsData = allRequestsDocs.docs.map((doc) => {
|
46
|
+
return doc.data();
|
47
|
+
});
|
48
|
+
let openRequests = allRequestsData.filter((doc) => {
|
49
|
+
return doc.reqCompanyId === companyId && !doc.isProcessed;
|
50
|
+
});
|
51
|
+
return openRequests;
|
52
|
+
}
|
53
|
+
static async approve(firestore, approvalDetails) {
|
54
|
+
const extraData = approvalDetails.extra.extraData;
|
55
|
+
const companyId = extraData.companyNameId;
|
56
|
+
const requestId = extraData.requestId;
|
57
|
+
const requestStatus = extraData.approval;
|
58
|
+
const openRequests = await this.fetchOpenReqs(firestore, companyId);
|
59
|
+
const objToProcess = [];
|
60
|
+
openRequests.forEach(async (doc) => {
|
61
|
+
if (doc.eventId === requestId) {
|
62
|
+
objToProcess.push(doc);
|
63
|
+
}
|
64
|
+
});
|
65
|
+
if (objToProcess.length !== 0) {
|
66
|
+
const licenseDoc = await firestore.collection("Licenses")
|
67
|
+
.where("company", "==", objToProcess[0].company)
|
68
|
+
.where("user", "==", `+${objToProcess[0].extraData.phone}`)
|
69
|
+
.get();
|
70
|
+
let license = licenseDoc.docs.map((doc) => {
|
71
|
+
return doc.data();
|
72
|
+
})[0];
|
73
|
+
const updatedLicense = await this.replaceOldDeviceWithNew(license, objToProcess[0]);
|
74
|
+
console.log(updatedLicense);
|
75
|
+
if (updatedLicense) {
|
76
|
+
licenseDoc.forEach(doc => {
|
77
|
+
doc.ref.set(updatedLicense);
|
78
|
+
});
|
79
|
+
}
|
80
|
+
await this.updateCompanyActionDoc(firestore, requestId, requestStatus);
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
throw new Error("no documents to process");
|
84
|
+
}
|
85
|
+
}
|
86
|
+
static async replaceOldDeviceWithNew(license, objToProcess) {
|
87
|
+
const extraDevices = license.extraDevices;
|
88
|
+
const newDeviceObj = {
|
89
|
+
fromDate: Date.now(),
|
90
|
+
modelName: objToProcess.extraData.model,
|
91
|
+
brandName: objToProcess.extraData.brand,
|
92
|
+
deviceId: objToProcess.extraData.deviceId
|
93
|
+
};
|
94
|
+
const indexToReplace = await this.getIndexToReplace(extraDevices, objToProcess.extraData.oldDeviceId);
|
95
|
+
if (indexToReplace === "not found") {
|
96
|
+
return null;
|
97
|
+
}
|
98
|
+
extraDevices.splice(indexToReplace, 1, newDeviceObj);
|
99
|
+
license.extraDevices = extraDevices;
|
100
|
+
return license;
|
101
|
+
}
|
102
|
+
static async getIndexToReplace(extraDevices, deviceId) {
|
103
|
+
for (let i = 0; i < extraDevices.length; i++) {
|
104
|
+
if (extraDevices[i].deviceId === deviceId) {
|
105
|
+
return i;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return "not found";
|
109
|
+
}
|
110
|
+
static async updateCompanyActionDoc(firestore, requestId, requestStatus) {
|
111
|
+
const companyId = await company_model_1.Company.getCompanyIdByNickName(firestore, "mobiOffice");
|
112
|
+
const actionName = "requestForm";
|
113
|
+
const actionId = await action_model_1.Action.getActionId(firestore, companyId, actionName);
|
114
|
+
const doc = await firestore.collection("Companies")
|
115
|
+
.doc(companyId)
|
116
|
+
.collection("Actions")
|
117
|
+
.doc(actionId)
|
118
|
+
.collection(actionName)
|
119
|
+
.doc(requestId)
|
120
|
+
.get();
|
121
|
+
await doc.ref.update({
|
122
|
+
isProcessed: true,
|
123
|
+
approval: requestStatus
|
124
|
+
});
|
125
|
+
const supportUsers = await company_model_1.Company.getUsersListbyCompany(firestore, "mobiOffice");
|
126
|
+
for (let user of supportUsers) {
|
127
|
+
const docRef = await firestore.collection("Feeds").doc(user.id).collection(companyId).doc(requestId).get();
|
128
|
+
const docData = docRef.data();
|
129
|
+
const extraData = docData?.extraData;
|
130
|
+
extraData["approval"] = requestStatus;
|
131
|
+
await firestore.collection("Feeds").doc(user.id).collection(companyId).doc(requestId).update({
|
132
|
+
isProcessed: true,
|
133
|
+
extraData: extraData
|
134
|
+
});
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
exports.DeviceChangeReq = DeviceChangeReq;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Post } from "./post.model";
|
2
|
+
import * as admin from "firebase-admin";
|
3
|
+
declare class Dispatch extends Post {
|
4
|
+
actionEvent: string;
|
5
|
+
actionType: string;
|
6
|
+
actionName: string;
|
7
|
+
customerName: string;
|
8
|
+
static createPostforDispatch(firestore: admin.firestore.Firestore, postInfo: any, uniqueId: string): Promise<unknown>;
|
9
|
+
static createPostForSODispatch(firestore: admin.firestore.Firestore, postInfo: any, status: string): Promise<unknown>;
|
10
|
+
static setIncomingInfoToDispatch(info: any, post: Dispatch): Promise<Dispatch>;
|
11
|
+
static modifyExtraDataForDispatch(info: any): Promise<any>;
|
12
|
+
static getSODesignsByDocId(firestore: admin.firestore.Firestore, uniqueId: string): Promise<any>;
|
13
|
+
}
|
14
|
+
export { Dispatch };
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Dispatch = void 0;
|
4
|
+
const post_model_1 = require("./post.model");
|
5
|
+
const tempCollection_model_1 = require("./tempCollection.model");
|
6
|
+
const user_model_1 = require("./user.model");
|
7
|
+
class Dispatch extends post_model_1.Post {
|
8
|
+
actionEvent = "";
|
9
|
+
actionType = "worklog";
|
10
|
+
actionName = "dispatch";
|
11
|
+
customerName = "";
|
12
|
+
static async createPostforDispatch(firestore, postInfo, uniqueId) {
|
13
|
+
let post = new Dispatch();
|
14
|
+
post = await Dispatch.setIncomingInfoToDispatch(postInfo, post);
|
15
|
+
console.log(post);
|
16
|
+
let eventId = await post_model_1.Post.createNewPost(firestore, post);
|
17
|
+
await tempCollection_model_1.TempCollection.deleteTempCollection(firestore, uniqueId);
|
18
|
+
return eventId;
|
19
|
+
}
|
20
|
+
static async createPostForSODispatch(firestore, postInfo, status) {
|
21
|
+
console.log("in create post for dispatch");
|
22
|
+
const userInfo = await user_model_1.User.getUserInfoById(firestore, postInfo.userId, postInfo.companyId);
|
23
|
+
const extraData = postInfo.extra.extraData;
|
24
|
+
extraData.status = status;
|
25
|
+
extraData.time = postInfo.createdAt;
|
26
|
+
extraData.date = new Date(postInfo.createdAt).toLocaleDateString("en-GB");
|
27
|
+
extraData.userName = userInfo.name;
|
28
|
+
console.log(extraData);
|
29
|
+
let post = {
|
30
|
+
...postInfo,
|
31
|
+
extraData: extraData,
|
32
|
+
actionId: postInfo.extra.actionId,
|
33
|
+
description: postInfo.extra.extraData.customerName,
|
34
|
+
actionType: "worklog"
|
35
|
+
};
|
36
|
+
delete post.extra;
|
37
|
+
console.log(post);
|
38
|
+
console.log("creating post for dispatch");
|
39
|
+
let eventId = await post_model_1.Post.createNewPost(firestore, post);
|
40
|
+
return eventId;
|
41
|
+
}
|
42
|
+
static async setIncomingInfoToDispatch(info, post) {
|
43
|
+
post.actionEvent = info.extra.actionEvent;
|
44
|
+
post.id = info.id;
|
45
|
+
post.customerName = info.customerName;
|
46
|
+
post.actionId = info.extra.actionId;
|
47
|
+
post.companyId = info.extra.companyId;
|
48
|
+
post.createdAt = info.extra.createdAt;
|
49
|
+
post.description = info.description;
|
50
|
+
post.eventId = info.extra.eventId;
|
51
|
+
post.isGeofence = info.extra.isGeofence;
|
52
|
+
post.userId = info.userId;
|
53
|
+
const newExtraData = await this.modifyExtraDataForDispatch(info);
|
54
|
+
post.extraData = newExtraData;
|
55
|
+
post.seen = info.extra.seen;
|
56
|
+
post.startAt = "";
|
57
|
+
post.startLat = info.extra.startLat;
|
58
|
+
post.startLong = info.extra.startLong;
|
59
|
+
post.endAt = "";
|
60
|
+
post.endLat = info.extra.endLat;
|
61
|
+
post.endLong = info.extra.endLong;
|
62
|
+
post.stepValues = info.extra.stepValues;
|
63
|
+
post.time = info.extra.time;
|
64
|
+
post.checkInternet = info.extra.checkInternet;
|
65
|
+
return post;
|
66
|
+
}
|
67
|
+
static async modifyExtraDataForDispatch(info) {
|
68
|
+
const time = info.createdAt;
|
69
|
+
const date = new Date(time).toLocaleDateString("en-GB");
|
70
|
+
const newExtraData = {
|
71
|
+
...info.extra.extraData,
|
72
|
+
status: "Pending",
|
73
|
+
customerName: info.description.split("--")[0],
|
74
|
+
date: date,
|
75
|
+
time: time
|
76
|
+
};
|
77
|
+
return newExtraData;
|
78
|
+
}
|
79
|
+
static async getSODesignsByDocId(firestore, uniqueId) {
|
80
|
+
try {
|
81
|
+
const storedInfoDoc = await firestore.collection("TempCollection")
|
82
|
+
.doc(uniqueId)
|
83
|
+
.get();
|
84
|
+
const info = storedInfoDoc.data();
|
85
|
+
console.log(info.scannedTakas);
|
86
|
+
return info.scannedTakas;
|
87
|
+
}
|
88
|
+
catch (error) {
|
89
|
+
throw new Error(error.message);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
exports.Dispatch = Dispatch;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as admin from 'firebase-admin';
|
2
|
+
declare class Feeds {
|
3
|
+
static initFeed(firestore: admin.firestore.Firestore): Promise<string>;
|
4
|
+
static updateFeed(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, data: any, isError: boolean, lotNo: string): Promise<string>;
|
5
|
+
static updateFeedForUser(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, data: any, isError: boolean, lotNo: string): Promise<string>;
|
6
|
+
static updateEndMeetingsTimeInFeeds(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, endTime: number): Promise<"success" | undefined>;
|
7
|
+
}
|
8
|
+
export { Feeds };
|
@@ -0,0 +1,97 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Feeds = void 0;
|
4
|
+
const offline_model_1 = require("./offline.model");
|
5
|
+
class Feeds {
|
6
|
+
static async initFeed(firestore) {
|
7
|
+
let document = firestore.collection('Feeds').doc();
|
8
|
+
await document.set({
|
9
|
+
id: document.id,
|
10
|
+
});
|
11
|
+
return "success";
|
12
|
+
}
|
13
|
+
static async updateFeed(firestore, userId, companyId, eventId, data, isError, lotNo) {
|
14
|
+
console.log("going to update cards");
|
15
|
+
await Feeds.updateFeedForUser(firestore, userId, companyId, eventId, data, isError, lotNo);
|
16
|
+
let managersList = await offline_model_1.Offline.getUserManagersList(firestore, companyId, userId);
|
17
|
+
for (let manager of managersList) {
|
18
|
+
await Feeds.updateFeedForUser(firestore, manager, companyId, eventId, data, isError, lotNo);
|
19
|
+
}
|
20
|
+
return "success";
|
21
|
+
}
|
22
|
+
static async updateFeedForUser(firestore, userId, companyId, eventId, data, isError, lotNo) {
|
23
|
+
console.log("received info");
|
24
|
+
let userFeedDoc = await firestore.collection("Feeds").doc(userId).collection(companyId).where("eventId", "==", eventId).get();
|
25
|
+
let description = userFeedDoc.docs[0].data().description || "";
|
26
|
+
let extraData = userFeedDoc.docs[0].data().extraData;
|
27
|
+
const oldUserFeedDoc = userFeedDoc.docs[0].data();
|
28
|
+
delete oldUserFeedDoc.extraData;
|
29
|
+
console.log("deleted extraData from oldUserFeedDoc");
|
30
|
+
extraData = {
|
31
|
+
...extraData,
|
32
|
+
lotNo,
|
33
|
+
status: data
|
34
|
+
};
|
35
|
+
let newUserFeedDoc = {};
|
36
|
+
if (isError) {
|
37
|
+
console.log("api sent error response");
|
38
|
+
newUserFeedDoc.cardColor = "#FFF44336";
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
console.log("api send success response");
|
42
|
+
if (extraData.toBePrinted) {
|
43
|
+
extraData.print = extraData.toBePrinted;
|
44
|
+
extraData.print["lot_no"] = lotNo;
|
45
|
+
delete extraData.toBePrinted;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
description = `${description}--${data.split(" ").slice(0, 3).join(" ")}`;
|
49
|
+
console.log("updated the description");
|
50
|
+
newUserFeedDoc = {
|
51
|
+
...oldUserFeedDoc,
|
52
|
+
...newUserFeedDoc,
|
53
|
+
description: description,
|
54
|
+
extraData: extraData
|
55
|
+
};
|
56
|
+
console.log("going to set the newUserFeedDoc");
|
57
|
+
userFeedDoc.forEach((doc) => {
|
58
|
+
doc.ref.set(newUserFeedDoc);
|
59
|
+
});
|
60
|
+
console.log("done");
|
61
|
+
// userFeedDoc.forEach((doc)=>{
|
62
|
+
// doc.ref.update({
|
63
|
+
// description:description,
|
64
|
+
// extraData:extraData
|
65
|
+
// })
|
66
|
+
// if (doc.data().tobePrinted) {
|
67
|
+
// doc.ref.update({
|
68
|
+
// print: doc.data().tobePrinted
|
69
|
+
// })
|
70
|
+
// }
|
71
|
+
// if (isError) {
|
72
|
+
// doc.ref.update({
|
73
|
+
// cardColor: "#FFF44336"
|
74
|
+
// })
|
75
|
+
// }
|
76
|
+
// })
|
77
|
+
return "success";
|
78
|
+
}
|
79
|
+
static async updateEndMeetingsTimeInFeeds(firestore, userId, companyId, eventId, endTime) {
|
80
|
+
let userFeedDoc = await firestore.collection("Feeds").doc(userId).collection(companyId).where("eventId", "==", eventId).get();
|
81
|
+
if (userFeedDoc.docs.length) {
|
82
|
+
let extraData = userFeedDoc.docs[0].data().extraData;
|
83
|
+
extraData = {
|
84
|
+
...extraData,
|
85
|
+
"End Time": endTime
|
86
|
+
};
|
87
|
+
console.log(extraData);
|
88
|
+
userFeedDoc.forEach((doc) => {
|
89
|
+
doc.ref.update({
|
90
|
+
extraData: extraData
|
91
|
+
});
|
92
|
+
});
|
93
|
+
return "success";
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
exports.Feeds = Feeds;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
declare class Geofence {
|
3
|
+
static getOrCreateGeoFence(firestore: admin.firestore.Firestore, geofenceDoc: any): Promise<any>;
|
4
|
+
static convertGeofenceDataType(geoFenceDoc: any): Promise<any>;
|
5
|
+
static updateGeofence(firestore: admin.firestore.Firestore, arrayUnion: any, geofenceDoc: any): Promise<string>;
|
6
|
+
}
|
7
|
+
export { Geofence };
|