argous 1.2.167 → 1.2.168

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.
@@ -37,6 +37,7 @@ export function endFileUpload(data: any): Promise<any>;
37
37
  export function cancelFileUpload(data: any): Promise<any>;
38
38
  export function getFileInfo(data: any): Promise<any>;
39
39
  export function searchUsers(data: any): Promise<any>;
40
+ export function getDocsUrl(data: any): Promise<any>;
40
41
  export function prepareFile(file: any): Promise<any>;
41
42
  export function createDocument({ idUnidade, cdUnidade, idDocPai, path, dsKeyWords, dtValidade, idTipoDocumento, FileName, title, idRecebimento, tpPrivacidade, description, dsClassificacao, dsCategoria, dsSubCategoria, snSensivel }: {
42
43
  idUnidade: any;
package/dist/api/index.js CHANGED
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.scanDocument = exports.getLink = exports.getFileFromLink = exports.createDocument = exports.prepareFile = exports.searchUsers = exports.getFileInfo = exports.cancelFileUpload = exports.endFileUpload = exports.sendFilePart = exports.inicFileUpload = exports.enviaCompartilhamentoDePrograma = exports.removePostTimeLine = exports.publicaTimeline = exports.toggleLikePost = exports.recebeInfoEstatisticas = exports.recebeInfoLoginsAtivos = exports.recebeThreadsUsuario = exports.recebeInfoThread = exports.recebeThread = exports.readNotificacao = exports.readNotificacoes = exports.getNotificacoes = exports.callProgram = exports.toggleFavorite = exports.getFavorites = exports.method = exports.action = exports.agSet = exports.agGet = exports.getProgram = exports.getPostPublicacao = exports.addCommentPost = exports.getPostsTimeline = exports.getMenu = exports.validaToken = exports.logout = exports.login = exports.fetchToArgous = exports.headers = exports.api = exports.server = void 0;
50
+ exports.scanDocument = exports.getLink = exports.getFileFromLink = exports.createDocument = exports.prepareFile = exports.getDocsUrl = exports.searchUsers = exports.getFileInfo = exports.cancelFileUpload = exports.endFileUpload = exports.sendFilePart = exports.inicFileUpload = exports.enviaCompartilhamentoDePrograma = exports.removePostTimeLine = exports.publicaTimeline = exports.toggleLikePost = exports.recebeInfoEstatisticas = exports.recebeInfoLoginsAtivos = exports.recebeThreadsUsuario = exports.recebeInfoThread = exports.recebeThread = exports.readNotificacao = exports.readNotificacoes = exports.getNotificacoes = exports.callProgram = exports.toggleFavorite = exports.getFavorites = exports.method = exports.action = exports.agSet = exports.agGet = exports.getProgram = exports.getPostPublicacao = exports.addCommentPost = exports.getPostsTimeline = exports.getMenu = exports.validaToken = exports.logout = exports.login = exports.fetchToArgous = exports.headers = exports.api = exports.server = void 0;
51
51
  var utils_1 = require("../utils");
52
52
  var config_1 = require("../utils/config");
53
53
  var server = function () { return "://" + config_1.getConfig()[/^[a-z]+.+\.com\.br$/.test(window.location.host) ? 'ip' : 'ip'] + "/" + (config_1.getConfig().path ? config_1.getConfig().path : 'jUniIII') + "/"; };
@@ -656,18 +656,34 @@ var searchUsers = function (data) { return __awaiter(void 0, void 0, void 0, fun
656
656
  });
657
657
  }); };
658
658
  exports.searchUsers = searchUsers;
659
+ var getDocsUrl = function (data) { return __awaiter(void 0, void 0, void 0, function () {
660
+ var res;
661
+ return __generator(this, function (_a) {
662
+ switch (_a.label) {
663
+ case 0: return [4 /*yield*/, fetch(exports.api() + "agdocsurl.rslvr", {
664
+ method: 'POST',
665
+ body: JSON.stringify(data),
666
+ headers: exports.headers()
667
+ })];
668
+ case 1:
669
+ res = _a.sent();
670
+ return [4 /*yield*/, res.json()];
671
+ case 2: return [2 /*return*/, _a.sent()];
672
+ }
673
+ });
674
+ }); };
675
+ exports.getDocsUrl = getDocsUrl;
659
676
  var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
660
- var formData, _a, status, docsUrl, res, _b, _c;
677
+ var _a, status, docsUrl, formData, res, _b, _c;
661
678
  var _d;
662
679
  return __generator(this, function (_e) {
663
680
  switch (_e.label) {
664
- case 0:
665
- formData = new FormData();
666
- return [4 /*yield*/, exports.fetchToArgous('agdocsurl', {})];
681
+ case 0: return [4 /*yield*/, exports.getDocsUrl()];
667
682
  case 1:
668
683
  _a = _e.sent(), status = _a.status, docsUrl = _a.docsUrl;
669
684
  if (!status)
670
685
  return [2 /*return*/];
686
+ formData = new FormData();
671
687
  formData.append('blob', file);
672
688
  return [4 /*yield*/, fetch(docsUrl + "/argous/docs/upload.agdoc", {
673
689
  method: 'POST',
@@ -690,20 +706,26 @@ exports.prepareFile = prepareFile;
690
706
  var createDocument = function (_a) {
691
707
  var idUnidade = _a.idUnidade, cdUnidade = _a.cdUnidade, idDocPai = _a.idDocPai, path = _a.path, dsKeyWords = _a.dsKeyWords, dtValidade = _a.dtValidade, idTipoDocumento = _a.idTipoDocumento, FileName = _a.FileName, title = _a.title, idRecebimento = _a.idRecebimento, tpPrivacidade = _a.tpPrivacidade, description = _a.description, dsClassificacao = _a.dsClassificacao, dsCategoria = _a.dsCategoria, dsSubCategoria = _a.dsSubCategoria, snSensivel = _a.snSensivel;
692
708
  return __awaiter(void 0, void 0, void 0, function () {
693
- return __generator(this, function (_b) {
694
- switch (_b.label) {
695
- case 0: return [4 /*yield*/, fetch(exports.api() + "docs/upload.agdoc", {
696
- method: 'POST',
697
- headers: exports.headers(),
698
- body: JSON.stringify({
699
- idUnidade: idUnidade, cdUnidade: cdUnidade, idDocPai: idDocPai, path: path,
700
- dsKeyWords: dsKeyWords, dtValidade: dtValidade, idTipoDocumento: idTipoDocumento,
701
- FileName: FileName, title: title, idRecebimento: idRecebimento,
702
- tpPrivacidade: tpPrivacidade, description: description, dsClassificacao: dsClassificacao,
703
- dsCategoria: dsCategoria, dsSubCategoria: dsSubCategoria, snSensivel: snSensivel
704
- })
705
- })];
706
- case 1: return [2 /*return*/, (_b.sent()).json()];
709
+ var _b, status, docsUrl;
710
+ return __generator(this, function (_c) {
711
+ switch (_c.label) {
712
+ case 0: return [4 /*yield*/, exports.getDocsUrl()];
713
+ case 1:
714
+ _b = _c.sent(), status = _b.status, docsUrl = _b.docsUrl;
715
+ if (!status)
716
+ return [2 /*return*/];
717
+ return [4 /*yield*/, fetch(docsUrl + "docs/upload.agdoc", {
718
+ method: 'POST',
719
+ headers: exports.headers(),
720
+ body: JSON.stringify({
721
+ idUnidade: idUnidade, cdUnidade: cdUnidade, idDocPai: idDocPai, path: path,
722
+ dsKeyWords: dsKeyWords, dtValidade: dtValidade, idTipoDocumento: idTipoDocumento,
723
+ FileName: FileName, title: title, idRecebimento: idRecebimento,
724
+ tpPrivacidade: tpPrivacidade, description: description, dsClassificacao: dsClassificacao,
725
+ dsCategoria: dsCategoria, dsSubCategoria: dsSubCategoria, snSensivel: snSensivel
726
+ })
727
+ })];
728
+ case 2: return [2 /*return*/, (_c.sent()).json()];
707
729
  }
708
730
  });
709
731
  });
@@ -201,26 +201,21 @@ var FilePreparer = function (_a, ref) {
201
201
  onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
202
202
  };
203
203
  var preparaArquivo = react_1.useCallback(function (file) { return __awaiter(void 0, void 0, void 0, function () {
204
- var resultUrl, reqs, i, res, resps;
204
+ var reqs, i, res, resps;
205
205
  return __generator(this, function (_a) {
206
206
  switch (_a.label) {
207
207
  case 0:
208
208
  if (!file)
209
209
  return [2 /*return*/];
210
210
  setLoading(true);
211
- return [4 /*yield*/, api_1.fetchToArgous('agdocsurl', {})];
212
- case 1:
213
- resultUrl = _a.sent();
214
- if (!resultUrl.status)
215
- return [2 /*return*/];
216
211
  reqs = [];
217
212
  if (file.map)
218
213
  reqs = file;
219
214
  else
220
215
  for (i = 0; i < file.length; i++)
221
216
  reqs.push(file[i]);
222
- return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item, resultUrl.docsUrl); }))];
223
- case 2:
217
+ return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item); }))];
218
+ case 1:
224
219
  res = _a.sent();
225
220
  resps = [];
226
221
  res.forEach(function (item, i) {
package/lib/api/index.js CHANGED
@@ -335,10 +335,19 @@ export const searchUsers = async (data) => {
335
335
  return await res.json();
336
336
  };
337
337
 
338
+ export const getDocsUrl = async (data) => {
339
+ const res = await fetch(`${api()}agdocsurl.rslvr`, {
340
+ method: 'POST',
341
+ body: JSON.stringify(data),
342
+ headers: headers()
343
+ });
344
+ return await res.json();
345
+ };
346
+
338
347
  export const prepareFile = async (file) => {
339
- const formData = new FormData();
340
- const { status, docsUrl } = await fetchToArgous('agdocsurl', { });
348
+ const { status, docsUrl } = await getDocsUrl();
341
349
  if (!status) return;
350
+ const formData = new FormData();
342
351
  formData.append('blob', file);
343
352
  const res = await fetch(`${docsUrl}/argous/docs/upload.agdoc`, {
344
353
  method: 'POST',
@@ -363,7 +372,9 @@ export const createDocument = async ({
363
372
  tpPrivacidade, description, dsClassificacao,
364
373
  dsCategoria, dsSubCategoria, snSensivel
365
374
  }) => {
366
- return (await fetch(`${api()}docs/upload.agdoc`, {
375
+ const { status, docsUrl } = await getDocsUrl();
376
+ if (!status) return;
377
+ return (await fetch(`${docsUrl}docs/upload.agdoc`, {
367
378
  method: 'POST',
368
379
  headers: headers(),
369
380
  body: JSON.stringify({
@@ -1,4 +1,4 @@
1
- import { fetchToArgous, prepareFile } from '../../api';
1
+ import { prepareFile } from '../../api';
2
2
  import { setError } from '../../utils/api';
3
3
  import { Chip, CircularProgress, FilledInput, IconButton, makeStyles, TextField } from '@material-ui/core';
4
4
  import { useAutocomplete } from '@material-ui/lab';
@@ -132,12 +132,10 @@ const FilePreparer = ({
132
132
  const preparaArquivo = useCallback(async file => {
133
133
  if (!file) return;
134
134
  setLoading(true);
135
- const resultUrl = await fetchToArgous('agdocsurl', { });
136
- if (!resultUrl.status) return;
137
135
  let reqs = [];
138
136
  if (file.map) reqs = file;
139
137
  else for (let i = 0; i < file.length; i++) reqs.push(file[i]);
140
- const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item, resultUrl.docsUrl)));
138
+ const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item)));
141
139
  let resps = [];
142
140
  res.forEach((item, i) => {
143
141
  if (item.idRecebimento) resps.push({ ...item, path: file[i].fullPath });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.167",
3
+ "version": "1.2.168",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",