@docbrasil/api-systemmanager 1.0.79 → 1.0.80
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 +55 -1
- package/dist/bundle.cjs +55 -1
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +36 -1
- package/package.json +1 -1
package/api/user/document.js
CHANGED
|
@@ -385,7 +385,7 @@ class Documents {
|
|
|
385
385
|
* const api = new API();
|
|
386
386
|
* const params - {
|
|
387
387
|
* documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
|
|
388
|
-
*
|
|
388
|
+
* orgId: '5df7f19618430c89a41a19d2',
|
|
389
389
|
* };
|
|
390
390
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
391
391
|
* await api.user.document.findByIdsAndRemove(params, session);
|
|
@@ -628,6 +628,60 @@ class Documents {
|
|
|
628
628
|
return true;
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
+
/**
|
|
632
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
633
|
+
* Checks if a document can be added and it does not repeat its primary key
|
|
634
|
+
* @param params
|
|
635
|
+
* @param params.orgId {string} the organization id
|
|
636
|
+
* @param params.docTypeId {string} the id of the doc type
|
|
637
|
+
* @param params.docs {array<object>} an array of documents
|
|
638
|
+
* @param params.docs.id {string} an unique id representing the document
|
|
639
|
+
* @param params.docs.docTypeFields {object} thje docTypeFields of the document
|
|
640
|
+
* @param params.docs.docTypeFieldsData {object} thje docTypeFieldsData of the document
|
|
641
|
+
* @param session
|
|
642
|
+
* @return {Promise<array>} Return the array of the documents that are repeated. If not document is repeaded, then if returns an empty array.
|
|
643
|
+
* @return id {array<string>} the id of the repeated document
|
|
644
|
+
* @public
|
|
645
|
+
* @async
|
|
646
|
+
* @example
|
|
647
|
+
*
|
|
648
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
649
|
+
* const api = new API();
|
|
650
|
+
* const docTypeFields = [...]; // the doc type fields array
|
|
651
|
+
* const docTypeFieldsData = {...}; // the data of this fields
|
|
652
|
+
* const params - {
|
|
653
|
+
* docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
|
|
654
|
+
* orgId: '5df7f19618430c89a41a19d2',
|
|
655
|
+
* docTypeId: '5df7f19618430c89a41a19d5',
|
|
656
|
+
* };
|
|
657
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
658
|
+
* const retDocs = await api.user.document.findByIdsAndRemove(params, session);
|
|
659
|
+
*
|
|
660
|
+
*/
|
|
661
|
+
async checkPrimaryKeys(params, session) {
|
|
662
|
+
Joi.assert(params, Joi.object().required().label('params'));
|
|
663
|
+
Joi.assert(params.orgId, Joi.string().required().label('orgId'));
|
|
664
|
+
Joi.assert(params.docTypeId, Joi.string().required().label('docTypeId'));
|
|
665
|
+
Joi.assert(params.docs, Joi.array().required().label('docs'));
|
|
666
|
+
Joi.assert(session, Joi.string().required().label('session'));
|
|
667
|
+
|
|
668
|
+
const { docs = [], orgId = '', docTypeId = '' } = params;
|
|
669
|
+
|
|
670
|
+
if(docs.length === 0) return;
|
|
671
|
+
|
|
672
|
+
try {
|
|
673
|
+
const self = this;
|
|
674
|
+
const payloadToSend = {
|
|
675
|
+
docs,
|
|
676
|
+
docTypeId
|
|
677
|
+
};
|
|
678
|
+
const apiCall = self._client.post(`/organizations/${orgId}/documents/can/add`, payloadToSend, self._setHeader(session));
|
|
679
|
+
return self._returnData(await apiCall);
|
|
680
|
+
} catch (ex) {
|
|
681
|
+
throw ex;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
631
685
|
}
|
|
632
686
|
|
|
633
687
|
export default Documents;
|
package/dist/bundle.cjs
CHANGED
|
@@ -937,7 +937,7 @@ class Documents {
|
|
|
937
937
|
* const api = new API();
|
|
938
938
|
* const params - {
|
|
939
939
|
* documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
|
|
940
|
-
*
|
|
940
|
+
* orgId: '5df7f19618430c89a41a19d2',
|
|
941
941
|
* };
|
|
942
942
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
943
943
|
* await api.user.document.findByIdsAndRemove(params, session);
|
|
@@ -1180,6 +1180,60 @@ class Documents {
|
|
|
1180
1180
|
return true;
|
|
1181
1181
|
}
|
|
1182
1182
|
|
|
1183
|
+
/**
|
|
1184
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1185
|
+
* Checks if a document can be added and it does not repeat its primary key
|
|
1186
|
+
* @param params
|
|
1187
|
+
* @param params.orgId {string} the organization id
|
|
1188
|
+
* @param params.docTypeId {string} the id of the doc type
|
|
1189
|
+
* @param params.docs {array<object>} an array of documents
|
|
1190
|
+
* @param params.docs.id {string} an unique id representing the document
|
|
1191
|
+
* @param params.docs.docTypeFields {object} thje docTypeFields of the document
|
|
1192
|
+
* @param params.docs.docTypeFieldsData {object} thje docTypeFieldsData of the document
|
|
1193
|
+
* @param session
|
|
1194
|
+
* @return {Promise<array>} Return the array of the documents that are repeated. If not document is repeaded, then if returns an empty array.
|
|
1195
|
+
* @return id {array<string>} the id of the repeated document
|
|
1196
|
+
* @public
|
|
1197
|
+
* @async
|
|
1198
|
+
* @example
|
|
1199
|
+
*
|
|
1200
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
1201
|
+
* const api = new API();
|
|
1202
|
+
* const docTypeFields = [...]; // the doc type fields array
|
|
1203
|
+
* const docTypeFieldsData = {...}; // the data of this fields
|
|
1204
|
+
* const params - {
|
|
1205
|
+
* docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
|
|
1206
|
+
* orgId: '5df7f19618430c89a41a19d2',
|
|
1207
|
+
* docTypeId: '5df7f19618430c89a41a19d5',
|
|
1208
|
+
* };
|
|
1209
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1210
|
+
* const retDocs = await api.user.document.findByIdsAndRemove(params, session);
|
|
1211
|
+
*
|
|
1212
|
+
*/
|
|
1213
|
+
async checkPrimaryKeys(params, session) {
|
|
1214
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().label('params'));
|
|
1215
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required().label('orgId'));
|
|
1216
|
+
Joi__default["default"].assert(params.docTypeId, Joi__default["default"].string().required().label('docTypeId'));
|
|
1217
|
+
Joi__default["default"].assert(params.docs, Joi__default["default"].array().required().label('docs'));
|
|
1218
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required().label('session'));
|
|
1219
|
+
|
|
1220
|
+
const { docs = [], orgId = '', docTypeId = '' } = params;
|
|
1221
|
+
|
|
1222
|
+
if(docs.length === 0) return;
|
|
1223
|
+
|
|
1224
|
+
try {
|
|
1225
|
+
const self = this;
|
|
1226
|
+
const payloadToSend = {
|
|
1227
|
+
docs,
|
|
1228
|
+
docTypeId
|
|
1229
|
+
};
|
|
1230
|
+
const apiCall = self._client.post(`/organizations/${orgId}/documents/can/add`, payloadToSend, self._setHeader(session));
|
|
1231
|
+
return self._returnData(await apiCall);
|
|
1232
|
+
} catch (ex) {
|
|
1233
|
+
throw ex;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1183
1237
|
}
|
|
1184
1238
|
|
|
1185
1239
|
/**
|