code7-leia 0.2.27 → 0.2.29

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.
@@ -1222,10 +1222,27 @@ var url = 'https://api.leia.digitalcontact.cloud';
1222
1222
  axios.defaults.baseURL = "" + url;
1223
1223
  var api = /*#__PURE__*/axios.create();
1224
1224
 
1225
- var url$1 = 'http://localhost:5000';
1225
+ var url$1 = 'https://api-hml.leia.digitalcontact.cloud';
1226
1226
  axios.defaults.baseURL = "" + url$1;
1227
1227
  var apiHml = /*#__PURE__*/axios.create();
1228
1228
 
1229
+ var url$2 = 'http://localhost:5000';
1230
+ axios.defaults.baseURL = "" + url$2;
1231
+ var apiDev = /*#__PURE__*/axios.create();
1232
+
1233
+ var getApi = function getApi(env) {
1234
+ switch (env.toLowerCase()) {
1235
+ case 'dev':
1236
+ return apiDev;
1237
+ case 'prod':
1238
+ return api;
1239
+ case 'test':
1240
+ return apiHml;
1241
+ default:
1242
+ return api;
1243
+ }
1244
+ };
1245
+
1229
1246
  var _excluded$5 = ["children"];
1230
1247
  var SharedPropsContext = /*#__PURE__*/createContext(undefined);
1231
1248
  var useSharedProps = function useSharedProps() {
@@ -1247,97 +1264,72 @@ var SharedPropsProvider = function SharedPropsProvider(_ref) {
1247
1264
  var _useState2 = useState(null),
1248
1265
  personas = _useState2[0],
1249
1266
  setPersonas = _useState2[1];
1267
+ var api = getApi(env);
1250
1268
  useEffect(function () {
1251
1269
  var fetchData = /*#__PURE__*/function () {
1252
1270
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1253
- var _ref3, data;
1271
+ var _yield$api$get, data;
1254
1272
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1255
1273
  while (1) switch (_context.prev = _context.next) {
1256
1274
  case 0:
1257
1275
  _context.prev = 0;
1258
- if (!(env.toLowerCase() === 'dev')) {
1259
- _context.next = 7;
1260
- break;
1261
- }
1262
- _context.next = 4;
1276
+ _context.next = 3;
1263
1277
  return api.get("/tags/" + id);
1264
- case 4:
1265
- _context.t0 = _context.sent;
1266
- _context.next = 10;
1267
- break;
1268
- case 7:
1269
- _context.next = 9;
1270
- return apiHml.get("/tags/" + id);
1271
- case 9:
1272
- _context.t0 = _context.sent;
1273
- case 10:
1274
- _ref3 = _context.t0;
1275
- data = _ref3.data;
1278
+ case 3:
1279
+ _yield$api$get = _context.sent;
1280
+ data = _yield$api$get.data;
1276
1281
  if (data) {
1277
1282
  setTags(data);
1278
1283
  } else {
1279
1284
  console.error('Erro ao fazer a solicitação');
1280
1285
  }
1281
- _context.next = 18;
1286
+ _context.next = 11;
1282
1287
  break;
1283
- case 15:
1284
- _context.prev = 15;
1285
- _context.t1 = _context["catch"](0);
1286
- console.error('Erro ao fazer a solicitação:', _context.t1);
1287
- case 18:
1288
+ case 8:
1289
+ _context.prev = 8;
1290
+ _context.t0 = _context["catch"](0);
1291
+ console.error('Erro ao fazer a solicitação:', _context.t0);
1292
+ case 11:
1288
1293
  case "end":
1289
1294
  return _context.stop();
1290
1295
  }
1291
- }, _callee, null, [[0, 15]]);
1296
+ }, _callee, null, [[0, 8]]);
1292
1297
  }));
1293
1298
  return function fetchData() {
1294
1299
  return _ref2.apply(this, arguments);
1295
1300
  };
1296
1301
  }();
1297
1302
  var personas = /*#__PURE__*/function () {
1298
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1299
- var _ref5, data;
1303
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1304
+ var _yield$api$get2, data;
1300
1305
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1301
1306
  while (1) switch (_context2.prev = _context2.next) {
1302
1307
  case 0:
1303
1308
  _context2.prev = 0;
1304
- if (!(env.toLowerCase() === 'dev')) {
1305
- _context2.next = 7;
1306
- break;
1307
- }
1308
- _context2.next = 4;
1309
+ _context2.next = 3;
1309
1310
  return api.get("/personas?language=" + language);
1310
- case 4:
1311
- _context2.t0 = _context2.sent;
1312
- _context2.next = 10;
1313
- break;
1314
- case 7:
1315
- _context2.next = 9;
1316
- return apiHml.get("/personas?language=" + language);
1317
- case 9:
1318
- _context2.t0 = _context2.sent;
1319
- case 10:
1320
- _ref5 = _context2.t0;
1321
- data = _ref5.data;
1311
+ case 3:
1312
+ _yield$api$get2 = _context2.sent;
1313
+ data = _yield$api$get2.data;
1322
1314
  if (data) {
1323
1315
  setPersonas(data);
1324
1316
  } else {
1325
1317
  console.error('Erro ao fazer a solicitação');
1326
1318
  }
1327
- _context2.next = 18;
1319
+ _context2.next = 11;
1328
1320
  break;
1329
- case 15:
1330
- _context2.prev = 15;
1331
- _context2.t1 = _context2["catch"](0);
1332
- console.error('Erro ao fazer a solicitação:', _context2.t1);
1333
- case 18:
1321
+ case 8:
1322
+ _context2.prev = 8;
1323
+ _context2.t0 = _context2["catch"](0);
1324
+ console.error('Erro ao fazer a solicitação:', _context2.t0);
1325
+ case 11:
1334
1326
  case "end":
1335
1327
  return _context2.stop();
1336
1328
  }
1337
- }, _callee2, null, [[0, 15]]);
1329
+ }, _callee2, null, [[0, 8]]);
1338
1330
  }));
1339
1331
  return function personas() {
1340
- return _ref4.apply(this, arguments);
1332
+ return _ref3.apply(this, arguments);
1341
1333
  };
1342
1334
  }();
1343
1335
  fetchData();
@@ -2181,7 +2173,7 @@ var _marked = /*#__PURE__*/_regeneratorRuntime().mark(getFilesSaga),
2181
2173
  _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(TrainingSaga),
2182
2174
  _marked6 = /*#__PURE__*/_regeneratorRuntime().mark(filesSagas);
2183
2175
  function getFilesSaga(action) {
2184
- var _action$payload, id, token, env, _yield$call, data;
2176
+ var _action$payload, id, token, env, api, _yield$call, data;
2185
2177
  return _regeneratorRuntime().wrap(function getFilesSaga$(_context) {
2186
2178
  while (1) switch (_context.prev = _context.next) {
2187
2179
  case 0:
@@ -2190,36 +2182,37 @@ function getFilesSaga(action) {
2190
2182
  return put(commonLoadingStart());
2191
2183
  case 3:
2192
2184
  _action$payload = action.payload, id = _action$payload.id, token = _action$payload.token, env = _action$payload.env;
2193
- _context.next = 6;
2194
- return call(env.toLowerCase() === 'dev' ? api.get : apiHml.get, "/training/" + id + "?token=" + token);
2195
- case 6:
2185
+ api = getApi(env);
2186
+ _context.next = 7;
2187
+ return call(api.get, "/training/" + id + "?token=" + token);
2188
+ case 7:
2196
2189
  _yield$call = _context.sent;
2197
2190
  data = _yield$call.data;
2198
- _context.next = 10;
2191
+ _context.next = 11;
2199
2192
  return put(getFilesActionSuccess({
2200
2193
  files: data.files
2201
2194
  }));
2202
- case 10:
2203
- _context.next = 15;
2195
+ case 11:
2196
+ _context.next = 16;
2204
2197
  break;
2205
- case 12:
2206
- _context.prev = 12;
2198
+ case 13:
2199
+ _context.prev = 13;
2207
2200
  _context.t0 = _context["catch"](0);
2208
2201
  console.log('-----------getFiles.error------------------->', _context.t0);
2209
- case 15:
2210
- _context.prev = 15;
2211
- _context.next = 18;
2202
+ case 16:
2203
+ _context.prev = 16;
2204
+ _context.next = 19;
2212
2205
  return put(commonLoadingFinish());
2213
- case 18:
2214
- return _context.finish(15);
2215
2206
  case 19:
2207
+ return _context.finish(16);
2208
+ case 20:
2216
2209
  case "end":
2217
2210
  return _context.stop();
2218
2211
  }
2219
- }, _marked, null, [[0, 12, 15, 19]]);
2212
+ }, _marked, null, [[0, 13, 16, 20]]);
2220
2213
  }
2221
2214
  function deleteFilesSaga(action) {
2222
- var t, _action$payload2, id, name, token, env, _yield$call2, data;
2215
+ var t, _action$payload2, id, name, token, env, api, _yield$call2, data;
2223
2216
  return _regeneratorRuntime().wrap(function deleteFilesSaga$(_context2) {
2224
2217
  while (1) switch (_context2.prev = _context2.next) {
2225
2218
  case 0:
@@ -2229,44 +2222,45 @@ function deleteFilesSaga(action) {
2229
2222
  return put(commonLoadingStart());
2230
2223
  case 4:
2231
2224
  _action$payload2 = action.payload, id = _action$payload2.id, name = _action$payload2.name, token = _action$payload2.token, env = _action$payload2.env;
2232
- _context2.next = 7;
2233
- return call(env.toLowerCase() === 'dev' ? api["delete"] : apiHml["delete"], "/delete/" + id + "/" + name + "?token=" + token);
2234
- case 7:
2235
- _context2.next = 9;
2236
- return call(env.toLowerCase() === 'dev' ? api.get : apiHml.get, "/training/" + id + "?token=" + token);
2237
- case 9:
2225
+ api = getApi(env);
2226
+ _context2.next = 8;
2227
+ return call(api["delete"], "/delete/" + id + "/" + name + "?token=" + token);
2228
+ case 8:
2229
+ _context2.next = 10;
2230
+ return call(api.get, "/training/" + id + "?token=" + token);
2231
+ case 10:
2238
2232
  _yield$call2 = _context2.sent;
2239
2233
  data = _yield$call2.data;
2240
- _context2.next = 13;
2234
+ _context2.next = 14;
2241
2235
  return put(deleteFilesActionSuccess({
2242
2236
  files: data.files,
2243
2237
  success: true
2244
2238
  }));
2245
- case 13:
2246
- _context2.next = 19;
2239
+ case 14:
2240
+ _context2.next = 20;
2247
2241
  break;
2248
- case 15:
2249
- _context2.prev = 15;
2242
+ case 16:
2243
+ _context2.prev = 16;
2250
2244
  _context2.t0 = _context2["catch"](1);
2251
2245
  toast.error({
2252
2246
  title: t.toast.deleteFile.fail.title,
2253
2247
  description: t.toast.deleteFile.fail.description
2254
2248
  });
2255
2249
  console.log('-----------deleteFilesSaga.error------------------->', _context2.t0);
2256
- case 19:
2257
- _context2.prev = 19;
2258
- _context2.next = 22;
2250
+ case 20:
2251
+ _context2.prev = 20;
2252
+ _context2.next = 23;
2259
2253
  return put(commonLoadingFinish());
2260
- case 22:
2261
- return _context2.finish(19);
2262
2254
  case 23:
2255
+ return _context2.finish(20);
2256
+ case 24:
2263
2257
  case "end":
2264
2258
  return _context2.stop();
2265
2259
  }
2266
- }, _marked2, null, [[1, 15, 19, 23]]);
2260
+ }, _marked2, null, [[1, 16, 20, 24]]);
2267
2261
  }
2268
2262
  function testSaga(action) {
2269
- var _action$payload3, question, prompt, profile, presset, files_directory, token, env, _yield$call3, data;
2263
+ var _action$payload3, question, prompt, profile, presset, files_directory, token, env, api, _yield$call3, data;
2270
2264
  return _regeneratorRuntime().wrap(function testSaga$(_context3) {
2271
2265
  while (1) switch (_context3.prev = _context3.next) {
2272
2266
  case 0:
@@ -2275,8 +2269,9 @@ function testSaga(action) {
2275
2269
  return put(commonLoadingStart());
2276
2270
  case 3:
2277
2271
  _action$payload3 = action.payload, question = _action$payload3.question, prompt = _action$payload3.prompt, profile = _action$payload3.profile, presset = _action$payload3.presset, files_directory = _action$payload3.files_directory, token = _action$payload3.token, env = _action$payload3.env;
2278
- _context3.next = 6;
2279
- return call(env.toLowerCase() === 'dev' ? api.post : apiHml.post, "/ask", {
2272
+ api = getApi(env);
2273
+ _context3.next = 7;
2274
+ return call(api.post, "/ask", {
2280
2275
  question: question,
2281
2276
  description: prompt,
2282
2277
  profile: profile,
@@ -2284,34 +2279,34 @@ function testSaga(action) {
2284
2279
  files_directory: files_directory,
2285
2280
  token: token
2286
2281
  });
2287
- case 6:
2282
+ case 7:
2288
2283
  _yield$call3 = _context3.sent;
2289
2284
  data = _yield$call3.data;
2290
- _context3.next = 10;
2285
+ _context3.next = 11;
2291
2286
  return put(testActionSuccess({
2292
2287
  message: data.message
2293
2288
  }));
2294
- case 10:
2295
- _context3.next = 15;
2289
+ case 11:
2290
+ _context3.next = 16;
2296
2291
  break;
2297
- case 12:
2298
- _context3.prev = 12;
2292
+ case 13:
2293
+ _context3.prev = 13;
2299
2294
  _context3.t0 = _context3["catch"](0);
2300
2295
  console.log('-----------testSaga.error------------------->', _context3.t0);
2301
- case 15:
2302
- _context3.prev = 15;
2303
- _context3.next = 18;
2296
+ case 16:
2297
+ _context3.prev = 16;
2298
+ _context3.next = 19;
2304
2299
  return put(commonLoadingFinish());
2305
- case 18:
2306
- return _context3.finish(15);
2307
2300
  case 19:
2301
+ return _context3.finish(16);
2302
+ case 20:
2308
2303
  case "end":
2309
2304
  return _context3.stop();
2310
2305
  }
2311
- }, _marked3, null, [[0, 12, 15, 19]]);
2306
+ }, _marked3, null, [[0, 13, 16, 20]]);
2312
2307
  }
2313
2308
  function uploadFilesSaga(action) {
2314
- var t, _action$payload4, id, file, pressets, token, env, blob, formData, sanitizedPath, queryParams, url, _yield$call4, data;
2309
+ var t, _action$payload4, id, file, pressets, token, env, api, blob, formData, sanitizedPath, queryParams, url, _yield$call4, data;
2315
2310
  return _regeneratorRuntime().wrap(function uploadFilesSaga$(_context4) {
2316
2311
  while (1) switch (_context4.prev = _context4.next) {
2317
2312
  case 0:
@@ -2321,6 +2316,7 @@ function uploadFilesSaga(action) {
2321
2316
  return put(commonLoadingStart());
2322
2317
  case 4:
2323
2318
  _action$payload4 = action.payload, id = _action$payload4.id, file = _action$payload4.file, pressets = _action$payload4.pressets, token = _action$payload4.token, env = _action$payload4.env;
2319
+ api = getApi(env);
2324
2320
  blob = new Blob([file.content]);
2325
2321
  formData = new FormData();
2326
2322
  sanitizedPath = file.properties.path.replace(/^\/+|\/+$/g, '');
@@ -2329,47 +2325,47 @@ function uploadFilesSaga(action) {
2329
2325
  tags: pressets.join(',')
2330
2326
  }).toString() : '';
2331
2327
  url = queryParams ? "/upload/" + id + "?token=" + token + "&" + queryParams : "/upload/" + id + "?token=" + token;
2332
- _context4.next = 13;
2333
- return call(env.toLowerCase() === 'dev' ? api.post : apiHml.post, url, formData, {
2328
+ _context4.next = 14;
2329
+ return call(api.post, url, formData, {
2334
2330
  headers: {
2335
2331
  'Content-Type': 'multipart/form-data'
2336
2332
  }
2337
2333
  });
2338
- case 13:
2339
- _context4.next = 15;
2340
- return call(env.toLowerCase() === 'dev' ? api.get : apiHml.get, "/training/" + id + "?token=" + token);
2341
- case 15:
2334
+ case 14:
2335
+ _context4.next = 16;
2336
+ return call(api.get, "/training/" + id + "?token=" + token);
2337
+ case 16:
2342
2338
  _yield$call4 = _context4.sent;
2343
2339
  data = _yield$call4.data;
2344
- _context4.next = 19;
2340
+ _context4.next = 20;
2345
2341
  return put(uploadFilesActionSuccess({
2346
2342
  files: data.files
2347
2343
  }));
2348
- case 19:
2349
- _context4.next = 25;
2344
+ case 20:
2345
+ _context4.next = 26;
2350
2346
  break;
2351
- case 21:
2352
- _context4.prev = 21;
2347
+ case 22:
2348
+ _context4.prev = 22;
2353
2349
  _context4.t0 = _context4["catch"](1);
2354
2350
  toast.error({
2355
2351
  title: t.toast.uploadFile.fail.title,
2356
2352
  description: t.toast.uploadFile.fail.description
2357
2353
  });
2358
2354
  console.log('-----------uploadFilesSaga.error------------------->', _context4.t0);
2359
- case 25:
2360
- _context4.prev = 25;
2361
- _context4.next = 28;
2355
+ case 26:
2356
+ _context4.prev = 26;
2357
+ _context4.next = 29;
2362
2358
  return put(commonLoadingFinish());
2363
- case 28:
2364
- return _context4.finish(25);
2365
2359
  case 29:
2360
+ return _context4.finish(26);
2361
+ case 30:
2366
2362
  case "end":
2367
2363
  return _context4.stop();
2368
2364
  }
2369
- }, _marked4, null, [[1, 21, 25, 29]]);
2365
+ }, _marked4, null, [[1, 22, 26, 30]]);
2370
2366
  }
2371
2367
  function TrainingSaga(action) {
2372
- var t, _action$payload5, id, pressets, token, env, tag, queryParams, _yield$call5, data;
2368
+ var t, _action$payload5, id, pressets, token, env, tag, api, queryParams, _yield$call5, data;
2373
2369
  return _regeneratorRuntime().wrap(function TrainingSaga$(_context5) {
2374
2370
  while (1) switch (_context5.prev = _context5.next) {
2375
2371
  case 0:
@@ -2380,50 +2376,51 @@ function TrainingSaga(action) {
2380
2376
  case 4:
2381
2377
  _action$payload5 = action.payload, id = _action$payload5.id, pressets = _action$payload5.pressets, token = _action$payload5.token, env = _action$payload5.env;
2382
2378
  tag = pressets.join(',');
2379
+ api = getApi(env);
2383
2380
  queryParams = new URLSearchParams({
2384
2381
  tag: tag
2385
2382
  }).toString();
2386
- _context5.next = 9;
2387
- return call(env.toLowerCase() === 'dev' ? api.post : apiHml.post, pressets.length > 0 ? "/training?" + queryParams : "/training", {
2383
+ _context5.next = 10;
2384
+ return call(api.post, pressets.length > 0 ? "/training?" + queryParams : "/training", {
2388
2385
  files_directory: id,
2389
2386
  token: token
2390
2387
  });
2391
- case 9:
2392
- _context5.next = 11;
2393
- return call(env.toLowerCase() === 'dev' ? api.get : apiHml.get, "/training/" + id + "?token=" + token);
2394
- case 11:
2388
+ case 10:
2389
+ _context5.next = 12;
2390
+ return call(api.get, "/training/" + id + "?token=" + token);
2391
+ case 12:
2395
2392
  _yield$call5 = _context5.sent;
2396
2393
  data = _yield$call5.data;
2397
- _context5.next = 15;
2394
+ _context5.next = 16;
2398
2395
  return put(uploadFilesActionSuccess({
2399
2396
  files: data.files
2400
2397
  }));
2401
- case 15:
2398
+ case 16:
2402
2399
  toast.success({
2403
2400
  title: t.toast.Train.success.title,
2404
2401
  description: t.toast.Train.success.description
2405
2402
  });
2406
- _context5.next = 22;
2403
+ _context5.next = 23;
2407
2404
  break;
2408
- case 18:
2409
- _context5.prev = 18;
2405
+ case 19:
2406
+ _context5.prev = 19;
2410
2407
  _context5.t0 = _context5["catch"](1);
2411
2408
  toast.error({
2412
2409
  title: t.toast.Train.fail.title,
2413
2410
  description: t.toast.Train.fail.description
2414
2411
  });
2415
2412
  console.log('-----------TrainingSaga.error------------------->', _context5.t0);
2416
- case 22:
2417
- _context5.prev = 22;
2418
- _context5.next = 25;
2413
+ case 23:
2414
+ _context5.prev = 23;
2415
+ _context5.next = 26;
2419
2416
  return put(commonLoadingFinish());
2420
- case 25:
2421
- return _context5.finish(22);
2422
2417
  case 26:
2418
+ return _context5.finish(23);
2419
+ case 27:
2423
2420
  case "end":
2424
2421
  return _context5.stop();
2425
2422
  }
2426
- }, _marked5, null, [[1, 18, 22, 26]]);
2423
+ }, _marked5, null, [[1, 19, 23, 27]]);
2427
2424
  }
2428
2425
  function filesSagas() {
2429
2426
  return _regeneratorRuntime().wrap(function filesSagas$(_context6) {