cityworks 0.0.52 → 0.0.53
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 +1 -1
- package/dist/activity_link.js +219 -0
- package/dist/attachments.d.ts +59 -0
- package/dist/briefcase.d.ts +22 -1
- package/dist/briefcase.js +327 -0
- package/dist/case_admin.d.ts +0 -22
- package/dist/case_admin.js +821 -0
- package/dist/case_assets.js +129 -0
- package/dist/case_data.js +416 -0
- package/dist/case_financial.js +848 -0
- package/dist/case_workflow.js +455 -0
- package/dist/comments.js +126 -0
- package/dist/error.js +30 -0
- package/dist/event_layer.d.ts +97 -0
- package/dist/event_layer.js +207 -0
- package/dist/general.d.ts +23 -0
- package/dist/general.js +212 -0
- package/dist/gis.js +250 -0
- package/dist/index.d.ts +10 -8
- 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.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/inspection.d.ts +17 -1
- package/dist/inspection.js +933 -0
- package/dist/inspection_admin.js +43 -0
- package/dist/inspection_costs.js +200 -0
- package/dist/message_queue.js +248 -0
- package/dist/query.d.ts +108 -0
- package/dist/query.js +242 -0
- package/dist/request.d.ts +5 -1
- package/dist/request.js +899 -0
- package/dist/request_admin.js +32 -0
- package/dist/request_costs.js +113 -0
- package/dist/search.d.ts +12 -1
- package/dist/search.js +371 -0
- package/dist/workorder.d.ts +4 -0
- package/dist/workorder.js +951 -0
- package/dist/workorder_admin.js +248 -0
- package/dist/workorder_costs.js +274 -0
- package/package.json +7 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InspectionAdmin = void 0;
|
|
4
|
+
var _ = require('lodash');
|
|
5
|
+
var InspectionAdmin = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
function InspectionAdmin(cw) {
|
|
10
|
+
this.cw = cw;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get inspection templates
|
|
14
|
+
*
|
|
15
|
+
* @category Inspection Templates
|
|
16
|
+
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
17
|
+
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
18
|
+
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
19
|
+
* @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
|
|
20
|
+
*/
|
|
21
|
+
InspectionAdmin.prototype.getTemplates = function (entityTypes, canCreate, options) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
return new Promise(function (resolve, reject) {
|
|
24
|
+
var data = {};
|
|
25
|
+
if (typeof (entityTypes) !== 'undefined') {
|
|
26
|
+
data.EntityTypes = entityTypes;
|
|
27
|
+
}
|
|
28
|
+
data.CanCreate = typeof (canCreate) !== 'undefined' ? canCreate : true;
|
|
29
|
+
if (typeof (options) === 'object') {
|
|
30
|
+
_.forIn(options, function (v, k) {
|
|
31
|
+
data[k] = v;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
_this.cw.runRequest('Ams/InspectionTemplate/Templates', data).then(function (r) {
|
|
35
|
+
resolve(r.Value);
|
|
36
|
+
}).catch(function (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return InspectionAdmin;
|
|
42
|
+
}());
|
|
43
|
+
exports.InspectionAdmin = InspectionAdmin;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InspectionCosts = void 0;
|
|
4
|
+
var _ = require('lodash');
|
|
5
|
+
var InspectionCosts = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
function InspectionCosts(cw) {
|
|
10
|
+
this.cw = cw;
|
|
11
|
+
this.currentActivityType = "Inspection";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get Cost Codes
|
|
15
|
+
*
|
|
16
|
+
* @category Labor Costs
|
|
17
|
+
* @param {Array<number>} employeeSids - A list of Employee IDs for which to get the job codes.
|
|
18
|
+
* @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.
|
|
19
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
20
|
+
*/
|
|
21
|
+
InspectionCosts.prototype.getCodes = function (employeeSids, commonOnly) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
if (commonOnly === void 0) { commonOnly = false; }
|
|
24
|
+
return new Promise(function (resolve, reject) {
|
|
25
|
+
var data = {
|
|
26
|
+
EmployeeSids: employeeSids,
|
|
27
|
+
CommonCodesOnly: commonOnly
|
|
28
|
+
};
|
|
29
|
+
_this.cw.runRequest('Ams/LaborCost/CostCodes', data).then(function (r) {
|
|
30
|
+
resolve(r.Value);
|
|
31
|
+
}).catch(function (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Get Job Codes
|
|
38
|
+
*
|
|
39
|
+
* @category Labor Costs
|
|
40
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
41
|
+
*/
|
|
42
|
+
InspectionCosts.prototype.getJobCodes = function () {
|
|
43
|
+
var _this = this;
|
|
44
|
+
return new Promise(function (resolve, reject) {
|
|
45
|
+
_this.cw.runRequest('Ams/LaborCost/JobCodes').then(function (r) {
|
|
46
|
+
resolve(r.Value);
|
|
47
|
+
}).catch(function (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Add Inspection Labor Costs
|
|
54
|
+
*
|
|
55
|
+
* @category Inspection Costs
|
|
56
|
+
* @param {number} inspectionId - Inspection ID to add labor costs to
|
|
57
|
+
* @param {number} hours - The hours to add to the inspection
|
|
58
|
+
* @param {Object} options - Additional settings for hours setting
|
|
59
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
60
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
61
|
+
*/
|
|
62
|
+
InspectionCosts.prototype.addLabor = function (inspectionId, hours, options, estimated) {
|
|
63
|
+
var _this = this;
|
|
64
|
+
if (estimated === void 0) { estimated = false; }
|
|
65
|
+
return new Promise(function (resolve, reject) {
|
|
66
|
+
var data = {
|
|
67
|
+
Estimated: estimated,
|
|
68
|
+
InspectionIds: inspectionId,
|
|
69
|
+
Hours: hours
|
|
70
|
+
};
|
|
71
|
+
if (typeof (options) != 'undefined') {
|
|
72
|
+
data = _.merge(data, options);
|
|
73
|
+
}
|
|
74
|
+
_this.cw.runRequest('Ams/LaborCost/AddInspectionCosts', data).then(function (response) {
|
|
75
|
+
resolve(response.Value);
|
|
76
|
+
}).catch(function (e) {
|
|
77
|
+
reject(e);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Get Labor Costs for a specific list of Inspections
|
|
83
|
+
*
|
|
84
|
+
* @category Inspection Costs
|
|
85
|
+
* @param {Array<int>} inspectionIds - An array of inspection IDs to get associated costs for.
|
|
86
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
87
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
88
|
+
*/
|
|
89
|
+
InspectionCosts.prototype.getLabor = function (inspectionIds, estimated) {
|
|
90
|
+
var _this = this;
|
|
91
|
+
if (estimated === void 0) { estimated = false; }
|
|
92
|
+
return new Promise(function (resolve, reject) {
|
|
93
|
+
var data = {
|
|
94
|
+
Estimated: estimated,
|
|
95
|
+
InspectionIds: inspectionIds
|
|
96
|
+
};
|
|
97
|
+
_this.cw.runRequest('Ams/LaborCost/InspectionCostsByInspection', data).then(function (response) {
|
|
98
|
+
resolve(response.Value);
|
|
99
|
+
}).catch(function (e) {
|
|
100
|
+
reject(e);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Delete Inspection Labor Costs
|
|
106
|
+
*
|
|
107
|
+
* @category Inspection Costs
|
|
108
|
+
* @param {Array<int>} laborCostIds - An array of inspection labor cost IDs to delete
|
|
109
|
+
* @param {boolean} estimated - Boolean, delete estimated or real costs, defaults to false (delete real by default)
|
|
110
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
111
|
+
*/
|
|
112
|
+
InspectionCosts.prototype.deleteLabor = function (laborCostIds, estimated) {
|
|
113
|
+
var _this = this;
|
|
114
|
+
if (estimated === void 0) { estimated = false; }
|
|
115
|
+
return new Promise(function (resolve, reject) {
|
|
116
|
+
var data = {
|
|
117
|
+
Estimated: estimated,
|
|
118
|
+
reqLaborCostIds: laborCostIds
|
|
119
|
+
};
|
|
120
|
+
_this.cw.runRequest('Ams/LaborCost/DeleteInspectionCosts', data).then(function (response) {
|
|
121
|
+
resolve(response.Value);
|
|
122
|
+
}).catch(function (e) {
|
|
123
|
+
reject(e);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Add Inspection Equipment Costs
|
|
129
|
+
*
|
|
130
|
+
* @category Inspection Costs
|
|
131
|
+
* @param {Object} inspectionId - the inspection to add the equipment costs to
|
|
132
|
+
* @param {Object} options - additional options
|
|
133
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
134
|
+
*/
|
|
135
|
+
InspectionCosts.prototype.addEquipment = function (inspectionId, options) {
|
|
136
|
+
var _this = this;
|
|
137
|
+
return new Promise(function (resolve, reject) {
|
|
138
|
+
var data = {
|
|
139
|
+
InspectionId: inspectionId
|
|
140
|
+
};
|
|
141
|
+
if (typeof (options) != 'undefined') {
|
|
142
|
+
data = _.merge(data, options);
|
|
143
|
+
}
|
|
144
|
+
// TODO: ensure each object has Hours & InspectionId
|
|
145
|
+
_this.cw.runRequest('Ams/EquipmentCost/AddInspectionCosts', data).then(function (response) {
|
|
146
|
+
resolve(response.Value);
|
|
147
|
+
}).catch(function (e) {
|
|
148
|
+
reject(e);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Get Equipment Costs for Inspection(s)
|
|
154
|
+
*
|
|
155
|
+
* @category Inspection Costs
|
|
156
|
+
* @param {Array<number>} inspectionIds - the inspection to get the equipment costs for.
|
|
157
|
+
* @param {Object} estimated - get estimated equipment costs. Defaults to false.
|
|
158
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
159
|
+
*/
|
|
160
|
+
InspectionCosts.prototype.getEquipment = function (inspectionIds, estimated) {
|
|
161
|
+
var _this = this;
|
|
162
|
+
if (estimated === void 0) { estimated = false; }
|
|
163
|
+
return new Promise(function (resolve, reject) {
|
|
164
|
+
var data = {
|
|
165
|
+
InspectionIds: inspectionIds,
|
|
166
|
+
Estimated: estimated
|
|
167
|
+
};
|
|
168
|
+
_this.cw.runRequest('Ams/EquipmentCost/InspectionCostsByInspection', data).then(function (response) {
|
|
169
|
+
resolve(response.Value);
|
|
170
|
+
}).catch(function (e) {
|
|
171
|
+
reject(e);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Delete Inspection Equipment Costs
|
|
177
|
+
*
|
|
178
|
+
* @category Inspection Costs
|
|
179
|
+
* @param {Array<number>} equipmentCostIds - the equipment cost IDs to delete.
|
|
180
|
+
* @param {Object} estimated - delete estimated equipment costs. Defaults to false.
|
|
181
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
182
|
+
*/
|
|
183
|
+
InspectionCosts.prototype.deleteEquipment = function (equipmentCostIds, estimated) {
|
|
184
|
+
var _this = this;
|
|
185
|
+
if (estimated === void 0) { estimated = false; }
|
|
186
|
+
return new Promise(function (resolve, reject) {
|
|
187
|
+
var data = {
|
|
188
|
+
EquipmentCostIds: equipmentCostIds,
|
|
189
|
+
Estimated: estimated
|
|
190
|
+
};
|
|
191
|
+
_this.cw.runRequest('Ams/EquipmentCost/DeleteInspectionCosts', data).then(function (response) {
|
|
192
|
+
resolve(response.Value);
|
|
193
|
+
}).catch(function (e) {
|
|
194
|
+
reject(e);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
return InspectionCosts;
|
|
199
|
+
}());
|
|
200
|
+
exports.InspectionCosts = InspectionCosts;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageQueue = void 0;
|
|
4
|
+
var error_1 = require("./error");
|
|
5
|
+
var _ = require('lodash');
|
|
6
|
+
var MessageQueue = /** @class */ (function () {
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
function MessageQueue(cw) {
|
|
11
|
+
/**
|
|
12
|
+
* Statuses -
|
|
13
|
+
* Pending: 0,
|
|
14
|
+
* Processing: 1,
|
|
15
|
+
* Complete: 2,
|
|
16
|
+
* Failed: 3
|
|
17
|
+
*/
|
|
18
|
+
this.status = {
|
|
19
|
+
Pending: 0,
|
|
20
|
+
Processing: 1,
|
|
21
|
+
Complete: 2,
|
|
22
|
+
Failed: 3
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Hook Types -
|
|
26
|
+
* Unknown: 0,
|
|
27
|
+
* ActivityUpdate: 1,
|
|
28
|
+
* Email: 2,
|
|
29
|
+
* WebHook: 3
|
|
30
|
+
*/
|
|
31
|
+
this.hook_types = {
|
|
32
|
+
Unknown: 0,
|
|
33
|
+
ActivityUpdate: 1,
|
|
34
|
+
Email: 2,
|
|
35
|
+
WebHook: 3
|
|
36
|
+
};
|
|
37
|
+
this.cw = cw;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Process Webhook MessageQueue records by MessageQueueId
|
|
41
|
+
*
|
|
42
|
+
* @param {Array<number>} [ids] - List of MessageQueueId values
|
|
43
|
+
* @param {boolean} [delete_successful] - automatically delete messages that complete with successful execution, default is false
|
|
44
|
+
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
45
|
+
*/
|
|
46
|
+
MessageQueue.prototype.processMessages = function (ids, delete_successful) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
if (delete_successful === void 0) { delete_successful = false; }
|
|
49
|
+
return new Promise(function (resolve, reject) {
|
|
50
|
+
var data = { Ids: ids, Delete: delete_successful };
|
|
51
|
+
var path = 'General/WebHookEvent/ProcessMessages';
|
|
52
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
53
|
+
// TODO
|
|
54
|
+
}).catch(function (e) {
|
|
55
|
+
reject(e);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Get Messages specified in list of MessageQueueIds
|
|
61
|
+
*
|
|
62
|
+
* @param {Array<number>} ids - List of MessageQueueId values
|
|
63
|
+
* @param {string} status -
|
|
64
|
+
* @param {number} [maxcount] - Maximum number returned. Defaults to 15
|
|
65
|
+
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
66
|
+
*/
|
|
67
|
+
MessageQueue.prototype.get = function (ids, status, maxcount) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
if (maxcount === void 0) { maxcount = 15; }
|
|
70
|
+
return new Promise(function (resolve, reject) {
|
|
71
|
+
if (typeof (_this.status[status]) == 'undefined') {
|
|
72
|
+
reject(new error_1.CWError(1, 'Status provided does not exist or is mispelled.', { 'provided': status, 'available': _this.status }));
|
|
73
|
+
}
|
|
74
|
+
var data = {
|
|
75
|
+
"Ids": ids,
|
|
76
|
+
"MaxCount": typeof (maxcount) != 'undefined' ? maxcount : 15,
|
|
77
|
+
"Status": _this.status[status]
|
|
78
|
+
};
|
|
79
|
+
var path = 'General/MessageQueue/ByIds';
|
|
80
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
81
|
+
// TODO
|
|
82
|
+
}).catch(function (e) {
|
|
83
|
+
reject(e);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Delete Messages specified in list of MessageQueueIds
|
|
89
|
+
*
|
|
90
|
+
* @param {Array<number>} ids - List of MessageQueueId values
|
|
91
|
+
* @param {string} status - automatically delete messages that complete with successful execution, default is false
|
|
92
|
+
* @param {number} [hours_to_keep] - utomatically delete messages that complete with successful execution, default is false
|
|
93
|
+
* @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
|
|
94
|
+
*/
|
|
95
|
+
MessageQueue.prototype.delete = function (ids, status, hours_to_keep) {
|
|
96
|
+
var _this = this;
|
|
97
|
+
return new Promise(function (resolve, reject) {
|
|
98
|
+
if (typeof (_this.status[status]) == 'undefined') {
|
|
99
|
+
reject(new error_1.CWError(2, 'Status provided does not exist or is mispelled.', { 'provided': status, 'available': _this.status }));
|
|
100
|
+
}
|
|
101
|
+
var data = {
|
|
102
|
+
"Ids": ids,
|
|
103
|
+
"Status": _this.status[status],
|
|
104
|
+
"HoursToKeep": hours_to_keep
|
|
105
|
+
};
|
|
106
|
+
var path = 'General/MessageQueue/Delete';
|
|
107
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
108
|
+
// TODO
|
|
109
|
+
}).catch(function (e) {
|
|
110
|
+
reject(e);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
// PreferencesList<GlobalPreference>
|
|
115
|
+
// Base response type: CoreResponseBase
|
|
116
|
+
// Get a list of message queue preferences
|
|
117
|
+
// This method has no parameters
|
|
118
|
+
MessageQueue.prototype.preferences = function () {
|
|
119
|
+
var _this = this;
|
|
120
|
+
return new Promise(function (resolve, reject) {
|
|
121
|
+
var data = {};
|
|
122
|
+
var path = 'General/MessageQueue/Preferences';
|
|
123
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
124
|
+
// TODO
|
|
125
|
+
}).catch(function (e) {
|
|
126
|
+
reject(e);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
MessageQueue.prototype.search = function (parameters, max_results) {
|
|
131
|
+
var _this = this;
|
|
132
|
+
var data;
|
|
133
|
+
return new Promise(function (resolve, reject) {
|
|
134
|
+
if (typeof (parameters.status) !== 'undefined' && typeof (_this.status[parameters.status]) == 'undefined') {
|
|
135
|
+
reject(new error_1.CWError(3, 'Status provided does not exist or is mispelled.', { 'provided': parameters.status, 'available': _this.status }));
|
|
136
|
+
}
|
|
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
|
+
var allowed_params = ['Id', 'HookId', 'HookType', 'Result', 'DateCreatedBegin', 'DateCreatedEnd', 'DateUpdatedBegin', 'DateUpdatedEnd'];
|
|
144
|
+
var disallowed_params = ['Status', 'MaxResults'];
|
|
145
|
+
_.forEach(parameters, function (v, k) {
|
|
146
|
+
if (_.indexOf(allowed_params, k) != -1 && _.indexOf(disallowed_params, k) == -1) {
|
|
147
|
+
data[k] = v;
|
|
148
|
+
}
|
|
149
|
+
else if (_.indexOf(disallowed_params, k) == -1) {
|
|
150
|
+
reject(new error_1.CWError(4, 'Provided parameter does not exist or is mispelled.', { 'provided': k, 'value': v, 'available': _.concat(allowed_params, disallowed_params) }));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
var path = 'General/MessageQueue/Search';
|
|
154
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
155
|
+
// TODO
|
|
156
|
+
if (typeof (response.Value) == 'undefined') {
|
|
157
|
+
response.Value = [];
|
|
158
|
+
}
|
|
159
|
+
resolve(response.Value);
|
|
160
|
+
}).catch(function (e) {
|
|
161
|
+
reject(e);
|
|
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
|
+
MessageQueue.prototype.update = function (parameters) {
|
|
182
|
+
var _this = this;
|
|
183
|
+
var data;
|
|
184
|
+
return new Promise(function (resolve, reject) {
|
|
185
|
+
if (typeof (parameters.status) !== 'undefined' && typeof (_this.status[parameters.status]) == 'undefined') {
|
|
186
|
+
reject(new error_1.CWError(3, 'Status provided does not exist or is mispelled.', { 'provided': parameters.status, 'available': _this.status }));
|
|
187
|
+
}
|
|
188
|
+
else if (typeof (parameters.status) !== 'undefined' && typeof (_this.status[parameters.status]) !== 'undefined') {
|
|
189
|
+
data.Status = _this.status[parameters.status];
|
|
190
|
+
}
|
|
191
|
+
if (typeof (parameters.hook_types) !== 'undefined' && typeof (_this.hook_types[parameters.hook_types]) == 'undefined') {
|
|
192
|
+
reject(new error_1.CWError(3, 'Status provided does not exist or is mispelled.', { 'provided': parameters.hook_types, 'available': _this.hook_types }));
|
|
193
|
+
}
|
|
194
|
+
else if (typeof (parameters.hook_types) !== 'undefined' && typeof (_this.hook_types[parameters.hook_types]) !== 'undefined') {
|
|
195
|
+
data.HookType = _this.hook_types[parameters.hook_types];
|
|
196
|
+
}
|
|
197
|
+
var allowed_params = ['Id', 'HookId', 'Packet', 'Result'];
|
|
198
|
+
var disallowed_params = ['Status', 'HookType'];
|
|
199
|
+
_.forEach(parameters, function (v, k) {
|
|
200
|
+
if (_.indexOf(allowed_params, k) != -1 && _.indexOf(disallowed_params, k) == -1) {
|
|
201
|
+
data[k] = v;
|
|
202
|
+
}
|
|
203
|
+
else if (_.indexOf(disallowed_params, k) == -1) {
|
|
204
|
+
reject(new error_1.CWError(5, 'Provided parameter does not exist or is mispelled.', { 'provided': k, 'value': v, 'available': _.concat(allowed_params, disallowed_params) }));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
var path = 'General/MessageQueue/Update';
|
|
208
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
209
|
+
// TODO
|
|
210
|
+
if (typeof (response.Value) == 'undefined') {
|
|
211
|
+
response.Value = [];
|
|
212
|
+
}
|
|
213
|
+
resolve(response.Value);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
MessageQueue.prototype.updateMessageStatus = function (ids, status, hours_to_keep) {
|
|
218
|
+
var _this = this;
|
|
219
|
+
return new Promise(function (resolve, reject) {
|
|
220
|
+
if (typeof (_this.status[status]) == 'undefined') {
|
|
221
|
+
reject(new error_1.CWError(2, 'Status provided does not exist or is mispelled.', { 'provided': status, 'available': _this.status }));
|
|
222
|
+
}
|
|
223
|
+
var data = {
|
|
224
|
+
"Ids": ids,
|
|
225
|
+
"Status": _this.status[status],
|
|
226
|
+
"HoursToKeep": hours_to_keep
|
|
227
|
+
};
|
|
228
|
+
var path = 'General/MessageQueue/UpdateMessageStatus';
|
|
229
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
230
|
+
// TODO
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
MessageQueue.prototype.getWebooks = function (hook_ids) {
|
|
235
|
+
var _this = this;
|
|
236
|
+
return new Promise(function (resolve, reject) {
|
|
237
|
+
var data = {
|
|
238
|
+
"HookIds": hook_ids
|
|
239
|
+
};
|
|
240
|
+
var path = 'General/MessageQueue/WebHooks';
|
|
241
|
+
_this.cw.runRequest(path, data).then(function (response) {
|
|
242
|
+
// TODO
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
return MessageQueue;
|
|
247
|
+
}());
|
|
248
|
+
exports.MessageQueue = MessageQueue;
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
interface DynamicVariableMap {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
interface DynamicResponseDefinition {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare class Query {
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
cw: any;
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
constructor(cw: any);
|
|
16
|
+
/**
|
|
17
|
+
* Build a query using query language syntax or by specifying a saved query ID
|
|
18
|
+
*
|
|
19
|
+
* @category Query
|
|
20
|
+
* @param {number} query - Query to run (specify syntax or queryID)
|
|
21
|
+
* @param {Object} options - Other options. See: /{subdirectory}/apidocs/#/service-info/General/Query
|
|
22
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain
|
|
23
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
24
|
+
*/
|
|
25
|
+
build(query: number | string, options?: {
|
|
26
|
+
Page?: number;
|
|
27
|
+
PageSize?: number;
|
|
28
|
+
SortDescending?: boolean;
|
|
29
|
+
SortField?: string;
|
|
30
|
+
Variables?: DynamicVariableMap;
|
|
31
|
+
}, domainId?: number): Promise<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Get available query types
|
|
34
|
+
*
|
|
35
|
+
* @category Query
|
|
36
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
37
|
+
*/
|
|
38
|
+
getTypes(): Promise<unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Get info about query types
|
|
41
|
+
*
|
|
42
|
+
* @category Query
|
|
43
|
+
* @param {boolean} includeDefaultSchemasInclude - Include schemas (Work Order, Service Request, etc), default is true.
|
|
44
|
+
* @param {boolean} includeGisSchemas - Include gis schemas, ddefault is true.
|
|
45
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain
|
|
46
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
47
|
+
*/
|
|
48
|
+
getTypesInfo(includeDefaultSchemasInclude?: boolean, includeGisSchemas?: boolean, domainId?: number): Promise<unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Validate a query string
|
|
51
|
+
*
|
|
52
|
+
* @category Query
|
|
53
|
+
* @param {string} query - The query to validate
|
|
54
|
+
* @param {DynamicVariableMap} variables - Required if the query includes variables
|
|
55
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain
|
|
56
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
57
|
+
*/
|
|
58
|
+
validateQuery(query: string, variables: DynamicVariableMap, domainId?: number): Promise<unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Validate a query response definition
|
|
61
|
+
*
|
|
62
|
+
* @category Query
|
|
63
|
+
* @param {string} queryType - The query to validate
|
|
64
|
+
* @param {DynamicResponseDefinition} responseDefinition - Required if the query includes variables
|
|
65
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain
|
|
66
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
67
|
+
*/
|
|
68
|
+
validateResponseDefinition(queryType: string, responseDefinition: DynamicResponseDefinition, domainId?: number): Promise<unknown>;
|
|
69
|
+
/**
|
|
70
|
+
* Get schema for specified query type
|
|
71
|
+
*
|
|
72
|
+
* @category Query
|
|
73
|
+
* @param {string} queryType - Specify Query Type
|
|
74
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain. Used to determine query field configuration for the schema fields.
|
|
75
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
76
|
+
*/
|
|
77
|
+
getSchema(queryType: string, domainId?: number): Promise<unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Run a query using query language syntax
|
|
80
|
+
*
|
|
81
|
+
* @category Query
|
|
82
|
+
* @param {number} query - Query syntax string or saved query ID to run. If you want to append addt'l query items to a saved query, add QueryValue in the options
|
|
83
|
+
* @param {Object} options - Other options. See: /{subdirectory}/apidocs/#/service-info/General/Query
|
|
84
|
+
* @return {Object} Returns Promise object that represents a list of Objects
|
|
85
|
+
*/
|
|
86
|
+
run(query: string, options?: {
|
|
87
|
+
QueryValue?: string;
|
|
88
|
+
Page?: number;
|
|
89
|
+
PageSize?: number;
|
|
90
|
+
ResponseFields?: any;
|
|
91
|
+
SortDescending?: boolean;
|
|
92
|
+
SortField?: string;
|
|
93
|
+
Variables?: DynamicVariableMap;
|
|
94
|
+
}): Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Get a list of the saved queries the current user can access.
|
|
97
|
+
*
|
|
98
|
+
* @category Query
|
|
99
|
+
* @param {Array<string>} queryTypes - Get the saved queries for a particular type, default is all types
|
|
100
|
+
* @param {boolean} createdOnly - Get only queries created by the current user, default is get all queries current user can access
|
|
101
|
+
* @param {boolean} includeQuery - Restrict GIS searches to specified entity types
|
|
102
|
+
* @param {boolean} [visibleToMobile] - Filter visibility to mobile. Default ignore visibility to mobile.
|
|
103
|
+
* @param {number} [domainId] - The domain ID of the domain to search, defaut is authenticated user's current domain
|
|
104
|
+
* @return {Object} Returns Promise object that represents a collection of SavedQueries
|
|
105
|
+
*/
|
|
106
|
+
getSaved(queryTypes?: Array<string>, createdOnly?: boolean, includeQuery?: boolean, visibleToMobile?: boolean, domainId?: number): Promise<unknown>;
|
|
107
|
+
}
|
|
108
|
+
export {};
|