@docbrasil/api-systemmanager 1.1.35 → 1.1.37

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.
@@ -0,0 +1 @@
1
+ {}
@@ -705,6 +705,61 @@ class Documents {
705
705
  return true;
706
706
  }
707
707
 
708
+ /**
709
+ * Uploads the file
710
+ * @param {object} params Params to upload document S3
711
+ * @param {buffer} params.data The data of the file
712
+ * @param {string} params.areaId The docAreaId
713
+ * @param {string} params.orgId The orgId
714
+ * @param {string} params.onUploadProgress A callback for the upload progress. It will return a progressEvent.
715
+ * @return {Promise<boolean>} True if success
716
+ *
717
+ * @public
718
+ * @async
719
+ * @example
720
+ *
721
+ * const API = require('@docbrasil/api-systemmanager');
722
+ * const api = new API();
723
+ * const params - {
724
+ * data: {},
725
+ * areaId: '5dadd01dc4af3941d42f8c5c',
726
+ * orgId: '5dadd01dc4af3941d42f8c5c'
727
+ * };
728
+ * const retData = await api.user.document.uploadDocumentS3(params);
729
+ *
730
+ * onUploadProgress return the progressEvent
731
+ * - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
732
+ * - loaded: The number of bytes of the file that have been uploaded.
733
+ * - total: The total number of bytes in the file.
734
+ */
735
+ async uploadDocumentS3(params= {}) {
736
+ const { data, areaId, orgId } = params;
737
+ Joi.assert(params, Joi.object().required());
738
+ Joi.assert(params.data, Joi.required());
739
+ Joi.assert(params.areaId, Joi.string().required());
740
+ Joi.assert(params.orgId, Joi.string().required());
741
+
742
+ const self = this;
743
+ const reqOpts = {
744
+ headers: {
745
+ 'Content-Type': data.type
746
+ },
747
+ maxContentLength: Infinity,
748
+ maxBodyLength: Infinity
749
+ };
750
+
751
+ const onUploadProgress = params.onUploadProgress;
752
+
753
+ if(onUploadProgress) {
754
+ reqOpts.onUploadProgress = onUploadProgress;
755
+ }
756
+
757
+ const apiCall = self._client
758
+ .put(`/organizations/${orgId}/areas/${areaId}/documents`, data, reqOpts);
759
+ self._returnData(await apiCall);
760
+ return true;
761
+ }
762
+
708
763
  /**
709
764
  * @author Myndware <augusto.pissarra@myndware.com>
710
765
  * Checks if a document can be added and it does not repeat its primary key
@@ -438,6 +438,44 @@ class Process {
438
438
  throw ex;
439
439
  }
440
440
  }
441
+
442
+ /**
443
+ * @author Myndware <augusto.pissarra@myndware.com>
444
+ * @description Get DocType properties of process
445
+ * @param {object} params Params to get document DocType
446
+ * @param {string} params.docTypeId Document DocTypeId id (_id database);
447
+ * @param {string} params.orgId Organization id (_id database);
448
+ * @param {string} session Session, token JWT
449
+ * @return {Promise}
450
+ * @public
451
+ * @async
452
+ * @example
453
+ *
454
+ * const API = require('@docbrasil/api-systemmanager');
455
+ * const api = new API();
456
+ * const params = {
457
+ * docTypeId: '5dadd01dc4af3941d42f8c5c',
458
+ * orgId: '5edd11c46b6ce9729c2c297c',
459
+ * }
460
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
461
+ * await api.user.process.getOrgDocTypes(params, session);
462
+ */
463
+ async getOrgDocTypes(params, session) {
464
+ const self = this;
465
+
466
+ try {
467
+ Joi.assert(params, Joi.object().required());
468
+ Joi.assert(params.docTypeId, Joi.string().required());
469
+ Joi.assert(params.orgId, Joi.string().required());
470
+ Joi.assert(session, Joi.string().required());
471
+
472
+ const {docTypeId, orgId} = params;
473
+ const apiCall = self._client.get(`/organizations/${orgId}/doctype/${docTypeId}`, self._setHeader(session));
474
+ return self._returnData(await apiCall);
475
+ } catch (ex) {
476
+ throw ex;
477
+ }
478
+ }
441
479
  }
442
480
 
443
481
  export default Process;
package/dist/bundle.cjs CHANGED
@@ -1257,6 +1257,61 @@ class Documents {
1257
1257
  return true;
1258
1258
  }
1259
1259
 
1260
+ /**
1261
+ * Uploads the file
1262
+ * @param {object} params Params to upload document S3
1263
+ * @param {buffer} params.data The data of the file
1264
+ * @param {string} params.areaId The docAreaId
1265
+ * @param {string} params.orgId The orgId
1266
+ * @param {string} params.onUploadProgress A callback for the upload progress. It will return a progressEvent.
1267
+ * @return {Promise<boolean>} True if success
1268
+ *
1269
+ * @public
1270
+ * @async
1271
+ * @example
1272
+ *
1273
+ * const API = require('@docbrasil/api-systemmanager');
1274
+ * const api = new API();
1275
+ * const params - {
1276
+ * data: {},
1277
+ * areaId: '5dadd01dc4af3941d42f8c5c',
1278
+ * orgId: '5dadd01dc4af3941d42f8c5c'
1279
+ * };
1280
+ * const retData = await api.user.document.uploadDocumentS3(params);
1281
+ *
1282
+ * onUploadProgress return the progressEvent
1283
+ * - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
1284
+ * - loaded: The number of bytes of the file that have been uploaded.
1285
+ * - total: The total number of bytes in the file.
1286
+ */
1287
+ async uploadDocumentS3(params= {}) {
1288
+ const { data, areaId, orgId } = params;
1289
+ Joi__default["default"].assert(params, Joi__default["default"].object().required());
1290
+ Joi__default["default"].assert(params.data, Joi__default["default"].required());
1291
+ Joi__default["default"].assert(params.areaId, Joi__default["default"].string().required());
1292
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
1293
+
1294
+ const self = this;
1295
+ const reqOpts = {
1296
+ headers: {
1297
+ 'Content-Type': data.type
1298
+ },
1299
+ maxContentLength: Infinity,
1300
+ maxBodyLength: Infinity
1301
+ };
1302
+
1303
+ const onUploadProgress = params.onUploadProgress;
1304
+
1305
+ if(onUploadProgress) {
1306
+ reqOpts.onUploadProgress = onUploadProgress;
1307
+ }
1308
+
1309
+ const apiCall = self._client
1310
+ .put(`/organizations/${orgId}/areas/${areaId}/documents`, data, reqOpts);
1311
+ self._returnData(await apiCall);
1312
+ return true;
1313
+ }
1314
+
1260
1315
  /**
1261
1316
  * @author Myndware <augusto.pissarra@myndware.com>
1262
1317
  * Checks if a document can be added and it does not repeat its primary key
@@ -2191,6 +2246,44 @@ class Process {
2191
2246
  throw ex;
2192
2247
  }
2193
2248
  }
2249
+
2250
+ /**
2251
+ * @author Myndware <augusto.pissarra@myndware.com>
2252
+ * @description Get DocType properties of process
2253
+ * @param {object} params Params to get document DocType
2254
+ * @param {string} params.docTypeId Document DocTypeId id (_id database);
2255
+ * @param {string} params.orgId Organization id (_id database);
2256
+ * @param {string} session Session, token JWT
2257
+ * @return {Promise}
2258
+ * @public
2259
+ * @async
2260
+ * @example
2261
+ *
2262
+ * const API = require('@docbrasil/api-systemmanager');
2263
+ * const api = new API();
2264
+ * const params = {
2265
+ * docTypeId: '5dadd01dc4af3941d42f8c5c',
2266
+ * orgId: '5edd11c46b6ce9729c2c297c',
2267
+ * }
2268
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2269
+ * await api.user.process.getOrgDocTypes(params, session);
2270
+ */
2271
+ async getOrgDocTypes(params, session) {
2272
+ const self = this;
2273
+
2274
+ try {
2275
+ Joi__default["default"].assert(params, Joi__default["default"].object().required());
2276
+ Joi__default["default"].assert(params.docTypeId, Joi__default["default"].string().required());
2277
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
2278
+ Joi__default["default"].assert(session, Joi__default["default"].string().required());
2279
+
2280
+ const {docTypeId, orgId} = params;
2281
+ const apiCall = self._client.get(`/organizations/${orgId}/doctype/${docTypeId}`, self._setHeader(session));
2282
+ return self._returnData(await apiCall);
2283
+ } catch (ex) {
2284
+ throw ex;
2285
+ }
2286
+ }
2194
2287
  }
2195
2288
 
2196
2289
  /**
@@ -14018,7 +14111,7 @@ class MyndAI {
14018
14111
  * @param {object} params.context The context to apply to a prompt
14019
14112
  * @param {string} params.text The text to add to the prompt
14020
14113
  * @param {array<base64>} params.medias Medias to add to the case in base64 (PDF, Image, Video, Audio)
14021
- * @param {string} params.propmpt The actual prompt with context and text to apply to
14114
+ * @param {string} params.prompt The actual prompt with context and text to apply to
14022
14115
  * @return {Promise<object>} data
14023
14116
  * @return {boolean} data.success true|false for success
14024
14117
  * @return {object} data.result the result of the AI call
@@ -14045,7 +14138,7 @@ class MyndAI {
14045
14138
 
14046
14139
  try {
14047
14140
  Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
14048
- Joi__default["default"].assert(params.propmpt, Joi__default["default"].string().required().error(new Error('Provide a prompt')));
14141
+ Joi__default["default"].assert(params.prompt, Joi__default["default"].string().required().error(new Error('Provide a prompt')));
14049
14142
 
14050
14143
  const apiCall = self._client
14051
14144
  .post('/agents/explain', params, self._setHeader(authorization));