@docbrasil/api-systemmanager 1.1.5 → 1.1.6
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 +65 -1
- package/dist/bundle.cjs +8 -10
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +1229 -499
- 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/Datasource.html +1 -1
- package/docs/Dispatch.html +1 -1
- package/docs/Documents.html +1 -1
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +1 -1
- package/docs/Login.html +1 -1
- package/docs/MyTasks.html +603 -0
- 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/Task.html +5 -5
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +1 -1
- package/docs/User.html +1 -1
- package/docs/Users.html +1 -1
- package/docs/admin_doctypes.js.html +1 -1
- package/docs/admin_document.js.html +1 -1
- package/docs/admin_form.js.html +1 -1
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +1 -1
- package/docs/admin_message.js.html +1 -1
- package/docs/admin_notification.js.html +1 -1
- package/docs/admin_organization.js.html +1 -1
- package/docs/admin_plugin.js.html +1 -1
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +1 -1
- package/docs/admin_task.js.html +1 -1
- package/docs/admin_user.js.html +1 -1
- package/docs/dispatch.js.html +1 -1
- package/docs/external.js.html +1 -1
- package/docs/general_geoLocation.js.html +1 -1
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +1 -1
- package/docs/session.js.html +1 -1
- package/docs/user_application.js.html +1 -1
- package/docs/user_datasource.js.html +1 -1
- package/docs/user_document.js.html +1 -1
- package/docs/user_help.js.html +1 -1
- package/docs/user_index.js.html +1 -1
- package/docs/user_my_tasks.js.html +212 -0
- package/docs/user_notification.js.html +1 -1
- package/docs/user_organization.js.html +1 -1
- package/docs/user_page.js.html +1 -1
- package/docs/user_process.js.html +1 -1
- package/docs/user_register.js.html +1 -1
- package/docs/user_task.js.html +3 -1
- package/docs/user_task_available.js.html +1 -1
- package/docs/user_updates.js.html +1 -1
- package/docs/user_user.js.html +1 -1
- package/docs/utils_promises.js.html +1 -1
- package/package.json +1 -1
- package/tests/documents_002.spec.js +107 -0
package/api/user/document.js
CHANGED
|
@@ -225,6 +225,71 @@ class Documents {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
230
|
+
* @description Updates a document
|
|
231
|
+
* @param {string} id Document _id
|
|
232
|
+
* @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
|
|
233
|
+
* @param {string} session Session, token JWT
|
|
234
|
+
* @return {Promise}
|
|
235
|
+
* @public
|
|
236
|
+
* @async
|
|
237
|
+
* @example
|
|
238
|
+
*
|
|
239
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
240
|
+
* const api = new API();
|
|
241
|
+
* const params = { ... };
|
|
242
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
243
|
+
* await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);
|
|
244
|
+
*/
|
|
245
|
+
async findByIdAndUpdate(id, params, session) {
|
|
246
|
+
const self = this;
|
|
247
|
+
try {
|
|
248
|
+
Joi.assert(params._id, Joi.string().required().error(new Error('_id is required')));
|
|
249
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
250
|
+
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
251
|
+
const {areaId, orgId} = params;
|
|
252
|
+
const apiCall = self._client
|
|
253
|
+
.put(`/organizations/${orgId}/areas/${areaId}/documents/${id}`, params, self._setHeader(session));
|
|
254
|
+
|
|
255
|
+
return self._returnData(await apiCall);
|
|
256
|
+
} catch (ex) {
|
|
257
|
+
throw ex;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
263
|
+
* @description Updates a document.
|
|
264
|
+
* IMPORTANT: if your document has a content, it will NOT bring the content.
|
|
265
|
+
* @param {string} id Document _id
|
|
266
|
+
* @param {string} session Session, token JWT
|
|
267
|
+
* @return {Promise}
|
|
268
|
+
* @public
|
|
269
|
+
* @async
|
|
270
|
+
* @example
|
|
271
|
+
*
|
|
272
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
273
|
+
* const api = new API();
|
|
274
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
275
|
+
* await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
|
|
276
|
+
*/
|
|
277
|
+
async findById(id, session) {
|
|
278
|
+
const self = this;
|
|
279
|
+
try {
|
|
280
|
+
Joi.assert(params._id, Joi.string().required().error(new Error('_id is required')));
|
|
281
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
282
|
+
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
283
|
+
const {areaId, orgId} = params;
|
|
284
|
+
const apiCall = self._client
|
|
285
|
+
.get(`/organizations/${orgId}/documents/${id}/data/DOC`, params, self._setHeader(session));
|
|
286
|
+
|
|
287
|
+
return self._returnData(await apiCall);
|
|
288
|
+
} catch (ex) {
|
|
289
|
+
throw ex;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
228
293
|
/**
|
|
229
294
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
230
295
|
* @param {object} params Object with params
|
|
@@ -722,7 +787,6 @@ class Documents {
|
|
|
722
787
|
throw ex;
|
|
723
788
|
}
|
|
724
789
|
}
|
|
725
|
-
|
|
726
790
|
}
|
|
727
791
|
|
|
728
792
|
export default Documents;
|
package/dist/bundle.cjs
CHANGED
|
@@ -631,12 +631,15 @@ class Documents {
|
|
|
631
631
|
*/
|
|
632
632
|
_formatDocument(params) {
|
|
633
633
|
try {
|
|
634
|
+
const document = ___default["default"].get(params, 'document');
|
|
635
|
+
const urlType = ___default["default"].isEmpty(document) ? '' : ___default["default"].get(params, 'urlType', 'S3');
|
|
636
|
+
const addType = ___default["default"].isEmpty(document) ? '' : ___default["default"].get(params, 'addType', 'S3_SIGNED');
|
|
634
637
|
return {
|
|
635
638
|
orgname: ___default["default"].get(params, 'orgname'),
|
|
636
639
|
areaId: ___default["default"].get(params, 'areaId'),
|
|
637
640
|
docId: ___default["default"].get(params, 'docId'),
|
|
638
641
|
documentDate: ___default["default"].get(params, 'documentDate', Moment__default["default"]().format()),
|
|
639
|
-
document
|
|
642
|
+
document,
|
|
640
643
|
type: ___default["default"].get(params, 'type'),
|
|
641
644
|
name: ___default["default"].get(params, 'name'),
|
|
642
645
|
content: ___default["default"].get(params, 'content', ''),
|
|
@@ -653,8 +656,8 @@ class Documents {
|
|
|
653
656
|
docTypeFields: ___default["default"].get(params, 'docTypeFields', []), // {"extraId": userId},
|
|
654
657
|
docTypeFieldsData: ___default["default"].get(params, 'docTypeFieldsData', {}), // {"extraId": userId},
|
|
655
658
|
signedUrl: ___default["default"].get(params, 'signedUrl', ''),
|
|
656
|
-
urlType
|
|
657
|
-
addType
|
|
659
|
+
urlType,
|
|
660
|
+
addType
|
|
658
661
|
};
|
|
659
662
|
} catch (ex) {
|
|
660
663
|
throw ex;
|
|
@@ -739,17 +742,12 @@ class Documents {
|
|
|
739
742
|
*/
|
|
740
743
|
async add(params, session) {
|
|
741
744
|
const self = this;
|
|
742
|
-
|
|
743
745
|
try {
|
|
744
746
|
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
745
|
-
Joi__default["default"].assert(params.
|
|
747
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required().error(new Error('orgId is required')));
|
|
746
748
|
Joi__default["default"].assert(params.areaId, Joi__default["default"].string().required().error(new Error('areaId is required')));
|
|
747
|
-
Joi__default["default"].assert(params.
|
|
748
|
-
Joi__default["default"].assert(params.type, Joi__default["default"].string().required().error(new Error('type is required')));
|
|
749
|
-
Joi__default["default"].assert(params.name, Joi__default["default"].string().required().error(new Error('name is required')));
|
|
749
|
+
Joi__default["default"].assert(params.orgname, Joi__default["default"].string().required().error(new Error('orgname is required')));
|
|
750
750
|
Joi__default["default"].assert(params.docTypeId, Joi__default["default"].string().required().error(new Error('docTypeId is required')));
|
|
751
|
-
Joi__default["default"].assert(params.bytes, Joi__default["default"].number().required().error(new Error('bytes is required')));
|
|
752
|
-
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required().error(new Error('orgId is required')));
|
|
753
751
|
Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
|
|
754
752
|
|
|
755
753
|
// Get fields required, and set data default to create document
|