@docbrasil/api-systemmanager 1.1.59 → 1.1.61
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/api/user/document.js +1 -1
- package/api/user/index.js +3 -0
- package/api/user/kanban.js +510 -0
- package/api/user/organization.js +1 -1
- package/dist/bundle.cjs +506 -2
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +354 -24
- package/docs/Admin.html +1 -1
- package/docs/AdminDocuments.html +1 -1
- package/docs/AdminForm.html +1 -1
- package/docs/AdminLists.html +1 -1
- package/docs/AdminMessage.html +1 -1
- package/docs/AdminNotification.html +1 -1
- package/docs/AdminPlugin.html +1 -1
- package/docs/AdminPolicy.html +1 -1
- package/docs/AdminProcesses.html +1 -1
- package/docs/AdminTask.html +1 -1
- package/docs/AdminUser.html +1 -1
- package/docs/Application.html +1 -1
- package/docs/Chart.html +1 -1
- package/docs/Dashboard.html +1 -1
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +132 -41
- package/docs/Documents.html +8 -8
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +1 -1
- package/docs/Kanban.html +3038 -0
- package/docs/Login.html +2 -2
- package/docs/MyTasks.html +1 -1
- package/docs/MyndAI.html +1 -1
- package/docs/Notification.html +1 -1
- package/docs/Organization.html +1 -1
- package/docs/Page.html +1 -1
- package/docs/Process.html +1 -1
- package/docs/Register.html +1 -1
- package/docs/Session.html +1 -1
- package/docs/Settings.html +1 -1
- package/docs/Task.html +1 -1
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +1 -1
- package/docs/User.html +1 -1
- package/docs/Users.html +2 -2
- package/docs/admin_doctypes.js.html +2 -2
- package/docs/admin_document.js.html +2 -2
- package/docs/admin_form.js.html +2 -2
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +2 -2
- package/docs/admin_message.js.html +2 -2
- package/docs/admin_notification.js.html +2 -2
- package/docs/admin_organization.js.html +2 -2
- package/docs/admin_plugin.js.html +2 -2
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +2 -2
- package/docs/admin_task.js.html +2 -2
- package/docs/admin_user.js.html +2 -2
- package/docs/ai.js.html +2 -2
- package/docs/dispatch.js.html +75 -78
- package/docs/external.js.html +2 -2
- package/docs/general_geoLocation.js.html +2 -2
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +3 -3
- package/docs/session.js.html +2 -2
- package/docs/user_application.js.html +2 -2
- package/docs/user_dashboard.js.html +2 -2
- package/docs/user_datasource.js.html +2 -2
- package/docs/user_document.js.html +5 -4
- package/docs/user_help.js.html +2 -2
- package/docs/user_index.js.html +4 -1
- package/docs/user_kanban.js.html +627 -0
- package/docs/user_my_tasks.js.html +9 -9
- package/docs/user_notification.js.html +2 -2
- package/docs/user_organization.js.html +3 -3
- package/docs/user_page.js.html +2 -2
- package/docs/user_process.js.html +14 -14
- package/docs/user_register.js.html +2 -2
- package/docs/user_settings.js.html +2 -2
- package/docs/user_task.js.html +2 -2
- package/docs/user_task_available.js.html +2 -2
- package/docs/user_updates.js.html +2 -2
- package/docs/user_user.js.html +2 -2
- package/docs/utils_promises.js.html +1 -1
- package/package.json +1 -1
package/api/user/document.js
CHANGED
|
@@ -296,7 +296,7 @@ class Documents {
|
|
|
296
296
|
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
297
297
|
const {id, orgId} = params;
|
|
298
298
|
const apiCall = self._client
|
|
299
|
-
.get(`/organizations/${orgId}/documents/${id}/data/DOC`,
|
|
299
|
+
.get(`/organizations/${orgId}/documents/${id}/data/DOC`, self._setHeader(session));
|
|
300
300
|
|
|
301
301
|
return self._returnData(await apiCall);
|
|
302
302
|
} catch (ex) {
|
package/api/user/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import Datasource from './datasource.js';
|
|
|
14
14
|
import Application from './application.js';
|
|
15
15
|
import Settings from './settings.js';
|
|
16
16
|
import Dashboard from './dashboard.js';
|
|
17
|
+
import Kanban from './kanban.js';
|
|
18
|
+
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* @class API request, user permission level
|
|
@@ -43,6 +45,7 @@ class Users {
|
|
|
43
45
|
self.help = new Help(options);
|
|
44
46
|
self.application = new Application(options);
|
|
45
47
|
self.dashboard = new Dashboard(options);
|
|
48
|
+
self.kanban = new Kanban(options);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
import TaskAvailable from './task_available.js';
|
|
5
|
+
import MyTasks from './my_tasks.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Class for task, permission user
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
11
|
+
class Kanban {
|
|
12
|
+
|
|
13
|
+
constructor(options) {
|
|
14
|
+
Joi.assert(options, Joi.object().required());
|
|
15
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
16
|
+
|
|
17
|
+
const self = this;
|
|
18
|
+
self.parent = options.parent;
|
|
19
|
+
self._client = self.parent.dispatch.getClient();
|
|
20
|
+
self.available = new TaskAvailable(options);
|
|
21
|
+
self.mytasks = new MyTasks(options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
26
|
+
* @description Get the return data and check for errors
|
|
27
|
+
* @param {object} retData Response HTTP
|
|
28
|
+
* @return {*}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
_returnData(retData, def = {}) {
|
|
32
|
+
if (retData.status !== 200) {
|
|
33
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
34
|
+
} else {
|
|
35
|
+
return _.get(retData, 'data', def);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
41
|
+
* @description Set header with new session
|
|
42
|
+
* @param {string} session Session, token JWT
|
|
43
|
+
* @return {object} header with new session
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
_setHeader(session) {
|
|
47
|
+
return {
|
|
48
|
+
headers: {
|
|
49
|
+
Authorization: session,
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
56
|
+
* @description Retrieves the Kanban board data for a specified organization process
|
|
57
|
+
* @param {Object} params - Parameters object
|
|
58
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
59
|
+
* @param {string} params.orgProcessName - The name of the organization process
|
|
60
|
+
* @param {string} params.flowName - Flow name for the specific kanban flow
|
|
61
|
+
* @param {string} session - Session, token JWT
|
|
62
|
+
* @returns {promise} Promise that resolves to Kanban board data
|
|
63
|
+
* @returns {Object} returns.data - The response data containing:
|
|
64
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
65
|
+
* @returns {Array} returns.data.kanban - Array of status columns with their tasks
|
|
66
|
+
* @returns {string} returns.data.kanban[].id - Unique identifier for the status column
|
|
67
|
+
* @returns {string} returns.data.kanban[].title - Display title of the status column
|
|
68
|
+
* @returns {boolean} returns.data.kanban[].isExpanded - Whether the status column is expanded or collapsed
|
|
69
|
+
* @returns {Array} returns.data.kanban[].taskList - Array of tasks within this status column
|
|
70
|
+
* @returns {Array} returns.data.kanban[].statusTagsList - List of status tags available for filtering
|
|
71
|
+
* @public
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
75
|
+
* const api = new API();
|
|
76
|
+
* const params = {
|
|
77
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
78
|
+
* orgProcessName: 'employee-onboarding',
|
|
79
|
+
* flowName: 'approval-flow'
|
|
80
|
+
* };
|
|
81
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
82
|
+
* const kanbanData = await api.user.kanban.get(params, session);
|
|
83
|
+
*
|
|
84
|
+
* Expected response structure:
|
|
85
|
+
* {
|
|
86
|
+
* success: true,
|
|
87
|
+
* kanban: [
|
|
88
|
+
* {
|
|
89
|
+
* id: 'pending',
|
|
90
|
+
* title: 'Pending Tasks',
|
|
91
|
+
* isExpanded: true,
|
|
92
|
+
* taskList: [
|
|
93
|
+
* { taskId: '507f1f77bcf86cd799439011', title: 'Review Document', ... },
|
|
94
|
+
* { taskId: '507f1f77bcf86cd799439012', title: 'Approve Request', ... }
|
|
95
|
+
* ],
|
|
96
|
+
* statusTagsList: ['urgent', 'review', 'approved', 'rejected']
|
|
97
|
+
* },
|
|
98
|
+
* {
|
|
99
|
+
* id: 'in-progress',
|
|
100
|
+
* title: 'In Progress',
|
|
101
|
+
* isExpanded: true,
|
|
102
|
+
* taskList: [...],
|
|
103
|
+
* statusTagsList: ['urgent', 'review', 'approved', 'rejected']
|
|
104
|
+
* }
|
|
105
|
+
* ]
|
|
106
|
+
* }
|
|
107
|
+
*/
|
|
108
|
+
async get(params, session) {
|
|
109
|
+
const self = this;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
113
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
114
|
+
Joi.assert(params.orgProcessName, Joi.string().required(), 'The organization process name');
|
|
115
|
+
Joi.assert(params.flowName, Joi.string().required(), 'Flow name for the specific kanban flow');
|
|
116
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
117
|
+
|
|
118
|
+
const { orgId, orgProcessName, flowName } = params;
|
|
119
|
+
|
|
120
|
+
// Build API endpoint with flowName as part of the path
|
|
121
|
+
const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/flow/${flowName}`;
|
|
122
|
+
|
|
123
|
+
const apiCall = self._client
|
|
124
|
+
.get(endpoint, self._setHeader(session));
|
|
125
|
+
|
|
126
|
+
return self._returnData(await apiCall);
|
|
127
|
+
} catch (ex) {
|
|
128
|
+
throw ex;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
134
|
+
* @description Updates the order of a task in its status column on the Kanban board
|
|
135
|
+
* @param {Object} params - Parameters object
|
|
136
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
137
|
+
* @param {string} params.taskId - The ID of the task to update
|
|
138
|
+
* @param {number} params.order - The new order position of the task
|
|
139
|
+
* @param {string} session - Session, token JWT
|
|
140
|
+
* @returns {promise} Promise that resolves to operation status
|
|
141
|
+
* @returns {Object} returns.data - The response data containing:
|
|
142
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
143
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
144
|
+
* @public
|
|
145
|
+
* @example
|
|
146
|
+
*
|
|
147
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
148
|
+
* const api = new API();
|
|
149
|
+
* const params = {
|
|
150
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
151
|
+
* taskId: '507f1f77bcf86cd799439011',
|
|
152
|
+
* order: 3
|
|
153
|
+
* };
|
|
154
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
155
|
+
* const result = await api.user.kanban.updateTaskOrder(params, session);
|
|
156
|
+
*
|
|
157
|
+
* Expected response structure (success):
|
|
158
|
+
* {
|
|
159
|
+
* success: true
|
|
160
|
+
* }
|
|
161
|
+
*
|
|
162
|
+
* Expected response structure (error):
|
|
163
|
+
* {
|
|
164
|
+
* success: false,
|
|
165
|
+
* error: "Task not found"
|
|
166
|
+
* }
|
|
167
|
+
*/
|
|
168
|
+
async updateTaskOrder(params, session) {
|
|
169
|
+
const self = this;
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
Joi.assert(params, Joi.object().required(), 'Params to update task order');
|
|
173
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
174
|
+
Joi.assert(params.taskId, Joi.string().required(), 'The ID of the task to update');
|
|
175
|
+
Joi.assert(params.order, Joi.number().required(), 'The new order position of the task');
|
|
176
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
177
|
+
|
|
178
|
+
const { orgId, taskId, order } = params;
|
|
179
|
+
|
|
180
|
+
// Build API endpoint for updating task order
|
|
181
|
+
const endpoint = `/organization/${orgId}/kanban/task/${taskId}/order`;
|
|
182
|
+
|
|
183
|
+
const apiCall = self._client
|
|
184
|
+
.put(endpoint, { order }, self._setHeader(session));
|
|
185
|
+
|
|
186
|
+
return self._returnData(await apiCall);
|
|
187
|
+
} catch (ex) {
|
|
188
|
+
throw ex;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
194
|
+
* @description Updates the order of multiple tasks in their status columns on the Kanban board
|
|
195
|
+
* @param {Object} params - Parameters object
|
|
196
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
197
|
+
* @param {Array} params.tasks - Array of task objects containing taskId and order
|
|
198
|
+
* @param {string} params.tasks[].taskId - The unique identifier of the task to update
|
|
199
|
+
* @param {number} params.tasks[].order - The new order position for the task
|
|
200
|
+
* @param {string} session - Session, token JWT
|
|
201
|
+
* @returns {promise} Promise that resolves to operation status
|
|
202
|
+
* @returns {Object} returns.data - The response data containing:
|
|
203
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
204
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
205
|
+
* @public
|
|
206
|
+
* @example
|
|
207
|
+
*
|
|
208
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
209
|
+
* const api = new API();
|
|
210
|
+
* const params = {
|
|
211
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
212
|
+
* tasks: [
|
|
213
|
+
* { taskId: '507f1f77bcf86cd799439011', order: 1 },
|
|
214
|
+
* { taskId: '507f1f77bcf86cd799439012', order: 2 },
|
|
215
|
+
* { taskId: '507f1f77bcf86cd799439013', order: 3 }
|
|
216
|
+
* ]
|
|
217
|
+
* };
|
|
218
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
219
|
+
* const result = await api.user.kanban.updateTasksOrder(params, session);
|
|
220
|
+
*
|
|
221
|
+
* Expected response structure (success):
|
|
222
|
+
* {
|
|
223
|
+
* success: true
|
|
224
|
+
* }
|
|
225
|
+
*
|
|
226
|
+
* Expected response structure (error):
|
|
227
|
+
* {
|
|
228
|
+
* success: false,
|
|
229
|
+
* error: "One or more tasks not found"
|
|
230
|
+
* }
|
|
231
|
+
*/
|
|
232
|
+
async updateTasksOrder(params, session) {
|
|
233
|
+
const self = this;
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
Joi.assert(params, Joi.object().required(), 'Params to update tasks order');
|
|
237
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
238
|
+
Joi.assert(params.tasks, Joi.array().required(), 'Array of task objects containing taskId and order');
|
|
239
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
240
|
+
|
|
241
|
+
const { orgId, tasks } = params;
|
|
242
|
+
|
|
243
|
+
// Build API endpoint for updating multiple tasks order
|
|
244
|
+
const endpoint = `/organization/${orgId}/kanban/task/orders`;
|
|
245
|
+
|
|
246
|
+
const apiCall = self._client
|
|
247
|
+
.put(endpoint, { tasks }, self._setHeader(session));
|
|
248
|
+
|
|
249
|
+
return self._returnData(await apiCall);
|
|
250
|
+
} catch (ex) {
|
|
251
|
+
throw ex;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
257
|
+
* @description Updates the status of a task on the Kanban board when moved between columns
|
|
258
|
+
* @param {Object} params - Parameters object
|
|
259
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
260
|
+
* @param {string} params.taskId - The ID of the task to update
|
|
261
|
+
* @param {string} params.status - The new status value for the task
|
|
262
|
+
* @param {string} session - Session, token JWT
|
|
263
|
+
* @returns {promise} Promise that resolves to operation status
|
|
264
|
+
* @returns {Object} returns.data - The response data containing:
|
|
265
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
266
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
267
|
+
* @public
|
|
268
|
+
* @example
|
|
269
|
+
*
|
|
270
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
271
|
+
* const api = new API();
|
|
272
|
+
* const params = {
|
|
273
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
274
|
+
* taskId: '507f1f77bcf86cd799439011',
|
|
275
|
+
* status: 'in-progress'
|
|
276
|
+
* };
|
|
277
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
278
|
+
* const result = await api.user.kanban.updateTaskStatus(params, session);
|
|
279
|
+
*
|
|
280
|
+
* Expected response structure (success):
|
|
281
|
+
* {
|
|
282
|
+
* success: true
|
|
283
|
+
* }
|
|
284
|
+
*
|
|
285
|
+
* Expected response structure (error):
|
|
286
|
+
* {
|
|
287
|
+
* success: false,
|
|
288
|
+
* error: "Task not found"
|
|
289
|
+
* }
|
|
290
|
+
*/
|
|
291
|
+
async updateTaskStatus(params, session) {
|
|
292
|
+
const self = this;
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
Joi.assert(params, Joi.object().required(), 'Params to update task status');
|
|
296
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
297
|
+
Joi.assert(params.taskId, Joi.string().required(), 'The ID of the task to update');
|
|
298
|
+
Joi.assert(params.status, Joi.string().required(), 'The new status value for the task');
|
|
299
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
300
|
+
|
|
301
|
+
const { orgId, taskId, status } = params;
|
|
302
|
+
|
|
303
|
+
// Build API endpoint for updating task status
|
|
304
|
+
const endpoint = `/organization/${orgId}/kanban/task/${taskId}/status`;
|
|
305
|
+
|
|
306
|
+
const apiCall = self._client
|
|
307
|
+
.put(endpoint, { status }, self._setHeader(session));
|
|
308
|
+
|
|
309
|
+
return self._returnData(await apiCall);
|
|
310
|
+
} catch (ex) {
|
|
311
|
+
throw ex;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
317
|
+
* @description Adds a tag to a task on the Kanban board without creating duplicates
|
|
318
|
+
* @param {Object} params - Parameters object
|
|
319
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
320
|
+
* @param {string} params.taskId - The ID of the task to update
|
|
321
|
+
* @param {string} params.tag - The tag to add to the task
|
|
322
|
+
* @param {string} session - Session, token JWT
|
|
323
|
+
* @returns {promise} Promise that resolves to operation status
|
|
324
|
+
* @returns {Object} returns.data - The response data containing:
|
|
325
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
326
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
327
|
+
* @public
|
|
328
|
+
* @example
|
|
329
|
+
*
|
|
330
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
331
|
+
* const api = new API();
|
|
332
|
+
* const params = {
|
|
333
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
334
|
+
* taskId: '507f1f77bcf86cd799439011',
|
|
335
|
+
* tag: 'urgent'
|
|
336
|
+
* };
|
|
337
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
338
|
+
* const result = await api.user.kanban.addTaskTag(params, session);
|
|
339
|
+
*
|
|
340
|
+
* Expected response structure (success):
|
|
341
|
+
* {
|
|
342
|
+
* success: true
|
|
343
|
+
* }
|
|
344
|
+
*
|
|
345
|
+
* Expected response structure (error):
|
|
346
|
+
* {
|
|
347
|
+
* success: false,
|
|
348
|
+
* error: "Task not found"
|
|
349
|
+
* }
|
|
350
|
+
*/
|
|
351
|
+
async addTaskTag(params, session) {
|
|
352
|
+
const self = this;
|
|
353
|
+
|
|
354
|
+
try {
|
|
355
|
+
Joi.assert(params, Joi.object().required(), 'Params to add task tag');
|
|
356
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
357
|
+
Joi.assert(params.taskId, Joi.string().required(), 'The ID of the task to update');
|
|
358
|
+
Joi.assert(params.tag, Joi.string().required(), 'The tag to add to the task');
|
|
359
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
360
|
+
|
|
361
|
+
const { orgId, taskId, tag } = params;
|
|
362
|
+
|
|
363
|
+
// Build API endpoint for adding task tag
|
|
364
|
+
const endpoint = `/organization/${orgId}/kanban/task/${taskId}/tag`;
|
|
365
|
+
|
|
366
|
+
const apiCall = self._client
|
|
367
|
+
.put(endpoint, { tag }, self._setHeader(session));
|
|
368
|
+
|
|
369
|
+
return self._returnData(await apiCall);
|
|
370
|
+
} catch (ex) {
|
|
371
|
+
throw ex;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
377
|
+
* @description Removes a specific tag from a task on the Kanban board
|
|
378
|
+
* @param {Object} params - Parameters object
|
|
379
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
380
|
+
* @param {string} params.taskId - The ID of the task to update
|
|
381
|
+
* @param {string} params.tag - The tag to remove from the task
|
|
382
|
+
* @param {string} session - Session, token JWT
|
|
383
|
+
* @returns {promise} Promise that resolves to operation status
|
|
384
|
+
* @returns {Object} returns.data - The response data containing:
|
|
385
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
386
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
387
|
+
* @public
|
|
388
|
+
* @example
|
|
389
|
+
*
|
|
390
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
391
|
+
* const api = new API();
|
|
392
|
+
* const params = {
|
|
393
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
394
|
+
* taskId: '507f1f77bcf86cd799439011',
|
|
395
|
+
* tag: 'urgent'
|
|
396
|
+
* };
|
|
397
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
398
|
+
* const result = await api.user.kanban.removeTaskTag(params, session);
|
|
399
|
+
*
|
|
400
|
+
* Expected response structure (success):
|
|
401
|
+
* {
|
|
402
|
+
* success: true
|
|
403
|
+
* }
|
|
404
|
+
*
|
|
405
|
+
* Expected response structure (error):
|
|
406
|
+
* {
|
|
407
|
+
* success: false,
|
|
408
|
+
* error: "Task not found"
|
|
409
|
+
* }
|
|
410
|
+
*/
|
|
411
|
+
async removeTaskTag(params, session) {
|
|
412
|
+
const self = this;
|
|
413
|
+
|
|
414
|
+
try {
|
|
415
|
+
Joi.assert(params, Joi.object().required(), 'Params to remove task tag');
|
|
416
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
417
|
+
Joi.assert(params.taskId, Joi.string().required(), 'The ID of the task to update');
|
|
418
|
+
Joi.assert(params.tag, Joi.string().required(), 'The tag to remove from the task');
|
|
419
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
420
|
+
|
|
421
|
+
const { orgId, taskId, tag } = params;
|
|
422
|
+
|
|
423
|
+
// Build API endpoint for removing task tag
|
|
424
|
+
const endpoint = `/organization/${orgId}/kanban/task/${taskId}/tag/${tag}`;
|
|
425
|
+
|
|
426
|
+
const apiCall = self._client
|
|
427
|
+
.delete(endpoint, self._setHeader(session));
|
|
428
|
+
|
|
429
|
+
return self._returnData(await apiCall);
|
|
430
|
+
} catch (ex) {
|
|
431
|
+
throw ex;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
437
|
+
* @description Updates the status list order for a specific flow in an organization process on the Kanban board
|
|
438
|
+
* Can also be used to update the name, expanded and or the color value of an status of the status list
|
|
439
|
+
* That is: updates the whole status list
|
|
440
|
+
* @param {Object} params - Parameters object
|
|
441
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
442
|
+
* @param {string} params.orgProcessName - The name of the organization process
|
|
443
|
+
* @param {string} params.flowName - The name of the organization process step flowName
|
|
444
|
+
* @param {Array} params.statusList - The status list with new order
|
|
445
|
+
* @param {Object} params.statusList[] - Status object configuration
|
|
446
|
+
* @param {string} params.statusList[].value - The title of the status
|
|
447
|
+
* @param {boolean} params.statusList[].expanded - If the status column is expanded or not
|
|
448
|
+
* @param {string} params.statusList[].color - The hexadecimal color code for the status
|
|
449
|
+
* @param {string} session - Session, token JWT
|
|
450
|
+
* @returns {promise} Promise that resolves to operation status
|
|
451
|
+
* @returns {Object} returns.data - The response data containing:
|
|
452
|
+
* @returns {boolean} returns.data.success - Indicates if the operation was successful
|
|
453
|
+
* @returns {string} [returns.data.error] - Error message if operation failed
|
|
454
|
+
* @public
|
|
455
|
+
* @example
|
|
456
|
+
*
|
|
457
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
458
|
+
* const api = new API();
|
|
459
|
+
* const params = {
|
|
460
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
461
|
+
* orgProcessName: 'employee-onboarding',
|
|
462
|
+
* flowName: 'approval-flow',
|
|
463
|
+
* statusList: [
|
|
464
|
+
* { value: 'Pending', expanded: true, color: '#FF6B6B' },
|
|
465
|
+
* { value: 'In Progress', expanded: true, color: '#4ECDC4' },
|
|
466
|
+
* { value: 'Under Review', expanded: false, color: '#45B7D1' },
|
|
467
|
+
* { value: 'Completed', expanded: true, color: '#96CEB4' }
|
|
468
|
+
* ]
|
|
469
|
+
* };
|
|
470
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
471
|
+
* const result = await api.user.kanban.updateStatusList(params, session);
|
|
472
|
+
*
|
|
473
|
+
* Expected response structure (success):
|
|
474
|
+
* {
|
|
475
|
+
* success: true
|
|
476
|
+
* }
|
|
477
|
+
*
|
|
478
|
+
* Expected response structure (error):
|
|
479
|
+
* {
|
|
480
|
+
* success: false,
|
|
481
|
+
* error: "Organization process not found"
|
|
482
|
+
* }
|
|
483
|
+
*/
|
|
484
|
+
async updateStatusList(params, session) {
|
|
485
|
+
const self = this;
|
|
486
|
+
|
|
487
|
+
try {
|
|
488
|
+
Joi.assert(params, Joi.object().required(), 'Params to update status list');
|
|
489
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
490
|
+
Joi.assert(params.orgProcessName, Joi.string().required(), 'The name of the organization process');
|
|
491
|
+
Joi.assert(params.flowName, Joi.string().required(), 'The name of the organization process step flowName');
|
|
492
|
+
Joi.assert(params.statusList, Joi.array().required(), 'The status list with new order');
|
|
493
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
494
|
+
|
|
495
|
+
const { orgId, orgProcessName, flowName, statusList } = params;
|
|
496
|
+
|
|
497
|
+
// Build API endpoint for updating status list
|
|
498
|
+
const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/flow/${flowName}`;
|
|
499
|
+
|
|
500
|
+
const apiCall = self._client
|
|
501
|
+
.put(endpoint, { statusList }, self._setHeader(session));
|
|
502
|
+
|
|
503
|
+
return self._returnData(await apiCall);
|
|
504
|
+
} catch (ex) {
|
|
505
|
+
throw ex;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export default Kanban;
|