cityworks 0.0.36 → 0.0.38

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 (47) hide show
  1. package/README.md +4 -2
  2. package/dist/cityworks.d.ts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.m.js +1 -1
  7. package/dist/index.m.js.map +1 -1
  8. package/dist/index.modern.mjs +1 -1
  9. package/dist/index.modern.mjs.map +1 -1
  10. package/dist/index.umd.js +1 -1
  11. package/dist/index.umd.js.map +1 -1
  12. package/package.json +2 -1
  13. package/index.js +0 -1
  14. package/src/activity_link.ts +0 -241
  15. package/src/case.ts +0 -282
  16. package/src/case_admin.ts +0 -883
  17. package/src/case_assets.ts +0 -129
  18. package/src/case_data.ts +0 -446
  19. package/src/case_financial.ts +0 -848
  20. package/src/case_workflow.ts +0 -462
  21. package/src/cityworks.ts +0 -719
  22. package/src/comments.ts +0 -167
  23. package/src/costs.ts +0 -289
  24. package/src/error.ts +0 -56
  25. package/src/event_layer.ts +0 -231
  26. package/src/general.ts +0 -143
  27. package/src/gis.ts +0 -242
  28. package/src/index.ts +0 -1
  29. package/src/inspection.ts +0 -851
  30. package/src/inspection_admin.ts +0 -45
  31. package/src/message_queue.ts +0 -243
  32. package/src/request.ts +0 -823
  33. package/src/request_admin.ts +0 -35
  34. package/src/search.ts +0 -339
  35. package/src/workorder.ts +0 -838
  36. package/src/workorder_admin.ts +0 -248
  37. package/test/01.cityworksTest.js +0 -80
  38. package/test/02.activitylinkTest.js +0 -58
  39. package/test/03.generalTest.js +0 -87
  40. package/test/04.requestTest.js +0 -293
  41. package/test/05.caseTest.js +0 -110
  42. package/test/06.caseFinancialTest.js +0 -172
  43. package/test/07.searchTest.js +0 -191
  44. package/test/08.workOrderTest.js +0 -48
  45. package/test/09.caseAssetsTest.js +0 -72
  46. package/test/09.inspectionTest.js +0 -28
  47. package/tsconfig.json +0 -68
package/src/comments.ts DELETED
@@ -1,167 +0,0 @@
1
- import { CWError } from './error'
2
- import ReversibleMap from 'reversible-map'
3
- const _ = require('lodash')
4
-
5
-
6
- /**
7
- * A plugin that contains "comments" methods
8
- */
9
- export class Comments {
10
- /**
11
- * @hidden
12
- */
13
- cw: any
14
-
15
- /**
16
- * Storage of all potential activity types which comments can be attached to: Unknown, Request, WorkOrder, CaTask, CaObject, CaCorrection, Project, Contract
17
- */
18
- activityTypes: ReversibleMap<string, number>
19
-
20
- /**
21
- * Storage of object's active activityType
22
- */
23
- currentActivityType: string
24
-
25
- /**
26
- * @hidden
27
- */
28
- constructor(cw: any, activityType: string) {
29
- this.cw = cw
30
- this.activityTypes = new ReversibleMap<string, number>()
31
- this.activityTypes.set("Unknown", 0)
32
- this.activityTypes.set("Request", 1)
33
- this.activityTypes.set("WorkOrder", 2)
34
- this.activityTypes.set("CaTask", 3)
35
- this.activityTypes.set("CaObject", 4)
36
- this.activityTypes.set("CaCorrection", 5)
37
- this.activityTypes.set("Project", 6)
38
- this.activityTypes.set("Contract", 7)
39
-
40
- if(!this.activityTypes.has(activityType)) {
41
- throw new CWError(1, 'Comment activity type not found.', {'provided': activityType, 'options':this.activityTypes})
42
- }
43
- this.currentActivityType = activityType
44
- }
45
-
46
- /**
47
- * 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.
48
- *
49
- * @param {number} sid - The SID of the activity to which the comment should be attached
50
- * @param {string} comment - The text for the comment
51
- * @return {Object} Returns a Promise which represents a CommentRecord object
52
- */
53
- add(sid: number, comment: string) {
54
- return new Promise((resolve, reject) => {
55
- var data = {
56
- ActivityType: this.activityTypes.get(this.currentActivityType),
57
- ActivitySid: sid,
58
- Comments: comment
59
- }
60
- this.cw.runRequest('Ams/Comment/Add', data).then((response: any) => {
61
- resolve(response.Value)
62
- }).catch(e => {
63
- reject(e)
64
- })
65
- })
66
- }
67
-
68
- /**
69
- * Update a comment
70
- *
71
- * @param {number} id - The ID of the comment which should be updated
72
- * @param {string} comment - The new text for the updated comment
73
- * @return {Object} Returns a Promise which represents a CommentRecord object
74
- */
75
- update(id: number, comment: string) {
76
- return new Promise((resolve, reject) => {
77
- var data = {
78
- ActivityType: this.activityTypes.get(this.currentActivityType),
79
- CommentId: id,
80
- Comments: comment
81
- }
82
- this.cw.runRequest('Ams/Comment/Update', data).then((response: any) => {
83
- resolve(response.Value)
84
- }).catch(e => {
85
- reject(e)
86
- })
87
- })
88
- }
89
-
90
- /**
91
- * Get comments for activity items
92
- *
93
- * @param {Array<number>} sids - The options SIDs to get comments for.
94
- * @return {Object} Returns Promise object that represents a collection of available comments
95
- */
96
- get(sids: Array<number>) {
97
- return new Promise((resolve, reject) => {
98
- if(typeof(sids)!='undefined' && sids !=null) {
99
- var data = {
100
- ActivitySids: sids,
101
- ActivityType: this.activityTypes.get(this.currentActivityType),
102
- }
103
- this.cw.runRequest('Ams/Comment/ByActivitySids', data).then((response: any) => {
104
- if(sids.length==1) {
105
- resolve(response.Value[sids[0]])
106
- } else {
107
- resolve(response.Value)
108
- }
109
- })
110
- }
111
- })
112
- }
113
-
114
- /**
115
- * Get pre-defined comments for activityTypes
116
- *
117
- * @param {number} problemSid - The ProblemSid if currentActivityType is (Service) Request
118
- * @param {string} [category] - Only applies to WorkOrder and ServiceRequest category comments.
119
- * @return {Object} Returns Promise object that represents a collection of available comment templates.
120
- */
121
- getPredefined(problemSid?: number, category?: string) {
122
- return new Promise((resolve, reject) => {
123
- var data = {}
124
- if(this.currentActivityType=='Request') {
125
- _.set(data, 'ProblemSid', problemSid)
126
- }
127
- if(typeof(category)!='undefined' && (this.currentActivityType=='Request' || this.currentActivityType=='WorkOrder')) {
128
- _.set(data, 'Category', category)
129
- }
130
- _.set(data, 'ActivityType', this.activityTypes.get(this.currentActivityType))
131
- this.cw.runRequest('Ams/Comment/PredefinedComments', data).then((response: any) => {
132
- resolve(response.Value)
133
- }).catch(e => {
134
- reject(e)
135
- })
136
- })
137
- }
138
-
139
- // /**
140
- // * Get pre-set comments for activityTypes
141
- // *
142
- // * @param {Array<string>} [activityTypes] - Provide a list of activity types. Defaults to current activity type.
143
- // * @param {Array<string>} [categories] - Only applies to WorkOrder and ServiceRequest category comments.
144
- // * @return {Object} Returns Promise object that represents a collection of available comment templates.
145
- // */
146
- // getForActivityList(activityTypes?: Array<string>, categories?: Array<string>) {
147
- // return new Promise((resolve, reject) => {
148
- // var data = {}
149
- // if(typeof(activityTypes)!='undefined') {
150
- // // TODO: iterate through it and output numeric types
151
- // _.set(data, 'ActivityTypes', activityTypes)
152
- // } else {
153
- // _.set(data, 'ActivityTypes', [this.activityTypes.get(this.currentActivityType)])
154
- // }
155
- // if(typeof(categories)!='undefined') {
156
- // _.set(data, 'Categories', categories)
157
- // }
158
- // console.log(data, 'data')
159
- // this.cw.runRequest('Ams/Comment/ByActivityTypes', data).then((response: any) => {
160
- // resolve(response.Value)
161
- // }).catch(e => {
162
- // reject(e)
163
- // })
164
- // })
165
- // }
166
-
167
- }
package/src/costs.ts DELETED
@@ -1,289 +0,0 @@
1
- import { CWError } from './error'
2
- import ReversibleMap from 'reversible-map'
3
- const _ = require('lodash')
4
-
5
- export class Costs {
6
- /**
7
- * @hidden
8
- */
9
- cw: any
10
-
11
- /**
12
- * Storage of all potential activity types which comments can be attached to: Unknown, Request, WorkOrder, CaTask, CaObject, CaCorrection, Project, Contract
13
- */
14
- activityTypes: ReversibleMap<string, number>
15
-
16
- /**
17
- * Storage of object's active activityType
18
- */
19
- currentActivityType: string
20
-
21
- /**
22
- * @hidden
23
- */
24
- constructor(cw:any, activityType:string) {
25
- this.cw = cw
26
- this.activityTypes = new ReversibleMap<string, number>()
27
- this.activityTypes.set("Request", 1)
28
- this.activityTypes.set("WorkOrder", 2)
29
- this.activityTypes.set("Inspection", 3)
30
-
31
- if(!this.activityTypes.has(activityType)) {
32
- throw new CWError(1, 'Cost activity type not found.', {'provided': activityType, 'options':this.activityTypes})
33
- }
34
- this.currentActivityType = activityType
35
- }
36
-
37
- /**
38
- * Get Cost Codes
39
- *
40
- * @category Labor Costs
41
- * @param {Array<number>} employeeSids - A list of Employee IDs for which to get the job codes.
42
- * @param {boolean} commonOnly - Set to true to get the Cost Codes that are common to ALL employees in the list, otherwise get all job codes that apply to at least one employee in the list.
43
- * @return {Object} Returns Promise that represents an object describing
44
- */
45
- getCodes(employeeSids: Object, commonOnly: boolean = false) {
46
- return new Promise((resolve, reject) => {
47
- var data = {
48
- EmployeeSids: employeeSids,
49
- CommonCodesOnly: commonOnly
50
- }
51
- this.cw.runRequest('Ams/LaborCost/CostCodes', data).then(r => {
52
- resolve(r.Value)
53
- }).catch(e => {
54
- reject(e)
55
- })
56
- })
57
- }
58
-
59
- /**
60
- * Get Job Codes
61
- *
62
- * @category Labor Costs
63
- * @return {Object} Returns Promise that represents an object describing
64
- */
65
- getJobCodes() {
66
- return new Promise((resolve, reject) => {
67
- this.cw.runRequest('Ams/LaborCost/JobCodes').then(r => {
68
- resolve(r.Value)
69
- }).catch(e => {
70
- reject(e)
71
- })
72
- })
73
- }
74
-
75
- /**
76
- * Add Inspection Labor Costs
77
- *
78
- * @category Inspection Costs
79
- * @param {number} inspectionId - Inspection ID to add labor costs to
80
- * @param {number} hours - The hours to add to the inspection
81
- * @param {Object} options - Additional settings for hours setting
82
- * @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
83
- * @return {Object} Returns Promise that represents an object describing
84
- */
85
- addInspectionLabor(inspectionId: number, hours: number, options: object, estimated: boolean = false) {
86
- return new Promise((resolve, reject) => {
87
- var data = {
88
- Estimated: estimated,
89
- InspectionIds: inspectionId,
90
- Hours: hours
91
- }
92
- this.cw.runRequest('Ams/LaborCost/AddInspectionCosts', data).then((response: any) => {
93
- resolve(response.Value)
94
- }).catch(e => {
95
- reject(e)
96
- })
97
- })
98
- }
99
-
100
- /**
101
- * Get Labor Costs for a specific list of Inspections
102
- *
103
- * @category Inspection Costs
104
- * @param {Array<int>} inspectionIds - An array of inspection IDs to get associated costs for.
105
- * @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
106
- * @return {Object} Returns Promise that represents an object describing
107
- */
108
- getInspectionLabor(inspectionIds: Array<number>, estimated: boolean = false) {
109
- return new Promise((resolve, reject) => {
110
- var data = {
111
- Estimated: estimated,
112
- InspectionIds: inspectionIds
113
- }
114
- this.cw.runRequest('Ams/LaborCost/InspectionCostsByInspection', data).then((response: any) => {
115
- resolve(response.Value)
116
- }).catch(e => {
117
- reject(e)
118
- })
119
- })
120
- }
121
-
122
- /**
123
- * Delete Inspection Labor Costs
124
- *
125
- * @category Inspection Costs
126
- * @param {Array<int>} laborCostIds - An array of inspection labor cost IDs to delete
127
- * @param {boolean} estimated - Boolean, delete estimated or real costs, defaults to false (delete real by default)
128
- * @return {Object} Returns Promise that represents an object describing
129
- */
130
- deleteInspectionLabor(laborCostIds: Array<number>, estimated: boolean = false) {
131
- return new Promise((resolve, reject) => {
132
- var data = {
133
- Estimated: estimated,
134
- reqLaborCostIds: laborCostIds
135
- }
136
- this.cw.runRequest('Ams/LaborCost/DeleteInspectionCosts', data).then((response: any) => {
137
- resolve(response.Value)
138
- }).catch(e => {
139
- reject(e)
140
- })
141
- })
142
- }
143
-
144
- /**
145
- * Add Request Labor Costs
146
- *
147
- * @category Request Costs
148
- * @param {Object} requestCosts - Array of inspection labor costings
149
- * @return {Object} Returns Promise that represents an object describing
150
- */
151
- addRequestLabor(requestCosts: Array<Object>) {
152
- return new Promise((resolve, reject) => {
153
- var data = requestCosts
154
- // ensure each object has Hours & InspectionId
155
- this.cw.runRequest('Ams/LaborCost/AddRequestCosts', data).then((response: any) => {
156
- resolve(response.Value)
157
- }).catch(e => {
158
- reject(e)
159
- })
160
- })
161
- }
162
-
163
- /**
164
- * Get Labor Costs for Request(s)
165
- *
166
- * @category Request Costs
167
- * @param {Object}
168
- * @return {Object} Returns Promise that represents an object describing
169
- */
170
- // RequestCostsByRequestList<RequestLaborCost>
171
-
172
- /**
173
- * Delete Request Labor Costs
174
- *
175
- * @category InspeRequestction Costs
176
- * @param {Object}
177
- * @return {Object} Returns Promise that represents an object describing
178
- */
179
- // DeleteRequestCostsDictionary<Int32, Boolean>
180
-
181
- /**
182
- * Add WorkOrder Labor Costs
183
- *
184
- * @category WorkOrder Costs
185
- * @param {Object}
186
- * @return {Object} Returns Promise that represents an object describing
187
- */
188
- // AddWorkOrderCostsList<WorkOrderLaborCost>
189
-
190
- /**
191
- * Get Labor Costs for WorkOrder(s)
192
- *
193
- * @category WorkOrder Costs
194
- * @param {Object}
195
- * @return {Object} Returns Promise that represents an object describing
196
- */
197
- // WorkOrderCostsByWorkOrderList<WorkOrderLaborCost>
198
-
199
- /**
200
- * Delete WorkOrder Labor Costs
201
- *
202
- * @category WorkOrder Costs
203
- * @param {Object}
204
- * @return {Object} Returns Promise that represents an object describing
205
- */
206
- // DeleteWorkOrderCostsDictionary<Int32, Boolean>
207
-
208
- /**
209
- * Add Inspection Equipment Costs
210
- *
211
- * @category Inspection Costs
212
- * @param {Object}
213
- * @return {Object} Returns Promise that represents an object describing
214
- */
215
- // AddInspectionCostsList<InspectionEquipmentCost>
216
-
217
- /**
218
- * Get Equipment Costs for Inspection(s)
219
- *
220
- * @category Inspection Costs
221
- * @param {Object}
222
- * @return {Object} Returns Promise that represents an object describing
223
- */
224
- // InspectionCostsByInspectionList<InspectionEquipmentCost>
225
-
226
- /**
227
- * Delete Inspection Equipment Costs
228
- *
229
- * @category Inspection Costs
230
- * @param {Object}
231
- * @return {Object} Returns Promise that represents an object describing
232
- */
233
- // DeleteInspectionCostsDictionary<Int32, Boolean>
234
-
235
- /**
236
- * Add WorkOrder Equipment Costs
237
- *
238
- * @category WorkOrder Costs
239
- * @param {Object}
240
- * @return {Object} Returns Promise that represents an object describing
241
- */
242
- // AddWorkOrderCostsList<EquipmentCost>
243
-
244
- /**
245
- * Get Equipment Costs for WorkOrder(s)
246
- *
247
- * @category WorkOrder Costs
248
- * @param {Object}
249
- * @return {Object} Returns Promise that represents an object describing
250
- */
251
- // WorkOrderCostsByWorkOrderList<EquipmentCost>
252
-
253
- /**
254
- * Delete WorkOrder Equipment Costs
255
- *
256
- * @category WorkOrder Costs
257
- * @param {Object}
258
- * @return {Object} Returns Promise that represents an object describing
259
- */
260
- // DeleteWorkOrderCostsDictionary<Int32, Boolean>
261
-
262
- /**
263
- * Add WorkOrder Material Costs
264
- *
265
- * @category WorkOrder Costs
266
- * @param {Object}
267
- * @return {Object} Returns Promise that represents an object describing
268
- */
269
- // AddWorkOrderCostsList<MaterialCost>
270
-
271
- /**
272
- * Get Material Costs for WorkOrder(s)
273
- *
274
- * @category WorkOrder Costs
275
- * @param {Object}
276
- * @return {Object} Returns Promise that represents an object describing
277
- */
278
- // WorkOrderCostsByWorkOrderList<MaterialCost>
279
-
280
- /**
281
- * Delete WorkOrder Material Costs
282
- *
283
- * @category WorkOrder Costs
284
- * @param {Object}
285
- * @return {Object} Returns Promise that represents an object describing
286
- */
287
- // DeleteWorkOrderCostsDictionary<Int32, Boolean>
288
-
289
- }
package/src/error.ts DELETED
@@ -1,56 +0,0 @@
1
- const _ = require('lodash')
2
-
3
- /**
4
- * CWErrorInt interface definition for implementation by CWError
5
- *
6
- * `{name: string, code: number, message: string, info?: string}`
7
- *
8
- */
9
- export interface CWErrorInt {
10
- name: string
11
- code: number
12
- message: string
13
- info?: string
14
- }
15
-
16
- /**
17
- * CWError implements a custom error class for this codebase with additional information
18
- *
19
- */
20
- export class CWError implements CWErrorInt {
21
- /**
22
- * Just statically set to "Cityworks Exception" for now
23
- */
24
- name: string
25
- /**
26
- * Number for the thrown error (Efforts were made to make these unique when thrown throughout the codebase)
27
- */
28
- code: number
29
- /**
30
- * The error message
31
- */
32
- message: string
33
- /**
34
- * Object stuffed with any other information one wishes to include in the thrown error
35
- */
36
- info?: string
37
-
38
- /**
39
- * CWError implements a custom error class for this codebase with additional information
40
- *
41
- * @param {number} code - Number for the thrown error (Efforts were made to make these unique when thrown throughout the codebase)
42
- * @param {string} message - The error message
43
- * @param {Object} info - Object stuffed with any other information one wishes to include in the thrown error
44
- * @return {Object} Returns instance of CWError object
45
- */
46
- constructor(code:number, message:string, info?:object) {
47
- this.name = "Cityworks Exception"
48
- this.code = code
49
- this.message = message
50
- if(typeof(info) !== 'undefined') {
51
- if(_.has(info, 'Message'))
52
- this.message = _.get(info, 'Message')
53
- this.info = JSON.stringify(info)
54
- }
55
- }
56
- }