@docbrasil/api-systemmanager 1.1.4 → 1.1.5

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.
@@ -79,12 +79,15 @@ class Documents {
79
79
  */
80
80
  _formatDocument(params) {
81
81
  try {
82
+ const document = _.get(params, 'document');
83
+ const urlType = _.isEmpty(document) ? '' : _.get(params, 'urlType', 'S3');
84
+ const addType = _.isEmpty(document) ? '' : _.get(params, 'addType', 'S3_SIGNED');
82
85
  return {
83
86
  orgname: _.get(params, 'orgname'),
84
87
  areaId: _.get(params, 'areaId'),
85
88
  docId: _.get(params, 'docId'),
86
89
  documentDate: _.get(params, 'documentDate', Moment().format()),
87
- document: _.get(params, 'document'),
90
+ document,
88
91
  type: _.get(params, 'type'),
89
92
  name: _.get(params, 'name'),
90
93
  content: _.get(params, 'content', ''),
@@ -101,8 +104,8 @@ class Documents {
101
104
  docTypeFields: _.get(params, 'docTypeFields', []), // {"extraId": userId},
102
105
  docTypeFieldsData: _.get(params, 'docTypeFieldsData', {}), // {"extraId": userId},
103
106
  signedUrl: _.get(params, 'signedUrl', ''),
104
- urlType: _.get(params, 'urlType', 'S3'),
105
- addType: _.get(params, 'addType', 'S3_SIGNED'),
107
+ urlType,
108
+ addType
106
109
  };
107
110
  } catch (ex) {
108
111
  throw ex;
@@ -187,17 +190,12 @@ class Documents {
187
190
  */
188
191
  async add(params, session) {
189
192
  const self = this;
190
-
191
193
  try {
192
194
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
193
- Joi.assert(params.orgname, Joi.string().required().error(new Error('orgname is required')));
195
+ Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
194
196
  Joi.assert(params.areaId, Joi.string().required().error(new Error('areaId is required')));
195
- Joi.assert(params.docId, Joi.string().required().error(new Error('docId is required')));
196
- Joi.assert(params.type, Joi.string().required().error(new Error('type is required')));
197
- Joi.assert(params.name, Joi.string().required().error(new Error('name is required')));
197
+ Joi.assert(params.orgname, Joi.string().required().error(new Error('orgname is required')));
198
198
  Joi.assert(params.docTypeId, Joi.string().required().error(new Error('docTypeId is required')));
199
- Joi.assert(params.bytes, Joi.number().required().error(new Error('bytes is required')));
200
- Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
201
199
  Joi.assert(session, Joi.string().required().error(new Error('session is required')));
202
200
 
203
201
  // Get fields required, and set data default to create document
@@ -167,7 +167,7 @@
167
167
  <p class="tag-source">
168
168
  <a href="user_application.js.html" class="button">View Source</a>
169
169
  <span>
170
- <a href="user_application.js.html">user/application.js</a>, <a href="user_application.js.html#line9">line 9</a>
170
+ <a href="user_application.js.html">user/application.js</a>, <a href="user_application.js.html#line10">line 10</a>
171
171
  </span>
172
172
  </p>
173
173
 
@@ -402,7 +402,7 @@
402
402
  <p class="tag-source">
403
403
  <a href="user_application.js.html" class="button">View Source</a>
404
404
  <span>
405
- <a href="user_application.js.html">user/application.js</a>, <a href="user_application.js.html#line68">line 68</a>
405
+ <a href="user_application.js.html">user/application.js</a>, <a href="user_application.js.html#line70">line 70</a>
406
406
  </span>
407
407
  </p>
408
408
 
@@ -1299,7 +1299,7 @@
1299
1299
  <p class="tag-source">
1300
1300
  <a href="user_document.js.html" class="button">View Source</a>
1301
1301
  <span>
1302
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line188">line 188</a>
1302
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line191">line 191</a>
1303
1303
  </span>
1304
1304
  </p>
1305
1305
 
@@ -1657,7 +1657,7 @@ Checks if a document can be added and it does not repeat its primary key</li>
1657
1657
  <p class="tag-source">
1658
1658
  <a href="user_document.js.html" class="button">View Source</a>
1659
1659
  <span>
1660
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line661">line 661</a>
1660
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line659">line 659</a>
1661
1661
  </span>
1662
1662
  </p>
1663
1663
 
@@ -2368,7 +2368,7 @@ const retDocs = await api.user.document.checkPrimaryKeys(params, session);</code
2368
2368
  <p class="tag-source">
2369
2369
  <a href="user_document.js.html" class="button">View Source</a>
2370
2370
  <span>
2371
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line264">line 264</a>
2371
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line262">line 262</a>
2372
2372
  </span>
2373
2373
  </p>
2374
2374
 
@@ -2642,7 +2642,7 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
2642
2642
  <p class="tag-source">
2643
2643
  <a href="user_document.js.html" class="button">View Source</a>
2644
2644
  <span>
2645
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line348">line 348</a>
2645
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line346">line 346</a>
2646
2646
  </span>
2647
2647
  </p>
2648
2648
 
@@ -3027,7 +3027,7 @@ await api.user.document.findByIdAndRemove(params, session);</code></pre>
3027
3027
  <p class="tag-source">
3028
3028
  <a href="user_document.js.html" class="button">View Source</a>
3029
3029
  <span>
3030
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line393">line 393</a>
3030
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line391">line 391</a>
3031
3031
  </span>
3032
3032
  </p>
3033
3033
 
@@ -3389,7 +3389,7 @@ await api.user.document.findByIdsAndRemove(params, session);</code></pre>
3389
3389
  <p class="tag-source">
3390
3390
  <a href="user_document.js.html" class="button">View Source</a>
3391
3391
  <span>
3392
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line709">line 709</a>
3392
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line707">line 707</a>
3393
3393
  </span>
3394
3394
  </p>
3395
3395
 
@@ -3848,7 +3848,7 @@ const retSearch = await api.user.document.searchDocuments(params, session);</cod
3848
3848
  <p class="tag-source">
3849
3849
  <a href="user_document.js.html" class="button">View Source</a>
3850
3850
  <span>
3851
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line459">line 459</a>
3851
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line457">line 457</a>
3852
3852
  </span>
3853
3853
  </p>
3854
3854
 
@@ -4364,7 +4364,7 @@ const base64Data = await api.user.document.signedUrl(params, session);</code></p
4364
4364
  <p class="tag-source">
4365
4365
  <a href="user_document.js.html" class="button">View Source</a>
4366
4366
  <span>
4367
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line555">line 555</a>
4367
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line553">line 553</a>
4368
4368
  </span>
4369
4369
  </p>
4370
4370
 
@@ -4762,7 +4762,7 @@ const base64Data = await api.user.document.signedUrls(params, session);</code></
4762
4762
  <p class="tag-source">
4763
4763
  <a href="user_document.js.html" class="button">View Source</a>
4764
4764
  <span>
4765
- <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line603">line 603</a>
4765
+ <a href="user_document.js.html">user/document.js</a>, <a href="user_document.js.html#line601">line 601</a>
4766
4766
  </span>
4767
4767
  </p>
4768
4768
 
@@ -88,6 +88,7 @@
88
88
  <pre class="prettyprint source linenums"><code>import _ from 'lodash';
89
89
  import Boom from '@hapi/boom';
90
90
  import Joi from 'joi';
91
+ import Page from './page.js';
91
92
 
92
93
  /**
93
94
  * Class for Applications, permission user
@@ -102,6 +103,7 @@ class Application {
102
103
  const self = this;
103
104
  self.parent = options.parent;
104
105
  self._client = self.parent.dispatch.getClient();
106
+ self.page = new Page(options);
105
107
  }
106
108
 
107
109
  /**
@@ -166,12 +166,15 @@ class Documents {
166
166
  */
167
167
  _formatDocument(params) {
168
168
  try {
169
+ const document = _.get(params, 'document');
170
+ const urlType = _.isEmpty(document) ? '' : _.get(params, 'urlType', 'S3');
171
+ const addType = _.isEmpty(document) ? '' : _.get(params, 'addType', 'S3_SIGNED');
169
172
  return {
170
173
  orgname: _.get(params, 'orgname'),
171
174
  areaId: _.get(params, 'areaId'),
172
175
  docId: _.get(params, 'docId'),
173
176
  documentDate: _.get(params, 'documentDate', Moment().format()),
174
- document: _.get(params, 'document'),
177
+ document,
175
178
  type: _.get(params, 'type'),
176
179
  name: _.get(params, 'name'),
177
180
  content: _.get(params, 'content', ''),
@@ -188,8 +191,8 @@ class Documents {
188
191
  docTypeFields: _.get(params, 'docTypeFields', []), // {"extraId": userId},
189
192
  docTypeFieldsData: _.get(params, 'docTypeFieldsData', {}), // {"extraId": userId},
190
193
  signedUrl: _.get(params, 'signedUrl', ''),
191
- urlType: _.get(params, 'urlType', 'S3'),
192
- addType: _.get(params, 'addType', 'S3_SIGNED'),
194
+ urlType,
195
+ addType
193
196
  };
194
197
  } catch (ex) {
195
198
  throw ex;
@@ -274,17 +277,12 @@ class Documents {
274
277
  */
275
278
  async add(params, session) {
276
279
  const self = this;
277
-
278
280
  try {
279
281
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
280
- Joi.assert(params.orgname, Joi.string().required().error(new Error('orgname is required')));
282
+ Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
281
283
  Joi.assert(params.areaId, Joi.string().required().error(new Error('areaId is required')));
282
- Joi.assert(params.docId, Joi.string().required().error(new Error('docId is required')));
283
- Joi.assert(params.type, Joi.string().required().error(new Error('type is required')));
284
- Joi.assert(params.name, Joi.string().required().error(new Error('name is required')));
284
+ Joi.assert(params.orgname, Joi.string().required().error(new Error('orgname is required')));
285
285
  Joi.assert(params.docTypeId, Joi.string().required().error(new Error('docTypeId is required')));
286
- Joi.assert(params.bytes, Joi.number().required().error(new Error('bytes is required')));
287
- Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
288
286
  Joi.assert(session, Joi.string().required().error(new Error('session is required')));
289
287
 
290
288
  // Get fields required, and set data default to create document
@@ -98,7 +98,7 @@ import Notification from './notification.js';
98
98
  import Updates from './updates.js';
99
99
  import Help from './help.js';
100
100
  import Datasource from './datasource.js';
101
- import Application from './notification.js';
101
+ import Application from './application.js';
102
102
 
103
103
  /**
104
104
  * @class API request, user permission level
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",
4
+ "version": "1.1.5",
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",
@@ -1 +0,0 @@
1
- {}