@docbrasil/api-systemmanager 1.1.75 → 1.1.77

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/docs/Help.html CHANGED
@@ -863,6 +863,281 @@ const externalUrls = await api.user.help.listExternalUrls(session);
863
863
 
864
864
 
865
865
 
866
+ </div>
867
+
868
+ <div class="member">
869
+
870
+
871
+
872
+ <h4 class="name" id="updateSchedule">
873
+ <a class="href-link" href="#updateSchedule">#</a>
874
+
875
+
876
+ <span class='tag'>async</span>
877
+
878
+
879
+ <span class="code-name">
880
+
881
+ updateSchedule<span class="signature">(params, session)</span><span class="type-signature"> &rarr; {promise.&lt;object>}</span>
882
+
883
+ </span>
884
+ </h4>
885
+
886
+
887
+
888
+
889
+ <div class="description">
890
+ Update a schedule associated with a help page.
891
+ Allows partial updates (e.g., just the cron expression).
892
+ </div>
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+ <h5>Parameters:</h5>
904
+
905
+ <div class="table-container">
906
+ <table class="params table">
907
+ <thead>
908
+ <tr>
909
+
910
+ <th>Name</th>
911
+
912
+
913
+ <th>Type</th>
914
+
915
+
916
+
917
+
918
+
919
+ <th class="last">Description</th>
920
+ </tr>
921
+ </thead>
922
+
923
+ <tbody>
924
+
925
+
926
+
927
+ <tr class="deep-level-0">
928
+
929
+ <td class="name"><code>params</code></td>
930
+
931
+
932
+ <td class="type">
933
+
934
+
935
+ <code class="param-type">object</code>
936
+
937
+
938
+
939
+ </td>
940
+
941
+
942
+
943
+
944
+
945
+ <td class="description last">Params for update</td>
946
+ </tr>
947
+
948
+
949
+
950
+
951
+ <tr class="deep-level-1">
952
+
953
+ <td class="name"><code>id</code></td>
954
+
955
+
956
+ <td class="type">
957
+
958
+
959
+ <code class="param-type">string</code>
960
+
961
+
962
+
963
+ </td>
964
+
965
+
966
+
967
+
968
+
969
+ <td class="description last">Schedule id (_id database)</td>
970
+ </tr>
971
+
972
+
973
+
974
+ <tr class="deep-level-1">
975
+
976
+ <td class="name"><code>data</code></td>
977
+
978
+
979
+ <td class="type">
980
+
981
+
982
+ <code class="param-type">object</code>
983
+
984
+
985
+
986
+ </td>
987
+
988
+
989
+
990
+
991
+
992
+ <td class="description last">Partial update data (e.g., { schedule: { cron: '0 9 * * *' } })</td>
993
+ </tr>
994
+
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+ <tr class="deep-level-0">
1002
+
1003
+ <td class="name"><code>session</code></td>
1004
+
1005
+
1006
+ <td class="type">
1007
+
1008
+
1009
+ <code class="param-type">string</code>
1010
+
1011
+
1012
+
1013
+ </td>
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+ <td class="description last">Session, token JWT</td>
1020
+ </tr>
1021
+
1022
+
1023
+
1024
+ </tbody>
1025
+ </table>
1026
+ </div>
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+ <dl class="details">
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+ <dt class="tag-author">Author:</dt>
1052
+ <dd class="tag-author">
1053
+ <ul>
1054
+ <li><a href="mailto:augusto.pissarra@myndware.com">Myndware</a></li>
1055
+ </ul>
1056
+ </dd>
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+ <p class="tag-source">
1072
+ <a href="user_help.js.html" class="button">View Source</a>
1073
+ <span>
1074
+ <a href="user_help.js.html">user/help.js</a>, <a href="user_help.js.html#line176">line 176</a>
1075
+ </span>
1076
+ </p>
1077
+
1078
+ </dl>
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+
1086
+
1087
+
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+ <div class='columns method-parameter'>
1098
+ <div class="column is-2"><label>Returns:</label></div>
1099
+ <div class="column is-10">
1100
+
1101
+
1102
+
1103
+ <div class="columns">
1104
+
1105
+ <div class='param-desc column is-7'>Updated schedule document</div>
1106
+
1107
+
1108
+ <div class='column is-5 has-text-left'>
1109
+ <label>Type: </label>
1110
+
1111
+ <code class="param-type">promise.&lt;object></code>
1112
+
1113
+
1114
+ </div>
1115
+
1116
+ </div>
1117
+
1118
+
1119
+ </div>
1120
+ </div>
1121
+
1122
+
1123
+
1124
+
1125
+ <h5>Example</h5>
1126
+
1127
+
1128
+ <pre class="prettyprint"><code>const API = require('@docbrasil/api-systemmanager');
1129
+ const api = new API();
1130
+ const params = {
1131
+ id: '5dadd01dc4af3941d42f8c5c',
1132
+ data: {
1133
+ schedule: { cron: '0 9 * * *' }
1134
+ }
1135
+ };
1136
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1137
+ await api.user.help.updateSchedule(params, session);</code></pre>
1138
+
1139
+
1140
+
866
1141
  </div>
867
1142
 
868
1143
  </div>
@@ -215,6 +215,220 @@ class AdminLists {
215
215
  throw ex;
216
216
  }
217
217
  }
218
+
219
+ /**
220
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
221
+ * @description Filter organization lists by name
222
+ * @param {object} params Parameters
223
+ * @param {string} params.orgId Organization ID (required)
224
+ * @param {array} [params.names=[]] Array of list names to filter (empty = all)
225
+ * @param {string} session JWT session token
226
+ * @return {Promise&lt;array>} Array of matching org lists sorted by name
227
+ * @public
228
+ * @async
229
+ * @example
230
+ *
231
+ * const API = require('@docbrasil/api-systemmanager');
232
+ * const api = new API();
233
+ * const params = { orgId: '5edd11c46b6ce9729c2c297c', names: ['Tags', 'Categorias'] };
234
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
235
+ * const lists = await api.admin.list.filterByName(params, session);
236
+ */
237
+ async filterByName(params = {}, session) {
238
+ const self = this;
239
+
240
+ try {
241
+ Joi.assert(params, Joi.object().required());
242
+ Joi.assert(params.orgId, Joi.string().required());
243
+ Joi.assert(session, Joi.string().required());
244
+
245
+ const { orgId, names = [] } = params;
246
+ const payload = { names };
247
+
248
+ const apiCall = self._client.post(
249
+ `/admin/organizations/${orgId}/orgtags/filter`,
250
+ payload,
251
+ self._setHeader(session)
252
+ );
253
+
254
+ return self._returnData(await apiCall);
255
+ } catch (ex) {
256
+ throw ex;
257
+ }
258
+ }
259
+
260
+ /**
261
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
262
+ * @description Create a new organization list
263
+ * @param {object} params Parameters
264
+ * @param {string} params.orgId Organization ID (required)
265
+ * @param {string} params.name List name (required)
266
+ * @param {array} [params.list=[]] Initial list items
267
+ * @param {string} session JWT session token
268
+ * @return {Promise&lt;object>} Created list document
269
+ * @public
270
+ * @async
271
+ * @example
272
+ *
273
+ * const API = require('@docbrasil/api-systemmanager');
274
+ * const api = new API();
275
+ * const params = { orgId: '5edd11c46b6ce9729c2c297c', name: 'My List', list: [] };
276
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
277
+ * const list = await api.admin.list.create(params, session);
278
+ */
279
+ async create(params = {}, session) {
280
+ const self = this;
281
+
282
+ try {
283
+ Joi.assert(params, Joi.object().required());
284
+ Joi.assert(params.orgId, Joi.string().required());
285
+ Joi.assert(params.name, Joi.string().required());
286
+ Joi.assert(session, Joi.string().required());
287
+
288
+ const { orgId, name, list = [] } = params;
289
+ const payload = { orgId, name, list };
290
+
291
+ const apiCall = self._client.put(
292
+ `/admin/organizations/${orgId}/orgtags`,
293
+ payload,
294
+ self._setHeader(session)
295
+ );
296
+
297
+ return self._returnData(await apiCall);
298
+ } catch (ex) {
299
+ throw ex;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
305
+ * @description Update an organization list
306
+ * @param {object} params Parameters
307
+ * @param {string} params.orgId Organization ID (required)
308
+ * @param {string} params.id List ID (required)
309
+ * @param {object} params.data Fields to update (name, list, etc.)
310
+ * @param {string} session JWT session token
311
+ * @return {Promise&lt;object>} Updated list document
312
+ * @public
313
+ * @async
314
+ * @example
315
+ *
316
+ * const API = require('@docbrasil/api-systemmanager');
317
+ * const api = new API();
318
+ * const params = { orgId: '5edd11c46b6ce9729c2c297c', id: '55e4a3bd6be6b45210833fae', data: { name: 'Renamed' } };
319
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
320
+ * const list = await api.admin.list.update(params, session);
321
+ */
322
+ async update(params = {}, session) {
323
+ const self = this;
324
+
325
+ try {
326
+ Joi.assert(params, Joi.object().required());
327
+ Joi.assert(params.orgId, Joi.string().required());
328
+ Joi.assert(params.id, Joi.string().required());
329
+ Joi.assert(params.data, Joi.object().required());
330
+ Joi.assert(session, Joi.string().required());
331
+
332
+ const { orgId, id, data } = params;
333
+
334
+ const apiCall = self._client.put(
335
+ `/admin/organizations/${orgId}/orgtags/${id}`,
336
+ data,
337
+ self._setHeader(session)
338
+ );
339
+
340
+ return self._returnData(await apiCall);
341
+ } catch (ex) {
342
+ throw ex;
343
+ }
344
+ }
345
+
346
+ /**
347
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
348
+ * @description Remove an organization list
349
+ * @param {object} params Parameters
350
+ * @param {string} params.orgId Organization ID (required)
351
+ * @param {string} params.id List ID to remove (required)
352
+ * @param {string} session JWT session token
353
+ * @return {Promise&lt;object>} Removal confirmation
354
+ * @public
355
+ * @async
356
+ * @example
357
+ *
358
+ * const API = require('@docbrasil/api-systemmanager');
359
+ * const api = new API();
360
+ * const params = { orgId: '5edd11c46b6ce9729c2c297c', id: '55e4a3bd6be6b45210833fae' };
361
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
362
+ * await api.admin.list.remove(params, session);
363
+ */
364
+ async remove(params = {}, session) {
365
+ const self = this;
366
+
367
+ try {
368
+ Joi.assert(params, Joi.object().required());
369
+ Joi.assert(params.orgId, Joi.string().required());
370
+ Joi.assert(params.id, Joi.string().required());
371
+ Joi.assert(session, Joi.string().required());
372
+
373
+ const { orgId, id } = params;
374
+
375
+ const apiCall = self._client.delete(
376
+ `/admin/organizations/${orgId}/orgtags/${id}`,
377
+ self._setHeader(session)
378
+ );
379
+
380
+ return self._returnData(await apiCall);
381
+ } catch (ex) {
382
+ throw ex;
383
+ }
384
+ }
385
+
386
+ /**
387
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
388
+ * @description Update list items of an organization list
389
+ * @param {object} params Parameters
390
+ * @param {string} params.orgId Organization ID (required)
391
+ * @param {string} params.id List ID (required)
392
+ * @param {array} params.list Updated list items array (required)
393
+ * @param {string} session JWT session token
394
+ * @return {Promise&lt;object>} Updated list document
395
+ * @public
396
+ * @async
397
+ * @example
398
+ *
399
+ * const API = require('@docbrasil/api-systemmanager');
400
+ * const api = new API();
401
+ * const params = {
402
+ * orgId: '5edd11c46b6ce9729c2c297c',
403
+ * id: '55e4a3bd6be6b45210833fae',
404
+ * list: [{ _id: '1', value: 'Item 1', filter: '', order: 0 }]
405
+ * };
406
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
407
+ * const list = await api.admin.list.updateListItems(params, session);
408
+ */
409
+ async updateListItems(params = {}, session) {
410
+ const self = this;
411
+
412
+ try {
413
+ Joi.assert(params, Joi.object().required());
414
+ Joi.assert(params.orgId, Joi.string().required());
415
+ Joi.assert(params.id, Joi.string().required());
416
+ Joi.assert(params.list, Joi.array().required());
417
+ Joi.assert(session, Joi.string().required());
418
+
419
+ const { orgId, id, list } = params;
420
+
421
+ const apiCall = self._client.put(
422
+ `/admin/organizations/${orgId}/orgtags/${id}`,
423
+ { list },
424
+ self._setHeader(session)
425
+ );
426
+
427
+ return self._returnData(await apiCall);
428
+ } catch (ex) {
429
+ throw ex;
430
+ }
431
+ }
218
432
  }
219
433
 
220
434
  export default AdminLists;
@@ -237,6 +237,47 @@ class Help {
237
237
  }
238
238
  }
239
239
 
240
+ /**
241
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
242
+ * @description Update a schedule associated with a help page.
243
+ * Allows partial updates (e.g., just the cron expression).
244
+ * @param {object} params Params for update
245
+ * @param {string} params.id Schedule id (_id database)
246
+ * @param {object} params.data Partial update data (e.g., { schedule: { cron: '0 9 * * *' } })
247
+ * @param {string} session Session, token JWT
248
+ * @returns {promise&lt;object>} Updated schedule document
249
+ * @public
250
+ * @example
251
+ *
252
+ * const API = require('@docbrasil/api-systemmanager');
253
+ * const api = new API();
254
+ * const params = {
255
+ * id: '5dadd01dc4af3941d42f8c5c',
256
+ * data: {
257
+ * schedule: { cron: '0 9 * * *' }
258
+ * }
259
+ * };
260
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
261
+ * await api.user.help.updateSchedule(params, session);
262
+ */
263
+ async updateSchedule(params, session) {
264
+ const self = this;
265
+
266
+ try {
267
+ Joi.assert(params, Joi.object().required(), 'Params to update schedule');
268
+ Joi.assert(params.id, Joi.string().required(), 'Schedule id (_id database)');
269
+ Joi.assert(params.data, Joi.object().required(), 'Data to update');
270
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
271
+
272
+ const { id, data } = params;
273
+ const apiCall = self._client.put(`/help/schedule/${id}`, data, self._setHeader(session));
274
+
275
+ return self._returnData(await apiCall);
276
+ } catch (ex) {
277
+ throw ex;
278
+ }
279
+ }
280
+
240
281
  }
241
282
 
242
283
  export default Help;
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.75",
4
+ "version": "1.1.77",
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",