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.
Files changed (253) hide show
  1. package/{src/index.ts → lib/index.d.ts} +1 -45
  2. package/lib/models/Feed-Details-Screen.model.d.ts +6 -0
  3. package/lib/models/Feed-Details-Screen.model.js +27 -0
  4. package/lib/models/action.model.d.ts +58 -0
  5. package/lib/models/action.model.js +315 -0
  6. package/lib/models/actions/doffing.d.ts +6 -0
  7. package/lib/models/actions/doffing.js +64 -0
  8. package/lib/models/actions/folding.d.ts +7 -0
  9. package/lib/models/actions/folding.js +37 -0
  10. package/lib/models/attendance.model.d.ts +44 -0
  11. package/lib/models/attendance.model.js +446 -0
  12. package/lib/models/cicoPost.model.d.ts +9 -0
  13. package/lib/models/cicoPost.model.js +19 -0
  14. package/lib/models/company.model.d.ts +67 -0
  15. package/lib/models/company.model.js +725 -0
  16. package/lib/models/contact-us/resquest.model.d.ts +30 -0
  17. package/lib/models/contact-us/resquest.model.js +73 -0
  18. package/lib/models/crud/crud.d.ts +7 -0
  19. package/lib/models/crud/crud.js +27 -0
  20. package/lib/models/customCollection.model.d.ts +9 -0
  21. package/lib/models/customCollection.model.js +40 -0
  22. package/lib/models/customer/customer.model.d.ts +32 -0
  23. package/lib/models/customer/customer.model.js +62 -0
  24. package/lib/models/deviceChangeReq.d.ts +10 -0
  25. package/lib/models/deviceChangeReq.js +138 -0
  26. package/lib/models/dispatch.model.d.ts +14 -0
  27. package/lib/models/dispatch.model.js +93 -0
  28. package/lib/models/feed.models.d.ts +8 -0
  29. package/lib/models/feed.models.js +97 -0
  30. package/lib/models/geofence.model.d.ts +7 -0
  31. package/lib/models/geofence.model.js +61 -0
  32. package/lib/models/leaveApplicationPost.model.d.ts +12 -0
  33. package/lib/models/leaveApplicationPost.model.js +72 -0
  34. package/lib/models/license.model.d.ts +25 -0
  35. package/lib/models/license.model.js +198 -0
  36. package/lib/models/log.model.d.ts +6 -0
  37. package/{src/models/log.model.ts → lib/models/log.model.js} +11 -11
  38. package/lib/models/meeting.model.d.ts +11 -0
  39. package/lib/models/meeting.model.js +79 -0
  40. package/lib/models/meter.model.d.ts +18 -0
  41. package/lib/models/meter.model.js +54 -0
  42. package/lib/models/missingPunchPost.model.d.ts +15 -0
  43. package/lib/models/missingPunchPost.model.js +69 -0
  44. package/lib/models/offline.model.d.ts +70 -0
  45. package/lib/models/offline.model.js +831 -0
  46. package/lib/models/post.model.d.ts +38 -0
  47. package/lib/models/post.model.js +94 -0
  48. package/lib/models/printDetailsScreen.model.d.ts +6 -0
  49. package/lib/models/printDetailsScreen.model.js +27 -0
  50. package/lib/models/pushNotifications/pushNotification.model.d.ts +4 -0
  51. package/lib/models/pushNotifications/pushNotification.model.js +17 -0
  52. package/lib/models/report-actions.model.d.ts +26 -0
  53. package/lib/models/report-actions.model.js +56 -0
  54. package/lib/models/report-definition-details.model.d.ts +13 -0
  55. package/lib/models/report-definition-details.model.js +85 -0
  56. package/lib/models/report-definition.model.d.ts +23 -0
  57. package/lib/models/report-definition.model.js +26 -0
  58. package/lib/models/report-definitions-summary.model.d.ts +8 -0
  59. package/lib/models/report-definitions-summary.model.js +59 -0
  60. package/lib/models/report-detail-data.model.d.ts +46 -0
  61. package/lib/models/report-detail-data.model.js +49 -0
  62. package/lib/models/report-visibility.model.d.ts +7 -0
  63. package/lib/models/report-visibility.model.js +42 -0
  64. package/lib/models/report.model.d.ts +19 -0
  65. package/lib/models/report.model.js +138 -0
  66. package/lib/models/reportGenerator.model.d.ts +164 -0
  67. package/lib/models/reportGenerator.model.js +642 -0
  68. package/lib/models/response.model.d.ts +18 -0
  69. package/lib/models/response.model.js +30 -0
  70. package/lib/models/steps.factory.model.d.ts +172 -0
  71. package/lib/models/steps.factory.model.js +187 -0
  72. package/lib/models/storeGupShupLog.model.d.ts +6 -0
  73. package/lib/models/storeGupShupLog.model.js +51 -0
  74. package/lib/models/summary.model.d.ts +10 -0
  75. package/{src/models/summary.model.ts → lib/models/summary.model.js} +28 -27
  76. package/lib/models/tasks/sub-task-group.model.d.ts +42 -0
  77. package/lib/models/tasks/sub-task-group.model.js +154 -0
  78. package/lib/models/tasks/tags.model.d.ts +29 -0
  79. package/lib/models/tasks/tags.model.js +70 -0
  80. package/lib/models/tasks/task-group.model.d.ts +53 -0
  81. package/lib/models/tasks/task-group.model.js +156 -0
  82. package/lib/models/tasks/task.model.d.ts +163 -0
  83. package/lib/models/tasks/task.model.js +603 -0
  84. package/lib/models/tempCollection.model.d.ts +40 -0
  85. package/{src/models/tempCollection.model.ts → lib/models/tempCollection.model.js} +114 -130
  86. package/lib/models/user.model.d.ts +42 -0
  87. package/lib/models/user.model.js +272 -0
  88. package/lib/models/utility.model.d.ts +13 -0
  89. package/lib/models/utility.model.js +93 -0
  90. package/lib/models/visitorManagement/acknowledgement.model.d.ts +9 -0
  91. package/lib/models/visitorManagement/acknowledgement.model.js +55 -0
  92. package/lib/models/visitorManagement/invite.model.d.ts +32 -0
  93. package/lib/models/visitorManagement/invite.model.js +326 -0
  94. package/lib/models/visitorManagement/newIn.model.d.ts +19 -0
  95. package/lib/models/visitorManagement/newIn.model.js +67 -0
  96. package/lib/models/visitorManagement/selfServe.model.d.ts +13 -0
  97. package/lib/models/visitorManagement/selfServe.model.js +46 -0
  98. package/lib/models/worklogPost.model.d.ts +6 -0
  99. package/lib/models/worklogPost.model.js +9 -0
  100. package/lib/services/customer.d.ts +30 -0
  101. package/lib/services/customer.js +354 -0
  102. package/lib/services/meeting.d.ts +19 -0
  103. package/lib/services/meeting.js +109 -0
  104. package/package.json +4 -1
  105. package/.prettierrc +0 -4
  106. package/a.js +0 -3
  107. package/scripts/1.ts +0 -1300
  108. package/scripts/GCloudPubSub/pub-sub-config.json +0 -12
  109. package/scripts/GCloudPubSub/visitorAutoRejection.ts +0 -86
  110. package/scripts/actions/assignUsersFromOneActionToOther.ts +0 -64
  111. package/scripts/actions/assignUsersListToAction.ts +0 -81
  112. package/scripts/actions/getActionsListOfUser.ts +0 -42
  113. package/scripts/actions/getCompanyUserDetails.ts +0 -49
  114. package/scripts/actions/giveActionToUser.ts +0 -41
  115. package/scripts/actions/giveUsersToActivitySelector.ts +0 -56
  116. package/scripts/actions/groupActionsInActivitySelector.ts +0 -101
  117. package/scripts/actions/modifySummaryReportDB.ts +0 -42
  118. package/scripts/actions/setUrlToActionStep.ts +0 -18
  119. package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +0 -93
  120. package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +0 -103
  121. package/scripts/actions/test.ts +0 -29
  122. package/scripts/actions/transferFeedsOldIdToNew.ts +0 -40
  123. package/scripts/actions/transformUserIntoManager.ts +0 -89
  124. package/scripts/argvConfig.js +0 -9
  125. package/scripts/backUpData/testCode.ts +0 -131
  126. package/scripts/benaraScripts/addWorkAreaMap.ts +0 -46
  127. package/scripts/benaraScripts/add_customers.ts +0 -26
  128. package/scripts/benaraScripts/add_customers_contact.ts +0 -27
  129. package/scripts/benaraScripts/add_empty_work_area.ts +0 -17
  130. package/scripts/benaraScripts/assignManagers.ts +0 -35
  131. package/scripts/benaraScripts/changeCheckInFlag.ts +0 -45
  132. package/scripts/benaraScripts/createCustomerContactsList.ts +0 -170
  133. package/scripts/benaraScripts/createUserByDeletingOldUser.ts +0 -70
  134. package/scripts/benaraScripts/createUsersAreaMapCollection.ts +0 -23
  135. package/scripts/benaraScripts/createWorkAreaMap.ts +0 -24
  136. package/scripts/benaraScripts/mapWorkAreasToUsers.ts +0 -112
  137. package/scripts/companies_data.json +0 -2496
  138. package/scripts/create_or_update_users.ts +0 -31
  139. package/scripts/csvToJson/csvToJson.ts +0 -90
  140. package/scripts/csvToJson/users.json +0 -3896
  141. package/scripts/db.js +0 -27
  142. package/scripts/db.json +0 -13
  143. package/scripts/dbMySql.ts +0 -63
  144. package/scripts/delete_action_steps.ts +0 -11
  145. package/scripts/delete_user.ts +0 -71
  146. package/scripts/dev_companies_data.json +0 -613
  147. package/scripts/enroll.xlsx +0 -0
  148. package/scripts/export_users.ts +0 -72
  149. package/scripts/files/visitorManagementFiles/displayScreen.json +0 -70
  150. package/scripts/files/visitorManagementFiles/init_report_visibility.ts +0 -79
  151. package/scripts/firebaseConfig.js +0 -12
  152. package/scripts/firebaseDocs/deleteIncommingCollection.ts +0 -47
  153. package/scripts/firebaseDocs/updateDoc.ts +0 -43
  154. package/scripts/getActionDataIntoJSON/getActionData.ts +0 -68
  155. package/scripts/get_attendance_by_any_date.ts +0 -14
  156. package/scripts/get_attendance_by_month.ts +0 -12
  157. package/scripts/get_attendance_monthly_by_team.ts +0 -11
  158. package/scripts/get_daily_report.ts +0 -10
  159. package/scripts/get_mangers.ts +0 -13
  160. package/scripts/grant_user_license.ts +0 -18
  161. package/scripts/init_CustomCollection.ts +0 -16
  162. package/scripts/init_action_steps.ts +0 -28
  163. package/scripts/init_actions.ts +0 -31
  164. package/scripts/init_company.ts +0 -18
  165. package/scripts/init_customer_mysql.ts +0 -12
  166. package/scripts/init_feed.ts +0 -4
  167. package/scripts/init_feed_details_screen.ts +0 -14
  168. package/scripts/init_geofence.ts +0 -26
  169. package/scripts/init_print_details_screen.ts +0 -14
  170. package/scripts/init_report_actions.ts +0 -24
  171. package/scripts/init_report_definition_detail.ts +0 -26
  172. package/scripts/init_report_definition_summary.ts +0 -16
  173. package/scripts/init_report_visibility.ts +0 -46
  174. package/scripts/init_user_customcollection.ts +0 -16
  175. package/scripts/json/action.json +0 -21
  176. package/scripts/json/company.json +0 -24
  177. package/scripts/json/report-action.json +0 -13
  178. package/scripts/json/report-def-deet.json +0 -43
  179. package/scripts/json/resp.json +0 -784
  180. package/scripts/json/steps.json +0 -24
  181. package/scripts/json/test.ts +0 -49
  182. package/scripts/mysqlConfig.ts +0 -9
  183. package/scripts/revoke_or_extend_license.ts +0 -14
  184. package/scripts/stream.js +0 -4
  185. package/scripts/testing1.ts +0 -35
  186. package/scripts/update/doc.json +0 -20
  187. package/scripts/update/getDocByPath.ts +0 -34
  188. package/scripts/update/updateDocByPath.ts +0 -47
  189. package/scripts/update/updateUsersOfCompanies.ts +0 -58
  190. package/scripts/update_actions.ts +0 -19
  191. package/scripts/update_actions_steps.ts +0 -19
  192. package/scripts/update_company.ts +0 -19
  193. package/scripts/update_geofence.ts +0 -20
  194. package/scripts/update_managers.ts +0 -16
  195. package/scripts/visitorMgmt/createArea.ts +0 -68
  196. package/scripts/visitorMgmt/createArea.txt +0 -3
  197. package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +0 -130
  198. package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +0 -18
  199. package/scripts/visitorMgmt/encryptDateString.ts +0 -71
  200. package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +0 -117
  201. package/scripts/whatsapp_gupshup/sendMessage.ts +0 -97
  202. package/src/models/Feed-Details-Screen.model.ts +0 -29
  203. package/src/models/action.model.ts +0 -355
  204. package/src/models/actions/doffing.ts +0 -71
  205. package/src/models/actions/folding.ts +0 -39
  206. package/src/models/attendance.model.ts +0 -615
  207. package/src/models/cicoPost.model.ts +0 -20
  208. package/src/models/company.model.ts +0 -975
  209. package/src/models/contact-us/resquest.model.ts +0 -87
  210. package/src/models/crud/crud.ts +0 -30
  211. package/src/models/customCollection.model.ts +0 -47
  212. package/src/models/customer/customer.model.ts +0 -85
  213. package/src/models/deviceChangeReq.ts +0 -150
  214. package/src/models/dispatch.model.ts +0 -99
  215. package/src/models/feed.models.ts +0 -104
  216. package/src/models/geofence.model.ts +0 -61
  217. package/src/models/leaveApplicationPost.model.ts +0 -79
  218. package/src/models/license.model.ts +0 -215
  219. package/src/models/meeting.model.ts +0 -80
  220. package/src/models/meter.model.ts +0 -62
  221. package/src/models/missingPunchPost.model.ts +0 -84
  222. package/src/models/offline.model.ts +0 -1133
  223. package/src/models/post.model.ts +0 -105
  224. package/src/models/printDetailsScreen.model.ts +0 -30
  225. package/src/models/pushNotifications/pushNotification.model.ts +0 -17
  226. package/src/models/report-actions.model.ts +0 -57
  227. package/src/models/report-definition-details.model.ts +0 -89
  228. package/src/models/report-definition.model.ts +0 -26
  229. package/src/models/report-definitions-summary.model.ts +0 -59
  230. package/src/models/report-detail-data.model.ts +0 -49
  231. package/src/models/report-visibility.model.ts +0 -44
  232. package/src/models/report.model.ts +0 -179
  233. package/src/models/reportGenerator.model.ts +0 -883
  234. package/src/models/response.model.ts +0 -31
  235. package/src/models/steps.factory.model.ts +0 -195
  236. package/src/models/storeGupShupLog.model.ts +0 -49
  237. package/src/models/tasks/sub-task-group.model.ts +0 -173
  238. package/src/models/tasks/tags.model.ts +0 -113
  239. package/src/models/tasks/task-group.model.ts +0 -172
  240. package/src/models/tasks/task.model.ts +0 -681
  241. package/src/models/user.model.ts +0 -319
  242. package/src/models/utility.model.ts +0 -100
  243. package/src/models/visitorManagement/acknowledgement.model.ts +0 -71
  244. package/src/models/visitorManagement/invite.model.ts +0 -406
  245. package/src/models/visitorManagement/newIn.model.ts +0 -82
  246. package/src/models/visitorManagement/selfServe.model.ts +0 -58
  247. package/src/models/worklogPost.model.ts +0 -8
  248. package/src/services/customer.ts +0 -382
  249. package/src/services/meeting.ts +0 -123
  250. package/test/1.ts +0 -13
  251. package/test/db.js +0 -19
  252. package/test/firebaseConfig.js +0 -1
  253. package/tsconfig.json +0 -16
@@ -1,31 +0,0 @@
1
- class HttpResponseAndErrorHandling {
2
- private statusCode: number;
3
- private message: string;
4
- private data: any;
5
- private error: any;
6
- constructor(statusCode: number,
7
- message: string,
8
- data: any,
9
- error: any) {
10
- this.statusCode = statusCode;
11
- this.message = message;
12
- this.data = data;
13
- this.error = error;
14
- }
15
- getSuccessResponse() {
16
- return {
17
- statusCode: this.statusCode,
18
- message: this.message,
19
- data: this.data
20
- };
21
- }
22
- getErrorResponse() {
23
- return {
24
- statusCode: this.statusCode,
25
- message: this.message,
26
- error: this.error
27
- };
28
- }
29
- }
30
-
31
- export { HttpResponseAndErrorHandling };
@@ -1,195 +0,0 @@
1
- class StepsFactory {
2
- buttonActionText:string = "";
3
- field:any = new Map();
4
- fieldType:string = "";
5
- id: string = "";
6
- label:string = "";
7
- nextCollection:string = "";
8
- nextRole:string = "";
9
- order:number = 0;
10
- submitUrl:string = "";
11
- type:string = "";
12
- value:string = "";
13
-
14
- initViaSnapshotDoc(doc:any) {
15
- var _data = doc.data();
16
-
17
- this.buttonActionText = _data.butttonActionText;
18
- this.field = _data.field;
19
- this.id = _data.id;
20
- this.label = _data.label;
21
- this.nextCollection = _data.nextCollection;
22
- this.nextRole = _data.nextRole;
23
- this.order = _data.order;
24
- this.submitUrl = _data.submitUrl;
25
- this.type = _data.type;
26
- this.value = _data.value;
27
- }
28
-
29
- static inputFieldTemplate = {
30
- buttonActionText: "Next",
31
- field: {
32
- hint: "",
33
- icon: "",
34
- id: "1",
35
- url: "",
36
- keys: [],
37
- typeAheadRequired: false,
38
- keyboardType: "",
39
- keyForAPI: "",
40
- isMultiline: false,
41
- isRequired: true,
42
- label: "Input",
43
- value: "",
44
- },
45
- fieldType: "InputField",
46
- label: "Input",
47
- id: "",
48
- nextCollection: "",
49
- nextRole: "",
50
- order: 0,
51
- submitUrl: "",
52
- type: "normal",
53
- value: "",
54
- };
55
-
56
- static datePickerTemplate = {
57
- buttonActionText: "Next",
58
- field: {
59
- hint: "",
60
- icon: "",
61
- id: "1",
62
- keyForAPI: "",
63
- isRequired: true,
64
- label: "Date",
65
- value: "",
66
- },
67
- fieldType: "datePicker",
68
- id: "",
69
- label: "Date",
70
- nextCollection: "",
71
- nextRole: "",
72
- order: 0,
73
- submitUrl: "",
74
- type: "normal",
75
- value: "",
76
- };
77
-
78
- static summaryStepTemplate = {
79
- buttonActionText: "Done",
80
- field: {
81
- hint: "",
82
- icon: "",
83
- id: "1",
84
- keyForAPI: "",
85
- label: "Summary",
86
- value: "",
87
- },
88
- fieldType: "Summary",
89
- id: "",
90
- label: "Summary",
91
- nextCollection: "",
92
- nextRole: "",
93
- order: 4,
94
- sumbitUrl: "",
95
- type: "summary",
96
- value: "",
97
- };
98
-
99
- static radioListItemsTemplate = {
100
- id: "",
101
- label: "",
102
- hint: "",
103
- icon: "",
104
- };
105
-
106
- static radioListTemplate = {
107
- id: "",
108
- buttonActionText: "Next",
109
- field: {
110
- autoChangePage: false,
111
- hint: "",
112
- icon: "",
113
- id: "RLMP101",
114
- isAPICalled: false,
115
- keyForAPI: "",
116
- isRequired: true,
117
- itemList: [],
118
- },
119
- fieldType: "RadioList",
120
- label: "label",
121
- nextCollection: "",
122
- nextRole: "",
123
- order: 1,
124
- submitUrl: "",
125
- type: "normal",
126
- value: "",
127
- };
128
-
129
- static qrCodeTemplate = {
130
- id: "",
131
- buttonActionText: "Next",
132
- field: {
133
- autoChangePage: false,
134
- hint: "",
135
- icon: "",
136
- keyForAPI: "",
137
- id: "RLMP101",
138
- isAPICalled: false,
139
- isRequired: true,
140
- },
141
- fieldType: "RadioList",
142
- label: "label",
143
- nextCollection: "",
144
- nextRole: "",
145
- order: 1,
146
- submitUrl: "",
147
- type: "normal",
148
- value: "",
149
- };
150
-
151
- static timePickerTemplate = {
152
- buttonActionText: "Next",
153
- field: {
154
- hint: "",
155
- icon: "",
156
- id: "1",
157
- keyForAPI: "",
158
- isRequired: true,
159
- label: "Time",
160
- value: "",
161
- },
162
- fieldType: "timePicker",
163
- type: "normal",
164
- id: "",
165
- label: "Time",
166
- nextCollection: "",
167
- nextRole: "",
168
- order: 2,
169
- submitUrl: "",
170
- value: "",
171
- };
172
-
173
- static selfieTemplate = {
174
- buttonActionText: "Next",
175
- field: {
176
- id: "1",
177
- label: "",
178
- hint: "",
179
- keyForAPI: "",
180
- value: "",
181
- isRequired: true,
182
- },
183
- fieldType: "Selfie",
184
- type: "normal",
185
- id: "",
186
- label: "Time",
187
- nextCollection: "",
188
- nextRole: "",
189
- order: 2,
190
- submitUrl: "",
191
- value: "",
192
- };
193
- }
194
-
195
- export { StepsFactory };
@@ -1,49 +0,0 @@
1
- import { Pool } from "mysql2";
2
- import CurdService from "./crud/crud";
3
-
4
- export class GupShupLogs {
5
-
6
-
7
- static async insertLog(connection: Pool, companyId: string, phoneNumber: string, msgId: string) {
8
- const crudServicce = new CurdService(connection);
9
- try {
10
- const qryString = `INSERT INTO GupShup_Logs (companyId, phone_number, gupshup_msg_id, sent, delivered, \`read\`, deleted)
11
- VALUES ('${companyId}', '${phoneNumber}', '${msgId}', NULL, NULL, NULL, NULL);`
12
- console.log("query", qryString)
13
- const result = await crudServicce.query(qryString);
14
- return result
15
- } catch (error: any) {
16
- console.log(error.message);
17
- return error
18
- }
19
- }
20
-
21
- static async getLogs(connection: Pool, phoneNumber: string, msgId: string) {
22
- const crudServicce = new CurdService(connection);
23
- try {
24
- const qryString = `SELECT * FROM GupShup_Logs
25
- WHERE phone_number='${phoneNumber}' AND gupshup_msg_id = '${msgId}';`
26
- console.log("query", qryString)
27
- const result = await crudServicce.query(qryString);
28
- return result;
29
- } catch (error: any) {
30
- console.log(error.message);
31
- return error
32
- }
33
- }
34
-
35
- static async updateLogs(connection: Pool, phoneNumber: string, msgId: string, action: string, data: string) {
36
- const crudServicce = new CurdService(connection);
37
- try {
38
- const qryString = `UPDATE GupShup_Logs SET ${action} = '${data}' WHERE phone_number='${phoneNumber}' AND gupshup_msg_id = '${msgId}';`;
39
- console.log("qryString",qryString)
40
- const result = await crudServicce.query(qryString);
41
- return result
42
- } catch (error: any) {
43
- console.log(error.message);
44
- return error
45
- }
46
- }
47
-
48
-
49
- }
@@ -1,173 +0,0 @@
1
- import * as admin from "firebase-admin";
2
-
3
- class SubTaskGroup {
4
- private _id!: string | "";
5
- public get id(): string | "" {
6
- return this._id;
7
- }
8
- public set id(value: string | "") {
9
- this._id = value;
10
- }
11
-
12
- private _groupId!: string | "";
13
- public get groupId(): string | "" {
14
- return this._groupId;
15
- }
16
- public set groupId(value: string | "") {
17
- this._groupId = value;
18
- }
19
-
20
- private _title!: string | "";
21
- public get title(): string | "" {
22
- return this._title;
23
- }
24
- public set title(value: string | "") {
25
- this._title = value;
26
- }
27
-
28
- private _userId!: string;
29
- public get userId(): string {
30
- return this._userId;
31
- }
32
- public set userId(value: string) {
33
- this._userId = value;
34
- }
35
-
36
- private _companyId!: string;
37
- public get companyId(): string {
38
- return this._companyId;
39
- }
40
- public set companyId(value: string) {
41
- this._companyId = value;
42
- }
43
-
44
- constructor() {}
45
-
46
- argConstructor(
47
- id: string,
48
- groupId: string,
49
- title: string,
50
- userId: string,
51
- companyId: string
52
- ) {
53
- this.id = id;
54
- this.groupId = groupId;
55
- this.title = title;
56
- this.userId = userId;
57
- this.companyId = companyId;
58
- }
59
-
60
- fromJSON(subTaskGroup: string) {
61
- let subTaskGroupJSON = JSON.parse(subTaskGroup);
62
- this.groupId = subTaskGroupJSON["groupId"];
63
- this.id = subTaskGroupJSON["id"];
64
- this.title = subTaskGroupJSON["title"];
65
- this.userId = subTaskGroupJSON["userId"];
66
- this.companyId = subTaskGroupJSON["companyId"];
67
- }
68
-
69
- toJSON() {
70
- return {
71
- id: this.id,
72
- title: this.title,
73
- groupId: this.groupId,
74
- userId: this.userId,
75
- companyId: this.companyId,
76
- };
77
- }
78
-
79
- getValue(key: string) {
80
- switch (key) {
81
- case "id":
82
- return this.id;
83
- case "title":
84
- return this.title;
85
- case "groupId":
86
- return this.groupId;
87
- case "userId":
88
- return this.userId;
89
- case "companyId":
90
- return this.companyId;
91
- }
92
- }
93
-
94
- async save(firestore: admin.firestore.Firestore) {
95
- if (this.id == null || this.id == "" || this.id == undefined) {
96
- return {
97
- status: "ERROR",
98
- message: "Error Saving Task Group. ID Not Found",
99
- };
100
- } else {
101
- let subGroupDoc: admin.firestore.DocumentReference = firestore
102
- .collection("Companies")
103
- .doc(this.companyId)
104
- .collection("Task-Group")
105
- .doc(this.groupId);
106
-
107
- try {
108
- let groupData: admin.firestore.DocumentSnapshot =
109
- await subGroupDoc.get();
110
- if (groupData.get("subGroups").length > 0) {
111
- var allSGs = groupData.get("subGroups");
112
- allSGs.push(this.toJSON());
113
- console.log("allSGs", allSGs);
114
- await subGroupDoc.update({
115
- subGroups: allSGs,
116
- });
117
- } else {
118
- await subGroupDoc.update({
119
- subGroups: [this.toJSON()],
120
- });
121
- }
122
- } catch (e) {
123
- console.log("Error in updating sub group", e);
124
- }
125
-
126
- return { status: "OK", message: "Task Group Added Successfully" };
127
- }
128
- }
129
-
130
- static async updateSubGroup(
131
- firestore: admin.firestore.Firestore,
132
- body: any
133
- ) {
134
- try {
135
- console.log("The BODY IS ", body);
136
- let subGroupModel = body["extra"];
137
- console.log("The Sub Group Model is ", subGroupModel);
138
- let subGroup: SubTaskGroup = new SubTaskGroup();
139
- subGroup.fromJSON(JSON.stringify(subGroupModel));
140
- console.log("The subGroup model is ", subGroup.toJSON());
141
- let response;
142
- try {
143
- response = await subGroup.save(firestore);
144
- } catch (e) {
145
- console.log("Error in sub group", e);
146
- throw {
147
- message: "Error in sub group",
148
- status: 500
149
- }
150
- }
151
-
152
- // Delete Incoming Ref
153
- if (body["id"] != "") {
154
- if (response?.["status"] == "OK") {
155
- await firestore
156
- .collection("Incoming")
157
- .doc(body["id"])
158
- .delete();
159
- }
160
- }
161
- return {
162
- ...response
163
- }
164
- } catch(error: any) {
165
- return {
166
- error: error?.message ?? "Internal Server Error",
167
- status: error?.status ?? 500
168
- }
169
- }
170
- }
171
- }
172
-
173
- export { SubTaskGroup };
@@ -1,113 +0,0 @@
1
- import * as admin from "firebase-admin";
2
-
3
- class Tag {
4
- private _id!: string | "";
5
- public get id(): string | "" {
6
- return this._id;
7
- }
8
- public set id(value: string | "") {
9
- this._id = value;
10
- }
11
-
12
- private _value!: string | "";
13
- public get value(): string | "" {
14
- return this._value;
15
- }
16
- public set value(value: string | "") {
17
- this._value = value;
18
- }
19
-
20
- private _userId!: string | "";
21
- public get userId(): string | "" {
22
- return this._userId;
23
- }
24
- public set userId(value: string | "") {
25
- this._userId = value;
26
- }
27
-
28
- private _companyId!: string | "";
29
- public get companyId(): string | "" {
30
- return this._companyId;
31
- }
32
- public set companyId(value: string | "") {
33
- this._companyId = value;
34
- }
35
-
36
- constructor() {}
37
-
38
- argConstructor(id: string, value: string, userId: string, companyId: string) {
39
- this.id = id;
40
- this.value = value;
41
- this.userId = userId;
42
- this.companyId = companyId;
43
- }
44
-
45
- fromJSON(tag: string) {
46
- let tagJSON = JSON.parse(tag);
47
- this.id = tagJSON["id"] ?? "";
48
- this.value = tagJSON["value"] ?? null;
49
- this.userId = tagJSON["userId"] ?? null;
50
- this.companyId = tagJSON["companyId"] ?? null;
51
- }
52
-
53
- toJSON() {
54
- return {
55
- id: this.id,
56
- value: this.value,
57
- userId: this.userId,
58
- companyId: this.companyId,
59
- };
60
- }
61
-
62
- async save(firestore: admin.firestore.Firestore) {
63
- if (this.id == null || this.id == "" || this.id == undefined) {
64
- return { status: "ERROR", message: "Error Saving Tag. ID Not Found" };
65
- } else {
66
- let tagDoc: admin.firestore.DocumentReference = firestore
67
- .collection("Companies")
68
- .doc(this.companyId)
69
- .collection("Tags")
70
- .doc(this.id);
71
-
72
- await tagDoc.set(this.toJSON());
73
-
74
- return { status: "OK", message: "Tag Added Successfully" };
75
- }
76
- }
77
-
78
- // static async getOrCreateTag(
79
- // tagsModel: any,
80
- // firestore: admin.firestore.Firestore
81
- // ) {
82
- // if (tagsModel.get("id") != null || tagsModel.get("id") != "") {
83
- // Tags.updateTag(tagsModel, firestore);
84
- // } else {
85
- // var docRef: admin.firestore.DocumentReference = firestore
86
- // .collection("Companies")
87
- // .doc(tagsModel.get("companyId"))
88
- // .collection("Tags")
89
- // .doc();
90
-
91
- // tagsModel.set("id", docRef.id);
92
-
93
- // await docRef.set(tagsModel);
94
- // return "Successful Added";
95
- // }
96
- // }
97
-
98
- // static async updateTag(
99
- // tagsModel: Tags,
100
- // firestore: admin.firestore.Firestore
101
- // ) {
102
- // await firestore
103
- // .collection("Companies")
104
- // .doc(tagsModel.get("companyId"))
105
- // .collection("Tags")
106
- // .doc(tagsModel.get("id"))
107
- // .update(tagsModel);
108
-
109
- // return "Successfully Updated";
110
- // }
111
- }
112
-
113
- export { Tag };