@docbrasil/api-systemmanager 1.1.76 → 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/api/admin/list.js +214 -0
- package/dist/bundle.cjs +214 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +137 -0
- package/docs/AdminLists.html +1591 -49
- package/docs/admin_list.js.html +214 -0
- package/package.json +1 -1
package/docs/admin_list.js.html
CHANGED
|
@@ -215,6 +215,220 @@ class AdminLists {
|
|
|
215
215
|
throw ex;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @author Myndware <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<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 <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<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 <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<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 <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<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 <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<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;
|
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
|
+
"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",
|