@docbrasil/api-systemmanager 1.1.36 → 1.1.38
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/.vscode/settings.json +1 -0
- package/api/user/document.js +55 -0
- package/api/user/process.js +38 -0
- package/dist/bundle.cjs +93 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +62 -0
- package/docs/Documents.html +297 -6
- package/docs/Process.html +270 -0
- package/docs/user_document.js.html +55 -0
- package/docs/user_process.js.html +38 -0
- package/package.json +1 -1
|
@@ -792,6 +792,61 @@ class Documents {
|
|
|
792
792
|
return true;
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Uploads the file
|
|
797
|
+
* @param {object} params Params to upload document S3
|
|
798
|
+
* @param {buffer} params.data The data of the file
|
|
799
|
+
* @param {string} params.areaId The docAreaId
|
|
800
|
+
* @param {string} params.orgId The orgId
|
|
801
|
+
* @param {string} params.onUploadProgress A callback for the upload progress. It will return a progressEvent.
|
|
802
|
+
* @return {Promise<boolean>} True if success
|
|
803
|
+
*
|
|
804
|
+
* @public
|
|
805
|
+
* @async
|
|
806
|
+
* @example
|
|
807
|
+
*
|
|
808
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
809
|
+
* const api = new API();
|
|
810
|
+
* const params - {
|
|
811
|
+
* data: {},
|
|
812
|
+
* areaId: '5dadd01dc4af3941d42f8c5c',
|
|
813
|
+
* orgId: '5dadd01dc4af3941d42f8c5c'
|
|
814
|
+
* };
|
|
815
|
+
* const retData = await api.user.document.uploadDocumentS3(params);
|
|
816
|
+
*
|
|
817
|
+
* onUploadProgress return the progressEvent
|
|
818
|
+
* - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
|
|
819
|
+
* - loaded: The number of bytes of the file that have been uploaded.
|
|
820
|
+
* - total: The total number of bytes in the file.
|
|
821
|
+
*/
|
|
822
|
+
async uploadDocumentS3(params= {}) {
|
|
823
|
+
const { data, areaId, orgId } = params;
|
|
824
|
+
Joi.assert(params, Joi.object().required());
|
|
825
|
+
Joi.assert(params.data, Joi.required());
|
|
826
|
+
Joi.assert(params.areaId, Joi.string().required());
|
|
827
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
828
|
+
|
|
829
|
+
const self = this;
|
|
830
|
+
const reqOpts = {
|
|
831
|
+
headers: {
|
|
832
|
+
'Content-Type': data.type
|
|
833
|
+
},
|
|
834
|
+
maxContentLength: Infinity,
|
|
835
|
+
maxBodyLength: Infinity
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
const onUploadProgress = params.onUploadProgress;
|
|
839
|
+
|
|
840
|
+
if(onUploadProgress) {
|
|
841
|
+
reqOpts.onUploadProgress = onUploadProgress;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
const apiCall = self._client
|
|
845
|
+
.put(`/organizations/${orgId}/areas/${areaId}/documents`, data, reqOpts);
|
|
846
|
+
self._returnData(await apiCall);
|
|
847
|
+
return true;
|
|
848
|
+
}
|
|
849
|
+
|
|
795
850
|
/**
|
|
796
851
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
797
852
|
* Checks if a document can be added and it does not repeat its primary key
|
|
@@ -525,6 +525,44 @@ class Process {
|
|
|
525
525
|
throw ex;
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
531
|
+
* @description Get DocType properties of process
|
|
532
|
+
* @param {object} params Params to get document DocType
|
|
533
|
+
* @param {string} params.docTypeId Document DocTypeId id (_id database);
|
|
534
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
535
|
+
* @param {string} session Session, token JWT
|
|
536
|
+
* @return {Promise}
|
|
537
|
+
* @public
|
|
538
|
+
* @async
|
|
539
|
+
* @example
|
|
540
|
+
*
|
|
541
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
542
|
+
* const api = new API();
|
|
543
|
+
* const params = {
|
|
544
|
+
* docTypeId: '5dadd01dc4af3941d42f8c5c',
|
|
545
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
546
|
+
* }
|
|
547
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
548
|
+
* await api.user.process.getOrgDocTypes(params, session);
|
|
549
|
+
*/
|
|
550
|
+
async getOrgDocTypes(params, session) {
|
|
551
|
+
const self = this;
|
|
552
|
+
|
|
553
|
+
try {
|
|
554
|
+
Joi.assert(params, Joi.object().required());
|
|
555
|
+
Joi.assert(params.docTypeId, Joi.string().required());
|
|
556
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
557
|
+
Joi.assert(session, Joi.string().required());
|
|
558
|
+
|
|
559
|
+
const {docTypeId, orgId} = params;
|
|
560
|
+
const apiCall = self._client.get(`/organizations/${orgId}/doctype/${docTypeId}`, self._setHeader(session));
|
|
561
|
+
return self._returnData(await apiCall);
|
|
562
|
+
} catch (ex) {
|
|
563
|
+
throw ex;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
528
566
|
}
|
|
529
567
|
|
|
530
568
|
export default Process;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docbrasil/api-systemmanager",
|
|
3
3
|
"description": "Module API System Manager",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.38",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
|
|
7
7
|
"doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",
|