mobioffice-cli 0.2.1 → 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.
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,681 +0,0 @@
1
- import * as admin from "firebase-admin";
2
- import { SubTaskGroup } from "./sub-task-group.model";
3
- import { Tag } from "./tags.model";
4
- import { TaskGroup } from "./task-group.model";
5
- import { Company } from "../company.model";
6
- import { Action } from "../action.model";
7
-
8
- class Task {
9
- private _id!: string | "";
10
- public get id(): string | "" {
11
- return this._id;
12
- }
13
- public set id(value: string | "") {
14
- this._id = value;
15
- }
16
-
17
- private _taskGroupId!: string | "";
18
- public get taskGroupId(): string | "" {
19
- return this._taskGroupId;
20
- }
21
- public set taskGroupId(value: string | "") {
22
- this._taskGroupId = value;
23
- }
24
-
25
- private _groupId!: string | "";
26
- public get groupId(): string | "" {
27
- return this._groupId;
28
- }
29
- public set groupId(value: string | "") {
30
- this._groupId = value;
31
- }
32
-
33
- private _title!: string | "";
34
- public get title(): string | "" {
35
- return this._title;
36
- }
37
- public set title(value: string | "") {
38
- this._title = value;
39
- }
40
-
41
- private _description!: string | "";
42
- public get description(): string | "" {
43
- return this._description;
44
- }
45
- public set description(value: string | "") {
46
- this._description = value;
47
- }
48
-
49
- private _priority!: string | "";
50
- public get priority(): string | "" {
51
- return this._priority;
52
- }
53
- public set priority(value: string | "") {
54
- this._priority = value;
55
- }
56
-
57
- private _assignee!: string[] | [];
58
- public get assignee(): string[] | [] {
59
- return this._assignee;
60
- }
61
- public set assignee(value: string[] | []) {
62
- this._assignee = value;
63
- }
64
-
65
- private _assets!: string[] | [];
66
- public get assets(): string[] | [] {
67
- return this._assets;
68
- }
69
- public set assets(value: string[] | []) {
70
- this._assets = value;
71
- }
72
-
73
- private _locations!: string[] | [];
74
- public get locations(): string[] | [] {
75
- return this._locations;
76
- }
77
- public set locations(value: string[] | []) {
78
- this._locations = value;
79
- }
80
-
81
- private _watchers!: string[] | [];
82
- public get watchers(): string[] | [] {
83
- return this._watchers;
84
- }
85
- public set watchers(value: string[] | []) {
86
- this._watchers = value;
87
- }
88
-
89
- private _reminderDate!: number | null;
90
- public get reminderDate(): number | null {
91
- return this._reminderDate;
92
- }
93
- public set reminderDate(value: number | null) {
94
- this._reminderDate = value;
95
- }
96
-
97
- private _deadlineDate!: number | null;
98
- public get deadlineDate(): number | null {
99
- return this._deadlineDate;
100
- }
101
- public set deadlineDate(value: number | null) {
102
- this._deadlineDate = value;
103
- }
104
-
105
- private _tags!: Tag[] | [];
106
- public get tags(): Tag[] | [] {
107
- return this._tags;
108
- }
109
- public set tags(value: Tag[] | []) {
110
- this._tags = value;
111
- }
112
-
113
- private _subGroupId!: string;
114
- public get subGroupId(): string {
115
- return this._subGroupId;
116
- }
117
- public set subGroupId(value: string) {
118
- this._subGroupId = value;
119
- }
120
-
121
- private cancelActionId!: string;
122
-
123
- // private _taskGroup!: TaskGroup | null;
124
- // public get taskGroup(): TaskGroup | null {
125
- // return this._taskGroup;
126
- // }
127
- // public set taskGroup(value: TaskGroup | null) {
128
- // this._taskGroup = value;
129
- // }
130
-
131
- // private _subTaskGroup!: SubTaskGroup | null;
132
- // public get subTaskGroup(): SubTaskGroup | null {
133
- // return this._subTaskGroup;
134
- // }
135
- // public set subTaskGroup(value: SubTaskGroup | null) {
136
- // this._subTaskGroup = value;
137
- // }
138
-
139
- private _updatedAt!: number | null;
140
- public get updatedAt(): number | null {
141
- return this._updatedAt;
142
- }
143
- public set updatedAt(value: number | null) {
144
- this._updatedAt = value;
145
- }
146
-
147
- private _createdAt!: number | null;
148
- public get createdAt(): number | null {
149
- return this._createdAt;
150
- }
151
- public set createdAt(value: number | null) {
152
- this._createdAt = value;
153
- }
154
-
155
- private _isCompleted!: boolean | false;
156
- public get isCompleted(): boolean | false {
157
- return this._isCompleted;
158
- }
159
- public set isCompleted(value: boolean | false) {
160
- this._isCompleted = value;
161
- }
162
-
163
- private _parentTaskId!: string | "";
164
- public get parentTaskId(): string | "" {
165
- return this._parentTaskId;
166
- }
167
- public set parentTaskId(value: string | "") {
168
- this._parentTaskId = value;
169
- }
170
-
171
- private _order!: number | null;
172
- public get order(): number | null {
173
- return this._order;
174
- }
175
- public set order(value: number | null) {
176
- this._order = value;
177
- }
178
-
179
- private _subTasks!: string[] | [];
180
- public get subTasks(): string[] | [] {
181
- return this._subTasks;
182
- }
183
- public set subTasks(value: string[] | []) {
184
- this._subTasks = value;
185
- }
186
-
187
- private _companyId!: string | "";
188
- public get companyId(): string | "" {
189
- return this._companyId;
190
- }
191
- public set companyId(value: string | "") {
192
- this._companyId = value;
193
- }
194
-
195
- private _actionId!: string | "";
196
- public get actionId(): string | "" {
197
- return this._actionId;
198
- }
199
- public set actionId(value: string | "") {
200
- this._actionId = value;
201
- }
202
-
203
- private _csTaskId!: string | "";
204
- public get csTaskId(): string | "" {
205
- return this._csTaskId;
206
- }
207
- public set csTaskId(value: string | "") {
208
- this._csTaskId = value;
209
- }
210
-
211
- constructor() {}
212
-
213
- argConstructor(
214
- id: string | "",
215
- taskGroupId: string | "",
216
- groupId: string | "",
217
- title: string | "",
218
- description: string,
219
- priority: string,
220
- assignee: string[],
221
- assets:string[],
222
- locations:string[],
223
- watchers: string[],
224
- reminderDate: number,
225
- deadlineDate: number,
226
- tags: Tag[],
227
- subGroupId: string,
228
- updatedAt: number,
229
- createdAt: number,
230
- isCompleted: boolean,
231
- parentTaskId: string,
232
- order: number,
233
- subtasks: string[],
234
- actionId: string,
235
- csTaskId: string,
236
- cancelActionId: string
237
- ) {
238
- this.id = id;
239
- this.assignee = assignee;
240
- this.deadlineDate = deadlineDate;
241
- this.description = description;
242
- this.groupId = groupId;
243
- this.order = order;
244
- this.assets = assets;
245
- this.locations = locations;
246
- this.taskGroupId = taskGroupId;
247
- this.title = title;
248
- this.priority = priority;
249
- this.watchers = watchers;
250
- this.reminderDate = reminderDate;
251
- this.tags = tags;
252
- this.subGroupId = subGroupId;
253
- this.updatedAt = updatedAt;
254
- this.createdAt = createdAt;
255
- this.isCompleted = isCompleted;
256
- this.parentTaskId = parentTaskId;
257
- this.subTasks = subtasks;
258
- this.actionId = actionId;
259
- this.csTaskId = csTaskId;
260
- this.cancelActionId = cancelActionId;
261
- }
262
-
263
- fromJSON(task: string) {
264
- let taskJSON = JSON.parse(task);
265
- this.id = taskJSON["id"] ?? null;
266
- this.assignee = taskJSON["assignee"] ?? null;
267
- this.assets = taskJSON["assets"] ?? null;
268
- this.locations = taskJSON["locations"] ?? null;
269
- this.deadlineDate = taskJSON["deadlineDate"] ?? null;
270
- this.description = taskJSON["description"] ?? null;
271
- this.groupId = taskJSON["groupId"] ?? null;
272
- this.order = parseInt(taskJSON["order"]) ?? null;
273
- this.taskGroupId = taskJSON["taskGroupId"] ?? null;
274
- this.title = taskJSON["title"] ?? null;
275
- this.priority = taskJSON["priority"] ?? null;
276
- this.watchers = taskJSON["watchers"] ?? null;
277
- this.reminderDate = taskJSON["reminderDate"] ?? null;
278
- this.subGroupId = taskJSON["subGroupId"] ?? null;
279
- this.updatedAt = taskJSON["updatedAt"] ?? null;
280
- this.createdAt = taskJSON["createdAt"] ?? null;
281
- this.isCompleted = taskJSON["isCompleted"] ?? null;
282
- this.parentTaskId = taskJSON["parentTaskId"] ?? null;
283
- this.subTasks = taskJSON["subTasks"] ?? [];
284
- this.companyId = taskJSON["companyId"] ?? null;
285
- this.actionId = taskJSON["actionId"] ?? null;
286
- this.csTaskId = taskJSON["csTaskId"];
287
- this.cancelActionId = taskJSON["cancelActionId"];
288
- if (taskJSON["tags"] != null) {
289
- let allTags = taskJSON["tags"];
290
-
291
- let arrayOfTagObjs = [];
292
- for (let tag of allTags) {
293
- let aTag = new Tag();
294
- aTag.fromJSON(JSON.stringify(tag));
295
- arrayOfTagObjs.push(aTag);
296
- }
297
-
298
- this.tags = arrayOfTagObjs;
299
- }
300
- }
301
-
302
- toJSON() {
303
- let allTagJSON = [];
304
- if (this.tags != null && this.tags != undefined) {
305
- let allTagObjs = this.tags;
306
- for (let tag of allTagObjs) {
307
- allTagJSON.push(tag.toJSON());
308
- }
309
- }
310
- return {
311
- id: this.id,
312
- assignee: this.assignee ?? [],
313
- deadlineDate: this.deadlineDate ?? null,
314
- description: this.description ?? "",
315
- groupId: this.groupId ?? "",
316
- order: this.order ?? 0,
317
- assets: this.assets ?? null,
318
- locations: this.locations ?? null,
319
- taskGroupId: this.taskGroupId ?? null,
320
- title: this.title ?? null,
321
- priority: this.priority ?? null,
322
- watchers: this.watchers ?? null,
323
- reminderDate: this.reminderDate ?? null,
324
- tags: allTagJSON ?? null,
325
- subGroupId: this.subGroupId ?? null,
326
- updatedAt: this.updatedAt ?? null,
327
- createdAt: this.createdAt ?? null,
328
- isCompleted: this.isCompleted ?? null,
329
- parentTaskId: this.parentTaskId ?? "pt",
330
- subTasks: this.subTasks ?? null,
331
- companyId: this.companyId ?? null,
332
- actionId: this.actionId ?? null,
333
- csTaskId: this.csTaskId ?? null,
334
- cancelActionId: this.cancelActionId ?? null
335
- };
336
- }
337
-
338
- async save(firestore: admin.firestore.Firestore) {
339
- // Checking if the ID is null
340
- if (this.id == null || this.id == "" || this.id == undefined) {
341
- return { status: "ERROR", message: "Error Saving Task. ID Not Found" };
342
- } else {
343
- let taskDoc: admin.firestore.DocumentReference = firestore
344
- .collection("Companies")
345
- .doc(this.companyId)
346
- .collection("Tasks")
347
- .doc(this.id);
348
-
349
- console.log("id => " + this.id + "company id => " + this.companyId);
350
-
351
- if (
352
- this.parentTaskId != null &&
353
- this.parentTaskId != "pt" &&
354
- this.parentTaskId != undefined
355
- ) {
356
- let parentTaskDoc: admin.firestore.DocumentReference = firestore
357
- .collection("Companies")
358
- .doc(this.companyId)
359
- .collection("Tasks")
360
- .doc(this.parentTaskId);
361
- let parentDoc:any = (await parentTaskDoc.get()).data()
362
- console.log(
363
- "id => " + this.parentTaskId + "company id => " + this.companyId + "parentTaksDoc =>"+ {...parentDoc}
364
- );
365
-
366
- try {
367
- parentDoc.subTasks.push(this.id)
368
- await parentTaskDoc.update({
369
- subTasks: parentDoc.subTasks,
370
- });
371
- } catch (e) {
372
- console.log("Error in task", e);
373
- }
374
- }
375
-
376
- try {
377
- await taskDoc.set(this.toJSON());
378
- } catch (e) {
379
- console.log("Error in task", e);
380
- }
381
-
382
- return {
383
- status: "OK",
384
- id:taskDoc.id,
385
- message: "Task Added Successfully",
386
- };
387
- }
388
- }
389
-
390
- static async markTaskAsCompleted(
391
- firestore: admin.firestore.Firestore,
392
- companyId: string,
393
- taskId: string
394
- ) {
395
- try {
396
-
397
- console.log("TaskId", taskId);
398
- const taskDocs = await firestore
399
- .collection("Companies")
400
- .doc(companyId)
401
- .collection("Tasks")
402
- .where("id", "==", `${taskId}`)
403
- .get();
404
- console.log("here---------------");
405
- const taskDoc = taskDocs.docs[0];
406
- const updationRes = await taskDoc.ref.update({
407
- isCompleted: true,
408
- });
409
- return updationRes;
410
- } catch(error) {
411
- throw new Error("Something Went wrong while updating");
412
- }
413
- }
414
-
415
- static async checkIsParentTaskCompleted(firestore: admin.firestore.Firestore,
416
- companyId: string,
417
- taskId: string
418
- ) {
419
- try {
420
- const taskDocs = await firestore.collection("Companies")
421
- .doc(companyId)
422
- .collection("Tasks")
423
- .where("id", "==", taskId)
424
- .get();
425
- if (taskDocs.docs.length) {
426
- const taskInfo = taskDocs.docs[0].data();
427
- const parentTaskId = taskInfo.parentTaskId;
428
- if (parentTaskId) {
429
- const parentTaskList = await firestore.collection("Companies")
430
- .doc(companyId)
431
- .collection("Tasks")
432
- .where("id", "==", parentTaskId)
433
- .get();
434
- if (parentTaskList.docs.length) {
435
- const parentTaskInfo = parentTaskList.docs[0].data();
436
- const subTasksIdList = parentTaskInfo.subTasks;
437
- const subTasksList = await firestore.collection("Companies")
438
- .doc(companyId)
439
- .collection("Tasks")
440
- .where("id", "in", subTasksIdList)
441
- .get();
442
- const parentTaskStatus = subTasksList.docs.every((subTaskDoc) => {
443
- const subTaskInfo = subTaskDoc.data();
444
- return subTaskInfo.isCompleted
445
- })
446
- return {
447
- status: parentTaskStatus,
448
- parentTaskId: parentTaskId
449
- }
450
- } else {
451
- return {
452
- parentTaskId: parentTaskId,
453
- status: null
454
- }
455
- }
456
- } else {
457
- return {
458
- parentTaskId: null,
459
- status: null
460
- }
461
- }
462
- } else {
463
- return null;
464
- }
465
- } catch(error: any) {
466
- console.log(error.message);
467
- throw {
468
- message: error.message
469
- }
470
- }
471
- }
472
-
473
- static async createTaskAction(
474
- firestore: admin.firestore.Firestore,
475
- body: any
476
- ) {
477
- try {
478
- const nickname = "child_safety";
479
- const companyId = await Company.getCompanyIdByNickName(firestore, nickname);
480
- console.log(companyId);
481
- console.log("-----------------", body.inputsList);
482
- let inputTypes = body.inputsList;
483
- let docId: string;
484
- let newDoc;
485
- if (inputTypes) {
486
- docId = inputTypes.join("_");
487
- } else {
488
- throw {
489
- message: "Please Provide inputs list",
490
- status: 400
491
- }
492
- }
493
- inputTypes = [
494
- "select_location",
495
- "select_asset",
496
- ...body.inputsList,
497
- "summary",
498
- ];
499
- const taskActionsDoc = await firestore
500
- .collection("Companies")
501
- .doc(companyId)
502
- .collection("TaskActions")
503
- .doc(docId)
504
- .get();
505
- const actionId = await Action.getActionId(
506
- firestore,
507
- companyId,
508
- "completeTask"
509
- );
510
- if (taskActionsDoc.exists) {
511
- return {
512
- status: 200,
513
- taskActions: docId,
514
- message: "Successfully fetched taskActions",
515
- };
516
- } else {
517
- newDoc = firestore
518
- .collection("Companies")
519
- .doc(companyId)
520
- .collection("TaskActions")
521
- .doc(docId);
522
- const taskActionDoc = await firestore
523
- .collection("Companies")
524
- .doc(companyId)
525
- .collection("Actions")
526
- .doc(actionId)
527
- .get();
528
- const newAction: any = taskActionDoc.data();
529
- newAction.id = newDoc.id;
530
- newAction.name = docId;
531
- console.log(newAction);
532
- await newDoc.set(newAction);
533
- console.log("newDocId", newDoc.id);
534
- }
535
- const feedDetailScreen = this.defFeedObj();
536
- feedDetailScreen.screen_title = "Task Details"
537
- await Promise.all(
538
- inputTypes.map(async (inputType: string, idx: number) => {
539
- console.log("actionId", actionId);
540
- console.log("inputType", inputType);
541
- const taskStep = await firestore
542
- .collection("Companies")
543
- .doc(companyId)
544
- .collection("Actions")
545
- .doc(actionId)
546
- .collection("task_completion_steps")
547
- .where("step_selector_key", "==", inputType)
548
- .get();
549
- // console.log("teskStepdata", taskStep);
550
- if (taskStep.empty) {
551
- throw "Invalid input type received.";
552
- } else {
553
- const doc = await firestore
554
- .collection("Companies")
555
- .doc(companyId)
556
- .collection("TaskActions")
557
- .doc(docId)
558
- .get();
559
- const newStep = taskStep.docs[0].data();
560
- newStep.order = idx;
561
- console.log("newStep =>", newStep);
562
- if (newStep.step_selector_key != "summary") {
563
- feedDetailScreen.data[0]["children"].push({
564
- type: this.type(newStep.fieldType),
565
- title: newStep.label,
566
- isMultiText:(newStep.fieldType ==='InputField' && !!newStep.field.isMultiInput)||newStep.fieldType ==='CheckList',
567
- key: newStep.field["keyForAPI"],
568
- });
569
- }
570
- const newDocRef = doc.ref.collection("task_completion_steps").doc();
571
- newStep.id = newDocRef.id;
572
- await newDocRef.set(newStep);
573
- // await newDoc.set(taskStep.docs[0].data());
574
- }
575
- })
576
- );
577
- feedDetailScreen.actionName = docId;
578
- console.log(JSON.stringify(feedDetailScreen));
579
- const fdsRef = firestore.collection("Companies")
580
- .doc(companyId)
581
- .collection("Feed-Details-Screen")
582
- .doc();
583
- feedDetailScreen.id = fdsRef.id;
584
- console.log(feedDetailScreen);
585
- await fdsRef.set(feedDetailScreen);
586
- return {
587
- status: 200,
588
- taskActions: docId,
589
- message: "Successfully created the taskAction"
590
- }
591
- } catch(error: any) {
592
- return {
593
- status: error?.status ?? 500,
594
- error: error?.message ?? "Internal Server Error"
595
- }
596
- }
597
- }
598
-
599
- static defFeedObj() {
600
- const children: any[] = [];
601
- return {
602
- "screen_title": "",
603
- "id": "",
604
- "cancelActionId": "",
605
- "data": [
606
- {
607
- "children": children,
608
- "height": "",
609
- "order": 0
610
- }
611
- ],
612
- "actionName": "worklog"
613
- }
614
- }
615
- static type(fieldType:string):string{
616
- console.log(fieldType)
617
- if(fieldType ==='InputField' || fieldType === 'CheckList' || fieldType === 'RadioList') return 'text'
618
- if(fieldType === 'datePicker') return 'date '
619
- if(fieldType === 'timePicker') return 'time '
620
- if(fieldType === 'ImagePicker' || fieldType === 'Selfie') return 'image'
621
- if(fieldType === 'MultiImagePicker') return 'multiImage'
622
- return "text"
623
- }
624
- static async addUpdateTask(
625
- firestore: admin.firestore.Firestore,
626
- body: any
627
- ) {
628
- try {
629
- let taskModel = body["extra"];
630
- console.log("The Task Model is ", taskModel);
631
- console.log("--------taskModel-------", taskModel);
632
-
633
- let newTask: Task = new Task();
634
- try {
635
- newTask.fromJSON(JSON.stringify(taskModel)); // id == ""
636
- } catch (e) {
637
- console.log("Error running newTask.fromJSON()", e);
638
- throw {
639
- message: "Error running newTask.fromJSON()",
640
- status: 500
641
- }
642
- }
643
- console.log("the newTask is ", newTask.toJSON());
644
-
645
- let response;
646
- try {
647
- console.log(
648
- "newTask.id => ",
649
- newTask.id,
650
- "newTask.companyId => ",
651
- newTask.companyId
652
- );
653
- response = await newTask.save(firestore);
654
- } catch (e) {
655
- console.log("ERROR saving task ", e);
656
- throw {
657
- message: "ERROR saving task"
658
- }
659
- }
660
- // Delete Incoming Ref
661
- if (body["id"] != "") {
662
- if (response?.["status"] == "OK") {
663
- await firestore
664
- .collection("Incoming")
665
- .doc(body["id"])
666
- .delete();
667
- }
668
- }
669
- return {
670
- ...response
671
- }
672
- } catch(error: any) {
673
- return {
674
- error: error?.message ?? "Internal Server Error",
675
- status: error?.status ?? 500
676
- }
677
- }
678
- }
679
- }
680
-
681
- export { Task };