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.
@@ -1,35 +0,0 @@
1
- import { CWError } from './error'
2
- const _ = require('lodash')
3
-
4
- export class RequestAdmin {
5
- /**
6
- * @hidden
7
- */
8
- cw: any
9
-
10
- /**
11
- * @hidden
12
- */
13
- constructor(cw) {
14
- this.cw = cw
15
- }
16
-
17
- /**
18
- * Get service request templates
19
- *
20
- * @category Requests Admin
21
- * @param {Object} searchData - search data
22
- * @return {Object} Returns Promise that represents a collection of all Service Request Templates
23
- */
24
- getTemplates(searchData: Object) {
25
- return new Promise((resolve, reject) => {
26
- var data = searchData
27
- this.cw.runRequest('Ams/ServiceRequestTemplate/Templates', data).then(r => {
28
- resolve(r.Value)
29
- }).catch(e => {
30
- reject(e)
31
- })
32
- })
33
- }
34
-
35
- }
package/src/search.ts DELETED
@@ -1,339 +0,0 @@
1
- import { CWError } from './error'
2
- const _ = require('lodash')
3
-
4
- export class Search {
5
- /**
6
- * @hidden
7
- */
8
- cw: any
9
-
10
- /**
11
- * Search Types: Null, Request, WorkOrder, Inspection, Contract, Permit, GIS, PermitTask, PermitAddress, InspCommon, Case, WorkOrderEntity, StoreTransaction, Requisition, Material, WorkActivity, MaterialLeaf, WoTemplate, Unknown, Employee, MessageQueue, Analytics, TokenState, AssetCalculationResult, Equipment, CustomerAccount, InspTemplate, ProblemLeaf, AssetSplitRecord, PavementInsp, TvInspection, Projects
12
- */
13
- searchTypes: Object = {
14
- "Null": 0,
15
- "Request": 1,
16
- "WorkOrder": 2,
17
- "Inspection": 3,
18
- "Contract": 4,
19
- "Permit": 5,
20
- "GIS": 6,
21
- "PermitTask": 7,
22
- "PermitAddress": 8,
23
- "InspCommon": 9,
24
- "Case": 10,
25
- "WorkOrderEntity": 11,
26
- "StoreTransaction": 12,
27
- "Requisition": 13,
28
- "Material": 14,
29
- "WorkActivity": 15,
30
- "MaterialLeaf": 16,
31
- "WoTemplate": 17,
32
- "Unknown": 18,
33
- "Employee": 19,
34
- "MessageQueue": 20,
35
- "Analytics": 21,
36
- "TokenState": 22,
37
- "AssetCalculationResult": 23,
38
- "Equipment": 24,
39
- "CustomerAccount": 25,
40
- "InspTemplate": 26,
41
- "ProblemLeaf": 27,
42
- "AssetSplitRecord": 28,
43
- "PavementInsp": 29,
44
- "TvInspection": 30,
45
- "Projects": 31
46
- }
47
-
48
- /**
49
- * @hidden
50
- */
51
- constructor(cw) {
52
- this.cw = cw
53
- }
54
-
55
- /**
56
- * Do a "quick" search for any string (an ID is best)
57
- *
58
- * @category Quick Search
59
- * @param {string} text - text to search the system for
60
- * @return {Object} Returns Promise object that represents a collection of the currently authenticated user's notifications
61
- */
62
- quick(text: string) {
63
- return new Promise((resolve, reject) => {
64
- let data = {
65
- "QuickSearchText": text,
66
- }
67
- this.cw.runRequest('General/QuickSearch/QuickSearch', data).then(r => {
68
- resolve(r.Value)
69
- }).catch(e => {
70
- reject(e)
71
- })
72
- })
73
- }
74
-
75
- /**
76
- * Execute a saved search
77
- *
78
- * @category Search
79
- * @param {number} searchId - SearchId to execute
80
- * @param {Object} options - Other options. See: /{subdirectory}/apidocs/#/service-info/Ams/Search
81
- * @return {Object} Returns Promise object that represents a list of Objects
82
- */
83
- execute(searchId: number, options?: {EmployeeSid?: number, ExcludeEmptyXY?: boolean, Extent?: Object, Frequency?: boolean, IdsOnly?: boolean, IncludeSearchOrder?: boolean, MaxResults?: number, ResultFields?: Array<string>, TotalOnly?: boolean}) {
84
- return new Promise((resolve, reject) => {
85
- var data = {
86
- SearchId: searchId
87
- }
88
- data = _.merge(data, options)
89
- this.cw.runRequest('Ams/Search/Execute', data).then(r => {
90
- resolve(r.Value)
91
- }).catch(e => {
92
- reject(e)
93
- })
94
- })
95
- }
96
-
97
- /**
98
- * Get a list of the saved searches by search type and specific entity types OR employeeSid/domainId. You cannot search for saved searches by both specific entity type AND employeeSid/domainId.
99
- *
100
- * @category Search
101
- * @param {string} searchType - Get the saved searches for a particular type
102
- * @param {Array<string>} [applyToEntities] - Restrict GIS searches to specified entity types
103
- * @param {number} [employeeSid] - The employee SID to retrieve the searches as
104
- * @param {number} [domainId] - The domain ID of the domain to search
105
- * @return {Object} Returns Promise object that represents a collection of SearchDefinitionName
106
- */
107
- getSaved(searchType: string, applyToEntities?: Array<string>, employeeSid?: number, domainId?: number) {
108
- return new Promise((resolve, reject) => {
109
- if(!_.has(this.searchTypes, searchType)) {
110
- reject(new CWError(2, 'SearchType provided does not exist or is mispelled.', {'provided': searchType, 'available':this.searchTypes}))
111
- } else if(typeof(applyToEntities)!='undefined' && applyToEntities!=null && applyToEntities.length>0 && (typeof(employeeSid)!='undefined' || typeof(domainId)!='undefined')) {
112
- reject(new CWError(3, 'You cannot specify both applyToEntities AND employeeSid/domainId'))
113
- }
114
- var data = {}
115
- var savedEndpoint = ''
116
- if(typeof(employeeSid)!='undefined' || typeof(domainId)!='undefined') {
117
- savedEndpoint = 'SavedByType'
118
- if(typeof(employeeSid)!='undefined' && employeeSid!=null) {
119
- _.set(data, 'EmployeeSid', employeeSid)
120
- }
121
- if(typeof(domainId)!='undefined' && domainId!=null) {
122
- _.set(data, 'DomainId', domainId)
123
- }
124
- } else {
125
- if(searchType=='Case') {
126
- savedEndpoint = 'PllSavedSaved'
127
- } else {
128
- savedEndpoint = searchType + 'Saved'
129
- }
130
- if(typeof(applyToEntities)!='undefined' && applyToEntities!=null) {
131
- _.set(data, 'ApplyToEntities', applyToEntities)
132
- }
133
- }
134
- this.cw.runRequest('Ams/Search/'+savedEndpoint, data).then(r => {
135
- resolve(r.Value)
136
- }).catch(e => {
137
- reject(e)
138
- })
139
- })
140
- }
141
-
142
- /**
143
- * Get a list display fields for a Search Type
144
- *
145
- * @category Search Options
146
- * @param {string} searchType - Restrict GIS searches to specified entity types
147
- * @return {Object} Returns Promise object that represents a collection of SearchDisplayFields
148
- */
149
- displayFields(searchType: string) {
150
- return new Promise((resolve, reject) => {
151
- if(!_.has(this.searchTypes, searchType)) {
152
- reject(new CWError(1, 'SearchType provided does not exist or is mispelled.', {'provided': searchType, 'available':this.searchTypes}))
153
- }
154
- var data = {
155
- searchType: _.get(this.searchTypes, searchType)
156
- }
157
- this.cw.runRequest('Ams/Search/DisplayFields', data).then(r => {
158
- resolve(r.Value)
159
- }).catch(e => {
160
- reject(e)
161
- })
162
- })
163
- }
164
-
165
- /**
166
- * Get a list search types
167
- *
168
- * @category Search Options
169
- * @return {Object} Returns Promise object that represents a collection of SearchTypeInfo objects
170
- */
171
- types() {
172
- return new Promise((resolve, reject) => {
173
- var data = {}
174
- this.cw.runRequest('Ams/Search/Types', data).then(r => {
175
- resolve(r.Value)
176
- }).catch(e => {
177
- reject(e)
178
- })
179
- })
180
- }
181
-
182
- /**
183
- * Enable Service URLs on Saved Searches
184
- *
185
- * @category Search Options
186
- * @param {Array<number>} searchIds - Search IDs to enable eURL on
187
- * @return {Object} Returns Promise object that represents a dictionary of SearchIds and EURL booleans
188
- */
189
- enableServices(searchIds: Array<number>) {
190
- return new Promise((resolve, reject) => {
191
- var data = {
192
- Enable: true,
193
- SearchIds: searchIds
194
- }
195
- this.cw.runRequest('Ams/Search/UpdateEurl', data).then(r => {
196
- resolve(r.Value)
197
- }).catch(e => {
198
- reject(e)
199
- })
200
- })
201
- }
202
-
203
- /**
204
- * Disable Service URLs on Saved Searches
205
- *
206
- * @category Search Options
207
- * @param {Array<number>} searchIds - Search IDs to enable eURL on
208
- * @return {Object} Returns Promise object that represents a dictionary of SearchIds and EURL booleans
209
- */
210
- disableServices(searchIds: Array<number>) {
211
- return new Promise((resolve, reject) => {
212
- var data = {
213
- Enable: false,
214
- SearchIds: searchIds
215
- }
216
- this.cw.runRequest('Ams/Search/UpdateEurl', data).then(r => {
217
- resolve(r.Value)
218
- }).catch(e => {
219
- reject(e)
220
- })
221
- })
222
- }
223
-
224
- /**
225
- * Get a search definition
226
- *
227
- * @category Search Definitions
228
- * @param {number} searchId - SearchId to get.
229
- * @param {number} employeeSid - Enforces employee security settings on search definition if provided.
230
- * @return {Object} Returns Promise object that represents a SearchDefinition object
231
- */
232
- getDefinition(searchId: number, employeeSid?: number) {
233
- return new Promise((resolve, reject) => {
234
- var data = {
235
- SearchId: searchId
236
- }
237
- if(typeof(employeeSid)!='undefined') {
238
- _.set(data, 'EmployeeSid', employeeSid)
239
- }
240
- this.cw.runRequest('Ams/Search/Definition', data).then(r => {
241
- resolve(r.Value)
242
- }).catch(e => {
243
- reject(e)
244
- })
245
- })
246
- }
247
-
248
- /**
249
- * Get search definitions
250
- *
251
- * @category Search Definitions
252
- * @param {Array<number>} searchIds - SearchIds to get.
253
- * @param {number} employeeSid - Enforces employee security settings on search definition if provided.
254
- * @return {Object} Returns Promise object that represents a collection of SearchDefinition objects
255
- */
256
- getDefinitions(searchIds: Array<number>, employeeSid?: number) {
257
- return new Promise((resolve, reject) => {
258
- var data = {
259
- SearchIds: searchIds
260
- }
261
- if(typeof(employeeSid)!='undefined') {
262
- _.set(data, 'EmployeeSid', employeeSid)
263
- }
264
- this.cw.runRequest('Ams/Search/Definitions', data).then(r => {
265
- resolve(r.Value)
266
- }).catch(e => {
267
- reject(e)
268
- })
269
- })
270
- }
271
-
272
- /**
273
- * Get search definition names
274
- *
275
- * @category Search Definitions
276
- * @param {Array<number>} searchIds - SearchIds to get.
277
- * @return {Object} Returns Promise object that represents a collection of SearchDefinitionNames
278
- */
279
- getDefinitionNames(searchIds: Array<number>) {
280
- return new Promise((resolve, reject) => {
281
- var data = {
282
- SearchIds: searchIds
283
- }
284
- this.cw.runRequest('Ams/Search/DefinitionNames', data).then(r => {
285
- resolve(r.Value)
286
- }).catch(e => {
287
- reject(e)
288
- })
289
- })
290
- }
291
-
292
- /**
293
- * Delete search definitions
294
- *
295
- * @category Search Definitions
296
- * @param {Array<number>} searchIds - SearchIds to get.
297
- * @return {Object} Returns Promise object that represents a list (dictionary) of search IDs and deletion success boolean
298
- */
299
- deleteDefinitions(searchIds: Array<number>) {
300
- return new Promise((resolve, reject) => {
301
- var data = {
302
- SearchIds: searchIds
303
- }
304
- this.cw.runRequest('Ams/Search/DeleteDefinitions', data).then(r => {
305
- resolve(r.Value)
306
- }).catch(e => {
307
- reject(e)
308
- })
309
- })
310
- }
311
-
312
- /**
313
- * Save a search definition
314
- *
315
- * @category Search Definitions
316
- * @param {string} searchFor - Name of type to search for from searchTypes
317
- * @param {Object} options - Other options. See: /{subdirectory}/apidocs/#/service-info/Ams/Search
318
- * @param {number} searchId - SearchId to update. Defaults to "0" which is "Create new saved search"
319
- * @return {Object} Returns Promise object that represents a SearchDefinitionName object
320
- */
321
- saveDefinition(searchFor: string, options?: Object, searchId: number = 0) {
322
- return new Promise((resolve, reject) => {
323
- if(!_.has(this.searchTypes, searchFor)) {
324
- reject(new CWError(1, 'SearchType provided does not exist or is mispelled.', {'provided': searchFor, 'available':this.searchTypes}))
325
- }
326
- var data = {
327
- SearchFor: _.get(this.searchTypes, searchFor),
328
- SearchId: searchId
329
- }
330
- data = _.merge(data, options)
331
- this.cw.runRequest('Ams/Search/SaveDefinition', data).then(r => {
332
- resolve(r.Value)
333
- }).catch(e => {
334
- reject(e)
335
- })
336
- })
337
- }
338
-
339
- }