mftsccs-browser 2.1.89-beta → 2.1.91-beta

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.
@@ -8975,8 +8975,10 @@ class LocalSyncData {
8975
8975
  }
8976
8976
  else if (Array.isArray(actions === null || actions === void 0 ? void 0 : actions.concepts) && Array.isArray(actions === null || actions === void 0 ? void 0 : actions.connections)) {
8977
8977
  // filter concepts from conceptsSyncArray and connectionSyncArray and sync only belonging to this tab
8978
+ console.log("this is the concepts and connections array", actions === null || actions === void 0 ? void 0 : actions.concepts, actions === null || actions === void 0 ? void 0 : actions.connections);
8978
8979
  conceptsArray = actions.concepts.filter(concept => this.conceptsSyncArray.some(con => concept.id == con.id || concept.ghostId == con.ghostId)).slice();
8979
8980
  connectionsArray = actions.connections.filter(connection => this.connectionSyncArray.some(conn => connection.id == conn.id || connection.ghostId == conn.ghostId)).slice();
8981
+ console.log("this is the concepts and connections array", conceptsArray, connectionsArray);
8980
8982
  // remove the concepts and connections from the array that belongs to the actions/tab
8981
8983
  this.conceptsSyncArray = this.conceptsSyncArray.filter(concept => !actions.concepts.some(con => concept.id == con.id || concept.ghostId == con.ghostId));
8982
8984
  this.connectionSyncArray = this.connectionSyncArray.filter(connection => !actions.connections.some(conn => connection.id == conn.id || connection.ghostId == conn.ghostId));
@@ -21800,10 +21802,15 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
21800
21802
  };
21801
21803
 
21802
21804
  function CreateData(json_1) {
21803
- return __awaiter(this, arguments, void 0, function* (json, ofConcept = null, typeConcept = "") {
21805
+ return __awaiter(this, arguments, void 0, function* (json, ofConcept = null, typeConcept = "", actions = { concepts: [], connections: [] }) {
21806
+ var _a, _b, _c, _d;
21804
21807
  if (_app__WEBPACK_IMPORTED_MODULE_0__.serviceWorker) {
21805
21808
  try {
21806
- const res = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.sendMessage)('CreateData', { json, ofConcept, typeConcept });
21809
+ const res = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.sendMessage)('CreateData', { json, ofConcept, typeConcept, actions });
21810
+ if ((_b = (_a = res === null || res === void 0 ? void 0 : res.actions) === null || _a === void 0 ? void 0 : _a.concepts) === null || _b === void 0 ? void 0 : _b.length)
21811
+ actions.concepts = JSON.parse(JSON.stringify(res.actions.concepts));
21812
+ if ((_d = (_c = res === null || res === void 0 ? void 0 : res.actions) === null || _c === void 0 ? void 0 : _c.connections) === null || _d === void 0 ? void 0 : _d.length)
21813
+ actions.connections = JSON.parse(JSON.stringify(res.actions.connections));
21807
21814
  return res.data;
21808
21815
  }
21809
21816
  catch (err) {
@@ -21816,50 +21823,45 @@ function CreateData(json_1) {
21816
21823
  let localSessionId = 999;
21817
21824
  let orderId = 1000;
21818
21825
  let MainConcept = (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateDefaultConcept)();
21819
- console.log("this is the json group 3 ", json);
21820
21826
  for (const key in json) {
21821
21827
  let prefixedKey = addPrefix(key);
21822
21828
  if ((typeof json[key] != 'string' && typeof json[key] != 'number')) {
21823
21829
  if (ofConcept == null || ofConcept.id == 0) {
21824
21830
  // let TypeConcept = await MakeTheTypeConceptLocal(prefixedKey, localSessionId, localUserId, localUserId);
21825
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId);
21831
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId, undefined, actions);
21826
21832
  let concept = conceptString;
21827
21833
  MainConcept = concept;
21828
21834
  if (Array.isArray(json[key])) {
21829
21835
  prefixedKey = addArrayPrefix(prefixedKey);
21830
21836
  }
21831
- console.log("this is the json group 1", json[key], prefixedKey);
21832
- yield CreateData(json[key], MainConcept, prefixedKey);
21837
+ yield CreateData(json[key], MainConcept, prefixedKey, actions);
21833
21838
  }
21834
21839
  else {
21835
21840
  // remove this because we do not want this to be the type of the connection.
21836
21841
  if (Array.isArray(json[key])) {
21837
21842
  prefixedKey = removeArrayPrefix(prefixedKey);
21838
- console.log("this is the prefix", prefixedKey);
21839
21843
  }
21840
21844
  let withoutSKey = removeArrayPrefix(key);
21841
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId);
21845
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId, undefined, actions);
21842
21846
  let concept = conceptString;
21843
21847
  MainConcept = concept;
21844
21848
  let typeConnectionString = createTypeString(typeConcept, withoutSKey);
21845
- let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId);
21846
- console.log("this is the type ", TypeConcept);
21847
- yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, TypeConcept.characterValue, localUserId);
21849
+ let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId, actions);
21850
+ yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, TypeConcept.characterValue, localUserId, actions);
21848
21851
  if (Array.isArray(json[key])) {
21849
21852
  prefixedKey = addArrayPrefix(prefixedKey);
21850
- console.log("this is the prefix after", prefixedKey);
21851
21853
  }
21852
- console.log("this is the json group 2", json[key], prefixedKey);
21853
- yield CreateData(json[key], concept, prefixedKey);
21854
+ yield CreateData(json[key], concept, prefixedKey, actions);
21854
21855
  }
21855
21856
  }
21856
21857
  else {
21857
21858
  let typeConnectionString = createTypeString(typeConcept, key);
21858
- let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId);
21859
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(key, json[key].toString(), false, localUserId, localAccessId, localSessionId);
21859
+ let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId, actions);
21860
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(key, json[key].toString(), false, localUserId, localAccessId, localSessionId, undefined, actions);
21860
21861
  let concept = conceptString;
21862
+ console.log("this is the type concept in down", TypeConcept, concept);
21861
21863
  if (ofConcept != null) {
21862
- yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, typeConnectionString, localUserId);
21864
+ yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, typeConnectionString, localUserId, actions);
21863
21865
  }
21864
21866
  }
21865
21867
  }
@@ -21878,7 +21880,11 @@ function addArrayPrefix(key) {
21878
21880
  function removeArrayPrefix(key) {
21879
21881
  return key.replace(/_s$/, '');
21880
21882
  }
21883
+ const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
21881
21884
  function createTypeString(typeConceptString, key) {
21885
+ if (isNumeric(key)) {
21886
+ return typeConceptString + "_";
21887
+ }
21882
21888
  return typeConceptString + "_" + removePrefix(key);
21883
21889
  }
21884
21890
 
@@ -25335,6 +25341,7 @@ function init() {
25335
25341
  console.warn("Service Worker not supported in this browser.");
25336
25342
  return;
25337
25343
  }
25344
+ yield initializeCacheServer();
25338
25345
  listenPostMessagaes();
25339
25346
  listenBroadCastMessages();
25340
25347
  // check if manual service worker was activated
@@ -25936,44 +25943,49 @@ function checkIfExecutingProcess(messageId, type) {
25936
25943
  }
25937
25944
  });
25938
25945
  }
25939
- // const myCacheServer = sessionStorage.getItem("myCacheServer")
25940
- // async function getCacheServer(data?: any) {
25941
- // try {
25942
- // const response = await fetch(BaseUrl.getMyCacheServer(), {
25943
- // method: "POST",
25944
- // headers: {
25945
- // "Content-Type": "application/json",
25946
- // },
25947
- // body: JSON.stringify({
25948
- // "my-coords": data ? data.coords : "location denied",
25949
- // }),
25950
- // });
25951
- // if (!response.ok) {
25952
- // throw new Error("Failed to sync data to the server.");
25953
- // }
25954
- // const cacheRes = await response.json();
25955
- // if (cacheRes.success) {
25956
- // sessionStorage.setItem("myCacheServer", cacheRes.nearestServer);
25957
- // BaseUrl.NODE_CACHE_URL = cacheRes.nearestServer;
25958
- // }
25959
- // } catch (error: any) {
25960
- // console.error("error getting cache server", error.message);
25961
- // }
25962
- // }
25963
- // if (!myCacheServer) {
25964
- // navigator.geolocation.getCurrentPosition(
25965
- // async (data) => {
25966
- // await getCacheServer(data);
25967
- // },
25968
- // async (error) => {
25969
- // if (error.code === error.PERMISSION_DENIED) {
25970
- // await getCacheServer();
25971
- // }
25972
- // }
25973
- // );
25974
- // } else {
25975
- // BaseUrl.NODE_CACHE_URL = myCacheServer;
25976
- // }
25946
+ function initializeCacheServer() {
25947
+ return __awaiter(this, void 0, void 0, function* () {
25948
+ const myCacheServer = sessionStorage.getItem("myCacheServer");
25949
+ function getCacheServer(data) {
25950
+ return __awaiter(this, void 0, void 0, function* () {
25951
+ try {
25952
+ const response = yield fetch(_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.getMyCacheServer(), {
25953
+ method: "POST",
25954
+ headers: {
25955
+ "Content-Type": "application/json",
25956
+ },
25957
+ body: JSON.stringify({
25958
+ "my-coords": data ? data.coords : "location denied",
25959
+ }),
25960
+ });
25961
+ if (!response.ok) {
25962
+ throw new Error("Failed to sync data to the server.");
25963
+ }
25964
+ const cacheRes = yield response.json();
25965
+ if (cacheRes.success) {
25966
+ sessionStorage.setItem("myCacheServer", cacheRes.nearestServer);
25967
+ _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.NODE_CACHE_URL = cacheRes.nearestServer;
25968
+ }
25969
+ }
25970
+ catch (error) {
25971
+ console.error("error getting cache server", error.message);
25972
+ }
25973
+ });
25974
+ }
25975
+ if (!myCacheServer) {
25976
+ navigator.geolocation.getCurrentPosition((data) => __awaiter(this, void 0, void 0, function* () {
25977
+ yield getCacheServer(data);
25978
+ }), (error) => __awaiter(this, void 0, void 0, function* () {
25979
+ if (error.code === error.PERMISSION_DENIED) {
25980
+ yield getCacheServer();
25981
+ }
25982
+ }));
25983
+ }
25984
+ else {
25985
+ _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.NODE_CACHE_URL = myCacheServer;
25986
+ }
25987
+ });
25988
+ }
25977
25989
 
25978
25990
 
25979
25991
  /***/ })