cityworks 0.0.51 → 0.0.53

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 (45) hide show
  1. package/README.md +1 -1
  2. package/dist/activity_link.js +219 -0
  3. package/dist/attachments.d.ts +59 -0
  4. package/dist/briefcase.d.ts +28 -7
  5. package/dist/briefcase.js +327 -0
  6. package/dist/case_admin.d.ts +0 -22
  7. package/dist/case_admin.js +821 -0
  8. package/dist/case_assets.js +129 -0
  9. package/dist/case_data.js +416 -0
  10. package/dist/case_financial.js +848 -0
  11. package/dist/case_workflow.js +455 -0
  12. package/dist/comments.js +126 -0
  13. package/dist/error.js +30 -0
  14. package/dist/event_layer.d.ts +97 -0
  15. package/dist/event_layer.js +207 -0
  16. package/dist/general.d.ts +23 -0
  17. package/dist/general.js +212 -0
  18. package/dist/gis.js +250 -0
  19. package/dist/index.d.ts +10 -8
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.m.js +1 -1
  23. package/dist/index.m.js.map +1 -1
  24. package/dist/index.modern.mjs +1 -1
  25. package/dist/index.modern.mjs.map +1 -1
  26. package/dist/index.umd.js +1 -1
  27. package/dist/index.umd.js.map +1 -1
  28. package/dist/inspection.d.ts +17 -1
  29. package/dist/inspection.js +933 -0
  30. package/dist/inspection_admin.js +43 -0
  31. package/dist/inspection_costs.js +200 -0
  32. package/dist/message_queue.js +248 -0
  33. package/dist/query.d.ts +108 -0
  34. package/dist/query.js +242 -0
  35. package/dist/request.d.ts +5 -1
  36. package/dist/request.js +899 -0
  37. package/dist/request_admin.js +32 -0
  38. package/dist/request_costs.js +113 -0
  39. package/dist/search.d.ts +12 -1
  40. package/dist/search.js +371 -0
  41. package/dist/workorder.d.ts +4 -0
  42. package/dist/workorder.js +951 -0
  43. package/dist/workorder_admin.js +248 -0
  44. package/dist/workorder_costs.js +274 -0
  45. package/package.json +7 -2
@@ -0,0 +1,455 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CaseWorkflow = void 0;
4
+ var error_1 = require("./error");
5
+ var _ = require('lodash');
6
+ var comments_1 = require("./comments");
7
+ var CaseWorkflow = /** @class */ (function () {
8
+ /**
9
+ * @hidden
10
+ */
11
+ function CaseWorkflow(cw) {
12
+ this.cw = cw;
13
+ this.task = {
14
+ comment: new comments_1.Comments(cw, 'CaTask')
15
+ };
16
+ }
17
+ /**
18
+ * Adds a task to the case specified by the CaObectId.
19
+ *
20
+ * @category Tasks
21
+ * @param {number} caObjectId - The Case Object to attach the task to
22
+ * @param {number} taskId - The task ID to add to the case workflow
23
+ * @param {number} startPoint - The start point in the workflow for the task
24
+ * @param {number} endPoint - The end point in the workflow for the task
25
+ * @param {Object} [options] - Options for the Task. See /{subdirectory}/apidocs/#/service-info/Pll/CaseTask
26
+ * @return {Object} Returns Promise that represents an object describing CaTaskItemBase.
27
+ */
28
+ CaseWorkflow.prototype.addTask = function (caObjectId, taskId, startPoint, endPoint, options) {
29
+ var _this = this;
30
+ return new Promise(function (resolve, reject) {
31
+ var data = {
32
+ CaObjectId: caObjectId,
33
+ TaskId: taskId,
34
+ StartPoint: startPoint,
35
+ EndPoint: endPoint
36
+ };
37
+ if (typeof (options) != 'undefined') {
38
+ data = _.merge(data, options);
39
+ }
40
+ _this.cw.runRequest('Pll/CaseTask/Add', data).then(function (r) {
41
+ resolve(r.Value);
42
+ }).catch(function (e) {
43
+ reject(e);
44
+ });
45
+ });
46
+ };
47
+ /**
48
+ * Add Task Result
49
+ *
50
+ * @category Task Results
51
+ * @param {number} caObjectId - The Case Object to attach the task to
52
+ * @param {number} caTaskId - The Case task ID to add the result to
53
+ * @param {number} resultCode - The result Code
54
+ * @param {number} resultID - The result ID
55
+ * @param {number} resultSetID - The result set ID
56
+ * @param {Object} [options] - Options for the Task. See /{subdirectory}/apidocs/#/service-info/Pll/CaseTaskResults
57
+ * @return {Object} Returns Promise that represents an object describing CaTaskResultsItem.
58
+ */
59
+ CaseWorkflow.prototype.addTaskResult = function (caObjectId, caTaskId, resultCode, resultID, resultSetID, options) {
60
+ var _this = this;
61
+ return new Promise(function (resolve, reject) {
62
+ var data = {
63
+ CaObjectId: caObjectId,
64
+ CaTaskId: caTaskId,
65
+ ResultCode: resultCode,
66
+ ResultID: resultID,
67
+ ResultSetID: resultSetID
68
+ };
69
+ if (typeof (options) != 'undefined') {
70
+ data = _.merge(data, options);
71
+ }
72
+ _this.cw.runRequest('Pll/CaseTaskResults/Add', data).then(function (r) {
73
+ resolve(r.Value);
74
+ }).catch(function (e) {
75
+ reject(e);
76
+ });
77
+ });
78
+ };
79
+ /**
80
+ * Add Task Comment
81
+ *
82
+ * @category Comments
83
+ * @param {number} caTaskId - The Case task ID of the task to add the comment to
84
+ * @param {string} comment - The comment text
85
+ * @return {Object} Returns Promise that represents an object describing CaTaskCommentsItemBase.
86
+ */
87
+ CaseWorkflow.prototype.addTaskComment = function (caTaskId, comment) {
88
+ var _this = this;
89
+ return new Promise(function (resolve, reject) {
90
+ var data = {
91
+ CaTaskId: caTaskId,
92
+ CommentText: comment
93
+ };
94
+ _this.cw.runRequest('Pll/CaseTaskComments/Add', data).then(function (r) {
95
+ resolve(r.Value);
96
+ }).catch(function (e) {
97
+ reject(e);
98
+ });
99
+ });
100
+ };
101
+ /**
102
+ * Get tasks by CaObjectId
103
+ *
104
+ * @category Tasks
105
+ * @param {number} caObjectId - The Case Object to get the attached tasks
106
+ * @param {boolean} checkRelatedItems - Wherther to check related items. Defaults to false.
107
+ * @return {Object} Returns Promise that represents a collection of the CaTaskItemBases.
108
+ */
109
+ CaseWorkflow.prototype.getTasksByCaseId = function (caObjectId, checkRelatedItems) {
110
+ var _this = this;
111
+ if (checkRelatedItems === void 0) { checkRelatedItems = false; }
112
+ return new Promise(function (resolve, reject) {
113
+ var data = {
114
+ CaObjectId: caObjectId,
115
+ CheckRelatedItems: checkRelatedItems
116
+ };
117
+ _this.cw.runRequest('Pll/CaseTask/ByCaObjectId', data).then(function (r) {
118
+ resolve(r.Value);
119
+ }).catch(function (e) {
120
+ reject(e);
121
+ });
122
+ });
123
+ };
124
+ /**
125
+ * Get tasks by TaskIds
126
+ *
127
+ * @category Tasks
128
+ * @param {Array<number>} caTaskIds - The IDs of the tasks to retrieve
129
+ * @param {boolean} checkRelatedItems - Wherther to check related items. Defaults to false.
130
+ * @return {Object} Returns Promise that represents a collection of the CaTaskItemBases.
131
+ */
132
+ CaseWorkflow.prototype.getTasksById = function (caTaskIds, checkRelatedItems) {
133
+ var _this = this;
134
+ if (checkRelatedItems === void 0) { checkRelatedItems = false; }
135
+ return new Promise(function (resolve, reject) {
136
+ var data = {
137
+ CaTaskIds: caTaskIds,
138
+ CheckRelatedItems: checkRelatedItems
139
+ };
140
+ _this.cw.runRequest('Pll/CaseTask/ByIds', data).then(function (r) {
141
+ resolve(r.Value);
142
+ }).catch(function (e) {
143
+ reject(e);
144
+ });
145
+ });
146
+ };
147
+ /**
148
+ * Get CaTaskResultsItem by CaTaskIds
149
+ *
150
+ * @category Task Results
151
+ * @param {Array<number>} caTaskIds - The IDs of the tasks for which to retrieve results
152
+ * @return {Object} Returns Promise that represents a collection of CaTaskResultsItems.
153
+ */
154
+ CaseWorkflow.prototype.getResultsByTaskId = function (caTaskIds) {
155
+ var _this = this;
156
+ return new Promise(function (resolve, reject) {
157
+ var data = {
158
+ CaTaskIds: caTaskIds
159
+ };
160
+ _this.cw.runRequest('Pll/CaseTaskResults/ByCaTaskIds', data).then(function (r) {
161
+ resolve(r.Value);
162
+ }).catch(function (e) {
163
+ reject(e);
164
+ });
165
+ });
166
+ };
167
+ /**
168
+ * Search for CaseTaskComments by CaTaskId
169
+ *
170
+ * @category Comments
171
+ * @param {number} caTaskId - The task ID for which to retrieve attached comments
172
+ * @return {Object} Returns Promise that represents a collection of CommentRecords.
173
+ */
174
+ CaseWorkflow.prototype.getCommentsForTask = function (caTaskId) {
175
+ var _this = this;
176
+ return new Promise(function (resolve, reject) {
177
+ var data = {
178
+ caTaskId: caTaskId
179
+ };
180
+ _this.cw.runRequest('Pll/CaseTaskComments/ByCaTaskId', data).then(function (r) {
181
+ resolve(r.Value);
182
+ }).catch(function (e) {
183
+ reject(e);
184
+ });
185
+ });
186
+ };
187
+ /**
188
+ * Search for CaseTaskComments by CaTaskId
189
+ *
190
+ * @category Comments
191
+ * @param {Array<number>} caTaskIds - The task IDs for which to retrieve attached comments
192
+ * @return {Object} Returns Promise that represents a collection of CaTaskCommentsItemBase.
193
+ */
194
+ CaseWorkflow.prototype.getCommentsForTasks = function (caTaskIds) {
195
+ var _this = this;
196
+ return new Promise(function (resolve, reject) {
197
+ var data = {
198
+ caTaskIds: caTaskIds
199
+ };
200
+ _this.cw.runRequest('Pll/CaseTaskComments/ByCaTaskIds', data).then(function (r) {
201
+ resolve(r.Value);
202
+ }).catch(function (e) {
203
+ reject(e);
204
+ });
205
+ });
206
+ };
207
+ /**
208
+ * Updates a task
209
+ *
210
+ * @category Tasks
211
+ * @param {number} caTaskId - The Case Object to attach the task to
212
+ * @param {Object} [options] - Options for Task. See /{subdirectory}/apidocs/#/service-info/Pll/CaseTask
213
+ * @return {Object} Returns Promise that represents an object describing CaTaskItemBase.
214
+ */
215
+ CaseWorkflow.prototype.updateTask = function (caTaskId, options) {
216
+ var _this = this;
217
+ return new Promise(function (resolve, reject) {
218
+ var data = {
219
+ CaTaskId: caTaskId
220
+ };
221
+ if (typeof (options) != 'undefined') {
222
+ data = _.merge(data, options);
223
+ }
224
+ _this.cw.runRequest('Pll/CaseTask/Update', data).then(function (r) {
225
+ resolve(r.Value);
226
+ }).catch(function (e) {
227
+ reject(e);
228
+ });
229
+ });
230
+ };
231
+ /**
232
+ * Update Task Comment
233
+ *
234
+ * @category Comments
235
+ * @param {number} caTaskCommentId - The Case task ID of the task to add the comment to
236
+ * @param {string} comment - The comment text
237
+ * @param {number} commentId - Probably unnecessary?
238
+ * @return {Object} Returns Promise that represents an object describing CaTaskCommentsItemBase.
239
+ */
240
+ CaseWorkflow.prototype.updateTaskComment = function (caTaskCommentId, comment, commentId) {
241
+ var _this = this;
242
+ return new Promise(function (resolve, reject) {
243
+ var data = {
244
+ CaTaskCommentId: caTaskCommentId,
245
+ CommentText: comment
246
+ };
247
+ if (typeof (commentId) != 'undefined') {
248
+ _.set(data, 'CommentId', commentId);
249
+ }
250
+ _this.cw.runRequest('Pll/CaseTaskComments/Update', data).then(function (r) {
251
+ resolve(r.Value);
252
+ }).catch(function (e) {
253
+ reject(e);
254
+ });
255
+ });
256
+ };
257
+ /**
258
+ * Updates a task
259
+ *
260
+ * @category Tasks
261
+ * @param {number} caTaskId - The Case Object to attach the task to
262
+ * @param {string} resultCode - The result code to set for the specified Task
263
+ * @param {Object} [options] - Options for Task. Specify either or both TaskCompletedBy & TaskCompleteDate. See /{subdirectory}/apidocs/#/service-info/Pll/CaseTask
264
+ * @return {Object} Returns Promise that represents an object describing CaTaskItemBase.
265
+ */
266
+ CaseWorkflow.prototype.setTaskResult = function (caTaskId, resultCode, options) {
267
+ var _this = this;
268
+ return new Promise(function (resolve, reject) {
269
+ var data = {
270
+ CaTaskId: caTaskId
271
+ };
272
+ if (_.intersectionBy(_.keysIn(options), ['TaskCompleteDate', 'TaskCompletedBy']).length == 0) {
273
+ reject(new error_1.CWError(2, 'At least one of the attributes (TaskCompletedBy, TaskCompleteDate) must be defined.'));
274
+ }
275
+ if (typeof (options) != 'undefined') {
276
+ data = _.merge(data, options);
277
+ }
278
+ _this.cw.runRequest('Pll/CaseTask/SetResult', data).then(function (r) {
279
+ resolve(r.Value);
280
+ }).catch(function (e) {
281
+ reject(e);
282
+ });
283
+ });
284
+ };
285
+ /**
286
+ * Deletes a task by TaskID
287
+ *
288
+ * @category Tasks
289
+ * @param {number} caTaskId - The caTaskId for the task which should be deleted
290
+ * @return {Object} Returns Promise that represents an object describing CaTaskItemBase.
291
+ */
292
+ CaseWorkflow.prototype.deleteTask = function (caTaskId) {
293
+ var _this = this;
294
+ return new Promise(function (resolve, reject) {
295
+ var data = {
296
+ CaTaskId: caTaskId
297
+ };
298
+ _this.cw.runRequest('Pll/CaseTask/Delete', data).then(function (r) {
299
+ resolve(r.Value);
300
+ }).catch(function (e) {
301
+ reject(e);
302
+ });
303
+ });
304
+ };
305
+ /**
306
+ * Deletes a task by TaskID
307
+ *
308
+ * @category Tasks
309
+ * @param {number} caTaskId - The caTaskId for the task which should be deleted
310
+ * @return {Object} Returns Promise that represents the number of the CaObjectID
311
+ */
312
+ CaseWorkflow.prototype.deleteTasksOnCase = function (caObjectId) {
313
+ var _this = this;
314
+ return new Promise(function (resolve, reject) {
315
+ var data = {
316
+ CaObjectId: caObjectId
317
+ };
318
+ _this.cw.runRequest('Pll/CaseTask/DeleteByCaObjectId', data).then(function (r) {
319
+ resolve(r.Value);
320
+ }).catch(function (e) {
321
+ reject(e);
322
+ });
323
+ });
324
+ };
325
+ /**
326
+ * Deletes tasks by TaskID
327
+ *
328
+ * @category Comments
329
+ * @param {Array<number>} caTaskCommentIds - The comments to delete
330
+ * @return {Object} Returns Promise that represents a dictionary of comment IDs.
331
+ */
332
+ CaseWorkflow.prototype.deleteTaskComments = function (caTaskCommentIds) {
333
+ var _this = this;
334
+ return new Promise(function (resolve, reject) {
335
+ var data = {
336
+ CaTaskCommentIds: caTaskCommentIds
337
+ };
338
+ _this.cw.runRequest('Pll/CaseTaskComments/Delete', data).then(function (r) {
339
+ resolve(r.Value);
340
+ }).catch(function (e) {
341
+ reject(e);
342
+ });
343
+ });
344
+ };
345
+ /**
346
+ * Search for Case Tasks. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
347
+ *
348
+ * @category Tasks
349
+ * @param {Object} filters - The parameters to search by. (ResponsibleUserId, TaskAvailable, TaskComplete, TaskType)
350
+ * @return {Object} Returns Promise that represents a collection of resulting CaTaskIDs
351
+ */
352
+ CaseWorkflow.prototype.searchForTasks = function (filters) {
353
+ var _this = this;
354
+ return new Promise(function (resolve, reject) {
355
+ if (_.intersectionBy(_.keysIn(filters), ['ResponsibleUserId', 'TaskAvailable', 'TaskComplete', 'TaskType']).length == 0) {
356
+ reject(new error_1.CWError(1, 'At least one of the attributes (ResponsibleUserId, TaskAvailable, TaskComplete, TaskType) must be defined.'));
357
+ }
358
+ var data = filters;
359
+ _this.cw.runRequest('Pll/CaseTask/Search', data).then(function (r) {
360
+ resolve(r.Value);
361
+ }).catch(function (e) {
362
+ reject(e);
363
+ });
364
+ });
365
+ };
366
+ /**
367
+ * Search for CaseTaskResults Objects. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
368
+ *
369
+ * @category Task Results
370
+ * @param {Object} filters - The parameters to search by. See: /{subdirectory}/apidocs/#/service-info/Pll/CaseTaskResults
371
+ * @return {Object} Returns Promise that represents a collection of resulting CaTaskResultsItem
372
+ */
373
+ CaseWorkflow.prototype.searchForTaskResults = function (filters) {
374
+ var _this = this;
375
+ return new Promise(function (resolve, reject) {
376
+ var data = filters;
377
+ _this.cw.runRequest('Pll/CaseTaskResults/Search', data).then(function (r) {
378
+ resolve(r.Value);
379
+ }).catch(function (e) {
380
+ reject(e);
381
+ });
382
+ });
383
+ };
384
+ /**
385
+ * Adds a task to the case specified by the CaObectId.
386
+ *
387
+ * @category Task Attachments
388
+ * @param {number} caTaskId - The Task ID to attach the document to
389
+ * @param {number} caObjectId - The Case Object ID
390
+ * @param {string} docName - The file name as it should display in the system
391
+ * @param {string} locationType - The location of the file...leave blank
392
+ * @param {any} file - The binary string for the file
393
+ * @return {Object} Returns Promise that represents an object describing added Attachment
394
+ */
395
+ CaseWorkflow.prototype.addTaskAttachment = function (caTaskId, caObjectId, docName, file, locationType) {
396
+ var _this = this;
397
+ return new Promise(function (resolve, reject) {
398
+ var data = {
399
+ CaObjectId: caObjectId,
400
+ CaTaskId: caTaskId,
401
+ DocName: docName
402
+ };
403
+ if (typeof (locationType) != 'undefined') {
404
+ _.set(data, 'LocationType', locationType);
405
+ }
406
+ _this.cw.runRequest('Pll/CaseRelDocs/AddTaskRelDoc', data, file).then(function (r) {
407
+ resolve(r.Value);
408
+ }).catch(function (e) {
409
+ reject(e);
410
+ });
411
+ });
412
+ };
413
+ /**
414
+ * Gets each Document Attached to the specified Task
415
+ *
416
+ * @category Task Attachments
417
+ * @param {number} caTaskId - The Task ID to attach the document to
418
+ * @return {Object} Returns Promise that represents a collection of objects describing each Attachment on the provided task
419
+ */
420
+ CaseWorkflow.prototype.getTaskAttachments = function (caTaskId) {
421
+ var _this = this;
422
+ return new Promise(function (resolve, reject) {
423
+ var data = {
424
+ CaTaskId: caTaskId
425
+ };
426
+ _this.cw.runRequest('Pll/CaseRelDocs/ByCaTaskId', data).then(function (r) {
427
+ resolve(r.Value);
428
+ }).catch(function (e) {
429
+ reject(e);
430
+ });
431
+ });
432
+ };
433
+ /**
434
+ * Deletes a task attachment by caRelDocId (Related Case Document ID). Same as RelDocs delete for case.
435
+ *
436
+ * @category Task Attachments
437
+ * @param {number} caRelDocId - The caRelDocId for the related document which should be deleted
438
+ * @return {Object} Returns Promise that represents the an object describing the deleted document.
439
+ */
440
+ CaseWorkflow.prototype.deleteTaskAttachment = function (caRelDocId) {
441
+ var _this = this;
442
+ return new Promise(function (resolve, reject) {
443
+ var data = {
444
+ CaRelDocId: caRelDocId
445
+ };
446
+ _this.cw.runRequest('PLL/CaseRelDocs/Delete', data).then(function (r) {
447
+ resolve(r.Value);
448
+ }).catch(function (e) {
449
+ reject(e);
450
+ });
451
+ });
452
+ };
453
+ return CaseWorkflow;
454
+ }());
455
+ exports.CaseWorkflow = CaseWorkflow;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Comments = void 0;
4
+ var error_1 = require("./error");
5
+ var reversible_map_1 = require("reversible-map");
6
+ var _ = require('lodash');
7
+ /**
8
+ * A plugin that contains "comments" methods
9
+ */
10
+ var Comments = /** @class */ (function () {
11
+ /**
12
+ * @hidden
13
+ */
14
+ function Comments(cw, activityType) {
15
+ this.cw = cw;
16
+ this.activityTypes = new reversible_map_1.default();
17
+ this.activityTypes.set("Unknown", 0);
18
+ this.activityTypes.set("Request", 1);
19
+ this.activityTypes.set("WorkOrder", 2);
20
+ this.activityTypes.set("CaTask", 3);
21
+ this.activityTypes.set("CaObject", 4);
22
+ this.activityTypes.set("CaCorrection", 5);
23
+ this.activityTypes.set("Project", 6);
24
+ this.activityTypes.set("Contract", 7);
25
+ if (!this.activityTypes.has(activityType)) {
26
+ throw new error_1.CWError(1, 'Comment activity type not found.', { 'provided': activityType, 'options': this.activityTypes });
27
+ }
28
+ this.currentActivityType = activityType;
29
+ }
30
+ /**
31
+ * Add a comment - for adding a comment to an object when the object is already known. Always call comment.add from request, case, workorder, or inspection.
32
+ *
33
+ * @param {number} sid - The SID of the activity to which the comment should be attached
34
+ * @param {string} comment - The text for the comment
35
+ * @return {Object} Returns a Promise which represents a CommentRecord object
36
+ */
37
+ Comments.prototype.add = function (sid, comment) {
38
+ var _this = this;
39
+ return new Promise(function (resolve, reject) {
40
+ var data = {
41
+ ActivityType: _this.activityTypes.get(_this.currentActivityType),
42
+ ActivitySid: sid,
43
+ Comments: comment
44
+ };
45
+ _this.cw.runRequest('Ams/Comment/Add', data).then(function (response) {
46
+ resolve(response.Value);
47
+ }).catch(function (e) {
48
+ reject(e);
49
+ });
50
+ });
51
+ };
52
+ /**
53
+ * Update a comment
54
+ *
55
+ * @param {number} id - The ID of the comment which should be updated
56
+ * @param {string} comment - The new text for the updated comment
57
+ * @return {Object} Returns a Promise which represents a CommentRecord object
58
+ */
59
+ Comments.prototype.update = function (id, comment) {
60
+ var _this = this;
61
+ return new Promise(function (resolve, reject) {
62
+ var data = {
63
+ ActivityType: _this.activityTypes.get(_this.currentActivityType),
64
+ CommentId: id,
65
+ Comments: comment
66
+ };
67
+ _this.cw.runRequest('Ams/Comment/Update', data).then(function (response) {
68
+ resolve(response.Value);
69
+ }).catch(function (e) {
70
+ reject(e);
71
+ });
72
+ });
73
+ };
74
+ /**
75
+ * Get comments for activity items
76
+ *
77
+ * @param {Array<number>} sids - The options SIDs to get comments for.
78
+ * @return {Object} Returns Promise object that represents a collection of available comments
79
+ */
80
+ Comments.prototype.get = function (sids) {
81
+ var _this = this;
82
+ return new Promise(function (resolve, reject) {
83
+ if (typeof (sids) != 'undefined' && sids != null) {
84
+ var data = {
85
+ ActivitySids: sids,
86
+ ActivityType: _this.activityTypes.get(_this.currentActivityType),
87
+ };
88
+ _this.cw.runRequest('Ams/Comment/ByActivitySids', data).then(function (response) {
89
+ if (sids.length == 1) {
90
+ resolve(response.Value[sids[0]]);
91
+ }
92
+ else {
93
+ resolve(response.Value);
94
+ }
95
+ });
96
+ }
97
+ });
98
+ };
99
+ /**
100
+ * Get pre-defined comments for activityTypes
101
+ *
102
+ * @param {number} problemSid - The ProblemSid if currentActivityType is (Service) Request
103
+ * @param {string} [category] - Only applies to WorkOrder and ServiceRequest category comments.
104
+ * @return {Object} Returns Promise object that represents a collection of available comment templates.
105
+ */
106
+ Comments.prototype.getPredefined = function (problemSid, category) {
107
+ var _this = this;
108
+ return new Promise(function (resolve, reject) {
109
+ var data = {};
110
+ if (_this.currentActivityType == 'Request') {
111
+ _.set(data, 'ProblemSid', problemSid);
112
+ }
113
+ if (typeof (category) != 'undefined' && (_this.currentActivityType == 'Request' || _this.currentActivityType == 'WorkOrder')) {
114
+ _.set(data, 'Category', category);
115
+ }
116
+ _.set(data, 'ActivityType', _this.activityTypes.get(_this.currentActivityType));
117
+ _this.cw.runRequest('Ams/Comment/PredefinedComments', data).then(function (response) {
118
+ resolve(response.Value);
119
+ }).catch(function (e) {
120
+ reject(e);
121
+ });
122
+ });
123
+ };
124
+ return Comments;
125
+ }());
126
+ exports.Comments = Comments;
package/dist/error.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CWError = void 0;
4
+ var _ = require('lodash');
5
+ /**
6
+ * CWError implements a custom error class for this codebase with additional information
7
+ *
8
+ */
9
+ var CWError = /** @class */ (function () {
10
+ /**
11
+ * CWError implements a custom error class for this codebase with additional information
12
+ *
13
+ * @param {number} code - Number for the thrown error (Efforts were made to make these unique when thrown throughout the codebase)
14
+ * @param {string} message - The error message
15
+ * @param {Object} info - Object stuffed with any other information one wishes to include in the thrown error
16
+ * @return {Object} Returns instance of CWError object
17
+ */
18
+ function CWError(code, message, info) {
19
+ this.name = "Cityworks Exception";
20
+ this.code = code;
21
+ this.message = message;
22
+ if (typeof (info) !== 'undefined') {
23
+ if (_.has(info, 'Message'))
24
+ this.message = _.get(info, 'Message');
25
+ this.info = JSON.stringify(info);
26
+ }
27
+ }
28
+ return CWError;
29
+ }());
30
+ exports.CWError = CWError;