@docbrasil/api-systemmanager 1.0.53 → 1.0.54
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 +0 -1
- package/doc/api.md +257 -0
- package/package.json +1 -1
package/api/admin/document.js
CHANGED
|
@@ -315,7 +315,6 @@ class AdminDocuments {
|
|
|
315
315
|
async getContent(params = {}, apiKey) {
|
|
316
316
|
|
|
317
317
|
Joi.assert(params, Joi.object().required());
|
|
318
|
-
Joi.assert(params.content, Joi.string().required());
|
|
319
318
|
Joi.assert(params.docId, Joi.string().required());
|
|
320
319
|
Joi.assert(params.page, Joi.string().required());
|
|
321
320
|
Joi.assert(apiKey, Joi.string().required());
|
package/doc/api.md
CHANGED
|
@@ -34,12 +34,21 @@
|
|
|
34
34
|
<dt><a href="#AdminUser">AdminUser</a></dt>
|
|
35
35
|
<dd><p>Admin Class for user, permission admin</p>
|
|
36
36
|
</dd>
|
|
37
|
+
<dt><a href="#Dispatch">Dispatch</a></dt>
|
|
38
|
+
<dd><p>Api dispatch manager</p>
|
|
39
|
+
</dd>
|
|
37
40
|
<dt><a href="#GeoLocation">GeoLocation</a></dt>
|
|
38
41
|
<dd><p>General Class for user, permission organization</p>
|
|
39
42
|
</dd>
|
|
40
43
|
<dt><a href="#Users">Users</a></dt>
|
|
41
44
|
<dd><p>API request, user permission level</p>
|
|
42
45
|
</dd>
|
|
46
|
+
<dt><a href="#Login">Login</a></dt>
|
|
47
|
+
<dd><p>Login manager</p>
|
|
48
|
+
</dd>
|
|
49
|
+
<dt><a href="#Session">Session</a></dt>
|
|
50
|
+
<dd><p>Session manager of the API</p>
|
|
51
|
+
</dd>
|
|
43
52
|
<dt><a href="#Documents">Documents</a></dt>
|
|
44
53
|
<dd><p>Class for documents, permission user</p>
|
|
45
54
|
</dd>
|
|
@@ -76,6 +85,7 @@ Admin Class for documents, permission admin
|
|
|
76
85
|
* [.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
86
|
* [.updateContent(params, apiKey)](#AdminDocuments+updateContent) ⇒ <code>Promise.<object></code>
|
|
78
87
|
* [.updateAI(params, apiKey)](#AdminDocuments+updateAI) ⇒ <code>Promise.<object></code>
|
|
88
|
+
* [.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
89
|
|
|
80
90
|
<a name="AdminDocuments+advancedSearch"></a>
|
|
81
91
|
|
|
@@ -251,6 +261,34 @@ const params - {
|
|
|
251
261
|
const apiKey: '...';
|
|
252
262
|
await api.admin.document.updateContent(params, apiKey);
|
|
253
263
|
```
|
|
264
|
+
<a name="AdminDocuments+getContent"></a>
|
|
265
|
+
|
|
266
|
+
### adminDocuments.getContent(params, apiKey) ⇒ <code>Promise.<object></code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>number</code>
|
|
267
|
+
Get the content of a document
|
|
268
|
+
|
|
269
|
+
**Kind**: instance method of [<code>AdminDocuments</code>](#AdminDocuments)
|
|
270
|
+
**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
|
|
271
|
+
**Access**: public
|
|
272
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
273
|
+
|
|
274
|
+
| Param | Type | Description |
|
|
275
|
+
| --- | --- | --- |
|
|
276
|
+
| params | <code>object</code> | Params to request signed url |
|
|
277
|
+
| params.docId | <code>string</code> | The unique id of the document |
|
|
278
|
+
| params.page | <code>string</code> | The page, from 0, or 'all' if all pages (the full content) |
|
|
279
|
+
| apiKey | <code>string</code> | Api Key as permission to use this functionality |
|
|
280
|
+
|
|
281
|
+
**Example**
|
|
282
|
+
```js
|
|
283
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
284
|
+
const api = new API();
|
|
285
|
+
const params - {
|
|
286
|
+
page: '0',
|
|
287
|
+
docId: '5dadd01dc4af3941d42f8c5c'
|
|
288
|
+
};
|
|
289
|
+
const apiKey: '...';
|
|
290
|
+
await api.admin.document.getContent(params, apiKey);
|
|
291
|
+
```
|
|
254
292
|
<a name="AdminForm"></a>
|
|
255
293
|
|
|
256
294
|
## AdminForm
|
|
@@ -904,6 +942,52 @@ const payload = {
|
|
|
904
942
|
};
|
|
905
943
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
906
944
|
```
|
|
945
|
+
<a name="Dispatch"></a>
|
|
946
|
+
|
|
947
|
+
## Dispatch
|
|
948
|
+
Api dispatch manager
|
|
949
|
+
|
|
950
|
+
**Kind**: global class
|
|
951
|
+
|
|
952
|
+
* [Dispatch](#Dispatch)
|
|
953
|
+
* [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.<object></code>
|
|
954
|
+
* [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
|
|
955
|
+
|
|
956
|
+
<a name="Dispatch+getContext"></a>
|
|
957
|
+
|
|
958
|
+
### dispatch.getContext(url, session) ⇒ <code>Promise.<object></code>
|
|
959
|
+
Get the URL context
|
|
960
|
+
|
|
961
|
+
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
962
|
+
**Returns**: <code>Promise.<object></code> - The full data context of the URL
|
|
963
|
+
**Access**: public
|
|
964
|
+
|
|
965
|
+
| Param | Type | Default | Description |
|
|
966
|
+
| --- | --- | --- | --- |
|
|
967
|
+
| url | <code>string</code> | | Full url |
|
|
968
|
+
| session | <code>session</code> | <code></code> | Session, token JWT |
|
|
969
|
+
|
|
970
|
+
**Example**
|
|
971
|
+
```js
|
|
972
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
973
|
+
const api = new API();
|
|
974
|
+
const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
|
|
975
|
+
```
|
|
976
|
+
<a name="Dispatch+getClient"></a>
|
|
977
|
+
|
|
978
|
+
### dispatch.getClient() ⇒ <code>promise</code>
|
|
979
|
+
Get client Axios
|
|
980
|
+
|
|
981
|
+
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
982
|
+
**Returns**: <code>promise</code> - return client axios
|
|
983
|
+
**Access**: public
|
|
984
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
985
|
+
**Example**
|
|
986
|
+
```js
|
|
987
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
988
|
+
const api = new API();
|
|
989
|
+
await api.dispatch.getClient();
|
|
990
|
+
```
|
|
907
991
|
<a name="GeoLocation"></a>
|
|
908
992
|
|
|
909
993
|
## GeoLocation
|
|
@@ -965,6 +1049,179 @@ API request, user permission level
|
|
|
965
1049
|
| options | <code>object</code> | Params of the constructor |
|
|
966
1050
|
| options.parent | <code>object</code> | This of the pararent |
|
|
967
1051
|
|
|
1052
|
+
<a name="Login"></a>
|
|
1053
|
+
|
|
1054
|
+
## Login
|
|
1055
|
+
Login manager
|
|
1056
|
+
|
|
1057
|
+
**Kind**: global class
|
|
1058
|
+
|
|
1059
|
+
* [Login](#Login)
|
|
1060
|
+
* [.facebook(params)](#Login+facebook) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1061
|
+
* [.google(params)](#Login+google) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1062
|
+
* [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1063
|
+
* [.userPass(params)](#Login+userPass) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1064
|
+
* [.logout(session)](#Login+logout) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1065
|
+
|
|
1066
|
+
<a name="Login+facebook"></a>
|
|
1067
|
+
|
|
1068
|
+
### login.facebook(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1069
|
+
Login with social login Facebook
|
|
1070
|
+
|
|
1071
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1072
|
+
**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
|
|
1073
|
+
**Access**: public
|
|
1074
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1075
|
+
|
|
1076
|
+
| Param | Type | Description |
|
|
1077
|
+
| --- | --- | --- |
|
|
1078
|
+
| params | <code>object</code> | Params to login Facebook |
|
|
1079
|
+
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1080
|
+
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1081
|
+
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1082
|
+
|
|
1083
|
+
**Example**
|
|
1084
|
+
```js
|
|
1085
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1086
|
+
|
|
1087
|
+
// Params of the instance
|
|
1088
|
+
const params = {...}
|
|
1089
|
+
const api = new API(params);
|
|
1090
|
+
const params = { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cC...' };
|
|
1091
|
+
const { auth, user } = await api.login.facebook(params);
|
|
1092
|
+
```
|
|
1093
|
+
<a name="Login+google"></a>
|
|
1094
|
+
|
|
1095
|
+
### login.google(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1096
|
+
Login with social login Google
|
|
1097
|
+
|
|
1098
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1099
|
+
**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
|
|
1100
|
+
**Access**: public
|
|
1101
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1102
|
+
|
|
1103
|
+
| Param | Type | Description |
|
|
1104
|
+
| --- | --- | --- |
|
|
1105
|
+
| params | <code>object</code> | Params to login Google |
|
|
1106
|
+
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1107
|
+
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1108
|
+
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1109
|
+
|
|
1110
|
+
**Example**
|
|
1111
|
+
```js
|
|
1112
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1113
|
+
|
|
1114
|
+
// Params of the instance
|
|
1115
|
+
const params = {...}
|
|
1116
|
+
const api = new API(params);
|
|
1117
|
+
const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cC...';
|
|
1118
|
+
const { auth, user } = await api.login.google(accessToken);
|
|
1119
|
+
```
|
|
1120
|
+
<a name="Login+apiKey"></a>
|
|
1121
|
+
|
|
1122
|
+
### login.apiKey(apikey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1123
|
+
Login with apikey
|
|
1124
|
+
|
|
1125
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1126
|
+
**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
|
|
1127
|
+
**Access**: public
|
|
1128
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1129
|
+
|
|
1130
|
+
| Param | Type | Description |
|
|
1131
|
+
| --- | --- | --- |
|
|
1132
|
+
| apikey | <code>string</code> | Access key |
|
|
1133
|
+
|
|
1134
|
+
**Example**
|
|
1135
|
+
```js
|
|
1136
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1137
|
+
|
|
1138
|
+
// Params of the instance
|
|
1139
|
+
const params = {...}
|
|
1140
|
+
const api = new API(params);
|
|
1141
|
+
const apiKey = '043a0eb2-f5c3-4900-b781-7f229d00d092';
|
|
1142
|
+
const { auth, user } = await api.login.apiKey(apiKey);
|
|
1143
|
+
```
|
|
1144
|
+
<a name="Login+userPass"></a>
|
|
1145
|
+
|
|
1146
|
+
### login.userPass(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1147
|
+
Login with user and password
|
|
1148
|
+
|
|
1149
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1150
|
+
**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
|
|
1151
|
+
**Access**: public
|
|
1152
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1153
|
+
|
|
1154
|
+
| Param | Type | Description |
|
|
1155
|
+
| --- | --- | --- |
|
|
1156
|
+
| params | <code>object</code> | Object with user and password |
|
|
1157
|
+
| params.username | <code>string</code> | Username or email of the user |
|
|
1158
|
+
| params.password | <code>string</code> | Password of the user |
|
|
1159
|
+
| params.orgname | <code>string</code> | The organame of the user |
|
|
1160
|
+
|
|
1161
|
+
**Example**
|
|
1162
|
+
```js
|
|
1163
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1164
|
+
|
|
1165
|
+
// Params of the instance
|
|
1166
|
+
const params = {...}
|
|
1167
|
+
const api = new API(params);
|
|
1168
|
+
const params = {
|
|
1169
|
+
username: 'ana.silva@gmail.com',
|
|
1170
|
+
password: '123456'
|
|
1171
|
+
};
|
|
1172
|
+
const { auth, user } = await api.login.userPass(params);
|
|
1173
|
+
```
|
|
1174
|
+
<a name="Login+logout"></a>
|
|
1175
|
+
|
|
1176
|
+
### login.logout(session) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1177
|
+
Logout user system manager
|
|
1178
|
+
|
|
1179
|
+
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1180
|
+
**Returns**: <code>promise.<object></code> - } data<code>boolean</code> - data.success true|false
|
|
1181
|
+
**Access**: public
|
|
1182
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1183
|
+
|
|
1184
|
+
| Param | Type | Description |
|
|
1185
|
+
| --- | --- | --- |
|
|
1186
|
+
| session | <code>string</code> | Session, token JWT |
|
|
1187
|
+
|
|
1188
|
+
**Example**
|
|
1189
|
+
```js
|
|
1190
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1191
|
+
|
|
1192
|
+
// Params of the instance
|
|
1193
|
+
const params = {...}
|
|
1194
|
+
const api = new API(params);
|
|
1195
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1196
|
+
const { success } = await api.login.logout(session);
|
|
1197
|
+
```
|
|
1198
|
+
<a name="Session"></a>
|
|
1199
|
+
|
|
1200
|
+
## Session
|
|
1201
|
+
Session manager of the API
|
|
1202
|
+
|
|
1203
|
+
**Kind**: global class
|
|
1204
|
+
<a name="Session+information"></a>
|
|
1205
|
+
|
|
1206
|
+
### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
|
|
1207
|
+
Show information for session, thus validating the session (Valid token JWT)
|
|
1208
|
+
|
|
1209
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
1210
|
+
**Access**: public
|
|
1211
|
+
|
|
1212
|
+
| Param | Type | Default | Description |
|
|
1213
|
+
| --- | --- | --- | --- |
|
|
1214
|
+
| sessionId | <code>string</code> | | The user session (JWT Token) |
|
|
1215
|
+
| suSessionId | <code>string</code> | <code>"sessionId"</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
|
|
1216
|
+
|
|
1217
|
+
**Example**
|
|
1218
|
+
```js
|
|
1219
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
1220
|
+
const api = new API();
|
|
1221
|
+
const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1222
|
+
const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1223
|
+
await api.session.information(sessionId, suSessionId);
|
|
1224
|
+
```
|
|
968
1225
|
<a name="Documents"></a>
|
|
969
1226
|
|
|
970
1227
|
## Documents
|
package/package.json
CHANGED