akeyless-client-commons 1.1.12 → 1.1.13

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.
@@ -36,8 +36,8 @@ declare const useSmartSnapshot: (configs: OnSnapshotConfig[], label?: string, se
36
36
  disableLogs?: boolean;
37
37
  }) => {
38
38
  groupedConfig: {
39
- configForDb: any[];
40
- configForCache: any[];
39
+ configForDb: OnSnapshotConfig[];
40
+ configForCache: OnSnapshotConfig[];
41
41
  };
42
42
  socketConnected: boolean;
43
43
  };
@@ -47,7 +47,7 @@ declare function useSafeEffect(callback: () => void, dependencies: any[], error_
47
47
  declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
48
48
  declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
49
49
 
50
- declare const useSocketSubscription: (config: OnSnapshotConfig[], label?: string, settings?: {
50
+ declare const useSocketSubscription: (configs: OnSnapshotConfig[], label?: string, settings?: {
51
51
  cleanupForConfigChange?: boolean;
52
52
  disableLogs?: boolean;
53
53
  }) => {
@@ -36,8 +36,8 @@ declare const useSmartSnapshot: (configs: OnSnapshotConfig[], label?: string, se
36
36
  disableLogs?: boolean;
37
37
  }) => {
38
38
  groupedConfig: {
39
- configForDb: any[];
40
- configForCache: any[];
39
+ configForDb: OnSnapshotConfig[];
40
+ configForCache: OnSnapshotConfig[];
41
41
  };
42
42
  socketConnected: boolean;
43
43
  };
@@ -47,7 +47,7 @@ declare function useSafeEffect(callback: () => void, dependencies: any[], error_
47
47
  declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
48
48
  declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
49
49
 
50
- declare const useSocketSubscription: (config: OnSnapshotConfig[], label?: string, settings?: {
50
+ declare const useSocketSubscription: (configs: OnSnapshotConfig[], label?: string, settings?: {
51
51
  cleanupForConfigChange?: boolean;
52
52
  disableLogs?: boolean;
53
53
  }) => {
@@ -941,21 +941,26 @@ function useDeepCompareEffect(effect, dependencies) {
941
941
  }
942
942
  // src/hooks/socket.ts
943
943
  var import_react3 = require("react");
944
- var useSocketSubscription = function(config, label, settings) {
944
+ var useSocketSubscription = function(configs, label, settings) {
945
945
  var _ref = _sliced_to_array((0, import_react3.useState)(socketServiceInstance.isConnected()), 2), socketConnected = _ref[0], setSocketConnected = _ref[1];
946
946
  var _ref1 = _sliced_to_array((0, import_react3.useState)([]), 2), cleanupSubscriptions = _ref1[0], setCleanupSubscriptions = _ref1[1];
947
947
  useDeepCompareEffect(function() {
948
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
949
- console.log("==> ".concat(label || "Custom snapshots", " started from cache... "));
950
- }
951
948
  if (socketConnected) {
952
949
  setCleanupSubscriptions(function(prev) {
953
950
  return _to_consumable_array(prev).concat([
954
- socketServiceInstance.subscribeToCollections(config)
951
+ socketServiceInstance.subscribeToCollections(configs)
955
952
  ]);
956
953
  });
954
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
955
+ console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
956
+ return c.collectionName;
957
+ }).join(", ")));
958
+ }
957
959
  } else {
958
960
  socketServiceInstance.getSocketInstance();
961
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
962
+ console.log("==> ".concat(label || "Cache snapshots", " started... "));
963
+ }
959
964
  }
960
965
  var uiOnConnect = function() {
961
966
  setSocketConnected(true);
@@ -970,8 +975,8 @@ var useSocketSubscription = function(config, label, settings) {
970
975
  socketServiceInstance.onDisconnect(uiOnDisconnect);
971
976
  setSocketConnected(socketServiceInstance.isConnected());
972
977
  return function() {
973
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
974
- console.log("==> ".concat(label || "Custom snapshots", " stopped from cache... "));
978
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
979
+ console.log("==> ".concat(label || "Cache snapshots", " stopped. "));
975
980
  }
976
981
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
977
982
  cleanupSubscriptions.forEach(function(cleanup) {
@@ -982,7 +987,8 @@ var useSocketSubscription = function(config, label, settings) {
982
987
  }
983
988
  };
984
989
  }, [
985
- socketConnected
990
+ socketConnected,
991
+ configs
986
992
  ]);
987
993
  (0, import_react3.useEffect)(function() {
988
994
  return function() {
@@ -1009,8 +1015,8 @@ var useSnapshotBulk = function(configs, label, settings) {
1009
1015
  var unsubscribeFunctions = (0, import_react5.useRef)([]);
1010
1016
  useDeepCompareEffect(function() {
1011
1017
  var start = performance.now();
1012
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1013
- console.log("==> ".concat(label || "Custom snapshots", " started from db... "));
1018
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1019
+ console.log("==> ".concat(label || "DB snapshots", " started from db... "));
1014
1020
  }
1015
1021
  var snapshotResults = configs.map(function(config) {
1016
1022
  return snapshot(config, snapshotsFirstTime.current, settings);
@@ -1021,8 +1027,8 @@ var useSnapshotBulk = function(configs, label, settings) {
1021
1027
  Promise.all(snapshotResults.map(function(result) {
1022
1028
  return result.promise;
1023
1029
  })).then(function() {
1024
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1025
- console.log("==> ".concat(label || "Custom snapshots", " ended from db. It took ").concat((performance.now() - start).toFixed(2), " ms"));
1030
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1031
+ console.log("==> ".concat(label || "DB snapshots", " ended from db. It took ").concat((performance.now() - start).toFixed(2), " ms"));
1026
1032
  }
1027
1033
  });
1028
1034
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
@@ -1032,8 +1038,8 @@ var useSnapshotBulk = function(configs, label, settings) {
1032
1038
  unsubscribe();
1033
1039
  }
1034
1040
  });
1035
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1036
- console.log("==> ".concat(label || "Custom snapshots", " unsubscribed from db"));
1041
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1042
+ console.log("==> ".concat(label || "DB snapshots", " unsubscribed from db"));
1037
1043
  }
1038
1044
  };
1039
1045
  }
@@ -1050,7 +1056,7 @@ var useSnapshotBulk = function(configs, label, settings) {
1050
1056
  }
1051
1057
  });
1052
1058
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1053
- console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
1059
+ console.log("==> ".concat(label || "DB snapshots", " unsubscribed"));
1054
1060
  }
1055
1061
  };
1056
1062
  }, []);
@@ -1065,7 +1071,7 @@ var useSmartSnapshot = function(configs, label, settings) {
1065
1071
  return setCacheCollectionsConfig(null);
1066
1072
  };
1067
1073
  }, []);
1068
- var groupedConfig = useDeepCompareMemo(function() {
1074
+ var groupedConfig = (0, import_react5.useMemo)(function() {
1069
1075
  if (!cacheCollectionsConfig) {
1070
1076
  return {
1071
1077
  configForDb: [],
@@ -253,7 +253,7 @@ function _ts_generator(thisArg, body) {
253
253
  }
254
254
  }
255
255
  import { CountryOptions as CountryOptions2 } from "akeyless-types-commons";
256
- import { useEffect as useEffect3, useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
256
+ import { useEffect as useEffect3, useLayoutEffect, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
257
257
  // src/helpers/firebase.ts
258
258
  import moment from "moment";
259
259
  import { initializeApp } from "firebase/app";
@@ -847,21 +847,26 @@ function useDeepCompareEffect(effect, dependencies) {
847
847
  }
848
848
  // src/hooks/socket.ts
849
849
  import { useEffect as useEffect2, useState } from "react";
850
- var useSocketSubscription = function(config, label, settings) {
850
+ var useSocketSubscription = function(configs, label, settings) {
851
851
  var _useState = _sliced_to_array(useState(socketServiceInstance.isConnected()), 2), socketConnected = _useState[0], setSocketConnected = _useState[1];
852
852
  var _useState1 = _sliced_to_array(useState([]), 2), cleanupSubscriptions = _useState1[0], setCleanupSubscriptions = _useState1[1];
853
853
  useDeepCompareEffect(function() {
854
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
855
- console.log("==> ".concat(label || "Custom snapshots", " started from cache... "));
856
- }
857
854
  if (socketConnected) {
858
855
  setCleanupSubscriptions(function(prev) {
859
856
  return _to_consumable_array(prev).concat([
860
- socketServiceInstance.subscribeToCollections(config)
857
+ socketServiceInstance.subscribeToCollections(configs)
861
858
  ]);
862
859
  });
860
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
861
+ console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
862
+ return c.collectionName;
863
+ }).join(", ")));
864
+ }
863
865
  } else {
864
866
  socketServiceInstance.getSocketInstance();
867
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
868
+ console.log("==> ".concat(label || "Cache snapshots", " started... "));
869
+ }
865
870
  }
866
871
  var uiOnConnect = function() {
867
872
  setSocketConnected(true);
@@ -876,8 +881,8 @@ var useSocketSubscription = function(config, label, settings) {
876
881
  socketServiceInstance.onDisconnect(uiOnDisconnect);
877
882
  setSocketConnected(socketServiceInstance.isConnected());
878
883
  return function() {
879
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
880
- console.log("==> ".concat(label || "Custom snapshots", " stopped from cache... "));
884
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
885
+ console.log("==> ".concat(label || "Cache snapshots", " stopped. "));
881
886
  }
882
887
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
883
888
  cleanupSubscriptions.forEach(function(cleanup) {
@@ -888,7 +893,8 @@ var useSocketSubscription = function(config, label, settings) {
888
893
  }
889
894
  };
890
895
  }, [
891
- socketConnected
896
+ socketConnected,
897
+ configs
892
898
  ]);
893
899
  useEffect2(function() {
894
900
  return function() {
@@ -915,8 +921,8 @@ var useSnapshotBulk = function(configs, label, settings) {
915
921
  var unsubscribeFunctions = useRef2([]);
916
922
  useDeepCompareEffect(function() {
917
923
  var start = performance.now();
918
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
919
- console.log("==> ".concat(label || "Custom snapshots", " started from db... "));
924
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
925
+ console.log("==> ".concat(label || "DB snapshots", " started from db... "));
920
926
  }
921
927
  var snapshotResults = configs.map(function(config) {
922
928
  return snapshot(config, snapshotsFirstTime.current, settings);
@@ -927,8 +933,8 @@ var useSnapshotBulk = function(configs, label, settings) {
927
933
  Promise.all(snapshotResults.map(function(result) {
928
934
  return result.promise;
929
935
  })).then(function() {
930
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
931
- console.log("==> ".concat(label || "Custom snapshots", " ended from db. It took ").concat((performance.now() - start).toFixed(2), " ms"));
936
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
937
+ console.log("==> ".concat(label || "DB snapshots", " ended from db. It took ").concat((performance.now() - start).toFixed(2), " ms"));
932
938
  }
933
939
  });
934
940
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
@@ -938,8 +944,8 @@ var useSnapshotBulk = function(configs, label, settings) {
938
944
  unsubscribe();
939
945
  }
940
946
  });
941
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
942
- console.log("==> ".concat(label || "Custom snapshots", " unsubscribed from db"));
947
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
948
+ console.log("==> ".concat(label || "DB snapshots", " unsubscribed from db"));
943
949
  }
944
950
  };
945
951
  }
@@ -956,7 +962,7 @@ var useSnapshotBulk = function(configs, label, settings) {
956
962
  }
957
963
  });
958
964
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
959
- console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
965
+ console.log("==> ".concat(label || "DB snapshots", " unsubscribed"));
960
966
  }
961
967
  };
962
968
  }, []);
@@ -971,7 +977,7 @@ var useSmartSnapshot = function(configs, label, settings) {
971
977
  return setCacheCollectionsConfig(null);
972
978
  };
973
979
  }, []);
974
- var groupedConfig = useDeepCompareMemo(function() {
980
+ var groupedConfig = useMemo2(function() {
975
981
  if (!cacheCollectionsConfig) {
976
982
  return {
977
983
  configForDb: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",