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