cityworks 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/cityworks.d.ts +10 -25
- package/dist/index.js.map +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/index.js +0 -1
- package/src/activity_link.ts +0 -241
- package/src/case.ts +0 -282
- package/src/case_admin.ts +0 -883
- package/src/case_assets.ts +0 -129
- package/src/case_data.ts +0 -446
- package/src/case_financial.ts +0 -848
- package/src/case_workflow.ts +0 -462
- package/src/cityworks.ts +0 -719
- package/src/comments.ts +0 -167
- package/src/costs.ts +0 -289
- package/src/error.ts +0 -56
- package/src/event_layer.ts +0 -231
- package/src/general.ts +0 -143
- package/src/gis.ts +0 -242
- package/src/index.ts +0 -1
- package/src/inspection.ts +0 -851
- package/src/inspection_admin.ts +0 -45
- package/src/message_queue.ts +0 -243
- package/src/request.ts +0 -823
- package/src/request_admin.ts +0 -35
- package/src/search.ts +0 -339
- package/src/workorder.ts +0 -838
- package/src/workorder_admin.ts +0 -248
- package/test/01.cityworksTest.js +0 -80
- package/test/02.activitylinkTest.js +0 -58
- package/test/03.generalTest.js +0 -87
- package/test/04.requestTest.js +0 -293
- package/test/05.caseTest.js +0 -110
- package/test/06.caseFinancialTest.js +0 -172
- package/test/07.searchTest.js +0 -191
- package/test/08.workOrderTest.js +0 -48
- package/test/09.caseAssetsTest.js +0 -72
- package/test/09.inspectionTest.js +0 -28
- package/tsconfig.json +0 -68
package/src/inspection_admin.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { CWError } from './error'
|
|
2
|
-
const _ = require('lodash')
|
|
3
|
-
|
|
4
|
-
export class InspectionAdmin {
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
*/
|
|
8
|
-
cw: any
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @hidden
|
|
12
|
-
*/
|
|
13
|
-
constructor(cw) {
|
|
14
|
-
this.cw = cw
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Get inspection templates
|
|
19
|
-
*
|
|
20
|
-
* @category Inspection Templates
|
|
21
|
-
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
22
|
-
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
23
|
-
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
24
|
-
* @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
|
|
25
|
-
*/
|
|
26
|
-
getTemplates(entityTypes?: Array<string>, canCreate?: boolean, options?: {IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>}) {
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
var data: {EntityTypes?: Array<string>, CanCreate?: boolean, IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>} = {}
|
|
29
|
-
if(typeof(entityTypes)!=='undefined') {
|
|
30
|
-
data.EntityTypes = entityTypes
|
|
31
|
-
}
|
|
32
|
-
data.CanCreate = typeof(canCreate)!=='undefined' ? canCreate : true
|
|
33
|
-
if(typeof(options)==='object') {
|
|
34
|
-
_.forIn(options, (v, k) => {
|
|
35
|
-
data[k] = v
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
this.cw.runRequest('Ams/InspectionTemplate/Templates', data).then(r => {
|
|
39
|
-
resolve(r.Value)
|
|
40
|
-
}).catch(e => {
|
|
41
|
-
reject(e)
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/message_queue.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { CWError } from './error'
|
|
2
|
-
const _ = require('lodash')
|
|
3
|
-
|
|
4
|
-
export class MessageQueue {
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
*/
|
|
8
|
-
cw: any
|
|
9
|
-
/**
|
|
10
|
-
* Statuses -
|
|
11
|
-
* Pending: 0,
|
|
12
|
-
* Processing: 1,
|
|
13
|
-
* Complete: 2,
|
|
14
|
-
* Failed: 3
|
|
15
|
-
*/
|
|
16
|
-
status: Object = {
|
|
17
|
-
Pending: 0,
|
|
18
|
-
Processing: 1,
|
|
19
|
-
Complete: 2,
|
|
20
|
-
Failed: 3
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Hook Types -
|
|
24
|
-
* Unknown: 0,
|
|
25
|
-
* ActivityUpdate: 1,
|
|
26
|
-
* Email: 2,
|
|
27
|
-
* WebHook: 3
|
|
28
|
-
*/
|
|
29
|
-
hook_types: Object = {
|
|
30
|
-
Unknown: 0,
|
|
31
|
-
ActivityUpdate: 1,
|
|
32
|
-
Email: 2,
|
|
33
|
-
WebHook: 3
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
constructor(cw) {
|
|
40
|
-
this.cw = cw
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Process Webhook MessageQueue records by MessageQueueId
|
|
45
|
-
*
|
|
46
|
-
* @param {Array<number>} [ids] - List of MessageQueueId values
|
|
47
|
-
* @param {boolean} [delete_successful] - automatically delete messages that complete with successful execution, default is false
|
|
48
|
-
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
49
|
-
*/
|
|
50
|
-
processMessages(ids: Array<number>, delete_successful: boolean = false) {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
let data = { Ids: ids, Delete: delete_successful}
|
|
53
|
-
let path = 'General/WebHookEvent/ProcessMessages'
|
|
54
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
55
|
-
// TODO
|
|
56
|
-
}).catch(e => {
|
|
57
|
-
reject(e)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get Messages specified in list of MessageQueueIds
|
|
64
|
-
*
|
|
65
|
-
* @param {Array<number>} ids - List of MessageQueueId values
|
|
66
|
-
* @param {string} status -
|
|
67
|
-
* @param {number} [maxcount] - Maximum number returned. Defaults to 15
|
|
68
|
-
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
69
|
-
*/
|
|
70
|
-
get(ids: Array<number>, status: string, maxcount: number = 15) {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
if(typeof(this.status[status])=='undefined') {
|
|
73
|
-
reject(new CWError(1, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
|
|
74
|
-
}
|
|
75
|
-
let data = {
|
|
76
|
-
"Ids": ids,
|
|
77
|
-
"MaxCount": typeof(maxcount)!='undefined' ? maxcount : 15,
|
|
78
|
-
"Status": this.status[status]
|
|
79
|
-
}
|
|
80
|
-
let path = 'General/MessageQueue/ByIds'
|
|
81
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
82
|
-
// TODO
|
|
83
|
-
}).catch(e => {
|
|
84
|
-
reject(e)
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Delete Messages specified in list of MessageQueueIds
|
|
91
|
-
*
|
|
92
|
-
* @param {Array<number>} ids - List of MessageQueueId values
|
|
93
|
-
* @param {string} status - automatically delete messages that complete with successful execution, default is false
|
|
94
|
-
* @param {number} [hours_to_keep] - utomatically delete messages that complete with successful execution, default is false
|
|
95
|
-
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
96
|
-
*/
|
|
97
|
-
delete(ids: Array<number>, status: string, hours_to_keep?: number) {
|
|
98
|
-
return new Promise((resolve, reject) => {
|
|
99
|
-
if(typeof(this.status[status])=='undefined') {
|
|
100
|
-
reject(new CWError(2, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
|
|
101
|
-
}
|
|
102
|
-
let data = {
|
|
103
|
-
"Ids": ids,
|
|
104
|
-
"Status": this.status[status],
|
|
105
|
-
"HoursToKeep": hours_to_keep
|
|
106
|
-
}
|
|
107
|
-
let path = 'General/MessageQueue/Delete'
|
|
108
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
109
|
-
// TODO
|
|
110
|
-
}).catch(e => {
|
|
111
|
-
reject(e)
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// PreferencesList<GlobalPreference>
|
|
117
|
-
// Base response type: CoreResponseBase
|
|
118
|
-
// Get a list of message queue preferences
|
|
119
|
-
// This method has no parameters
|
|
120
|
-
preferences() {
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
let data = {}
|
|
123
|
-
let path = 'General/MessageQueue/Preferences'
|
|
124
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
125
|
-
// TODO
|
|
126
|
-
}).catch(e => {
|
|
127
|
-
reject(e)
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
search(parameters, max_results?: number) {
|
|
133
|
-
let data: any
|
|
134
|
-
return new Promise((resolve, reject) => {
|
|
135
|
-
if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])=='undefined') {
|
|
136
|
-
reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.status, 'available':this.status}))
|
|
137
|
-
} else if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])!=='undefined') {
|
|
138
|
-
data.Status = this.status[parameters.status]
|
|
139
|
-
}
|
|
140
|
-
if(typeof(max_results)!=='undefined') {
|
|
141
|
-
data.MaxResults = max_results
|
|
142
|
-
}
|
|
143
|
-
let allowed_params = ['Id', 'HookId', 'HookType', 'Result', 'DateCreatedBegin', 'DateCreatedEnd', 'DateUpdatedBegin', 'DateUpdatedEnd']
|
|
144
|
-
let disallowed_params = ['Status', 'MaxResults']
|
|
145
|
-
_.forEach(parameters, (v, k) => {
|
|
146
|
-
if(_.indexOf(allowed_params,k)!=-1 && _.indexOf(disallowed_params, k)==-1) {
|
|
147
|
-
data[k] = v
|
|
148
|
-
} else if(_.indexOf(disallowed_params, k)==-1) {
|
|
149
|
-
reject(new CWError(4, 'Provided parameter does not exist or is mispelled.', {'provided': k, 'value': v, 'available':_.concat(allowed_params, disallowed_params)}))
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
let path = 'General/MessageQueue/Search'
|
|
153
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
154
|
-
// TODO
|
|
155
|
-
if(typeof(response.Value)=='undefined') {
|
|
156
|
-
response.Value = []
|
|
157
|
-
}
|
|
158
|
-
resolve(response.Value)
|
|
159
|
-
}).catch(e => {
|
|
160
|
-
reject(e)
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Update queue message
|
|
167
|
-
*
|
|
168
|
-
* @param {Object} parameters - Provide allowed parameters:
|
|
169
|
-
*
|
|
170
|
-
* {
|
|
171
|
-
* HookId: number,
|
|
172
|
-
* Id: number,
|
|
173
|
-
* Packet: string,
|
|
174
|
-
* Result: string,
|
|
175
|
-
* Status: string, // Available options: Pending, Processing, Complete, Failed
|
|
176
|
-
* HookType: string // Available options: Unknown, ActivityUpdate, Email, WebHook
|
|
177
|
-
* }
|
|
178
|
-
*
|
|
179
|
-
* @return {Object} Returns Promise object that represents an Object with the desired GIS service definitions
|
|
180
|
-
*/
|
|
181
|
-
update(parameters: any) {
|
|
182
|
-
let data: any
|
|
183
|
-
return new Promise((resolve, reject) => {
|
|
184
|
-
if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])=='undefined') {
|
|
185
|
-
reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.status, 'available':this.status}))
|
|
186
|
-
} else if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])!=='undefined') {
|
|
187
|
-
data.Status = this.status[parameters.status]
|
|
188
|
-
}
|
|
189
|
-
if(typeof(parameters.hook_types)!=='undefined' && typeof(this.hook_types[parameters.hook_types])=='undefined') {
|
|
190
|
-
reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.hook_types, 'available':this.hook_types}))
|
|
191
|
-
} else if(typeof(parameters.hook_types)!=='undefined' && typeof(this.hook_types[parameters.hook_types])!=='undefined') {
|
|
192
|
-
data.HookType = this.hook_types[parameters.hook_types]
|
|
193
|
-
}
|
|
194
|
-
let allowed_params = ['Id', 'HookId', 'Packet', 'Result']
|
|
195
|
-
let disallowed_params = ['Status', 'HookType']
|
|
196
|
-
_.forEach(parameters, (v, k) => {
|
|
197
|
-
if(_.indexOf(allowed_params,k)!=-1 && _.indexOf(disallowed_params, k)==-1) {
|
|
198
|
-
data[k] = v
|
|
199
|
-
} else if(_.indexOf(disallowed_params, k)==-1) {
|
|
200
|
-
reject(new CWError(5, 'Provided parameter does not exist or is mispelled.', {'provided': k, 'value': v, 'available':_.concat(allowed_params, disallowed_params)}))
|
|
201
|
-
}
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
let path = 'General/MessageQueue/Update'
|
|
205
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
206
|
-
// TODO
|
|
207
|
-
if(typeof(response.Value)=='undefined') {
|
|
208
|
-
response.Value = []
|
|
209
|
-
}
|
|
210
|
-
resolve(response.Value)
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
updateMessageStatus(ids: number[], status: string, hours_to_keep?: number) {
|
|
216
|
-
return new Promise((resolve, reject) => {
|
|
217
|
-
if(typeof(this.status[status])=='undefined') {
|
|
218
|
-
reject(new CWError(2, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
|
|
219
|
-
}
|
|
220
|
-
let data = {
|
|
221
|
-
"Ids": ids,
|
|
222
|
-
"Status": this.status[status],
|
|
223
|
-
"HoursToKeep": hours_to_keep
|
|
224
|
-
}
|
|
225
|
-
let path = 'General/MessageQueue/UpdateMessageStatus'
|
|
226
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
227
|
-
// TODO
|
|
228
|
-
})
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
getWebooks(hook_ids) {
|
|
233
|
-
return new Promise((resolve, reject) => {
|
|
234
|
-
let data = {
|
|
235
|
-
"HookIds": hook_ids
|
|
236
|
-
}
|
|
237
|
-
let path = 'General/MessageQueue/WebHooks'
|
|
238
|
-
this.cw.runRequest(path, data).then((response: any) => {
|
|
239
|
-
// TODO
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
}
|
|
243
|
-
}
|