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));
@@ -12728,7 +12730,7 @@ const createActions = {
12728
12730
  return { success: true, data, actions: payload.actions };
12729
12731
  }),
12730
12732
  CreateData: (payload) => __awaiter(void 0, void 0, void 0, function* () {
12731
- const data = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateData)(payload.json, payload.ofConcept, payload.typeConcept);
12733
+ const data = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateData)(payload.json, payload.ofConcept, payload.typeConcept, payload.actions);
12732
12734
  return { success: true, data, actions: payload.actions };
12733
12735
  })
12734
12736
  };
@@ -22750,10 +22752,15 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
22750
22752
  };
22751
22753
 
22752
22754
  function CreateData(json_1) {
22753
- return __awaiter(this, arguments, void 0, function* (json, ofConcept = null, typeConcept = "") {
22755
+ return __awaiter(this, arguments, void 0, function* (json, ofConcept = null, typeConcept = "", actions = { concepts: [], connections: [] }) {
22756
+ var _a, _b, _c, _d;
22754
22757
  if (_app__WEBPACK_IMPORTED_MODULE_0__.serviceWorker) {
22755
22758
  try {
22756
- const res = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.sendMessage)('CreateData', { json, ofConcept, typeConcept });
22759
+ const res = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.sendMessage)('CreateData', { json, ofConcept, typeConcept, actions });
22760
+ 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)
22761
+ actions.concepts = JSON.parse(JSON.stringify(res.actions.concepts));
22762
+ 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)
22763
+ actions.connections = JSON.parse(JSON.stringify(res.actions.connections));
22757
22764
  return res.data;
22758
22765
  }
22759
22766
  catch (err) {
@@ -22766,50 +22773,45 @@ function CreateData(json_1) {
22766
22773
  let localSessionId = 999;
22767
22774
  let orderId = 1000;
22768
22775
  let MainConcept = (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateDefaultConcept)();
22769
- console.log("this is the json group 3 ", json);
22770
22776
  for (const key in json) {
22771
22777
  let prefixedKey = addPrefix(key);
22772
22778
  if ((typeof json[key] != 'string' && typeof json[key] != 'number')) {
22773
22779
  if (ofConcept == null || ofConcept.id == 0) {
22774
22780
  // let TypeConcept = await MakeTheTypeConceptLocal(prefixedKey, localSessionId, localUserId, localUserId);
22775
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId);
22781
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId, undefined, actions);
22776
22782
  let concept = conceptString;
22777
22783
  MainConcept = concept;
22778
22784
  if (Array.isArray(json[key])) {
22779
22785
  prefixedKey = addArrayPrefix(prefixedKey);
22780
22786
  }
22781
- console.log("this is the json group 1", json[key], prefixedKey);
22782
- yield CreateData(json[key], MainConcept, prefixedKey);
22787
+ yield CreateData(json[key], MainConcept, prefixedKey, actions);
22783
22788
  }
22784
22789
  else {
22785
22790
  // remove this because we do not want this to be the type of the connection.
22786
22791
  if (Array.isArray(json[key])) {
22787
22792
  prefixedKey = removeArrayPrefix(prefixedKey);
22788
- console.log("this is the prefix", prefixedKey);
22789
22793
  }
22790
22794
  let withoutSKey = removeArrayPrefix(key);
22791
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId);
22795
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(prefixedKey, "", true, localUserId, localAccessId, localSessionId, undefined, actions);
22792
22796
  let concept = conceptString;
22793
22797
  MainConcept = concept;
22794
22798
  let typeConnectionString = createTypeString(typeConcept, withoutSKey);
22795
- let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId);
22796
- console.log("this is the type ", TypeConcept);
22797
- yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, TypeConcept.characterValue, localUserId);
22799
+ let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId, actions);
22800
+ yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, TypeConcept.characterValue, localUserId, actions);
22798
22801
  if (Array.isArray(json[key])) {
22799
22802
  prefixedKey = addArrayPrefix(prefixedKey);
22800
- console.log("this is the prefix after", prefixedKey);
22801
22803
  }
22802
- console.log("this is the json group 2", json[key], prefixedKey);
22803
- yield CreateData(json[key], concept, prefixedKey);
22804
+ yield CreateData(json[key], concept, prefixedKey, actions);
22804
22805
  }
22805
22806
  }
22806
22807
  else {
22807
22808
  let typeConnectionString = createTypeString(typeConcept, key);
22808
- let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId);
22809
- let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(key, json[key].toString(), false, localUserId, localAccessId, localSessionId);
22809
+ let TypeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheTypeConceptLocal)(typeConnectionString, localSessionId, localUserId, localUserId, actions);
22810
+ let conceptString = yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.MakeTheInstanceConceptLocal)(key, json[key].toString(), false, localUserId, localAccessId, localSessionId, undefined, actions);
22810
22811
  let concept = conceptString;
22812
+ console.log("this is the type concept in down", TypeConcept, concept);
22811
22813
  if (ofConcept != null) {
22812
- yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, typeConnectionString, localUserId);
22814
+ yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.CreateTheConnectionLocal)(ofConcept.id, concept.id, TypeConcept.id, orderId, typeConnectionString, localUserId, actions);
22813
22815
  }
22814
22816
  }
22815
22817
  }
@@ -22828,7 +22830,11 @@ function addArrayPrefix(key) {
22828
22830
  function removeArrayPrefix(key) {
22829
22831
  return key.replace(/_s$/, '');
22830
22832
  }
22833
+ const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string);
22831
22834
  function createTypeString(typeConceptString, key) {
22835
+ if (isNumeric(key)) {
22836
+ return typeConceptString + "_";
22837
+ }
22832
22838
  return typeConceptString + "_" + removePrefix(key);
22833
22839
  }
22834
22840
 
@@ -26285,6 +26291,7 @@ function init() {
26285
26291
  console.warn("Service Worker not supported in this browser.");
26286
26292
  return;
26287
26293
  }
26294
+ yield initializeCacheServer();
26288
26295
  listenPostMessagaes();
26289
26296
  listenBroadCastMessages();
26290
26297
  // check if manual service worker was activated
@@ -26886,44 +26893,49 @@ function checkIfExecutingProcess(messageId, type) {
26886
26893
  }
26887
26894
  });
26888
26895
  }
26889
- // const myCacheServer = sessionStorage.getItem("myCacheServer")
26890
- // async function getCacheServer(data?: any) {
26891
- // try {
26892
- // const response = await fetch(BaseUrl.getMyCacheServer(), {
26893
- // method: "POST",
26894
- // headers: {
26895
- // "Content-Type": "application/json",
26896
- // },
26897
- // body: JSON.stringify({
26898
- // "my-coords": data ? data.coords : "location denied",
26899
- // }),
26900
- // });
26901
- // if (!response.ok) {
26902
- // throw new Error("Failed to sync data to the server.");
26903
- // }
26904
- // const cacheRes = await response.json();
26905
- // if (cacheRes.success) {
26906
- // sessionStorage.setItem("myCacheServer", cacheRes.nearestServer);
26907
- // BaseUrl.NODE_CACHE_URL = cacheRes.nearestServer;
26908
- // }
26909
- // } catch (error: any) {
26910
- // console.error("error getting cache server", error.message);
26911
- // }
26912
- // }
26913
- // if (!myCacheServer) {
26914
- // navigator.geolocation.getCurrentPosition(
26915
- // async (data) => {
26916
- // await getCacheServer(data);
26917
- // },
26918
- // async (error) => {
26919
- // if (error.code === error.PERMISSION_DENIED) {
26920
- // await getCacheServer();
26921
- // }
26922
- // }
26923
- // );
26924
- // } else {
26925
- // BaseUrl.NODE_CACHE_URL = myCacheServer;
26926
- // }
26896
+ function initializeCacheServer() {
26897
+ return __awaiter(this, void 0, void 0, function* () {
26898
+ const myCacheServer = sessionStorage.getItem("myCacheServer");
26899
+ function getCacheServer(data) {
26900
+ return __awaiter(this, void 0, void 0, function* () {
26901
+ try {
26902
+ const response = yield fetch(_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.getMyCacheServer(), {
26903
+ method: "POST",
26904
+ headers: {
26905
+ "Content-Type": "application/json",
26906
+ },
26907
+ body: JSON.stringify({
26908
+ "my-coords": data ? data.coords : "location denied",
26909
+ }),
26910
+ });
26911
+ if (!response.ok) {
26912
+ throw new Error("Failed to sync data to the server.");
26913
+ }
26914
+ const cacheRes = yield response.json();
26915
+ if (cacheRes.success) {
26916
+ sessionStorage.setItem("myCacheServer", cacheRes.nearestServer);
26917
+ _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.NODE_CACHE_URL = cacheRes.nearestServer;
26918
+ }
26919
+ }
26920
+ catch (error) {
26921
+ console.error("error getting cache server", error.message);
26922
+ }
26923
+ });
26924
+ }
26925
+ if (!myCacheServer) {
26926
+ navigator.geolocation.getCurrentPosition((data) => __awaiter(this, void 0, void 0, function* () {
26927
+ yield getCacheServer(data);
26928
+ }), (error) => __awaiter(this, void 0, void 0, function* () {
26929
+ if (error.code === error.PERMISSION_DENIED) {
26930
+ yield getCacheServer();
26931
+ }
26932
+ }));
26933
+ }
26934
+ else {
26935
+ _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_99__.BaseUrl.NODE_CACHE_URL = myCacheServer;
26936
+ }
26937
+ });
26938
+ }
26927
26939
 
26928
26940
 
26929
26941
  /***/ })