akeyless-client-commons 1.0.227 → 1.0.228
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.
- package/dist/components/index.js +280 -9
- package/dist/components/index.mjs +280 -9
- package/dist/helpers/index.d.mts +34 -2
- package/dist/helpers/index.d.ts +34 -2
- package/dist/helpers/index.js +295 -0
- package/dist/helpers/index.mjs +292 -1
- package/dist/hooks/index.d.mts +5 -1
- package/dist/hooks/index.d.ts +5 -1
- package/dist/hooks/index.js +374 -1
- package/dist/hooks/index.mjs +370 -1
- package/package.json +4 -2
package/dist/hooks/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
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
|
+
}
|
|
2
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
11
|
try {
|
|
4
12
|
var info = gen[key](arg);
|
|
@@ -28,6 +36,25 @@ function _async_to_generator(fn) {
|
|
|
28
36
|
});
|
|
29
37
|
};
|
|
30
38
|
}
|
|
39
|
+
function _class_call_check(instance, Constructor) {
|
|
40
|
+
if (!(instance instanceof Constructor)) {
|
|
41
|
+
throw new TypeError("Cannot call a class as a function");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _defineProperties(target, props) {
|
|
45
|
+
for(var i = 0; i < props.length; i++){
|
|
46
|
+
var descriptor = props[i];
|
|
47
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
48
|
+
descriptor.configurable = true;
|
|
49
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
50
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
54
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
55
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
56
|
+
return Constructor;
|
|
57
|
+
}
|
|
31
58
|
function _define_property(obj, key, value) {
|
|
32
59
|
if (key in obj) {
|
|
33
60
|
Object.defineProperty(obj, key, {
|
|
@@ -41,6 +68,33 @@ function _define_property(obj, key, value) {
|
|
|
41
68
|
}
|
|
42
69
|
return obj;
|
|
43
70
|
}
|
|
71
|
+
function _iterable_to_array_limit(arr, i) {
|
|
72
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
73
|
+
if (_i == null) return;
|
|
74
|
+
var _arr = [];
|
|
75
|
+
var _n = true;
|
|
76
|
+
var _d = false;
|
|
77
|
+
var _s, _e;
|
|
78
|
+
try {
|
|
79
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
80
|
+
_arr.push(_s.value);
|
|
81
|
+
if (i && _arr.length === i) break;
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
_d = true;
|
|
85
|
+
_e = err;
|
|
86
|
+
} finally{
|
|
87
|
+
try {
|
|
88
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
89
|
+
} finally{
|
|
90
|
+
if (_d) throw _e;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return _arr;
|
|
94
|
+
}
|
|
95
|
+
function _non_iterable_rest() {
|
|
96
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
97
|
+
}
|
|
44
98
|
function _object_spread(target) {
|
|
45
99
|
for(var i = 1; i < arguments.length; i++){
|
|
46
100
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -80,10 +134,21 @@ function _object_spread_props(target, source) {
|
|
|
80
134
|
}
|
|
81
135
|
return target;
|
|
82
136
|
}
|
|
137
|
+
function _sliced_to_array(arr, i) {
|
|
138
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
139
|
+
}
|
|
83
140
|
function _type_of(obj) {
|
|
84
141
|
"@swc/helpers - typeof";
|
|
85
142
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
86
143
|
}
|
|
144
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
145
|
+
if (!o) return;
|
|
146
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
147
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
148
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
149
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
150
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
151
|
+
}
|
|
87
152
|
function _ts_generator(thisArg, body) {
|
|
88
153
|
var f, y, t, g, _ = {
|
|
89
154
|
label: 0,
|
|
@@ -257,6 +322,9 @@ __export(index_exports, {
|
|
|
257
322
|
},
|
|
258
323
|
useSnapshotBulk: function() {
|
|
259
324
|
return useSnapshotBulk;
|
|
325
|
+
},
|
|
326
|
+
useSocketSubscription: function() {
|
|
327
|
+
return useSocketSubscription;
|
|
260
328
|
}
|
|
261
329
|
});
|
|
262
330
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -513,6 +581,278 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
513
581
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
514
582
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
515
583
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
584
|
+
// src/helpers/socket.ts
|
|
585
|
+
var import_socket = require("socket.io-client");
|
|
586
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
587
|
+
"use strict";
|
|
588
|
+
function _SocketService() {
|
|
589
|
+
_class_call_check(this, _SocketService);
|
|
590
|
+
this.socket = null;
|
|
591
|
+
this.connectCallbacks = [];
|
|
592
|
+
this.disconnectCallbacks = [];
|
|
593
|
+
this.initSocket();
|
|
594
|
+
}
|
|
595
|
+
_create_class(_SocketService, [
|
|
596
|
+
{
|
|
597
|
+
/// Initialize the socket connection
|
|
598
|
+
key: "initSocket",
|
|
599
|
+
value: function initSocket() {
|
|
600
|
+
var _this = this;
|
|
601
|
+
if (!this.socket) {
|
|
602
|
+
var SOCKET_SERVER_URL = "http://localhost:9009";
|
|
603
|
+
var SOCKET_PATH = "/api/data-socket/connect";
|
|
604
|
+
this.socket = (0, import_socket.io)(SOCKET_SERVER_URL, {
|
|
605
|
+
path: SOCKET_PATH,
|
|
606
|
+
transports: [
|
|
607
|
+
"websocket"
|
|
608
|
+
]
|
|
609
|
+
});
|
|
610
|
+
this.socket.on("connect", function() {
|
|
611
|
+
var _this_socket;
|
|
612
|
+
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
613
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
614
|
+
return cb();
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
this.socket.on("disconnect", function(reason) {
|
|
618
|
+
console.log("Socket disconnected:", reason);
|
|
619
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
620
|
+
return cb();
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
this.socket.on("connect_error", function(error) {
|
|
624
|
+
console.error("Socket connection error:", error);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
/// get socket instance
|
|
631
|
+
key: "getSocketInstance",
|
|
632
|
+
value: function getSocketInstance() {
|
|
633
|
+
if (!this.socket) {
|
|
634
|
+
this.initSocket();
|
|
635
|
+
}
|
|
636
|
+
if (!this.socket) {
|
|
637
|
+
throw new Error("Socket not initialized");
|
|
638
|
+
}
|
|
639
|
+
if (!this.socket.connected) {
|
|
640
|
+
this.socket.connect();
|
|
641
|
+
}
|
|
642
|
+
return this.socket;
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
/// subscribe to collections
|
|
647
|
+
key: "subscribeToCollections",
|
|
648
|
+
value: function subscribeToCollections(config) {
|
|
649
|
+
var s = this.getSocketInstance();
|
|
650
|
+
var collectionsNames = config.map(function(c) {
|
|
651
|
+
return c.collectionName;
|
|
652
|
+
});
|
|
653
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
654
|
+
if (callback.success) {
|
|
655
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
656
|
+
} else {
|
|
657
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
var eventHandlers = [];
|
|
661
|
+
config.forEach(function(configuration) {
|
|
662
|
+
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;
|
|
663
|
+
s.on("initial:".concat(collectionName), onFirstTime);
|
|
664
|
+
eventHandlers.push({
|
|
665
|
+
eventName: "initial:".concat(collectionName),
|
|
666
|
+
handler: onFirstTime
|
|
667
|
+
});
|
|
668
|
+
s.on("add:".concat(collectionName), onAdd);
|
|
669
|
+
eventHandlers.push({
|
|
670
|
+
eventName: "add:".concat(collectionName),
|
|
671
|
+
handler: onAdd
|
|
672
|
+
});
|
|
673
|
+
s.on("update:".concat(collectionName), onModify);
|
|
674
|
+
eventHandlers.push({
|
|
675
|
+
eventName: "update:".concat(collectionName),
|
|
676
|
+
handler: onModify
|
|
677
|
+
});
|
|
678
|
+
s.on("delete:".concat(collectionName), onRemove);
|
|
679
|
+
eventHandlers.push({
|
|
680
|
+
eventName: "delete:".concat(collectionName),
|
|
681
|
+
handler: onRemove
|
|
682
|
+
});
|
|
683
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
684
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
685
|
+
s.on("initial:".concat(collectionName), extraOnFirstTime);
|
|
686
|
+
eventHandlers.push({
|
|
687
|
+
eventName: "initial:".concat(collectionName),
|
|
688
|
+
handler: extraOnFirstTime
|
|
689
|
+
});
|
|
690
|
+
s.on("add:".concat(collectionName), extraOnAdd);
|
|
691
|
+
eventHandlers.push({
|
|
692
|
+
eventName: "add:".concat(collectionName),
|
|
693
|
+
handler: extraOnAdd
|
|
694
|
+
});
|
|
695
|
+
s.on("update:".concat(collectionName), extraOnModify);
|
|
696
|
+
eventHandlers.push({
|
|
697
|
+
eventName: "update:".concat(collectionName),
|
|
698
|
+
handler: extraOnModify
|
|
699
|
+
});
|
|
700
|
+
s.on("delete:".concat(collectionName), extraOnRemove);
|
|
701
|
+
eventHandlers.push({
|
|
702
|
+
eventName: "delete:".concat(collectionName),
|
|
703
|
+
handler: extraOnRemove
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
return function() {
|
|
708
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
709
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
710
|
+
eventHandlers.forEach(function(eh) {
|
|
711
|
+
s.off(eh.eventName, eh.handler);
|
|
712
|
+
});
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
/// set data
|
|
718
|
+
key: "setData",
|
|
719
|
+
value: function setData(payload) {
|
|
720
|
+
var s = this.getSocketInstance();
|
|
721
|
+
return new Promise(function(resolve, reject) {
|
|
722
|
+
s.emit("set_data", payload, function(callback) {
|
|
723
|
+
if (callback.success) {
|
|
724
|
+
console.log("Data saved successfully:", payload);
|
|
725
|
+
console.log("ack", callback);
|
|
726
|
+
resolve(callback);
|
|
727
|
+
} else {
|
|
728
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
/// get data
|
|
736
|
+
key: "getCollectionData",
|
|
737
|
+
value: function getCollectionData(payload) {
|
|
738
|
+
var s = this.getSocketInstance();
|
|
739
|
+
s.emit("get_data", {
|
|
740
|
+
collection_name: payload.collection_name
|
|
741
|
+
}, function(socketCallback) {
|
|
742
|
+
if (socketCallback.success && socketCallback.data) {
|
|
743
|
+
payload.callback(socketCallback.data);
|
|
744
|
+
} else {
|
|
745
|
+
payload.callback(payload.defaultValue);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
key: "getDocumentData",
|
|
752
|
+
value: function getDocumentData(payload) {
|
|
753
|
+
var s = this.getSocketInstance();
|
|
754
|
+
s.emit("get_data", {
|
|
755
|
+
collection_name: payload.collection_name,
|
|
756
|
+
key: payload.key
|
|
757
|
+
}, function(socketCallback) {
|
|
758
|
+
if (socketCallback.success && socketCallback.data) {
|
|
759
|
+
payload.callback(socketCallback.data);
|
|
760
|
+
} else {
|
|
761
|
+
payload.callback(payload.defaultValue);
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
/// delete data
|
|
768
|
+
key: "deleteData",
|
|
769
|
+
value: function deleteData(payload) {
|
|
770
|
+
var s = this.getSocketInstance();
|
|
771
|
+
return new Promise(function(resolve, reject) {
|
|
772
|
+
s.emit("delete_data", payload, function(callback) {
|
|
773
|
+
if (callback.success) {
|
|
774
|
+
console.log("Data deleted successfully:", payload);
|
|
775
|
+
console.log("delete ack", callback);
|
|
776
|
+
resolve(callback);
|
|
777
|
+
} else {
|
|
778
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
key: "clearAllRedisData",
|
|
786
|
+
value: function clearAllRedisData() {
|
|
787
|
+
var s = this.getSocketInstance();
|
|
788
|
+
return new Promise(function(resolve, reject) {
|
|
789
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
790
|
+
if (ack.success) {
|
|
791
|
+
resolve(ack);
|
|
792
|
+
} else {
|
|
793
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
/// connection management methods
|
|
801
|
+
key: "onConnect",
|
|
802
|
+
value: function onConnect(callback) {
|
|
803
|
+
var _this_socket;
|
|
804
|
+
this.connectCallbacks.push(callback);
|
|
805
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
806
|
+
callback();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
key: "offConnect",
|
|
812
|
+
value: function offConnect(callback) {
|
|
813
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
814
|
+
return cb !== callback;
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
key: "onDisconnect",
|
|
820
|
+
value: function onDisconnect(callback) {
|
|
821
|
+
this.disconnectCallbacks.push(callback);
|
|
822
|
+
if (this.socket && !this.socket.connected) {
|
|
823
|
+
callback();
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
key: "offDisconnect",
|
|
829
|
+
value: function offDisconnect(callback) {
|
|
830
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
831
|
+
return cb !== callback;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
key: "isConnected",
|
|
837
|
+
value: function isConnected() {
|
|
838
|
+
var _this_socket;
|
|
839
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
], [
|
|
843
|
+
{
|
|
844
|
+
key: "getInstance",
|
|
845
|
+
value: function getInstance() {
|
|
846
|
+
if (!_SocketService.instance) {
|
|
847
|
+
_SocketService.instance = new _SocketService();
|
|
848
|
+
}
|
|
849
|
+
return _SocketService.instance;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
]);
|
|
853
|
+
return _SocketService;
|
|
854
|
+
}();
|
|
855
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
516
856
|
// src/hooks/react.ts
|
|
517
857
|
var import_lodash2 = require("lodash");
|
|
518
858
|
var import_react2 = require("react");
|
|
@@ -637,6 +977,38 @@ var useSetUserCountry = function(setUserCountry, changLang) {
|
|
|
637
977
|
};
|
|
638
978
|
// src/hooks/WebWorker.ts
|
|
639
979
|
var import_react5 = require("react");
|
|
980
|
+
// src/hooks/socket.ts
|
|
981
|
+
var import_react6 = require("react");
|
|
982
|
+
var useSocketSubscription = function(config) {
|
|
983
|
+
var _ref = _sliced_to_array((0, import_react6.useState)(socketServiceInstance.isConnected()), 2), socketConnected = _ref[0], setSocketConnected = _ref[1];
|
|
984
|
+
(0, import_react6.useEffect)(function() {
|
|
985
|
+
var cleanupSubscriptions;
|
|
986
|
+
if (socketConnected) {
|
|
987
|
+
cleanupSubscriptions = socketServiceInstance.subscribeToCollections(config);
|
|
988
|
+
}
|
|
989
|
+
var uiOnConnect = function() {
|
|
990
|
+
setSocketConnected(true);
|
|
991
|
+
};
|
|
992
|
+
var uiOnDisconnect = function() {
|
|
993
|
+
cleanupSubscriptions === null || cleanupSubscriptions === void 0 ? void 0 : cleanupSubscriptions();
|
|
994
|
+
setSocketConnected(false);
|
|
995
|
+
};
|
|
996
|
+
socketServiceInstance.onConnect(uiOnConnect);
|
|
997
|
+
socketServiceInstance.onDisconnect(uiOnDisconnect);
|
|
998
|
+
setSocketConnected(socketServiceInstance.isConnected());
|
|
999
|
+
return function() {
|
|
1000
|
+
console.log("cleanupSubscriptions");
|
|
1001
|
+
cleanupSubscriptions === null || cleanupSubscriptions === void 0 ? void 0 : cleanupSubscriptions();
|
|
1002
|
+
socketServiceInstance.offConnect(uiOnConnect);
|
|
1003
|
+
socketServiceInstance.offDisconnect(uiOnDisconnect);
|
|
1004
|
+
};
|
|
1005
|
+
}, [
|
|
1006
|
+
socketConnected
|
|
1007
|
+
]);
|
|
1008
|
+
return {
|
|
1009
|
+
socketConnected: socketConnected
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
640
1012
|
// Annotate the CommonJS export names for ESM import in node:
|
|
641
1013
|
0 && (module.exports = {
|
|
642
1014
|
useDeepCompareEffect: useDeepCompareEffect,
|
|
@@ -644,6 +1016,7 @@ var import_react5 = require("react");
|
|
|
644
1016
|
useDocumentTitle: useDocumentTitle,
|
|
645
1017
|
useSafeEffect: useSafeEffect,
|
|
646
1018
|
useSetUserCountry: useSetUserCountry,
|
|
647
|
-
useSnapshotBulk: useSnapshotBulk
|
|
1019
|
+
useSnapshotBulk: useSnapshotBulk,
|
|
1020
|
+
useSocketSubscription: useSocketSubscription
|
|
648
1021
|
});
|
|
649
1022
|
//# sourceMappingURL=index.js.map
|