akeyless-client-commons 1.1.17-test.8 → 1.1.18

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.
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- function _array_like_to_array(arr, len) {
3
- if (len == null || len > arr.length) len = arr.length;
4
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
- return arr2;
6
- }
7
- function _array_with_holes(arr) {
8
- if (Array.isArray(arr)) return arr;
9
- }
10
- function _array_without_holes(arr) {
11
- if (Array.isArray(arr)) return _array_like_to_array(arr);
12
- }
13
2
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
3
  try {
15
4
  var info = gen[key](arg);
@@ -39,25 +28,6 @@ function _async_to_generator(fn) {
39
28
  });
40
29
  };
41
30
  }
42
- function _class_call_check(instance, Constructor) {
43
- if (!(instance instanceof Constructor)) {
44
- throw new TypeError("Cannot call a class as a function");
45
- }
46
- }
47
- function _defineProperties(target, props) {
48
- for(var i = 0; i < props.length; i++){
49
- var descriptor = props[i];
50
- descriptor.enumerable = descriptor.enumerable || false;
51
- descriptor.configurable = true;
52
- if ("value" in descriptor) descriptor.writable = true;
53
- Object.defineProperty(target, descriptor.key, descriptor);
54
- }
55
- }
56
- function _create_class(Constructor, protoProps, staticProps) {
57
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
58
- if (staticProps) _defineProperties(Constructor, staticProps);
59
- return Constructor;
60
- }
61
31
  function _define_property(obj, key, value) {
62
32
  if (key in obj) {
63
33
  Object.defineProperty(obj, key, {
@@ -71,39 +41,6 @@ function _define_property(obj, key, value) {
71
41
  }
72
42
  return obj;
73
43
  }
74
- function _iterable_to_array(iter) {
75
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
76
- }
77
- function _iterable_to_array_limit(arr, i) {
78
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
79
- if (_i == null) return;
80
- var _arr = [];
81
- var _n = true;
82
- var _d = false;
83
- var _s, _e;
84
- try {
85
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
86
- _arr.push(_s.value);
87
- if (i && _arr.length === i) break;
88
- }
89
- } catch (err) {
90
- _d = true;
91
- _e = err;
92
- } finally{
93
- try {
94
- if (!_n && _i["return"] != null) _i["return"]();
95
- } finally{
96
- if (_d) throw _e;
97
- }
98
- }
99
- return _arr;
100
- }
101
- function _non_iterable_rest() {
102
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
103
- }
104
- function _non_iterable_spread() {
105
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
106
- }
107
44
  function _object_spread(target) {
108
45
  for(var i = 1; i < arguments.length; i++){
109
46
  var source = arguments[i] != null ? arguments[i] : {};
@@ -143,24 +80,10 @@ function _object_spread_props(target, source) {
143
80
  }
144
81
  return target;
145
82
  }
146
- function _sliced_to_array(arr, i) {
147
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
148
- }
149
- function _to_consumable_array(arr) {
150
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
151
- }
152
83
  function _type_of(obj) {
153
84
  "@swc/helpers - typeof";
154
85
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
155
86
  }
156
- function _unsupported_iterable_to_array(o, minLen) {
157
- if (!o) return;
158
- if (typeof o === "string") return _array_like_to_array(o, minLen);
159
- var n = Object.prototype.toString.call(o).slice(8, -1);
160
- if (n === "Object" && o.constructor) n = o.constructor.name;
161
- if (n === "Map" || n === "Set") return Array.from(n);
162
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
163
- }
164
87
  function _ts_generator(thisArg, body) {
165
88
  var f, y, t, g, _ = {
166
89
  label: 0,
@@ -332,20 +255,14 @@ __export(index_exports, {
332
255
  useSetUserCountry: function() {
333
256
  return useSetUserCountry;
334
257
  },
335
- useSmartSnapshot: function() {
336
- return useSmartSnapshot;
337
- },
338
258
  useSnapshotBulk: function() {
339
259
  return useSnapshotBulk;
340
- },
341
- useSocketSubscription: function() {
342
- return useSocketSubscription;
343
260
  }
344
261
  });
345
262
  module.exports = __toCommonJS(index_exports);
346
263
  // src/hooks/global.ts
347
264
  var import_akeyless_types_commons2 = require("akeyless-types-commons");
348
- var import_react5 = require("react");
265
+ var import_react3 = require("react");
349
266
  // src/helpers/firebase.ts
350
267
  var import_moment = __toESM(require("moment"));
351
268
  var import_app = require("firebase/app");
@@ -449,50 +366,6 @@ var simpleExtractData = function(doc2) {
449
366
  id: doc2.id
450
367
  });
451
368
  };
452
- var get_document_by_id = /*#__PURE__*/ function() {
453
- var _ref = _async_to_generator(function(collection_path, doc_id) {
454
- var doc_ref, doc_snap, error;
455
- return _ts_generator(this, function(_state) {
456
- switch(_state.label){
457
- case 0:
458
- _state.trys.push([
459
- 0,
460
- 2,
461
- ,
462
- 3
463
- ]);
464
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
465
- return [
466
- 4,
467
- (0, import_firestore.getDoc)(doc_ref)
468
- ];
469
- case 1:
470
- doc_snap = _state.sent();
471
- if (!doc_snap.exists()) {
472
- throw new Error("Document not found, document id: " + doc_id);
473
- }
474
- return [
475
- 2,
476
- simpleExtractData(doc_snap)
477
- ];
478
- case 2:
479
- error = _state.sent();
480
- console.error("Error from get_document_by_id", error);
481
- return [
482
- 2,
483
- null
484
- ];
485
- case 3:
486
- return [
487
- 2
488
- ];
489
- }
490
- });
491
- });
492
- return function get_document_by_id(collection_path, doc_id) {
493
- return _ref.apply(this, arguments);
494
- };
495
- }();
496
369
  var snapshot = function(config, snapshotsFirstTime, settings) {
497
370
  var resolvePromise;
498
371
  var isResolved = false;
@@ -640,300 +513,6 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
640
513
  var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
641
514
  var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
642
515
  var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
643
- var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
644
- var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
645
- // src/helpers/socket.ts
646
- var import_socket = require("socket.io-client");
647
- var SocketService = /*#__PURE__*/ function() {
648
- "use strict";
649
- function _SocketService() {
650
- _class_call_check(this, _SocketService);
651
- this.socket = null;
652
- this.connectCallbacks = [];
653
- this.disconnectCallbacks = [];
654
- this.authToken = null;
655
- }
656
- _create_class(_SocketService, [
657
- {
658
- /// Initialize the socket connection
659
- key: "initSocket",
660
- value: function initSocket() {
661
- var _this = this;
662
- if (!this.socket) {
663
- var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
664
- this.socket = (0, import_socket.io)(socketUrl, {
665
- path: "/api/data-socket/connect",
666
- transports: [
667
- "websocket"
668
- ],
669
- auth: this.authToken ? {
670
- token: this.authToken
671
- } : void 0
672
- });
673
- this.socket.on("connect", function() {
674
- var _this_socket;
675
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
676
- });
677
- this.connectCallbacks.forEach(function(cb) {
678
- return cb();
679
- });
680
- this.socket.on("disconnect", function(reason) {
681
- console.log("Socket disconnected:", reason);
682
- _this.disconnectCallbacks.forEach(function(cb) {
683
- return cb();
684
- });
685
- });
686
- this.socket.on("connect_error", function(error) {
687
- console.error("Socket connection error:", error);
688
- });
689
- }
690
- }
691
- },
692
- {
693
- /// get socket instance
694
- key: "getSocketInstance",
695
- value: function getSocketInstance() {
696
- if (!this.socket) {
697
- this.initSocket();
698
- }
699
- if (!this.socket) {
700
- throw new Error("Socket not initialized");
701
- }
702
- if (!this.socket.connected) {
703
- this.socket.connect();
704
- }
705
- return this.socket;
706
- }
707
- },
708
- {
709
- /// subscribe to collections
710
- key: "subscribeToCollections",
711
- value: function subscribeToCollections(config) {
712
- if (config.length === 0) {
713
- return function() {};
714
- }
715
- var s = this.getSocketInstance();
716
- var collectionsNames = config.map(function(c) {
717
- return c.collectionName;
718
- });
719
- var eventHandlers = [];
720
- config.forEach(function(configuration) {
721
- var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
722
- s.on("initial:".concat(collectionName), onFirstTime);
723
- eventHandlers.push({
724
- eventName: "initial:".concat(collectionName),
725
- handler: onFirstTime
726
- });
727
- s.on("add:".concat(collectionName), onAdd);
728
- eventHandlers.push({
729
- eventName: "add:".concat(collectionName),
730
- handler: onAdd
731
- });
732
- s.on("update:".concat(collectionName), onModify);
733
- eventHandlers.push({
734
- eventName: "update:".concat(collectionName),
735
- handler: onModify
736
- });
737
- s.on("delete:".concat(collectionName), onRemove);
738
- eventHandlers.push({
739
- eventName: "delete:".concat(collectionName),
740
- handler: onRemove
741
- });
742
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
743
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
744
- s.on("initial:".concat(collectionName), extraOnFirstTime);
745
- eventHandlers.push({
746
- eventName: "initial:".concat(collectionName),
747
- handler: extraOnFirstTime
748
- });
749
- s.on("add:".concat(collectionName), extraOnAdd);
750
- eventHandlers.push({
751
- eventName: "add:".concat(collectionName),
752
- handler: extraOnAdd
753
- });
754
- s.on("update:".concat(collectionName), extraOnModify);
755
- eventHandlers.push({
756
- eventName: "update:".concat(collectionName),
757
- handler: extraOnModify
758
- });
759
- s.on("delete:".concat(collectionName), extraOnRemove);
760
- eventHandlers.push({
761
- eventName: "delete:".concat(collectionName),
762
- handler: extraOnRemove
763
- });
764
- });
765
- });
766
- s.emit("subscribe_collections", collectionsNames, function(callback) {
767
- if (callback.success) {
768
- console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
769
- } else {
770
- console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
771
- }
772
- });
773
- return function() {
774
- console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
775
- s.emit("unsubscribe_collections", collectionsNames);
776
- eventHandlers.forEach(function(eh) {
777
- s.off(eh.eventName, eh.handler);
778
- });
779
- };
780
- }
781
- },
782
- {
783
- /// set data
784
- key: "setData",
785
- value: function setData(payload) {
786
- var s = this.getSocketInstance();
787
- return new Promise(function(resolve, reject) {
788
- s.emit("set_data", payload, function(callback) {
789
- if (callback.success) {
790
- console.log("Data saved successfully:", payload);
791
- console.log("ack", callback);
792
- resolve(callback);
793
- } else {
794
- reject(new Error(callback.message || "Save operation failed"));
795
- }
796
- });
797
- });
798
- }
799
- },
800
- {
801
- /// get data
802
- key: "getCollectionData",
803
- value: function getCollectionData(payload) {
804
- var s = this.getSocketInstance();
805
- s.emit("get_data", {
806
- collection_name: payload.collection_name
807
- }, function(socketCallback) {
808
- if (socketCallback.success && socketCallback.data) {
809
- payload.callback(socketCallback.data);
810
- } else {
811
- payload.callback(payload.defaultValue);
812
- }
813
- });
814
- }
815
- },
816
- {
817
- key: "getDocumentData",
818
- value: function getDocumentData(payload) {
819
- var s = this.getSocketInstance();
820
- s.emit("get_data", {
821
- collection_name: payload.collection_name,
822
- key: payload.key
823
- }, function(socketCallback) {
824
- if (socketCallback.success && socketCallback.data) {
825
- payload.callback(socketCallback.data);
826
- } else {
827
- payload.callback(payload.defaultValue);
828
- }
829
- });
830
- }
831
- },
832
- {
833
- /// delete data
834
- key: "deleteData",
835
- value: function deleteData(payload) {
836
- var s = this.getSocketInstance();
837
- return new Promise(function(resolve, reject) {
838
- s.emit("delete_data", payload, function(callback) {
839
- if (callback.success) {
840
- console.log("Data deleted successfully:", payload);
841
- console.log("delete ack", callback);
842
- resolve(callback);
843
- } else {
844
- reject(new Error(callback.message || "Delete operation failed"));
845
- }
846
- });
847
- });
848
- }
849
- },
850
- {
851
- key: "clearAllRedisData",
852
- value: function clearAllRedisData() {
853
- var s = this.getSocketInstance();
854
- return new Promise(function(resolve, reject) {
855
- s.emit("clear_all_redis_data", function(ack) {
856
- if (ack.success) {
857
- resolve(ack);
858
- } else {
859
- reject(new Error(ack.message || "Clear all Redis data operation failed"));
860
- }
861
- });
862
- });
863
- }
864
- },
865
- {
866
- /// connection management methods
867
- key: "onConnect",
868
- value: function onConnect(callback) {
869
- var _this_socket;
870
- this.connectCallbacks.push(callback);
871
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
872
- callback();
873
- }
874
- }
875
- },
876
- {
877
- key: "offConnect",
878
- value: function offConnect(callback) {
879
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
880
- return cb !== callback;
881
- });
882
- }
883
- },
884
- {
885
- key: "onDisconnect",
886
- value: function onDisconnect(callback) {
887
- this.disconnectCallbacks.push(callback);
888
- if (this.socket && !this.socket.connected) {
889
- callback();
890
- }
891
- }
892
- },
893
- {
894
- key: "offDisconnect",
895
- value: function offDisconnect(callback) {
896
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
897
- return cb !== callback;
898
- });
899
- }
900
- },
901
- {
902
- key: "isConnected",
903
- value: function isConnected() {
904
- var _this_socket;
905
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
906
- }
907
- },
908
- {
909
- key: "setAuthToken",
910
- value: function setAuthToken(token) {
911
- this.authToken = token;
912
- if (this.socket) {
913
- this.socket.auth = {
914
- token: token
915
- };
916
- if (this.socket.connected) {
917
- this.socket.disconnect();
918
- }
919
- this.socket.connect();
920
- }
921
- }
922
- }
923
- ], [
924
- {
925
- key: "getInstance",
926
- value: function getInstance() {
927
- if (!_SocketService.instance) {
928
- _SocketService.instance = new _SocketService();
929
- }
930
- return _SocketService.instance;
931
- }
932
- }
933
- ]);
934
- return _SocketService;
935
- }();
936
- var socketServiceInstance = SocketService.getInstance();
937
516
  // src/hooks/react.ts
938
517
  var import_lodash2 = require("lodash");
939
518
  var import_react2 = require("react");
@@ -962,78 +541,9 @@ function useDeepCompareEffect(effect, dependencies) {
962
541
  previousDepsRef.current
963
542
  ]);
964
543
  }
965
- // src/hooks/socket.ts
966
- var import_react3 = require("react");
967
- var useSocketSubscription = function(configs, label, settings) {
968
- var _ref = _sliced_to_array((0, import_react3.useState)(socketServiceInstance.isConnected()), 2), socketConnected = _ref[0], setSocketConnected = _ref[1];
969
- var _ref1 = _sliced_to_array((0, import_react3.useState)([]), 2), cleanupSubscriptions = _ref1[0], setCleanupSubscriptions = _ref1[1];
970
- useDeepCompareEffect(function() {
971
- if (!auth.currentUser) {
972
- return;
973
- }
974
- if (socketConnected) {
975
- setCleanupSubscriptions(function(prev) {
976
- return _to_consumable_array(prev).concat([
977
- socketServiceInstance.subscribeToCollections(configs)
978
- ]);
979
- });
980
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
981
- console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
982
- return c.collectionName;
983
- }).join(", ")));
984
- }
985
- } else {
986
- auth.currentUser.getIdToken().then(function(token) {
987
- socketServiceInstance.setAuthToken(token);
988
- socketServiceInstance.getSocketInstance();
989
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
990
- console.log("==> ".concat(label || "Cache snapshots", " started... "));
991
- }
992
- });
993
- }
994
- var uiOnConnect = function() {
995
- setSocketConnected(true);
996
- };
997
- var uiOnDisconnect = function() {
998
- cleanupSubscriptions.forEach(function(cleanup) {
999
- return cleanup();
1000
- });
1001
- setSocketConnected(false);
1002
- };
1003
- socketServiceInstance.onConnect(uiOnConnect);
1004
- socketServiceInstance.onDisconnect(uiOnDisconnect);
1005
- setSocketConnected(socketServiceInstance.isConnected());
1006
- return function() {
1007
- if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1008
- cleanupSubscriptions.forEach(function(cleanup) {
1009
- return cleanup();
1010
- });
1011
- socketServiceInstance.offConnect(uiOnConnect);
1012
- socketServiceInstance.offDisconnect(uiOnDisconnect);
1013
- }
1014
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1015
- console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1016
- }
1017
- };
1018
- }, [
1019
- socketConnected,
1020
- configs,
1021
- auth
1022
- ]);
1023
- (0, import_react3.useEffect)(function() {
1024
- return function() {
1025
- cleanupSubscriptions.forEach(function(cleanup) {
1026
- return cleanup();
1027
- });
1028
- };
1029
- }, []);
1030
- return {
1031
- socketConnected: socketConnected
1032
- };
1033
- };
1034
544
  // src/hooks/global.ts
1035
545
  var useDocumentTitle = function(title) {
1036
- (0, import_react5.useEffect)(function() {
546
+ (0, import_react3.useEffect)(function() {
1037
547
  document.title = title;
1038
548
  }, [
1039
549
  title
@@ -1041,12 +551,12 @@ var useDocumentTitle = function(title) {
1041
551
  return null;
1042
552
  };
1043
553
  var useSnapshotBulk = function(configs, label, settings) {
1044
- var snapshotsFirstTime = (0, import_react5.useRef)([]);
1045
- var unsubscribeFunctions = (0, import_react5.useRef)([]);
554
+ var snapshotsFirstTime = (0, import_react3.useRef)([]);
555
+ var unsubscribeFunctions = (0, import_react3.useRef)([]);
1046
556
  useDeepCompareEffect(function() {
1047
557
  var start = performance.now();
1048
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1049
- console.log("==> ".concat(label || "DB snapshots", " started from db... "));
558
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
559
+ console.log("==> ".concat(label || "Custom snapshots", " started... "));
1050
560
  }
1051
561
  var snapshotResults = configs.map(function(config) {
1052
562
  return snapshot(config, snapshotsFirstTime.current, settings);
@@ -1057,8 +567,8 @@ var useSnapshotBulk = function(configs, label, settings) {
1057
567
  Promise.all(snapshotResults.map(function(result) {
1058
568
  return result.promise;
1059
569
  })).then(function() {
1060
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1061
- console.log("==> ".concat(label || "DB snapshots", " ended from db. It took ").concat((performance.now() - start).toFixed(2), " ms"));
570
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
571
+ console.log("==> ".concat(label || "Custom snapshots", " ended. It took ").concat((performance.now() - start).toFixed(2), " ms"));
1062
572
  }
1063
573
  });
1064
574
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
@@ -1068,8 +578,8 @@ var useSnapshotBulk = function(configs, label, settings) {
1068
578
  unsubscribe();
1069
579
  }
1070
580
  });
1071
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1072
- console.log("==> ".concat(label || "DB snapshots", " unsubscribed from db"));
581
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
582
+ console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
1073
583
  }
1074
584
  };
1075
585
  }
@@ -1078,7 +588,7 @@ var useSnapshotBulk = function(configs, label, settings) {
1078
588
  label,
1079
589
  settings
1080
590
  ]);
1081
- (0, import_react5.useEffect)(function() {
591
+ (0, import_react3.useEffect)(function() {
1082
592
  return function() {
1083
593
  unsubscribeFunctions.current.forEach(function(unsubscribe) {
1084
594
  if (unsubscribe) {
@@ -1086,55 +596,13 @@ var useSnapshotBulk = function(configs, label, settings) {
1086
596
  }
1087
597
  });
1088
598
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1089
- console.log("==> ".concat(label || "DB snapshots", " unsubscribed"));
599
+ console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
1090
600
  }
1091
601
  };
1092
602
  }, []);
1093
603
  };
1094
- var useSmartSnapshot = function(configs, label, settings) {
1095
- var _ref = _sliced_to_array((0, import_react5.useState)(null), 2), cacheCollectionsConfig = _ref[0], setCacheCollectionsConfig = _ref[1];
1096
- (0, import_react5.useEffect)(function() {
1097
- get_document_by_id("nx-settings", "cache_collections_config").then(function(res) {
1098
- return setCacheCollectionsConfig(res);
1099
- });
1100
- return function() {
1101
- return setCacheCollectionsConfig(null);
1102
- };
1103
- }, []);
1104
- var groupedConfig = (0, import_react5.useMemo)(function() {
1105
- if (!cacheCollectionsConfig) {
1106
- return {
1107
- configForDb: [],
1108
- configForCache: []
1109
- };
1110
- }
1111
- var configForDb = [];
1112
- var configForCache = [];
1113
- configs.forEach(function(cfg) {
1114
- var collectionName = cfg.collectionName, _cfg_subscribeTo = cfg.subscribeTo, subscribeTo = _cfg_subscribeTo === void 0 ? "cache" : _cfg_subscribeTo;
1115
- if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName]) {
1116
- configForCache.push(cfg);
1117
- } else {
1118
- configForDb.push(cfg);
1119
- }
1120
- });
1121
- return {
1122
- configForDb: configForDb,
1123
- configForCache: configForCache
1124
- };
1125
- }, [
1126
- configs,
1127
- cacheCollectionsConfig
1128
- ]);
1129
- useSnapshotBulk(groupedConfig.configForDb, label, settings);
1130
- var socketConnected = useSocketSubscription(groupedConfig.configForCache, label, settings).socketConnected;
1131
- return {
1132
- groupedConfig: groupedConfig,
1133
- socketConnected: socketConnected
1134
- };
1135
- };
1136
604
  var useSetUserCountry = function(setUserCountry, changLang) {
1137
- (0, import_react5.useLayoutEffect)(function() {
605
+ (0, import_react3.useLayoutEffect)(function() {
1138
606
  var currentCountry = localStorage.getItem("userCountry");
1139
607
  if (!currentCountry) {
1140
608
  var updateCountry = /*#__PURE__*/ function() {
@@ -1168,7 +636,7 @@ var useSetUserCountry = function(setUserCountry, changLang) {
1168
636
  return null;
1169
637
  };
1170
638
  // src/hooks/WebWorker.ts
1171
- var import_react7 = require("react");
639
+ var import_react5 = require("react");
1172
640
  // Annotate the CommonJS export names for ESM import in node:
1173
641
  0 && (module.exports = {
1174
642
  useDeepCompareEffect: useDeepCompareEffect,
@@ -1176,8 +644,6 @@ var import_react7 = require("react");
1176
644
  useDocumentTitle: useDocumentTitle,
1177
645
  useSafeEffect: useSafeEffect,
1178
646
  useSetUserCountry: useSetUserCountry,
1179
- useSmartSnapshot: useSmartSnapshot,
1180
- useSnapshotBulk: useSnapshotBulk,
1181
- useSocketSubscription: useSocketSubscription
647
+ useSnapshotBulk: useSnapshotBulk
1182
648
  });
1183
649
  //# sourceMappingURL=index.js.map