@docbrasil/api-systemmanager 1.0.55 → 1.0.58
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/admin/document.js +42 -0
- package/api/login.js +31 -0
- package/api/user/process.js +18 -1
- package/dist/bundle.cjs +186 -7
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +522 -0
- package/package.json +1 -1
package/doc/api.md
CHANGED
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
<dt><a href="#AdminNotification">AdminNotification</a></dt>
|
|
20
20
|
<dd><p>Admin Class for notification, permission admin</p>
|
|
21
21
|
</dd>
|
|
22
|
+
<dt><a href="#Organization">Organization</a></dt>
|
|
23
|
+
<dd><p>Class for organizations, permission user</p>
|
|
24
|
+
</dd>
|
|
22
25
|
<dt><a href="#AdminPlugin">AdminPlugin</a></dt>
|
|
23
26
|
<dd><p>Admin Class for plugin, permission admin</p>
|
|
24
27
|
</dd>
|
|
@@ -34,12 +37,21 @@
|
|
|
34
37
|
<dt><a href="#AdminUser">AdminUser</a></dt>
|
|
35
38
|
<dd><p>Admin Class for user, permission admin</p>
|
|
36
39
|
</dd>
|
|
40
|
+
<dt><a href="#Dispatch">Dispatch</a></dt>
|
|
41
|
+
<dd><p>Api dispatch manager</p>
|
|
42
|
+
</dd>
|
|
37
43
|
<dt><a href="#GeoLocation">GeoLocation</a></dt>
|
|
38
44
|
<dd><p>General Class for user, permission organization</p>
|
|
39
45
|
</dd>
|
|
40
46
|
<dt><a href="#Users">Users</a></dt>
|
|
41
47
|
<dd><p>API request, user permission level</p>
|
|
42
48
|
</dd>
|
|
49
|
+
<dt><a href="#Login">Login</a></dt>
|
|
50
|
+
<dd><p>Login manager</p>
|
|
51
|
+
</dd>
|
|
52
|
+
<dt><a href="#Session">Session</a></dt>
|
|
53
|
+
<dd><p>Session manager of the API</p>
|
|
54
|
+
</dd>
|
|
43
55
|
<dt><a href="#Documents">Documents</a></dt>
|
|
44
56
|
<dd><p>Class for documents, permission user</p>
|
|
45
57
|
</dd>
|
|
@@ -76,6 +88,7 @@ Admin Class for documents, permission admin
|
|
|
76
88
|
* [.signedUrl(params, apiKey)](#AdminDocuments+signedUrl) ⇒ <code>Promise.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
|
|
77
89
|
* [.updateContent(params, apiKey)](#AdminDocuments+updateContent) ⇒ <code>Promise.<object></code>
|
|
78
90
|
* [.updateAI(params, apiKey)](#AdminDocuments+updateAI) ⇒ <code>Promise.<object></code>
|
|
91
|
+
* [.getContent(params, apiKey)](#AdminDocuments+getContent) ⇒ <code>Promise.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>number</code>
|
|
79
92
|
|
|
80
93
|
<a name="AdminDocuments+advancedSearch"></a>
|
|
81
94
|
|
|
@@ -251,6 +264,34 @@ const params - {
|
|
|
251
264
|
const apiKey: '...';
|
|
252
265
|
await api.admin.document.updateContent(params, apiKey);
|
|
253
266
|
```
|
|
267
|
+
<a name="AdminDocuments+getContent"></a>
|
|
268
|
+
|
|
269
|
+
### adminDocuments.getContent(params, apiKey) ⇒ <code>Promise.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>number</code>
|
|
270
|
+
Get the content of a document
|
|
271
|
+
|
|
272
|
+
**Kind**: instance method of [<code>AdminDocuments</code>](#AdminDocuments)
|
|
273
|
+
**Returns**: <code>Promise.<object></code> - data the document content<code>string</code> - data._id the _id of the document<code>string</code> - data.content all the pages or if asked by page, just one page, the one requested<code>string</code> - data.content.TextOverlay the overlay text if requested<code>string</code> - data.content.ParsedText the page text content<code>number</code> - data.total the total number of pages
|
|
274
|
+
**Access**: public
|
|
275
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
276
|
+
|
|
277
|
+
| Param | Type | Description |
|
|
278
|
+
| --- | --- | --- |
|
|
279
|
+
| params | <code>object</code> | Params to request signed url |
|
|
280
|
+
| params.docId | <code>string</code> | The unique id of the document |
|
|
281
|
+
| params.page | <code>string</code> | The page, from 0, or 'all' if all pages (the full content) |
|
|
282
|
+
| apiKey | <code>string</code> | Api Key as permission to use this functionality |
|
|
283
|
+
|
|
284
|
+
**Example**
|
|
285
|
+
```js
|
|
286
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
287
|
+
const api = new API();
|
|
288
|
+
const params - {
|
|
289
|
+
page: '0',
|
|
290
|
+
docId: '5dadd01dc4af3941d42f8c5c'
|
|
291
|
+
};
|
|
292
|
+
const apiKey: '...';
|
|
293
|
+
await api.admin.document.getContent(params, apiKey);
|
|
294
|
+
```
|
|
254
295
|
<a name="AdminForm"></a>
|
|
255
296
|
|
|
256
297
|
## AdminForm
|
|
@@ -611,6 +652,191 @@ const params = {
|
|
|
611
652
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
612
653
|
await api.admin.notifications.findByIdAndDelete(params, session);
|
|
613
654
|
```
|
|
655
|
+
<a name="Organization"></a>
|
|
656
|
+
|
|
657
|
+
## Organization
|
|
658
|
+
Class for organizations, permission user
|
|
659
|
+
|
|
660
|
+
**Kind**: global class
|
|
661
|
+
|
|
662
|
+
* [Organization](#Organization)
|
|
663
|
+
* [.upsertAvatar(params, session)](#Organization+upsertAvatar) ⇒ <code>Promise</code>
|
|
664
|
+
* [.removeAvatar(session)](#Organization+removeAvatar) ⇒ <code>Promise</code>
|
|
665
|
+
* [.findById(orgId, session)](#Organization+findById)
|
|
666
|
+
* [.idCardExist(idcard, session)](#Organization+idCardExist)
|
|
667
|
+
* [.upsertAvatar(params, session)](#Organization+upsertAvatar) ⇒ <code>Promise</code>
|
|
668
|
+
* [.removeAvatar(session)](#Organization+removeAvatar) ⇒ <code>Promise</code>
|
|
669
|
+
* [.callFetch(params)](#Organization+callFetch) ⇒ <code>promise</code>
|
|
670
|
+
|
|
671
|
+
<a name="Organization+upsertAvatar"></a>
|
|
672
|
+
|
|
673
|
+
### organization.upsertAvatar(params, session) ⇒ <code>Promise</code>
|
|
674
|
+
Update avatar of organization by session of user not allow session user SU
|
|
675
|
+
|
|
676
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
677
|
+
**Access**: public
|
|
678
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
679
|
+
|
|
680
|
+
| Param | Type | Description |
|
|
681
|
+
| --- | --- | --- |
|
|
682
|
+
| params | <code>object</code> | Params to update avatar |
|
|
683
|
+
| params.orgId | <code>string</code> | Organization id |
|
|
684
|
+
| params.avatar | <code>string</code> | Image in base64 to update |
|
|
685
|
+
| params.type | <code>string</code> | MimeType (image/png) |
|
|
686
|
+
| session | <code>string</code> | Is token JWT of user SU |
|
|
687
|
+
|
|
688
|
+
**Example**
|
|
689
|
+
```js
|
|
690
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
691
|
+
const api = new API();
|
|
692
|
+
const params = {
|
|
693
|
+
orgId: '5dadd01dc4af3941d42f8c5c',
|
|
694
|
+
avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
|
|
695
|
+
type: 'image/png',
|
|
696
|
+
};
|
|
697
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
698
|
+
await api.admin.organizations.upsertAvatar(params, session);
|
|
699
|
+
```
|
|
700
|
+
<a name="Organization+removeAvatar"></a>
|
|
701
|
+
|
|
702
|
+
### organization.removeAvatar(session) ⇒ <code>Promise</code>
|
|
703
|
+
Remove avatar of user by session of user not allow session user SU
|
|
704
|
+
|
|
705
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
706
|
+
**Access**: public
|
|
707
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
708
|
+
|
|
709
|
+
| Param | Type | Description |
|
|
710
|
+
| --- | --- | --- |
|
|
711
|
+
| params.orgId | <code>string</code> | Organization id |
|
|
712
|
+
| session | <code>string</code> | Is token JWT of user SU |
|
|
713
|
+
|
|
714
|
+
**Example**
|
|
715
|
+
```js
|
|
716
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
717
|
+
const api = new API();
|
|
718
|
+
const orgId = '5dadd01dc4af3941d42f8c5c';
|
|
719
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
720
|
+
await api.admin.organizations.removeAvatar(orgId, session);
|
|
721
|
+
```
|
|
722
|
+
<a name="Organization+findById"></a>
|
|
723
|
+
|
|
724
|
+
### organization.findById(orgId, session)
|
|
725
|
+
Find organization by id
|
|
726
|
+
|
|
727
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
728
|
+
**Access**: public
|
|
729
|
+
**Author**: Augusto Pissarra <abernardo.br@gmail.com>
|
|
730
|
+
|
|
731
|
+
| Param | Type | Description |
|
|
732
|
+
| --- | --- | --- |
|
|
733
|
+
| orgId | <code>string</code> | ID of the organization to find (_id database) |
|
|
734
|
+
| session | <code>string</code> | Is token JWT |
|
|
735
|
+
|
|
736
|
+
**Example**
|
|
737
|
+
```js
|
|
738
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
739
|
+
const api = new API();
|
|
740
|
+
const orgId = '80443245000122';
|
|
741
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
742
|
+
await api.user.organization.findById(idCard, session);
|
|
743
|
+
```
|
|
744
|
+
<a name="Organization+idCardExist"></a>
|
|
745
|
+
|
|
746
|
+
### organization.idCardExist(idcard, session)
|
|
747
|
+
Check if id card exist
|
|
748
|
+
|
|
749
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
750
|
+
**Access**: public
|
|
751
|
+
**Author**: Augusto Pissarra <abernardo.br@gmail.com>
|
|
752
|
+
|
|
753
|
+
| Param | Type | Description |
|
|
754
|
+
| --- | --- | --- |
|
|
755
|
+
| idcard | <code>string</code> | Check if id card exist |
|
|
756
|
+
| session | <code>string</code> | Is token JWT |
|
|
757
|
+
|
|
758
|
+
**Example**
|
|
759
|
+
```js
|
|
760
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
761
|
+
const api = new API();
|
|
762
|
+
const idCard = '80443245000122';
|
|
763
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
764
|
+
await api.user.organization.idCardExist(idCard, session);
|
|
765
|
+
```
|
|
766
|
+
<a name="Organization+upsertAvatar"></a>
|
|
767
|
+
|
|
768
|
+
### organization.upsertAvatar(params, session) ⇒ <code>Promise</code>
|
|
769
|
+
Update avatar of organization by session of user not allow session user SU
|
|
770
|
+
|
|
771
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
772
|
+
**Access**: public
|
|
773
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
774
|
+
|
|
775
|
+
| Param | Type | Description |
|
|
776
|
+
| --- | --- | --- |
|
|
777
|
+
| params | <code>object</code> | Params to update avatar |
|
|
778
|
+
| params.avatar | <code>string</code> | Image in base64 to update |
|
|
779
|
+
| params.type | <code>string</code> | mimeType (image/png) |
|
|
780
|
+
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
781
|
+
|
|
782
|
+
**Example**
|
|
783
|
+
```js
|
|
784
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
785
|
+
const api = new API();
|
|
786
|
+
const params = {
|
|
787
|
+
avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
|
|
788
|
+
type: 'image/png',
|
|
789
|
+
};
|
|
790
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
791
|
+
await api.user.profile.updateAvatar(params, session);
|
|
792
|
+
```
|
|
793
|
+
<a name="Organization+removeAvatar"></a>
|
|
794
|
+
|
|
795
|
+
### organization.removeAvatar(session) ⇒ <code>Promise</code>
|
|
796
|
+
Remove avatar of user by session of user not allow session user SU
|
|
797
|
+
|
|
798
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
799
|
+
**Access**: public
|
|
800
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
801
|
+
|
|
802
|
+
| Param | Type | Description |
|
|
803
|
+
| --- | --- | --- |
|
|
804
|
+
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
805
|
+
|
|
806
|
+
**Example**
|
|
807
|
+
```js
|
|
808
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
809
|
+
const api = new API();
|
|
810
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
811
|
+
await api.user.profile.removeAvatar(session);
|
|
812
|
+
```
|
|
813
|
+
<a name="Organization+callFetch"></a>
|
|
814
|
+
|
|
815
|
+
### organization.callFetch(params) ⇒ <code>promise</code>
|
|
816
|
+
Call URL internal, need auth JWT (session)
|
|
817
|
+
|
|
818
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
819
|
+
**Access**: public
|
|
820
|
+
**Author**: Thiago Anselmo <thiagoo.anselmoo@gmail.com>
|
|
821
|
+
|
|
822
|
+
| Param | Type | Default | Description |
|
|
823
|
+
| --- | --- | --- | --- |
|
|
824
|
+
| params | <code>object</code> | | Params to call fectch (URL internal) |
|
|
825
|
+
| params.url | <code>string</code> | | URL to call |
|
|
826
|
+
| [params.method] | <code>string</code> | <code>"POST"</code> | Fetch Method |
|
|
827
|
+
| params.payload | <code>string</code> | | Payload to send system manager |
|
|
828
|
+
|
|
829
|
+
**Example**
|
|
830
|
+
```js
|
|
831
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
832
|
+
const api = new API();
|
|
833
|
+
|
|
834
|
+
const params = {
|
|
835
|
+
url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
|
|
836
|
+
method: 'POST'
|
|
837
|
+
}
|
|
838
|
+
await api.user.organization.callFetchs(params, session);
|
|
839
|
+
```
|
|
614
840
|
<a name="AdminPlugin"></a>
|
|
615
841
|
|
|
616
842
|
## AdminPlugin
|
|
@@ -904,6 +1130,52 @@ const payload = {
|
|
|
904
1130
|
};
|
|
905
1131
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
906
1132
|
```
|
|
1133
|
+
<a name="Dispatch"></a>
|
|
1134
|
+
|
|
1135
|
+
## Dispatch
|
|
1136
|
+
Api dispatch manager
|
|
1137
|
+
|
|
1138
|
+
**Kind**: global class
|
|
1139
|
+
|
|
1140
|
+
* [Dispatch](#Dispatch)
|
|
1141
|
+
* [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.<object></code>
|
|
1142
|
+
* [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
|
|
1143
|
+
|
|
1144
|
+
<a name="Dispatch+getContext"></a>
|
|
1145
|
+
|
|
1146
|
+
### dispatch.getContext(url, session) ⇒ <code>Promise.<object></code>
|
|
1147
|
+
Get the URL context
|
|
1148
|
+
|
|
1149
|
+
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
1150
|
+
**Returns**: <code>Promise.<object></code> - The full data context of the URL
|
|
1151
|
+
**Access**: public
|
|
1152
|
+
|
|
1153
|
+
| Param | Type | Default | Description |
|
|
1154
|
+
| --- | --- | --- | --- |
|
|
1155
|
+
| url | <code>string</code> | | Full url |
|
|
1156
|
+
| session | <code>session</code> | <code></code> | Session, token JWT |
|
|
1157
|
+
|
|
1158
|
+
**Example**
|
|
1159
|
+
```js
|
|
1160
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1161
|
+
const api = new API();
|
|
1162
|
+
const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
|
|
1163
|
+
```
|
|
1164
|
+
<a name="Dispatch+getClient"></a>
|
|
1165
|
+
|
|
1166
|
+
### dispatch.getClient() ⇒ <code>promise</code>
|
|
1167
|
+
Get client Axios
|
|
1168
|
+
|
|
1169
|
+
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
1170
|
+
**Returns**: <code>promise</code> - return client axios
|
|
1171
|
+
**Access**: public
|
|
1172
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1173
|
+
**Example**
|
|
1174
|
+
```js
|
|
1175
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1176
|
+
const api = new API();
|
|
1177
|
+
await api.dispatch.getClient();
|
|
1178
|
+
```
|
|
907
1179
|
<a name="GeoLocation"></a>
|
|
908
1180
|
|
|
909
1181
|
## GeoLocation
|
|
@@ -965,6 +1237,203 @@ API request, user permission level
|
|
|
965
1237
|
| options | <code>object</code> | Params of the constructor |
|
|
966
1238
|
| options.parent | <code>object</code> | This of the pararent |
|
|
967
1239
|
|
|
1240
|
+
<a name="Login"></a>
|
|
1241
|
+
|
|
1242
|
+
## Login
|
|
1243
|
+
Login manager
|
|
1244
|
+
|
|
1245
|
+
**Kind**: global class
|
|
1246
|
+
|
|
1247
|
+
* [Login](#Login)
|
|
1248
|
+
* [.facebook(params)](#Login+facebook) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1249
|
+
* [.google(params)](#Login+google) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1250
|
+
* [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1251
|
+
* [.userPass(params)](#Login+userPass) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1252
|
+
* [.logout(session)](#Login+logout) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1253
|
+
* [.recover(username)](#Login+recover) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1254
|
+
|
|
1255
|
+
<a name="Login+facebook"></a>
|
|
1256
|
+
|
|
1257
|
+
### login.facebook(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1258
|
+
Login with social login Facebook
|
|
1259
|
+
|
|
1260
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1261
|
+
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1262
|
+
**Access**: public
|
|
1263
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1264
|
+
|
|
1265
|
+
| Param | Type | Description |
|
|
1266
|
+
| --- | --- | --- |
|
|
1267
|
+
| params | <code>object</code> | Params to login Facebook |
|
|
1268
|
+
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1269
|
+
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1270
|
+
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1271
|
+
|
|
1272
|
+
**Example**
|
|
1273
|
+
```js
|
|
1274
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1275
|
+
|
|
1276
|
+
// Params of the instance
|
|
1277
|
+
const params = {...}
|
|
1278
|
+
const api = new API(params);
|
|
1279
|
+
const params = { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cC...' };
|
|
1280
|
+
const { auth, user } = await api.login.facebook(params);
|
|
1281
|
+
```
|
|
1282
|
+
<a name="Login+google"></a>
|
|
1283
|
+
|
|
1284
|
+
### login.google(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1285
|
+
Login with social login Google
|
|
1286
|
+
|
|
1287
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1288
|
+
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1289
|
+
**Access**: public
|
|
1290
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1291
|
+
|
|
1292
|
+
| Param | Type | Description |
|
|
1293
|
+
| --- | --- | --- |
|
|
1294
|
+
| params | <code>object</code> | Params to login Google |
|
|
1295
|
+
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1296
|
+
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1297
|
+
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1298
|
+
|
|
1299
|
+
**Example**
|
|
1300
|
+
```js
|
|
1301
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1302
|
+
|
|
1303
|
+
// Params of the instance
|
|
1304
|
+
const params = {...}
|
|
1305
|
+
const api = new API(params);
|
|
1306
|
+
const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cC...';
|
|
1307
|
+
const { auth, user } = await api.login.google(accessToken);
|
|
1308
|
+
```
|
|
1309
|
+
<a name="Login+apiKey"></a>
|
|
1310
|
+
|
|
1311
|
+
### login.apiKey(apikey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1312
|
+
Login with apikey
|
|
1313
|
+
|
|
1314
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1315
|
+
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1316
|
+
**Access**: public
|
|
1317
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1318
|
+
|
|
1319
|
+
| Param | Type | Description |
|
|
1320
|
+
| --- | --- | --- |
|
|
1321
|
+
| apikey | <code>string</code> | Access key |
|
|
1322
|
+
|
|
1323
|
+
**Example**
|
|
1324
|
+
```js
|
|
1325
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1326
|
+
|
|
1327
|
+
// Params of the instance
|
|
1328
|
+
const params = {...}
|
|
1329
|
+
const api = new API(params);
|
|
1330
|
+
const apiKey = '043a0eb2-f5c3-4900-b781-7f229d00d092';
|
|
1331
|
+
const { auth, user } = await api.login.apiKey(apiKey);
|
|
1332
|
+
```
|
|
1333
|
+
<a name="Login+userPass"></a>
|
|
1334
|
+
|
|
1335
|
+
### login.userPass(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1336
|
+
Login with user and password
|
|
1337
|
+
|
|
1338
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1339
|
+
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1340
|
+
**Access**: public
|
|
1341
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1342
|
+
|
|
1343
|
+
| Param | Type | Description |
|
|
1344
|
+
| --- | --- | --- |
|
|
1345
|
+
| params | <code>object</code> | Object with user and password |
|
|
1346
|
+
| params.username | <code>string</code> | Username or email of the user |
|
|
1347
|
+
| params.password | <code>string</code> | Password of the user |
|
|
1348
|
+
| params.orgname | <code>string</code> | The organame of the user |
|
|
1349
|
+
|
|
1350
|
+
**Example**
|
|
1351
|
+
```js
|
|
1352
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1353
|
+
|
|
1354
|
+
// Params of the instance
|
|
1355
|
+
const params = {...}
|
|
1356
|
+
const api = new API(params);
|
|
1357
|
+
const params = {
|
|
1358
|
+
username: 'ana.silva@gmail.com',
|
|
1359
|
+
password: '123456'
|
|
1360
|
+
};
|
|
1361
|
+
const { auth, user } = await api.login.userPass(params);
|
|
1362
|
+
```
|
|
1363
|
+
<a name="Login+logout"></a>
|
|
1364
|
+
|
|
1365
|
+
### login.logout(session) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1366
|
+
Logout user system manager
|
|
1367
|
+
|
|
1368
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1369
|
+
**Returns**: <code>promise.<object></code> - } data<code>boolean</code> - data.success true|false
|
|
1370
|
+
**Access**: public
|
|
1371
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1372
|
+
|
|
1373
|
+
| Param | Type | Description |
|
|
1374
|
+
| --- | --- | --- |
|
|
1375
|
+
| session | <code>string</code> | Session, token JWT |
|
|
1376
|
+
|
|
1377
|
+
**Example**
|
|
1378
|
+
```js
|
|
1379
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1380
|
+
|
|
1381
|
+
// Params of the instance
|
|
1382
|
+
const params = {...}
|
|
1383
|
+
const api = new API(params);
|
|
1384
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1385
|
+
const { success } = await api.login.logout(session);
|
|
1386
|
+
```
|
|
1387
|
+
<a name="Login+recover"></a>
|
|
1388
|
+
|
|
1389
|
+
### login.recover(username) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1390
|
+
Recover the password
|
|
1391
|
+
|
|
1392
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1393
|
+
**Returns**: <code>promise.<object></code> - } data<code>boolean</code> - data.success true|false
|
|
1394
|
+
**Access**: public
|
|
1395
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1396
|
+
|
|
1397
|
+
| Param | Type | Description |
|
|
1398
|
+
| --- | --- | --- |
|
|
1399
|
+
| username | <code>string</code> | The username or email |
|
|
1400
|
+
|
|
1401
|
+
**Example**
|
|
1402
|
+
```js
|
|
1403
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1404
|
+
|
|
1405
|
+
// Params of the instance
|
|
1406
|
+
const params = {...}
|
|
1407
|
+
const api = new API(params);
|
|
1408
|
+
const { success } = await api.login.recover('myusername');
|
|
1409
|
+
```
|
|
1410
|
+
<a name="Session"></a>
|
|
1411
|
+
|
|
1412
|
+
## Session
|
|
1413
|
+
Session manager of the API
|
|
1414
|
+
|
|
1415
|
+
**Kind**: global class
|
|
1416
|
+
<a name="Session+information"></a>
|
|
1417
|
+
|
|
1418
|
+
### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
|
|
1419
|
+
Show information for session, thus validating the session (Valid token JWT)
|
|
1420
|
+
|
|
1421
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
1422
|
+
**Access**: public
|
|
1423
|
+
|
|
1424
|
+
| Param | Type | Default | Description |
|
|
1425
|
+
| --- | --- | --- | --- |
|
|
1426
|
+
| sessionId | <code>string</code> | | The user session (JWT Token) |
|
|
1427
|
+
| suSessionId | <code>string</code> | <code>"sessionId"</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
|
|
1428
|
+
|
|
1429
|
+
**Example**
|
|
1430
|
+
```js
|
|
1431
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1432
|
+
const api = new API();
|
|
1433
|
+
const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1434
|
+
const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1435
|
+
await api.session.information(sessionId, suSessionId);
|
|
1436
|
+
```
|
|
968
1437
|
<a name="Documents"></a>
|
|
969
1438
|
|
|
970
1439
|
## Documents
|
|
@@ -1248,12 +1717,65 @@ Class for organizations, permission user
|
|
|
1248
1717
|
**Kind**: global class
|
|
1249
1718
|
|
|
1250
1719
|
* [Organization](#Organization)
|
|
1720
|
+
* [.upsertAvatar(params, session)](#Organization+upsertAvatar) ⇒ <code>Promise</code>
|
|
1721
|
+
* [.removeAvatar(session)](#Organization+removeAvatar) ⇒ <code>Promise</code>
|
|
1251
1722
|
* [.findById(orgId, session)](#Organization+findById)
|
|
1252
1723
|
* [.idCardExist(idcard, session)](#Organization+idCardExist)
|
|
1253
1724
|
* [.upsertAvatar(params, session)](#Organization+upsertAvatar) ⇒ <code>Promise</code>
|
|
1254
1725
|
* [.removeAvatar(session)](#Organization+removeAvatar) ⇒ <code>Promise</code>
|
|
1255
1726
|
* [.callFetch(params)](#Organization+callFetch) ⇒ <code>promise</code>
|
|
1256
1727
|
|
|
1728
|
+
<a name="Organization+upsertAvatar"></a>
|
|
1729
|
+
|
|
1730
|
+
### organization.upsertAvatar(params, session) ⇒ <code>Promise</code>
|
|
1731
|
+
Update avatar of organization by session of user not allow session user SU
|
|
1732
|
+
|
|
1733
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
1734
|
+
**Access**: public
|
|
1735
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1736
|
+
|
|
1737
|
+
| Param | Type | Description |
|
|
1738
|
+
| --- | --- | --- |
|
|
1739
|
+
| params | <code>object</code> | Params to update avatar |
|
|
1740
|
+
| params.orgId | <code>string</code> | Organization id |
|
|
1741
|
+
| params.avatar | <code>string</code> | Image in base64 to update |
|
|
1742
|
+
| params.type | <code>string</code> | MimeType (image/png) |
|
|
1743
|
+
| session | <code>string</code> | Is token JWT of user SU |
|
|
1744
|
+
|
|
1745
|
+
**Example**
|
|
1746
|
+
```js
|
|
1747
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1748
|
+
const api = new API();
|
|
1749
|
+
const params = {
|
|
1750
|
+
orgId: '5dadd01dc4af3941d42f8c5c',
|
|
1751
|
+
avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
|
|
1752
|
+
type: 'image/png',
|
|
1753
|
+
};
|
|
1754
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1755
|
+
await api.admin.organizations.upsertAvatar(params, session);
|
|
1756
|
+
```
|
|
1757
|
+
<a name="Organization+removeAvatar"></a>
|
|
1758
|
+
|
|
1759
|
+
### organization.removeAvatar(session) ⇒ <code>Promise</code>
|
|
1760
|
+
Remove avatar of user by session of user not allow session user SU
|
|
1761
|
+
|
|
1762
|
+
**Kind**: instance method of [<code>Organization</code>](#Organization)
|
|
1763
|
+
**Access**: public
|
|
1764
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1765
|
+
|
|
1766
|
+
| Param | Type | Description |
|
|
1767
|
+
| --- | --- | --- |
|
|
1768
|
+
| params.orgId | <code>string</code> | Organization id |
|
|
1769
|
+
| session | <code>string</code> | Is token JWT of user SU |
|
|
1770
|
+
|
|
1771
|
+
**Example**
|
|
1772
|
+
```js
|
|
1773
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1774
|
+
const api = new API();
|
|
1775
|
+
const orgId = '5dadd01dc4af3941d42f8c5c';
|
|
1776
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1777
|
+
await api.admin.organizations.removeAvatar(orgId, session);
|
|
1778
|
+
```
|
|
1257
1779
|
<a name="Organization+findById"></a>
|
|
1258
1780
|
|
|
1259
1781
|
### organization.findById(orgId, session)
|
package/package.json
CHANGED