cityworks 0.0.32 → 0.0.36

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 CHANGED
@@ -4,11 +4,11 @@ This API wrapper for Cityworks follows the Cityworks release schedule as closely
4
4
 
5
5
  Require the class:
6
6
 
7
- const Cityworks = require('cityworks');
7
+ const Cityworks = require('cityworks')
8
8
 
9
9
  Instantiate the Class for the instance of Cityworks available given a domain:
10
10
 
11
- let cw = new Cityworks(CW_DOMAIN)
11
+ let cw = new Cityworks('cw.domain.tld', {path: 'cityworks'})
12
12
 
13
13
  ## Authentication
14
14
 
@@ -17,17 +17,17 @@ Authenticate with the Cityworks install:
17
17
  cw.authenticate('myuser', 'mypassword').then(resp => {
18
18
 
19
19
  }).catch(error => {
20
- console.log(error.message);
21
- });
20
+ console.log(error.message)
21
+ })
22
22
 
23
23
 
24
24
  Get the currently valid token in order to store it in a session or cookie:
25
25
 
26
- cityworks.getToken();
26
+ cityworks.getToken()
27
27
 
28
28
  Provide a saved token instead of the standard u/p auth:
29
29
 
30
- cityworks.setToken('mytoken');
30
+ cityworks.setToken('mytoken')
31
31
 
32
32
  ## Main method calls
33
33
 
@@ -78,7 +78,7 @@ Some of the methods are general or top-level, and so, are accessed separately ar
78
78
 
79
79
  })
80
80
 
81
- ## Case finnacials, data details, and admin
81
+ ## Case financials, data details, and admin
82
82
 
83
83
  For the sake of organizing some of the other methods needed by the primary and secondary libraries, there are also objects and methods accessed within those main libraries:
84
84
 
package/dist/case.d.ts CHANGED
@@ -7,6 +7,10 @@ export declare class Case {
7
7
  * Data Detail methods
8
8
  */
9
9
  data?: Object;
10
+ /**
11
+ * Asset (Address) methods
12
+ */
13
+ asset?: Object;
10
14
  /**
11
15
  * Workflow & task methods
12
16
  */
@@ -0,0 +1,88 @@
1
+ export declare class CaseAssets {
2
+ /**
3
+ * @hidden
4
+ */
5
+ cw: any;
6
+ /**
7
+ * @hidden
8
+ */
9
+ constructor(cw: any);
10
+ /**
11
+ * Attach asset to case
12
+ *
13
+ * @category Case Assets
14
+ * @param {number} caObjectId - The Case Object to attach the data group to.
15
+ * @param {boolean} updateXY - Whether or not to update the Case's X/Y values when attaching the asset. Defaults to true.
16
+ * @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
17
+ * @return {Object} Returns Promise that represents an object describing CaAddress.
18
+ */
19
+ attach(caObjectId: number, updateXY?: boolean, options?: {
20
+ Address?: string;
21
+ AddressId?: number;
22
+ AssetId?: string;
23
+ AssetObjectId?: number;
24
+ AssetType?: string;
25
+ CityName?: string;
26
+ CrossStreet?: string;
27
+ DateExpired?: string;
28
+ ExpiredFlag?: string;
29
+ Facility_Id?: string;
30
+ FeatureAssetId?: string;
31
+ FeatureClass?: string;
32
+ FeatureObjectId?: number;
33
+ LegacyId?: string;
34
+ Level_Id?: string;
35
+ LndObjectId?: number;
36
+ Location?: string;
37
+ MasterFlag?: string;
38
+ ObjectId?: string;
39
+ StateCode?: string;
40
+ StreetDirection?: string;
41
+ StreetFraction?: string;
42
+ StreetName?: string;
43
+ StreetNumber?: number;
44
+ StreetPostDir?: string;
45
+ StreetType?: string;
46
+ Suite?: string;
47
+ TileNo?: string;
48
+ UpdateCaseData?: boolean;
49
+ XCoord?: number;
50
+ YCoord?: number;
51
+ ZCoord?: number;
52
+ ZipCode?: string;
53
+ }): Promise<unknown>;
54
+ /**
55
+ * Detach specific asset from case
56
+ *
57
+ * @category Case Assets
58
+ * @param {number} caObjectId - The Case Object to attach the data group to.
59
+ * @param {boolean} updateXY - Whether or not to update the Case's X/Y values when detaching the assets. Defaults to true.
60
+ * @return {Object} Returns Promise that represents a collection of the default CaDataGroupItemBases.
61
+ */
62
+ detach(caAddressId: number, updateXY?: boolean): Promise<unknown>;
63
+ /**
64
+ * Detach all assets from case
65
+ *
66
+ * @category Case Assets
67
+ * @param {number} caObjectId - The Case Object to detach the assets from.
68
+ * @param {boolean} updateXY - Whether or not to update the Case's X/Y values when detaching the asset(s). Defaults to false.
69
+ * @return {Object} Returns Promise that represents a collection of detached CaAddressIds.
70
+ */
71
+ detachAll(caObjectId: number, updateXY?: boolean): Promise<unknown>;
72
+ /**
73
+ * Get assets attached to a specific case
74
+ *
75
+ * @category Case Assets
76
+ * @param {number} caObjectId - The Case Object from which to get attached assets
77
+ * @return {Object} Returns Promise that represents a collection of the default CaAddresses.
78
+ */
79
+ getForCase(caObjectId: number): Promise<unknown>;
80
+ /**
81
+ * Search for Case Assets. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
82
+ *
83
+ * @category Case Assets
84
+ * @param {Object} filters - The parameters to search by. (AssetType, CaAddressId, CaObjectId, CityName, ExpiredFlag, StateCode, StateName, StreetName, StreetNumber, Suite, ZipCode)
85
+ * @return {Object} Returns Promise that represents an Array of resulting CaAddresses
86
+ */
87
+ search(filters?: Object): Promise<unknown>;
88
+ }
@@ -157,7 +157,7 @@ export declare class CaseData {
157
157
  * Search for List Value Objects. Include one or more of the search fields. A logical 'and' operation is applied to muliple search fields
158
158
  *
159
159
  * @category Data List Values
160
- * @param {Object} filters - The parameters to search by. (CaDataDetailId, CaDataListId, ListValue)
160
+ * @param {Object} filters - The parameters to search by. (CaDataDetailId, CaDataListId, ListValue, CaDataGroupId)
161
161
  * @return {Object} Returns Promise that represents a collection of resulting CaDataListValuesItemBase objects
162
162
  */
163
163
  searchForListValueObjects(filters?: Object): Promise<unknown>;
@@ -156,4 +156,32 @@ export declare class CaseWorkflow {
156
156
  * @return {Object} Returns Promise that represents a collection of resulting CaTaskResultsItem
157
157
  */
158
158
  searchForTaskResults(filters?: Object): Promise<unknown>;
159
+ /**
160
+ * Adds a task to the case specified by the CaObectId.
161
+ *
162
+ * @category Task Attachments
163
+ * @param {number} caTaskId - The Task ID to attach the document to
164
+ * @param {number} caObjectId - The Case Object ID
165
+ * @param {string} docName - The file name as it should display in the system
166
+ * @param {string} locationType - The location of the file...leave blank
167
+ * @param {any} file - The binary string for the file
168
+ * @return {Object} Returns Promise that represents an object describing added Attachment
169
+ */
170
+ addTaskAttachment(caTaskId: number, caObjectId: number, docName: number, file: any, locationType?: string): Promise<unknown>;
171
+ /**
172
+ * Gets each Document Attached to the specified Task
173
+ *
174
+ * @category Task Attachments
175
+ * @param {number} caTaskId - The Task ID to attach the document to
176
+ * @return {Object} Returns Promise that represents a collection of objects describing each Attachment on the provided task
177
+ */
178
+ getTaskAttachments(caTaskId: number): Promise<unknown>;
179
+ /**
180
+ * Deletes a task attachment by caRelDocId (Related Case Document ID). Same as RelDocs delete for case.
181
+ *
182
+ * @category Task Attachments
183
+ * @param {number} caRelDocId - The caRelDocId for the related document which should be deleted
184
+ * @return {Object} Returns Promise that represents the an object describing the deleted document.
185
+ */
186
+ deleteTaskAttachment(caRelDocId: number): Promise<unknown>;
159
187
  }
@@ -1 +1,239 @@
1
+ /**
2
+ * Core interface Citywork which defines the access vars for many of the functions and the connection settings
3
+ */
4
+ interface Citywork {
5
+ base_url: any;
6
+ settings: Object;
7
+ login?: string;
8
+ password?: string;
9
+ Token?: string;
10
+ gisToken?: string;
11
+ gisTokenUrl?: string;
12
+ default_domain?: any;
13
+ general?: Object;
14
+ search?: Object;
15
+ activity_link?: Object;
16
+ message_queue?: Object;
17
+ gis?: Object;
18
+ inspection?: Object;
19
+ workorder?: Object;
20
+ request?: Object;
21
+ case?: Object;
22
+ extensions: Object;
23
+ features: Object;
24
+ }
25
+ /**
26
+ * Core class Cityworks with most of the authentication and install capabilities functions
27
+ */
28
+ export default class Cityworks implements Citywork {
29
+ /**
30
+ * The domain of the cityworks install. Defaults to Cityworks Online
31
+ */
32
+ base_url: string;
33
+ /**
34
+ * Stores the currently in use authentication token
35
+ */
36
+ Token?: string;
37
+ /**
38
+ * Stores the login username
39
+ */
40
+ login?: string;
41
+ /**
42
+ * Holds the login password
43
+ */
44
+ password?: string;
45
+ /**
46
+ * Holds the GIS Token for GIS-based Authentication (Portal)
47
+ */
48
+ gisToken?: string;
49
+ /**
50
+ * Holds the GIS Token URL for GIS-based Authentication (Portal)
51
+ */
52
+ gisTokenUrl?: string;
53
+ /**
54
+ * Stores settings including path (defaults to "cityworks"), secure (defaults to true), expires (defaults to null - does not expire), default_domain
55
+ */
56
+ settings: {
57
+ path: string;
58
+ secure: boolean;
59
+ expires: any;
60
+ default_domain?: any;
61
+ };
62
+ error?: Object;
63
+ general?: Object;
64
+ search?: Object;
65
+ activity_link?: Object;
66
+ message_queue?: Object;
67
+ gis?: Object;
68
+ request?: Object;
69
+ inspection?: Object;
70
+ workorder?: Object;
71
+ case?: Object;
72
+ extensions: Object;
73
+ features: Object;
74
+ potential_loads: Array<string>;
75
+ /**
76
+ * Contructor for a new cityworks instance's object, allows one to optionally configure the domain and other settings right from the get-go
77
+ * @param {string} [base_url] - The first color, in hexadecimal format.
78
+ * @param {object} [settings] - The second color, in hexadecimal format.
79
+ * @param {array} [load] - allows user to choose which modules to load and make available. Full availability array: ['general', 'activity_link', 'message_queue', 'gis', 'workorder', 'inspection', 'request', 'case']
80
+ */
81
+ constructor(base_url?: string, settings?: Object, load?: Array<string>);
82
+ /**
83
+ * Configure a new cityworks instance's domain and other settings
84
+ *
85
+ * @param {string} [base_url] - The first color, in hexadecimal format.
86
+ * @param {object} [settings] - The second color, in hexadecimal format.
87
+ * @param {array} [load] - allows user to choose which modules to load and make available. Full availability array: ['general', 'activity_link', 'message_queue', 'gis', 'search', 'workorder', 'inspection', 'request', 'case']
88
+ * @return {boolean} Returns true if successful, otherwise, throws error
89
+ */
90
+ configure(base_url?: string, settings?: Object, load?: Array<string>): void;
91
+ /**
92
+ * Send a request to the Cityworks API
93
+ *
94
+ * If one ever needs to access or call an unimplemented API endpoint of a Cityworks install, one can call this method directly with the path and data payload:
95
+ *
96
+ * `cityworks.runRequest(path, data)`
97
+ *
98
+ * @param {string} path - The path to the particular endpoint
99
+ * @param {Object} data - The data object to be sent to the Cityworks API
100
+ * @param {any} file - The file to send in binary to the Cityworks API
101
+ * @return {Object} Returns Promise object that represents the json object returned from the Cityworks API
102
+ */
103
+ runRequest(path: any, data?: any, file?: any): Promise<unknown>;
104
+ /**
105
+ * Authenticate with the Cityworks API and store an access token for use. Stores the token on cityworks.Token.
106
+ * @param {string} login - User's login name
107
+ * @param {password} password - User's password
108
+ * @return {Object} Returns Promise object that represents a boolean which tells you the login succeeded (true) or failed (false).
109
+ */
110
+ authenticate(login: string, password: string): Promise<unknown>;
111
+ /**
112
+ * Authenticate a username with a GIS Token
113
+ * @param {login} - Gis user name, should match a Cityworks employee login name
114
+ * @param {string} gisToken - Gis Oauth2 access token
115
+ * @param {string} gisTokenUrl - Base url to GIS server (not the '/generateToken' endpoint)
116
+ * @param {number} [expires] - Authenticate to Cityworks for a specified number of milliseconds, defaults to 2 weeks
117
+ */
118
+ authenticateWithGISToken(login: string, gisToken: string, gisTokenUrl: string, expires?: number): Promise<unknown>;
119
+ /**
120
+ * Validate provided token
121
+ * @param {string} token - User's login name
122
+ * @param {boolean} [set] - Set a valid token as the cityworks instance's active token
123
+ * @return {Object} Returns Promise object that represents a boolean which apprises one of the token's validity and that is was set (true) or throws an error if was not valid (and not set).
124
+ */
125
+ validateToken(token: string, set?: boolean): Promise<unknown>;
126
+ /**
127
+ * Set a token you've retrieved from your storage system as the active token for the cityworks instance. Note that this doesn't check the token for validity.
128
+ * @param {token} token - The token string to set as the active token.
129
+ * @return {boolean} Returns a boolean which apprises one that the token was set (true) or not set (false).
130
+ */
131
+ setToken(token: any): boolean;
132
+ /**
133
+ * Get currently set, valid token
134
+ * @param {token} token - The token string to set as the active token.
135
+ * @return {string} Returns a string which is the currently-set token or the boolean false value if no (valid) token set
136
+ */
137
+ getToken(): string | false;
138
+ /**
139
+ * Revoke all current user's tokens or only tokens created before a particular date and time.
140
+ * @param {number} [revokeBefore] - Datetime as an Epoch integer (number), if you wish to revoke only tokens created before a particular datetime
141
+ * @return {Object} Returns Promise object that represents a boolean which apprises one of the revocation outcome's success (true) or failure (false)
142
+ */
143
+ revokeToken(revokeBefore?: number): Promise<unknown>;
144
+ /**
145
+ * Get the localization settings for current Cityworks install
146
+ * @return {Object} Returns Promise object that represents an Object which contains all the localization settings for the current Cityworks install
147
+ */
148
+ getLocalizationSettings(): Promise<unknown>;
149
+ /**
150
+ * Get the system timezone options for current Cityworks install
151
+ * @return {Object} Returns Promise object that represents an Object which contains all the timezone settings for the currentCityworks install
152
+ */
153
+ getTimezoneOptions(): Promise<unknown>;
154
+ /**
155
+ * Get the current install's location information
156
+ * @return {Object} Returns Promise object that represents an Object which contains the location information
157
+ */
158
+ getCurrentLocation(): Promise<unknown>;
159
+ /**
160
+ * Check if a particular license is available to the currently-authenticated user
161
+ * @param {string} area - Area of access
162
+ * @param {string} service - Service to access
163
+ * @return {boolean} Returns Promise object that represents a boolean which informs access is granted (true) or denied (false)
164
+ */
165
+ licensedApiCheck(area: string, service: string): Promise<unknown>;
166
+ /**
167
+ * Check if a current Cityworks install is licensed to use a particular extension
168
+ *
169
+ * Possible extensions currently include: "UnknownExtension", "CwAnalytics", "WebHooks", "PLLPublicApp", "ActivityUpdate", "SingleSignOn"
170
+ *
171
+ * @param {string} extension - Extension name
172
+ * @return {boolean} Returns Promise object that represents a boolean which informs extension is licensed (true) or not (false)
173
+ */
174
+ licensedExtensionCheck(extension: string): Promise<unknown>;
175
+ /**
176
+ * Check a whole list to see if current Cityworks install is licensed to use extensions
177
+ *
178
+ * Possible extensions currently include: "UnknownExtension", "CwAnalytics", "WebHooks", "PLLPublicApp", "ActivityUpdate", "SingleSignOn"
179
+ *
180
+ * @param {Array<string>} extension - Extension names
181
+ * @return {Object} Returns Promise object that represents a boolean which informs extension is licensed (true) or not (false)
182
+ */
183
+ licensedExtensionsCheck(extensions: Array<string>): Promise<unknown>;
184
+ /**
185
+ * Check if current user is licensed to use a feature:
186
+ *
187
+ * "UnknownFeature", "ViewInspections", "EditInspections", "ViewServiceRequest", "EditServiceRequest", "ViewWorkOrder", "EditWorkOrder", "EquipmentCheckOut", "OfficeField", "Respond", "Eurl", "PaverInterface", "Contracts", "Storeroom", "PLL", "Cw4XL", "TableEditor", "CCTVInterface", "MobileAndroid", "MobileiOS", "PerformanceBudgeting", "Insights", "RespondCase", "RespondInspection", "RespondServiceRequest", "RespondTaskManager", "RespondWorkOrder", "Workload", "OpX", "TrimbleUnityMobile", "TrimbleVegetationManager"
188
+ *
189
+ * @param {string} [feature] - Feature to check to see if ciurrently authenticated user can utilize
190
+ * @return {Object} Returns Promise object that represents a boolean which communicates license state as licensed (true) or not (false)
191
+ */
192
+ licensedFeatureCheck(feature: string): Promise<unknown>;
193
+ /**
194
+ * Check if current user is licensed to use features:
195
+ *
196
+ * "UnknownFeature", "ViewInspections", "EditInspections", "ViewServiceRequest", "EditServiceRequest", "ViewWorkOrder", "EditWorkOrder", "EquipmentCheckOut", "OfficeField", "Respond", "Eurl", "PaverInterface", "Contracts", "Storeroom", "PLL", "Cw4XL", "TableEditor", "CCTVInterface", "MobileAndroid", "MobileiOS", "PerformanceBudgeting", "Insights", "RespondCase", "RespondInspection", "RespondServiceRequest", "RespondTaskManager", "RespondWorkOrder", "Workload", "OpX", "TrimbleUnityMobile", "TrimbleVegetationManager"
197
+ *
198
+ * @param {Array<string>} [feature] - Features to check to see if currently authenticated user can utilize
199
+ * @return {Object} Returns Promise object that represents a boolean which communicates license state as licensed (true) or not (false)
200
+ */
201
+ licensedFeaturesCheck(features: Array<string>): Promise<unknown>;
202
+ /**
203
+ * Check if current user is licensed to use services. List req ServicesList of 'Area/Service', i.e.:
204
+ *
205
+ * ['AMS/Inspection','AMS/WorkOrder','PLL/Case']
206
+ *
207
+ * @param {Array<string>} [services] - Services to check to see if currently authenticated user can utilize
208
+ * @return {Object} Returns Promise object that represents a boolean which communicates license state as licensed (true) or not (false)
209
+ */
210
+ licensedServicesCheck(services: Array<string>): Promise<unknown>;
211
+ /**
212
+ * Get a list of CityworksOnline sites for this user
213
+ *
214
+ * @param {string} [login] - Login Name to use when checking. Defaults to previously-stored login name.
215
+ * @param {string} [password] - Password to use when checking. Defaults to previously-stored password.
216
+ * @return {Object} Returns Promise object that represents an array of cityworks online sites available to this user.
217
+ */
218
+ cityworksOnlineSites(login?: string, password?: string): Promise<unknown>;
219
+ /**
220
+ * Get a list of Domains (not tld, but organizations) in the currently-connected Cityworks install
221
+ *
222
+ * @return {Object} Returns Promise object that represents a collection of the configured domains.
223
+ */
224
+ domains(): Promise<unknown>;
225
+ /**
226
+ * Get a list of Domains (not tld, but organizations) in the currently-connected Cityworks install
227
+ *
228
+ * @param {string} [login] - Optional login name to get user information for. Defaults to currently-set user name used for login.
229
+ * @return {Object} Returns Promise object that represents an Object with the user information
230
+ */
231
+ user(login?: string): Promise<unknown>;
232
+ /**
233
+ * Get the software version number of the currently-connected Cityworks install
234
+ *
235
+ * @return {Object} Returns Promise object that represents a string of the version number
236
+ */
237
+ version(): Promise<unknown>;
238
+ }
1
239
  export {};
@@ -18,9 +18,9 @@ export declare class Comments {
18
18
  /**
19
19
  * @hidden
20
20
  */
21
- constructor(cw: any, activityType: any);
21
+ constructor(cw: any, activityType: string);
22
22
  /**
23
- * Add a comment
23
+ * 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.
24
24
  *
25
25
  * @param {number} sid - The SID of the activity to which the comment should be attached
26
26
  * @param {string} comment - The text for the comment
package/dist/general.d.ts CHANGED
@@ -39,14 +39,14 @@ export declare class General {
39
39
  */
40
40
  getHistory(): Promise<unknown>;
41
41
  /**
42
- * Get cost summary for work order entities
42
+ * Get cost summary for WorkOrder entities
43
43
  *
44
44
  * @param {Array<number>} ObjectIds
45
45
  * @return {Object} Returns Promise object that represents a
46
46
  */
47
47
  getWOEntityCostSummary(object_ids: Array<number>): Promise<unknown>;
48
48
  /**
49
- * Get cost summary for work order entities selected through a search definition
49
+ * Get cost summary for WorkOrder entities selected through a search definition
50
50
  *
51
51
  * @param {number} SearchId - Search Definition Id
52
52
  * @return {Object} Returns Promise object that represents a
package/dist/gis.d.ts CHANGED
@@ -40,7 +40,7 @@ export declare class Gis {
40
40
  /**
41
41
  * Get service request gis services
42
42
  *
43
- * @param {number} requestId - The work order to check against.
43
+ * @param {number} requestId - The WorkOrder to check against.
44
44
  * @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
45
45
  * @return {Object} Returns Promise object that represents an Object with the specified request's entit(y|ies)
46
46
  */
@@ -48,7 +48,7 @@ export declare class Gis {
48
48
  /**
49
49
  * Get inspection gis services
50
50
  *
51
- * @param {number} inspectionId - The work order to check against.
51
+ * @param {number} inspectionId - The WorkOrder to check against.
52
52
  * @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
53
53
  * @return {Object} Returns Promise object that represents an Object with the specified inspection's entity
54
54
  */
@@ -56,9 +56,9 @@ export declare class Gis {
56
56
  /**
57
57
  * Get workorder gis services
58
58
  *
59
- * @param {number} workOrderSid - The work order to check against.
59
+ * @param {number} workOrderSid - The WorkOrder to check against.
60
60
  * @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
61
- * @return {Object} Returns Promise object that represents an Object with the specified work order's entit(y|ies)
61
+ * @return {Object} Returns Promise object that represents an Object with the specified WorkOrder's entit(y|ies)
62
62
  */
63
63
  workOrder(workOrderSid: any, getGisData?: boolean): Promise<unknown>;
64
64
  /**