cityworks 0.0.30 → 0.0.35
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/LICENSE +1 -1
- package/README.md +24 -24
- package/dist/activity_link.d.ts +6 -3
- package/dist/case.d.ts +4 -0
- package/dist/case_assets.d.ts +88 -0
- package/dist/case_data.d.ts +1 -1
- package/dist/case_workflow.d.ts +28 -0
- package/dist/cityworks.d.ts +238 -0
- package/dist/comments.d.ts +2 -2
- package/dist/error.d.ts +7 -4
- package/dist/general.d.ts +2 -2
- package/dist/gis.d.ts +17 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -0
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/inspection.d.ts +2 -2
- package/dist/inspection_admin.d.ts +15 -0
- package/dist/request.d.ts +10 -2
- package/dist/request_admin.d.ts +8 -0
- package/dist/workorder.d.ts +7 -7
- package/dist/workorder_admin.d.ts +101 -0
- package/package.json +13 -12
- package/src/activity_link.ts +17 -3
- package/src/case.ts +44 -0
- package/src/case_assets.ts +129 -0
- package/src/case_data.ts +54 -3
- package/src/case_workflow.ts +72 -0
- package/src/cityworks.ts +43 -19
- package/src/comments.ts +13 -5
- package/src/costs.ts +289 -0
- package/src/error.ts +11 -3
- package/src/event_layer.ts +219 -28
- package/src/general.ts +5 -3
- package/src/gis.ts +92 -57
- package/src/inspection.ts +2 -2
- package/src/inspection_admin.ts +28 -0
- package/src/message_queue.ts +10 -0
- package/src/request.ts +22 -2
- package/src/request_admin.ts +18 -0
- package/src/workorder.ts +9 -9
- package/src/workorder_admin.ts +231 -0
- package/test/01.cityworksTest.js +12 -12
- package/test/08.workOrderTest.js +1 -1
- package/test/09.caseAssetsTest.js +72 -0
package/dist/inspection.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class Inspection {
|
|
|
44
44
|
*/
|
|
45
45
|
createFromServiceRequest(insp_data: Object): Promise<unknown>;
|
|
46
46
|
/**
|
|
47
|
-
* Create an inspection from a
|
|
47
|
+
* Create an inspection from a WorkOrder
|
|
48
48
|
*
|
|
49
49
|
* @category Inspections
|
|
50
50
|
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
@@ -266,7 +266,7 @@ export declare class Inspection {
|
|
|
266
266
|
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
267
267
|
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
268
268
|
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
269
|
-
* @return {Object} Returns Promise that represents a collection of all
|
|
269
|
+
* @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
|
|
270
270
|
*/
|
|
271
271
|
getTemplates(entityTypes?: Array<string>, canCreate?: boolean, options?: {
|
|
272
272
|
IncludeInactive?: boolean;
|
|
@@ -7,4 +7,19 @@ export declare class InspectionAdmin {
|
|
|
7
7
|
* @hidden
|
|
8
8
|
*/
|
|
9
9
|
constructor(cw: any);
|
|
10
|
+
/**
|
|
11
|
+
* Get inspection templates
|
|
12
|
+
*
|
|
13
|
+
* @category Inspection Templates
|
|
14
|
+
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
15
|
+
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
16
|
+
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
17
|
+
* @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
|
|
18
|
+
*/
|
|
19
|
+
getTemplates(entityTypes?: Array<string>, canCreate?: boolean, options?: {
|
|
20
|
+
IncludeInactive?: boolean;
|
|
21
|
+
MaximumDateModified?: Date;
|
|
22
|
+
MinimumDateModified?: Date;
|
|
23
|
+
TemplateIds?: Array<number>;
|
|
24
|
+
}): Promise<unknown>;
|
|
10
25
|
}
|
package/dist/request.d.ts
CHANGED
|
@@ -47,6 +47,14 @@ export declare class Request {
|
|
|
47
47
|
WKT?: string;
|
|
48
48
|
VcsWKID?: string;
|
|
49
49
|
}, z?: number): Promise<unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* Update request's map layer fields
|
|
52
|
+
*
|
|
53
|
+
* @category Requests
|
|
54
|
+
* @param {number} requestId
|
|
55
|
+
* @return {Object} Returns Promise that represents an object describing the updated map layer fields
|
|
56
|
+
*/
|
|
57
|
+
updateMLF: (requestId: number) => Promise<unknown>;
|
|
50
58
|
/**
|
|
51
59
|
* Change a request's problem code
|
|
52
60
|
*
|
|
@@ -317,11 +325,11 @@ export declare class Request {
|
|
|
317
325
|
*/
|
|
318
326
|
getTemplates(templateIds: Array<number>, canCreate?: boolean, includeInactiveIf?: boolean, minimumDateModified?: Date, maximumDateModified?: Date): Promise<unknown>;
|
|
319
327
|
/**
|
|
320
|
-
* Get
|
|
328
|
+
* Get WorkOrder templates that are associated to this request template type
|
|
321
329
|
*
|
|
322
330
|
* @category Request Templates
|
|
323
331
|
* @param {Array<number>} problemSids - An array list of problemSids to retrieve Problem WO templates for
|
|
324
|
-
* @param {boolean} includeInactiveIf - Include inactive
|
|
332
|
+
* @param {boolean} includeInactiveIf - Include inactive WorkOrder templates, default is false
|
|
325
333
|
* @return {Object} Returns Promise that represents a collection of Problem WO Templates. See /{subdirectory}/apidocs/#/data-type-info;dataType=ProblemWOTemplate
|
|
326
334
|
*/
|
|
327
335
|
getWOTemplates(problemSids: Array<number>, includeInactive?: boolean): Promise<unknown>;
|
package/dist/request_admin.d.ts
CHANGED
|
@@ -7,4 +7,12 @@ export declare class RequestAdmin {
|
|
|
7
7
|
* @hidden
|
|
8
8
|
*/
|
|
9
9
|
constructor(cw: any);
|
|
10
|
+
/**
|
|
11
|
+
* Get service request templates
|
|
12
|
+
*
|
|
13
|
+
* @category Requests Admin
|
|
14
|
+
* @param {Object} searchData - search data
|
|
15
|
+
* @return {Object} Returns Promise that represents a collection of all Service Request Templates
|
|
16
|
+
*/
|
|
17
|
+
getTemplates(searchData: Object): Promise<unknown>;
|
|
10
18
|
}
|
package/dist/workorder.d.ts
CHANGED
|
@@ -47,8 +47,8 @@ export declare class WorkOrder {
|
|
|
47
47
|
*
|
|
48
48
|
* @category WorkOrders
|
|
49
49
|
* @param {Array<string>} fromWorkOrderIds - The workorder IDs which should be combined.
|
|
50
|
-
* @param {string} toWorkOrderId - The
|
|
51
|
-
* @param {boolean} cancelCombinedWorkOrders - If the
|
|
50
|
+
* @param {string} toWorkOrderId - The WorkOrder ID for the single WorkOrder that should contain the info/entities from the other WorkOrders
|
|
51
|
+
* @param {boolean} cancelCombinedWorkOrders - If the WorkOrders combined into the single should then be canceled, default is true.
|
|
52
52
|
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
53
53
|
*/
|
|
54
54
|
combine(fromWorkOrderIds: Array<string>, toWorkOrderId: string, cancelCombinedWorkOrders?: boolean): Promise<unknown>;
|
|
@@ -120,7 +120,7 @@ export declare class WorkOrder {
|
|
|
120
120
|
* @category WorkOrders
|
|
121
121
|
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
122
122
|
* @param {Object} entityInfo - Entity info object including: (req) EntityType: {string}, (req) EntityUids: {Array<string>}, Facility_Id: {string}, Level_Id: {string}
|
|
123
|
-
* @param {boolean} updateXY - Update
|
|
123
|
+
* @param {boolean} updateXY - Update WorkOrder xy after adding entit(y|ies), default is true.
|
|
124
124
|
* @return {Object} Returns object that represents a list of entities removed.
|
|
125
125
|
*/
|
|
126
126
|
addEntities(workOrderSId: string | number, entityInfo: Object, updateXY?: boolean): Promise<unknown>;
|
|
@@ -135,12 +135,12 @@ export declare class WorkOrder {
|
|
|
135
135
|
*/
|
|
136
136
|
updateEntity(workOrderSId: string | number, entityInfo: Object, workComplete?: boolean): Promise<unknown>;
|
|
137
137
|
/**
|
|
138
|
-
* Remove entities from a
|
|
138
|
+
* Remove entities from a WorkOrder. Provide WorkOrderId and either ObjectIds or EntityType and EntityUids
|
|
139
139
|
*
|
|
140
140
|
* @category WorkOrders
|
|
141
141
|
* @param {number} workOrderSId - The workorder S/ID which the entities should be removed from. # for SID, string for ID.
|
|
142
142
|
* @param {Object} entityInfo - Remove entities by WorkOrderEntity.ObjectId (not gis objectId).
|
|
143
|
-
* @param {boolean} updateXY - Update
|
|
143
|
+
* @param {boolean} updateXY - Update WorkOrder xy after removing entities, default is true.
|
|
144
144
|
* @return {Object} Returns object that represents a list of entities removed.
|
|
145
145
|
*/
|
|
146
146
|
removeEntities(workOrderSId: string | number, entityInfo: Object, updateXY?: boolean): Promise<unknown>;
|
|
@@ -190,10 +190,10 @@ export declare class WorkOrder {
|
|
|
190
190
|
* Get WorkOrderS/IDs connected to provided entities
|
|
191
191
|
*
|
|
192
192
|
* @category WorkOrder Search
|
|
193
|
-
* @param {string} entityType - The entity type to find connected
|
|
193
|
+
* @param {string} entityType - The entity type to find connected WorkOrders
|
|
194
194
|
* @param {Array<string>} entityUIDs - The list of entities to search for connected WorkOrders
|
|
195
195
|
* @param {boolean} s - Get WorkOrderSids. Defaults to true. When false, returned list is WorkOrderIds
|
|
196
|
-
* @param {Object} [search] - Any additional search properties of the
|
|
196
|
+
* @param {Object} [search] - Any additional search properties of the WorkOrder (open/closed, etc)
|
|
197
197
|
* @return {Object} Returns Promise that represents an array of WorkOrderS/IDs
|
|
198
198
|
*/
|
|
199
199
|
getWOsByEntities(entityType: string, entityUids: Array<string>, search?: Array<string | number>, s?: boolean): Promise<unknown>;
|
|
@@ -7,4 +7,105 @@ export declare class WorkOrderAdmin {
|
|
|
7
7
|
* @hidden
|
|
8
8
|
*/
|
|
9
9
|
constructor(cw: any);
|
|
10
|
+
/**
|
|
11
|
+
* Get entity groups
|
|
12
|
+
*
|
|
13
|
+
* @category WorkOrders Admin
|
|
14
|
+
* @return {Object} Returns Promise that represents a collection of all entity groups
|
|
15
|
+
*/
|
|
16
|
+
getEntityGroups(): Promise<unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Get entity types
|
|
19
|
+
*
|
|
20
|
+
* @category WorkOrders Admin
|
|
21
|
+
* @return {Object} Returns Promise that represents a collection of all GIS WorkOrder entity types
|
|
22
|
+
*/
|
|
23
|
+
getEntityTypes(entityGroups: Array<string>): Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Get WorkOrder templates
|
|
26
|
+
*
|
|
27
|
+
* @category WorkOrders Admin
|
|
28
|
+
* @return {Object} Returns Promise that represents a collection of all WorkOrder templates
|
|
29
|
+
*/
|
|
30
|
+
getTemplates(entityType: string, includeComments?: boolean, includeInstructions?: boolean): Promise<unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Update WorkOrder template
|
|
33
|
+
*
|
|
34
|
+
* @category WorkOrders Admin
|
|
35
|
+
* @param {Object} wOTemplate - Obect that describes the WorkOrder Template
|
|
36
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
37
|
+
*/
|
|
38
|
+
updateTemplate(wOTemplate: Object): Promise<unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Get template group rights for provided WorkOrder Templates
|
|
41
|
+
*
|
|
42
|
+
* @category WorkOrders Admin
|
|
43
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
44
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
45
|
+
*/
|
|
46
|
+
getTemplateGroupRights(wOTemplateIds: Array<number>): Promise<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Get template activity services for provided WorkOrder Templates
|
|
49
|
+
*
|
|
50
|
+
* @category WorkOrders Admin
|
|
51
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
52
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
53
|
+
*/
|
|
54
|
+
getTemplateActivity(wOTemplateIds: Array<number>): Promise<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Get fields which will be updated when provided WorkOrder Template instance closes
|
|
57
|
+
*
|
|
58
|
+
* @category WorkOrders Admin
|
|
59
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
60
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
61
|
+
*/
|
|
62
|
+
getUpdateFields(wOTemplateIds: Array<number>): Promise<unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* Get equipment
|
|
65
|
+
*
|
|
66
|
+
* @category WorkOrders Admin
|
|
67
|
+
* @param {Array<number>} wOTemplateIds - WorkOrder Template ID
|
|
68
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
69
|
+
*/
|
|
70
|
+
getTemplateEquipment(wOTemplateId: number): Promise<unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Get labor
|
|
73
|
+
*
|
|
74
|
+
* @category WorkOrders Admin
|
|
75
|
+
* @param {Array<number>} wOTemplateIds - WorkOrder Template ID
|
|
76
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
77
|
+
*/
|
|
78
|
+
getTemplateLabor(wOTemplateId: number): Promise<unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Get material
|
|
81
|
+
*
|
|
82
|
+
* @category WorkOrders Admin
|
|
83
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
84
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
85
|
+
*/
|
|
86
|
+
getTemplateMaterial(wOTemplateId: number): Promise<unknown>;
|
|
87
|
+
/**
|
|
88
|
+
* Get map layer fields configured for provided WorkOrder template
|
|
89
|
+
*
|
|
90
|
+
* @category WorkOrders Admin
|
|
91
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
92
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
93
|
+
*/
|
|
94
|
+
getTemplateMapLayerFields(wOTemplateId: number): Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Get tasks configured for provided WorkOrder template
|
|
97
|
+
*
|
|
98
|
+
* @category WorkOrders Admin
|
|
99
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
100
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on WorkOrder template
|
|
101
|
+
*/
|
|
102
|
+
getTemplateTasks(wOTemplateId: number): Promise<unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* Get inspections connected to provided WorkOrder template
|
|
105
|
+
*
|
|
106
|
+
* @category WorkOrders Admin
|
|
107
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
108
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on WorkOrder template
|
|
109
|
+
*/
|
|
110
|
+
getRelatedInspectionTemplates(wOTemplateId: number): Promise<unknown>;
|
|
10
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cityworks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "A Cityworks API wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"umd:main": "dist/index.umd.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "microbundle watch",
|
|
14
14
|
"build": "microbundle",
|
|
15
|
-
"test": "mocha --recursive
|
|
15
|
+
"test": "mocha -R spec --recursive ./test/ -g ",
|
|
16
|
+
"fulltest": "mocha -R spec --recursive ./test/",
|
|
16
17
|
"docs": "./node_modules/typedoc/bin/typedoc --tsconfig ./tsconfig.json"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
@@ -35,17 +36,17 @@
|
|
|
35
36
|
"homepage": "https://walker.github.io/cityworks/",
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"chai": "*",
|
|
38
|
-
"chai-as-promised": "
|
|
39
|
-
"dotenv": "
|
|
40
|
-
"jsdoc-to-markdown": "
|
|
41
|
-
"microbundle": "
|
|
42
|
-
"mocha": "
|
|
43
|
-
"typedoc": "
|
|
44
|
-
"typescript": "^4.
|
|
45
|
-
"winston": "
|
|
39
|
+
"chai-as-promised": "~7.1.1",
|
|
40
|
+
"dotenv": "~16.0.0",
|
|
41
|
+
"jsdoc-to-markdown": "~8.0.0",
|
|
42
|
+
"microbundle": "~0.15.1",
|
|
43
|
+
"mocha": "~10.2.0",
|
|
44
|
+
"typedoc": "~0.23.24",
|
|
45
|
+
"typescript": "^4.9.5",
|
|
46
|
+
"winston": "~3.8.2"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"lodash": "
|
|
49
|
-
"reversible-map": "
|
|
49
|
+
"lodash": "~4.17.21",
|
|
50
|
+
"reversible-map": "~1.0.1"
|
|
50
51
|
}
|
|
51
52
|
}
|
package/src/activity_link.ts
CHANGED
|
@@ -2,14 +2,18 @@ import { CWError } from './error'
|
|
|
2
2
|
import ReversibleMap from 'reversible-map'
|
|
3
3
|
const _ = require('lodash')
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* ActivityLink interface for ActivityLinks
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export interface ActivityLink {
|
|
6
10
|
linkTypes: ReversibleMap<string, number>
|
|
7
11
|
activityTypes: ReversibleMap<string, number>
|
|
8
12
|
cw: any
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
|
-
* ActivityLinks implements the activity link functions
|
|
16
|
+
* ActivityLinks implements the activity link functions via using the ActivityLink interface
|
|
13
17
|
*
|
|
14
18
|
*/
|
|
15
19
|
export class ActivityLinks implements ActivityLink {
|
|
@@ -89,6 +93,8 @@ export class ActivityLinks implements ActivityLink {
|
|
|
89
93
|
let path = 'General/ActivityLink/Add'
|
|
90
94
|
this.cw.runRequest(path, data).then((response: any) => {
|
|
91
95
|
resolve(response.Value)
|
|
96
|
+
}).catch(e => {
|
|
97
|
+
reject(e)
|
|
92
98
|
})
|
|
93
99
|
})
|
|
94
100
|
}
|
|
@@ -123,6 +129,8 @@ export class ActivityLinks implements ActivityLink {
|
|
|
123
129
|
return_data.push(link)
|
|
124
130
|
})
|
|
125
131
|
resolve(return_data)
|
|
132
|
+
}).catch(e => {
|
|
133
|
+
reject(e)
|
|
126
134
|
})
|
|
127
135
|
})
|
|
128
136
|
}
|
|
@@ -148,7 +156,7 @@ export class ActivityLinks implements ActivityLink {
|
|
|
148
156
|
reject(new CWError(1, 'Source type not found.', {'provided': source_type, 'options':this.activityTypes}))
|
|
149
157
|
}
|
|
150
158
|
if(!this.activityTypes.has(destination_type)) {
|
|
151
|
-
reject(new CWError(
|
|
159
|
+
reject(new CWError(2, 'Destination type not found.', {'provided': destination_type, 'options':this.activityTypes}))
|
|
152
160
|
}
|
|
153
161
|
let data = {
|
|
154
162
|
SourceActivityType: this.activityTypes.get(source_type),
|
|
@@ -159,6 +167,8 @@ export class ActivityLinks implements ActivityLink {
|
|
|
159
167
|
let path = 'General/ActivityLink/CloneByActivitySid'
|
|
160
168
|
this.cw.runRequest(path, data).then((response: any) => {
|
|
161
169
|
resolve(response.Value)
|
|
170
|
+
}).catch(e => {
|
|
171
|
+
reject(e)
|
|
162
172
|
})
|
|
163
173
|
})
|
|
164
174
|
}
|
|
@@ -177,6 +187,8 @@ export class ActivityLinks implements ActivityLink {
|
|
|
177
187
|
let path = 'General/ActivityLink/Delete'
|
|
178
188
|
this.cw.runRequest(path, data).then((response: any) => {
|
|
179
189
|
resolve(response.Value)
|
|
190
|
+
}).catch(e => {
|
|
191
|
+
reject(e)
|
|
180
192
|
})
|
|
181
193
|
})
|
|
182
194
|
}
|
|
@@ -221,6 +233,8 @@ export class ActivityLinks implements ActivityLink {
|
|
|
221
233
|
let path = 'General/ActivityLink/Remove'
|
|
222
234
|
this.cw.runRequest(path, data).then((response: any) => {
|
|
223
235
|
resolve(response.Value)
|
|
236
|
+
}).catch(e => {
|
|
237
|
+
reject(e)
|
|
224
238
|
})
|
|
225
239
|
})
|
|
226
240
|
}
|
package/src/case.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { CaseFinancial } from './case_financial'
|
|
|
6
6
|
import { CaseWorkflow} from './case_workflow'
|
|
7
7
|
import { CaseAdmin } from './case_admin'
|
|
8
8
|
import { Comments } from './comments'
|
|
9
|
+
import { CaseAssets } from './case_assets'
|
|
9
10
|
|
|
10
11
|
export class Case {
|
|
11
12
|
/**
|
|
@@ -18,6 +19,10 @@ export class Case {
|
|
|
18
19
|
* Data Detail methods
|
|
19
20
|
*/
|
|
20
21
|
data?: Object
|
|
22
|
+
/**
|
|
23
|
+
* Asset (Address) methods
|
|
24
|
+
*/
|
|
25
|
+
asset?: Object
|
|
21
26
|
/**
|
|
22
27
|
* Workflow & task methods
|
|
23
28
|
*/
|
|
@@ -41,6 +46,7 @@ export class Case {
|
|
|
41
46
|
constructor(cw) {
|
|
42
47
|
this.cw = cw
|
|
43
48
|
this.data = new CaseData(cw)
|
|
49
|
+
this.asset = new CaseAssets(cw)
|
|
44
50
|
this.workflow = new CaseWorkflow(cw)
|
|
45
51
|
this.financial = new CaseFinancial(cw)
|
|
46
52
|
this.comment = new Comments(cw, 'CaObject')
|
|
@@ -235,4 +241,42 @@ export class Case {
|
|
|
235
241
|
})
|
|
236
242
|
}
|
|
237
243
|
|
|
244
|
+
// importCase(caseTypeId: number, subTypeId: number, caseName: string, location: string, x: number, y:number, appData: object, comment: string, expiration: string, assetIds: object) {
|
|
245
|
+
// return new Promise(resolve => {
|
|
246
|
+
// const _this = this;
|
|
247
|
+
// let case_data = {"CaseName":caseName, "Location":location, "DateExpiration": expiration, "X":x,"Y":y}
|
|
248
|
+
// this.create(caseTypeId, subTypeId, case_data).then((response: any) => {
|
|
249
|
+
// if(response) {
|
|
250
|
+
// if(typeof(response.CaObjectId)!='undefined') {
|
|
251
|
+
// var CaObjectId = response.CaObjectId
|
|
252
|
+
// if(typeof(comment) != 'undefined') {
|
|
253
|
+
// _this.comments.add(CaObjectId, comment)
|
|
254
|
+
// }
|
|
255
|
+
// if(assetIds) {
|
|
256
|
+
// _this.assets!.attach(CaObjectId, true, assetIds)
|
|
257
|
+
// }
|
|
258
|
+
// if(appData) {
|
|
259
|
+
// _this.data!.getGroupsByCaseId(response.CaObjectId).then(response_one => {
|
|
260
|
+
// // loop through all groups
|
|
261
|
+
// let data_details_items = []
|
|
262
|
+
// _this.data!.caseDataGroupIterator(appData, response_one, data_details_items).then(di => {
|
|
263
|
+
// _this.data!.caseDataDetailIterator(appData, di).then(resp => {
|
|
264
|
+
// resolve(response)
|
|
265
|
+
// })
|
|
266
|
+
// })
|
|
267
|
+
// })
|
|
268
|
+
// } else {
|
|
269
|
+
// resolve(response)
|
|
270
|
+
// }
|
|
271
|
+
// } else {
|
|
272
|
+
// console.log('Error creating case: '+ JSON.stringify(case_data))
|
|
273
|
+
// process.exit(0)
|
|
274
|
+
// }
|
|
275
|
+
// } else {
|
|
276
|
+
// resolve(false)
|
|
277
|
+
// }
|
|
278
|
+
// })
|
|
279
|
+
// })
|
|
280
|
+
// }
|
|
281
|
+
|
|
238
282
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { CWError } from './error'
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
export class CaseAssets {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
cw: any
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
constructor(cw) {
|
|
15
|
+
this.cw = cw
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Attach asset to case
|
|
20
|
+
*
|
|
21
|
+
* @category Case Assets
|
|
22
|
+
* @param {number} caObjectId - The Case Object to attach the data group to.
|
|
23
|
+
* @param {boolean} updateXY - Whether or not to update the Case's X/Y values when attaching the asset. Defaults to true.
|
|
24
|
+
* @param {Object} [options] - Options for CaseDataGroup including Address, AddressId, AssetId, AssetObjectId, AssetType, CityName, CrossStreet, DateExpired, ExpiredFlag, Facility_Id, FeatureAssetId, FeatureClass, FeatureObjectId, LegacyId, Level_Id, LndObjectId, Location, MasterFlag, ObjectId, StateCode, StreetDirection, StreetFraction, StreetName, StreetNumber, StreetPostDir, StreetType, Suite, TileNo, UpdateCaseData, XCoord, YCoord, ZCoord, and ZipCode
|
|
25
|
+
* @return {Object} Returns Promise that represents an object describing CaAddress.
|
|
26
|
+
*/
|
|
27
|
+
attach(caObjectId: number, updateXY: boolean = true, options?: {Address?: string, AddressId?: number, AssetId?: string, AssetObjectId?: number, AssetType?: string, CityName?: string, CrossStreet?: string, DateExpired?: string, ExpiredFlag?: string, Facility_Id?: string, FeatureAssetId?: string, FeatureClass?: string, FeatureObjectId?: number, LegacyId?: string, Level_Id?: string, LndObjectId?: number, Location?: string, MasterFlag?: string, ObjectId?: string, StateCode?: string, StreetDirection?: string, StreetFraction?: string, StreetName?: string, StreetNumber?: number, StreetPostDir?: string, StreetType?: string, Suite?: string, TileNo?: string, UpdateCaseData?: boolean, XCoord?: number, YCoord?: number, ZCoord?: number, ZipCode?: string}) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
var data = {
|
|
30
|
+
CaObjectId: caObjectId,
|
|
31
|
+
UpdateXY: updateXY
|
|
32
|
+
}
|
|
33
|
+
if(typeof(options)!='undefined') {
|
|
34
|
+
data = _.merge(data, options)
|
|
35
|
+
}
|
|
36
|
+
this.cw.runRequest('Pll/CaseAddress/Add', data).then(r => {
|
|
37
|
+
resolve(r.Value)
|
|
38
|
+
}).catch(e => {
|
|
39
|
+
reject(e)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Detach specific asset from case
|
|
46
|
+
*
|
|
47
|
+
* @category Case Assets
|
|
48
|
+
* @param {number} caObjectId - The Case Object to attach the data group to.
|
|
49
|
+
* @param {boolean} updateXY - Whether or not to update the Case's X/Y values when detaching the assets. Defaults to true.
|
|
50
|
+
* @return {Object} Returns Promise that represents a collection of the default CaDataGroupItemBases.
|
|
51
|
+
*/
|
|
52
|
+
detach(caAddressId: number, updateXY: boolean = true) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
var data = {
|
|
55
|
+
CaAddressId: caAddressId,
|
|
56
|
+
UpdateXY: updateXY
|
|
57
|
+
}
|
|
58
|
+
this.cw.runRequest('Pll/CaseAddress/Delete', data).then(r => {
|
|
59
|
+
resolve(r.Value)
|
|
60
|
+
}).catch(e => {
|
|
61
|
+
reject(e)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Detach all assets from case
|
|
68
|
+
*
|
|
69
|
+
* @category Case Assets
|
|
70
|
+
* @param {number} caObjectId - The Case Object to detach the assets from.
|
|
71
|
+
* @param {boolean} updateXY - Whether or not to update the Case's X/Y values when detaching the asset(s). Defaults to false.
|
|
72
|
+
* @return {Object} Returns Promise that represents a collection of detached CaAddressIds.
|
|
73
|
+
*/
|
|
74
|
+
detachAll(caObjectId: number, updateXY: boolean = false) {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
var data = {
|
|
77
|
+
CaObjectId: caObjectId,
|
|
78
|
+
UpdateXY: updateXY
|
|
79
|
+
}
|
|
80
|
+
this.cw.runRequest('Pll/CaseAddress/DeleteByCaObjectId', data).then(r => {
|
|
81
|
+
resolve(r.Value)
|
|
82
|
+
}).catch(e => {
|
|
83
|
+
reject(e)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get assets attached to a specific case
|
|
90
|
+
*
|
|
91
|
+
* @category Case Assets
|
|
92
|
+
* @param {number} caObjectId - The Case Object from which to get attached assets
|
|
93
|
+
* @return {Object} Returns Promise that represents a collection of the default CaAddresses.
|
|
94
|
+
*/
|
|
95
|
+
getForCase(caObjectId: number) {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
var data = {
|
|
98
|
+
CaObjectId: caObjectId
|
|
99
|
+
}
|
|
100
|
+
this.cw.runRequest('Pll/CaseAddress/ByCaObjectId', data).then(r => {
|
|
101
|
+
resolve(r.Value)
|
|
102
|
+
}).catch(e => {
|
|
103
|
+
reject(e)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Search for Case Assets. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
|
|
111
|
+
*
|
|
112
|
+
* @category Case Assets
|
|
113
|
+
* @param {Object} filters - The parameters to search by. (AssetType, CaAddressId, CaObjectId, CityName, ExpiredFlag, StateCode, StateName, StreetName, StreetNumber, Suite, ZipCode)
|
|
114
|
+
* @return {Object} Returns Promise that represents an Array of resulting CaAddresses
|
|
115
|
+
*/
|
|
116
|
+
search(filters?: Object) {
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
if(_.intersectionBy(_.keysIn(filters), ['AssetType', 'CaAddressId', 'CaObjectId', 'CityName', 'ExpiredFlag', 'StateCode', 'StateName', 'StreetName', 'StreetNumber', 'Suite', 'ZipCode']).length==0) {
|
|
119
|
+
reject(new CWError(3, 'At least one of the attributes (AssetType, CaAddressId, CaObjectId, CityName, ExpiredFlag, StateCode, StateName, StreetName, StreetNumber, Suite, ZipCode) must be defined.'))
|
|
120
|
+
}
|
|
121
|
+
var data = filters
|
|
122
|
+
this.cw.runRequest('Pll/CaseAddress/Search', data).then(r => {
|
|
123
|
+
resolve(r.Value)
|
|
124
|
+
}).catch(e => {
|
|
125
|
+
reject(e)
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}
|
package/src/case_data.ts
CHANGED
|
@@ -375,13 +375,13 @@ export class CaseData {
|
|
|
375
375
|
* Search for List Value Objects. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
|
|
376
376
|
*
|
|
377
377
|
* @category Data List Values
|
|
378
|
-
* @param {Object} filters - The parameters to search by. (CaDataDetailId, CaDataListId, ListValue)
|
|
378
|
+
* @param {Object} filters - The parameters to search by. (CaDataDetailId, CaDataListId, ListValue, CaDataGroupId)
|
|
379
379
|
* @return {Object} Returns Promise that represents a collection of resulting CaDataListValuesItemBase objects
|
|
380
380
|
*/
|
|
381
381
|
searchForListValueObjects(filters?: Object) {
|
|
382
382
|
return new Promise((resolve, reject) => {
|
|
383
|
-
if(_.intersectionBy(_.keysIn(filters), ['CaDataDetailId', 'CaDataListId', 'ListValue']).length==0) {
|
|
384
|
-
reject(new CWError(
|
|
383
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaDataDetailId', 'CaDataListId', 'ListValue', 'CaDataGroupId']).length==0) {
|
|
384
|
+
reject(new CWError(4, 'At least one of the attributes (CaDataDetailId, CaDataListId, ListValue, CaDataGroupId) must be defined.'))
|
|
385
385
|
}
|
|
386
386
|
var data = filters
|
|
387
387
|
this.cw.runRequest('Pll/CaseDataGroup/SearchObject', data).then(r => {
|
|
@@ -392,4 +392,55 @@ export class CaseData {
|
|
|
392
392
|
})
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
// caseDataGroupIterator(appData: object, groups: Array<number>, items: Array<object>) {
|
|
396
|
+
// return new Promise(resolve => {
|
|
397
|
+
// var detail_items = items
|
|
398
|
+
// var dataDetailGroup = groups.pop()
|
|
399
|
+
// this.searchForListValueObjects({CaDataGroupId: dataDetailGroup!.CaDataGroupId}).then(r => {
|
|
400
|
+
// r.forEach(function (item) {
|
|
401
|
+
// detail_items.push(item)
|
|
402
|
+
// })
|
|
403
|
+
// if(groups.length>0) {
|
|
404
|
+
// this.caseDataGroupIterator(appData, groups, detail_items).then(di => {
|
|
405
|
+
// resolve(di)
|
|
406
|
+
// })
|
|
407
|
+
// } else {
|
|
408
|
+
// resolve(detail_items)
|
|
409
|
+
// }
|
|
410
|
+
// })
|
|
411
|
+
// })
|
|
412
|
+
// }
|
|
413
|
+
|
|
414
|
+
// caseDataDetailIterator(appData: object, detail_items: Array<object>) {
|
|
415
|
+
// return new Promise(resolve => {
|
|
416
|
+
// const this_data_detail = detail_items.pop()
|
|
417
|
+
// const detailCode = this_data_detail.DetailCode
|
|
418
|
+
// const detailId = this_data_detail.CaDataDetailId
|
|
419
|
+
// if(typeof(this_data_detail)!='undefined' && typeof(appData[detailCode])!='undefined') {
|
|
420
|
+
// this.searchForListValueObjects(detailId).then(r => {
|
|
421
|
+
// var CaseDataDetailUpdate = r.Value
|
|
422
|
+
// var rType = r.Value
|
|
423
|
+
// CaseDataDetailUpdate[rType] = appData[CaseDataDetailUpdate.DetailCode]
|
|
424
|
+
// this.updateDetail(CaseDataDetailUpdate).then(response => {
|
|
425
|
+
// if(detail_items.length > 0) {
|
|
426
|
+
// this.caseDataDetailIterator(appData, detail_items).then(resp => {
|
|
427
|
+
// resolve(resp)
|
|
428
|
+
// })
|
|
429
|
+
// } else {
|
|
430
|
+
// resolve(true)
|
|
431
|
+
// }
|
|
432
|
+
// })
|
|
433
|
+
// })
|
|
434
|
+
// } else {
|
|
435
|
+
// if(detail_items.length > 0) {
|
|
436
|
+
// this.caseDataDetailIterator(appData, detail_items).then(resp => {
|
|
437
|
+
// resolve(resp)
|
|
438
|
+
// })
|
|
439
|
+
// } else {
|
|
440
|
+
// resolve(true)
|
|
441
|
+
// }
|
|
442
|
+
// }
|
|
443
|
+
// });
|
|
444
|
+
// }
|
|
445
|
+
|
|
395
446
|
}
|