akeyless-client-commons 1.1.7 → 1.1.9
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 +277 -6
- package/dist/components/index.mjs +277 -6
- package/dist/helpers/index.d.mts +36 -2
- package/dist/helpers/index.d.ts +36 -2
- package/dist/helpers/index.js +294 -0
- package/dist/helpers/index.mjs +291 -1
- package/dist/hooks/index.d.mts +21 -1
- package/dist/hooks/index.d.ts +21 -1
- package/dist/hooks/index.js +463 -1
- package/dist/hooks/index.mjs +455 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +4 -2
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// src/hooks/global.ts
|
|
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,6 +134,17 @@ 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
|
+
}
|
|
140
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
141
|
+
if (!o) return;
|
|
142
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
143
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
144
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
145
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
146
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
147
|
+
}
|
|
83
148
|
function _ts_generator(thisArg, body) {
|
|
84
149
|
var f, y, t, g, _ = {
|
|
85
150
|
label: 0,
|
|
@@ -279,6 +344,50 @@ var simpleExtractData = function(doc2) {
|
|
|
279
344
|
id: doc2.id
|
|
280
345
|
});
|
|
281
346
|
};
|
|
347
|
+
var get_document_by_id = /*#__PURE__*/ function() {
|
|
348
|
+
var _ref = _async_to_generator(function(collection_path, doc_id) {
|
|
349
|
+
var doc_ref, doc_snap, error;
|
|
350
|
+
return _ts_generator(this, function(_state) {
|
|
351
|
+
switch(_state.label){
|
|
352
|
+
case 0:
|
|
353
|
+
_state.trys.push([
|
|
354
|
+
0,
|
|
355
|
+
2,
|
|
356
|
+
,
|
|
357
|
+
3
|
|
358
|
+
]);
|
|
359
|
+
doc_ref = doc(db, collection_path, doc_id);
|
|
360
|
+
return [
|
|
361
|
+
4,
|
|
362
|
+
getDoc(doc_ref)
|
|
363
|
+
];
|
|
364
|
+
case 1:
|
|
365
|
+
doc_snap = _state.sent();
|
|
366
|
+
if (!doc_snap.exists()) {
|
|
367
|
+
throw new Error("Document not found, document id: " + doc_id);
|
|
368
|
+
}
|
|
369
|
+
return [
|
|
370
|
+
2,
|
|
371
|
+
simpleExtractData(doc_snap)
|
|
372
|
+
];
|
|
373
|
+
case 2:
|
|
374
|
+
error = _state.sent();
|
|
375
|
+
console.error("Error from get_document_by_id", error);
|
|
376
|
+
return [
|
|
377
|
+
2,
|
|
378
|
+
null
|
|
379
|
+
];
|
|
380
|
+
case 3:
|
|
381
|
+
return [
|
|
382
|
+
2
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
return function get_document_by_id(collection_path, doc_id) {
|
|
388
|
+
return _ref.apply(this, arguments);
|
|
389
|
+
};
|
|
390
|
+
}();
|
|
282
391
|
var snapshot = function(config, snapshotsFirstTime, settings) {
|
|
283
392
|
var resolvePromise;
|
|
284
393
|
var isResolved = false;
|
|
@@ -425,6 +534,277 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
425
534
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
426
535
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
427
536
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
537
|
+
// src/helpers/socket.ts
|
|
538
|
+
import { io } from "socket.io-client";
|
|
539
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
540
|
+
"use strict";
|
|
541
|
+
function _SocketService() {
|
|
542
|
+
_class_call_check(this, _SocketService);
|
|
543
|
+
this.socket = null;
|
|
544
|
+
this.connectCallbacks = [];
|
|
545
|
+
this.disconnectCallbacks = [];
|
|
546
|
+
}
|
|
547
|
+
_create_class(_SocketService, [
|
|
548
|
+
{
|
|
549
|
+
/// Initialize the socket connection
|
|
550
|
+
key: "initSocket",
|
|
551
|
+
value: function initSocket() {
|
|
552
|
+
var _this = this;
|
|
553
|
+
if (!this.socket) {
|
|
554
|
+
var SOCKET_SERVER_URL = "http://localhost:9009";
|
|
555
|
+
var SOCKET_PATH = "/api/data-socket/connect";
|
|
556
|
+
this.socket = io(SOCKET_SERVER_URL, {
|
|
557
|
+
path: SOCKET_PATH,
|
|
558
|
+
transports: [
|
|
559
|
+
"websocket"
|
|
560
|
+
]
|
|
561
|
+
});
|
|
562
|
+
this.socket.on("connect", function() {
|
|
563
|
+
var _this_socket;
|
|
564
|
+
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
565
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
566
|
+
return cb();
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
this.socket.on("disconnect", function(reason) {
|
|
570
|
+
console.log("Socket disconnected:", reason);
|
|
571
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
572
|
+
return cb();
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
this.socket.on("connect_error", function(error) {
|
|
576
|
+
console.error("Socket connection error:", error);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
/// get socket instance
|
|
583
|
+
key: "getSocketInstance",
|
|
584
|
+
value: function getSocketInstance() {
|
|
585
|
+
if (!this.socket) {
|
|
586
|
+
this.initSocket();
|
|
587
|
+
}
|
|
588
|
+
if (!this.socket) {
|
|
589
|
+
throw new Error("Socket not initialized");
|
|
590
|
+
}
|
|
591
|
+
if (!this.socket.connected) {
|
|
592
|
+
this.socket.connect();
|
|
593
|
+
}
|
|
594
|
+
return this.socket;
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
/// subscribe to collections
|
|
599
|
+
key: "subscribeToCollections",
|
|
600
|
+
value: function subscribeToCollections(config) {
|
|
601
|
+
var s = this.getSocketInstance();
|
|
602
|
+
var collectionsNames = config.map(function(c) {
|
|
603
|
+
return c.collectionName;
|
|
604
|
+
});
|
|
605
|
+
var eventHandlers = [];
|
|
606
|
+
config.forEach(function(configuration) {
|
|
607
|
+
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;
|
|
608
|
+
s.on("initial:".concat(collectionName), onFirstTime);
|
|
609
|
+
eventHandlers.push({
|
|
610
|
+
eventName: "initial:".concat(collectionName),
|
|
611
|
+
handler: onFirstTime
|
|
612
|
+
});
|
|
613
|
+
s.on("add:".concat(collectionName), onAdd);
|
|
614
|
+
eventHandlers.push({
|
|
615
|
+
eventName: "add:".concat(collectionName),
|
|
616
|
+
handler: onAdd
|
|
617
|
+
});
|
|
618
|
+
s.on("update:".concat(collectionName), onModify);
|
|
619
|
+
eventHandlers.push({
|
|
620
|
+
eventName: "update:".concat(collectionName),
|
|
621
|
+
handler: onModify
|
|
622
|
+
});
|
|
623
|
+
s.on("delete:".concat(collectionName), onRemove);
|
|
624
|
+
eventHandlers.push({
|
|
625
|
+
eventName: "delete:".concat(collectionName),
|
|
626
|
+
handler: onRemove
|
|
627
|
+
});
|
|
628
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
629
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
630
|
+
s.on("initial:".concat(collectionName), extraOnFirstTime);
|
|
631
|
+
eventHandlers.push({
|
|
632
|
+
eventName: "initial:".concat(collectionName),
|
|
633
|
+
handler: extraOnFirstTime
|
|
634
|
+
});
|
|
635
|
+
s.on("add:".concat(collectionName), extraOnAdd);
|
|
636
|
+
eventHandlers.push({
|
|
637
|
+
eventName: "add:".concat(collectionName),
|
|
638
|
+
handler: extraOnAdd
|
|
639
|
+
});
|
|
640
|
+
s.on("update:".concat(collectionName), extraOnModify);
|
|
641
|
+
eventHandlers.push({
|
|
642
|
+
eventName: "update:".concat(collectionName),
|
|
643
|
+
handler: extraOnModify
|
|
644
|
+
});
|
|
645
|
+
s.on("delete:".concat(collectionName), extraOnRemove);
|
|
646
|
+
eventHandlers.push({
|
|
647
|
+
eventName: "delete:".concat(collectionName),
|
|
648
|
+
handler: extraOnRemove
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
653
|
+
if (callback.success) {
|
|
654
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
655
|
+
} else {
|
|
656
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
return function() {
|
|
660
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
661
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
662
|
+
eventHandlers.forEach(function(eh) {
|
|
663
|
+
s.off(eh.eventName, eh.handler);
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
/// set data
|
|
670
|
+
key: "setData",
|
|
671
|
+
value: function setData(payload) {
|
|
672
|
+
var s = this.getSocketInstance();
|
|
673
|
+
return new Promise(function(resolve, reject) {
|
|
674
|
+
s.emit("set_data", payload, function(callback) {
|
|
675
|
+
if (callback.success) {
|
|
676
|
+
console.log("Data saved successfully:", payload);
|
|
677
|
+
console.log("ack", callback);
|
|
678
|
+
resolve(callback);
|
|
679
|
+
} else {
|
|
680
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
/// get data
|
|
688
|
+
key: "getCollectionData",
|
|
689
|
+
value: function getCollectionData(payload) {
|
|
690
|
+
var s = this.getSocketInstance();
|
|
691
|
+
s.emit("get_data", {
|
|
692
|
+
collection_name: payload.collection_name
|
|
693
|
+
}, function(socketCallback) {
|
|
694
|
+
if (socketCallback.success && socketCallback.data) {
|
|
695
|
+
payload.callback(socketCallback.data);
|
|
696
|
+
} else {
|
|
697
|
+
payload.callback(payload.defaultValue);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
key: "getDocumentData",
|
|
704
|
+
value: function getDocumentData(payload) {
|
|
705
|
+
var s = this.getSocketInstance();
|
|
706
|
+
s.emit("get_data", {
|
|
707
|
+
collection_name: payload.collection_name,
|
|
708
|
+
key: payload.key
|
|
709
|
+
}, function(socketCallback) {
|
|
710
|
+
if (socketCallback.success && socketCallback.data) {
|
|
711
|
+
payload.callback(socketCallback.data);
|
|
712
|
+
} else {
|
|
713
|
+
payload.callback(payload.defaultValue);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
/// delete data
|
|
720
|
+
key: "deleteData",
|
|
721
|
+
value: function deleteData(payload) {
|
|
722
|
+
var s = this.getSocketInstance();
|
|
723
|
+
return new Promise(function(resolve, reject) {
|
|
724
|
+
s.emit("delete_data", payload, function(callback) {
|
|
725
|
+
if (callback.success) {
|
|
726
|
+
console.log("Data deleted successfully:", payload);
|
|
727
|
+
console.log("delete ack", callback);
|
|
728
|
+
resolve(callback);
|
|
729
|
+
} else {
|
|
730
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
key: "clearAllRedisData",
|
|
738
|
+
value: function clearAllRedisData() {
|
|
739
|
+
var s = this.getSocketInstance();
|
|
740
|
+
return new Promise(function(resolve, reject) {
|
|
741
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
742
|
+
if (ack.success) {
|
|
743
|
+
resolve(ack);
|
|
744
|
+
} else {
|
|
745
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
/// connection management methods
|
|
753
|
+
key: "onConnect",
|
|
754
|
+
value: function onConnect(callback) {
|
|
755
|
+
var _this_socket;
|
|
756
|
+
this.connectCallbacks.push(callback);
|
|
757
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
758
|
+
callback();
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
key: "offConnect",
|
|
764
|
+
value: function offConnect(callback) {
|
|
765
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
766
|
+
return cb !== callback;
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
key: "onDisconnect",
|
|
772
|
+
value: function onDisconnect(callback) {
|
|
773
|
+
this.disconnectCallbacks.push(callback);
|
|
774
|
+
if (this.socket && !this.socket.connected) {
|
|
775
|
+
callback();
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
key: "offDisconnect",
|
|
781
|
+
value: function offDisconnect(callback) {
|
|
782
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
783
|
+
return cb !== callback;
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
key: "isConnected",
|
|
789
|
+
value: function isConnected() {
|
|
790
|
+
var _this_socket;
|
|
791
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
], [
|
|
795
|
+
{
|
|
796
|
+
key: "getInstance",
|
|
797
|
+
value: function getInstance() {
|
|
798
|
+
if (!_SocketService.instance) {
|
|
799
|
+
_SocketService.instance = new _SocketService();
|
|
800
|
+
}
|
|
801
|
+
return _SocketService.instance;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
]);
|
|
805
|
+
return _SocketService;
|
|
806
|
+
}();
|
|
807
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
428
808
|
// src/hooks/react.ts
|
|
429
809
|
import { isEqual as isEqual2 } from "lodash";
|
|
430
810
|
import { useEffect, useMemo, useRef } from "react";
|
|
@@ -549,5 +929,79 @@ var useSetUserCountry = function(setUserCountry, changLang) {
|
|
|
549
929
|
};
|
|
550
930
|
// src/hooks/WebWorker.ts
|
|
551
931
|
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
552
|
-
|
|
932
|
+
// src/hooks/socket.ts
|
|
933
|
+
import { useEffect as useEffect4, useState } from "react";
|
|
934
|
+
var useSocketSubscription = function(config) {
|
|
935
|
+
var _useState = _sliced_to_array(useState(socketServiceInstance.isConnected()), 2), socketConnected = _useState[0], setSocketConnected = _useState[1];
|
|
936
|
+
useDeepCompareEffect(function() {
|
|
937
|
+
var cleanupSubscriptions;
|
|
938
|
+
if (socketConnected) {
|
|
939
|
+
cleanupSubscriptions = socketServiceInstance.subscribeToCollections(config);
|
|
940
|
+
}
|
|
941
|
+
var uiOnConnect = function() {
|
|
942
|
+
setSocketConnected(true);
|
|
943
|
+
};
|
|
944
|
+
var uiOnDisconnect = function() {
|
|
945
|
+
cleanupSubscriptions === null || cleanupSubscriptions === void 0 ? void 0 : cleanupSubscriptions();
|
|
946
|
+
setSocketConnected(false);
|
|
947
|
+
};
|
|
948
|
+
socketServiceInstance.onConnect(uiOnConnect);
|
|
949
|
+
socketServiceInstance.onDisconnect(uiOnDisconnect);
|
|
950
|
+
setSocketConnected(socketServiceInstance.isConnected());
|
|
951
|
+
return function() {
|
|
952
|
+
console.log("cleanupSubscriptions");
|
|
953
|
+
cleanupSubscriptions === null || cleanupSubscriptions === void 0 ? void 0 : cleanupSubscriptions();
|
|
954
|
+
socketServiceInstance.offConnect(uiOnConnect);
|
|
955
|
+
socketServiceInstance.offDisconnect(uiOnDisconnect);
|
|
956
|
+
};
|
|
957
|
+
}, [
|
|
958
|
+
socketConnected
|
|
959
|
+
]);
|
|
960
|
+
return {
|
|
961
|
+
socketConnected: socketConnected
|
|
962
|
+
};
|
|
963
|
+
};
|
|
964
|
+
var useSmartSnapshot = function(configs, options) {
|
|
965
|
+
var _useState = _sliced_to_array(useState(null), 2), cacheCollectionsConfig = _useState[0], setCacheCollectionsConfig = _useState[1];
|
|
966
|
+
useEffect4(function() {
|
|
967
|
+
get_document_by_id("nx-settings", "cache_collections_config").then(function(res) {
|
|
968
|
+
return setCacheCollectionsConfig(res);
|
|
969
|
+
});
|
|
970
|
+
return function() {
|
|
971
|
+
return setCacheCollectionsConfig(null);
|
|
972
|
+
};
|
|
973
|
+
}, []);
|
|
974
|
+
var groupedConfig = useDeepCompareMemo(function() {
|
|
975
|
+
if (!cacheCollectionsConfig) {
|
|
976
|
+
return {
|
|
977
|
+
configForDb: [],
|
|
978
|
+
configForCache: []
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
var configForDb = [];
|
|
982
|
+
var configForCache = [];
|
|
983
|
+
configs.forEach(function(cfg) {
|
|
984
|
+
var collectionName = cfg.collectionName, _cfg_subscribeTo = cfg.subscribeTo, subscribeTo = _cfg_subscribeTo === void 0 ? "cache" : _cfg_subscribeTo;
|
|
985
|
+
if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName]) {
|
|
986
|
+
configForCache.push(cfg);
|
|
987
|
+
} else {
|
|
988
|
+
configForDb.push(cfg);
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
return {
|
|
992
|
+
configForDb: configForDb,
|
|
993
|
+
configForCache: configForCache
|
|
994
|
+
};
|
|
995
|
+
}, [
|
|
996
|
+
configs,
|
|
997
|
+
cacheCollectionsConfig
|
|
998
|
+
]);
|
|
999
|
+
useSnapshotBulk(groupedConfig.configForDb, options === null || options === void 0 ? void 0 : options.label, options === null || options === void 0 ? void 0 : options.settings);
|
|
1000
|
+
useSocketSubscription(groupedConfig.configForCache);
|
|
1001
|
+
return {
|
|
1002
|
+
groupedConfig: groupedConfig,
|
|
1003
|
+
socketConnected: socketServiceInstance.isConnected()
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshot, useSnapshotBulk, useSocketSubscription };
|
|
553
1007
|
//# sourceMappingURL=index.mjs.map
|
package/dist/types/index.d.mts
CHANGED
|
@@ -97,6 +97,8 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
97
97
|
fieldName: string;
|
|
98
98
|
direction: "asc" | "desc";
|
|
99
99
|
}[];
|
|
100
|
+
parseAs?: "object" | "array";
|
|
101
|
+
subscribeTo?: "cache" | "db";
|
|
100
102
|
}
|
|
101
103
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
102
104
|
collectionName: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
97
97
|
fieldName: string;
|
|
98
98
|
direction: "asc" | "desc";
|
|
99
99
|
}[];
|
|
100
|
+
parseAs?: "object" | "array";
|
|
101
|
+
subscribeTo?: "cache" | "db";
|
|
100
102
|
}
|
|
101
103
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
102
104
|
collectionName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akeyless-client-commons",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsup",
|
|
6
6
|
"deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@radix-ui/react-progress": "^1.1.1",
|
|
17
17
|
"@radix-ui/react-slot": "^1.1.2",
|
|
18
18
|
"@types/lodash": "^4.17.13",
|
|
19
|
-
"akeyless-types-commons": "^1.0.
|
|
19
|
+
"akeyless-types-commons": "^1.0.41",
|
|
20
20
|
"assets": "^3.0.1",
|
|
21
21
|
"axios": "^1.7.9",
|
|
22
22
|
"class-variance-authority": "^0.7.0",
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
36
36
|
"react-phone-number-input": "^3.4.10",
|
|
37
37
|
"react-spinners": "^0.14.1",
|
|
38
|
+
"socket.io-client": "^4.8.1",
|
|
38
39
|
"tailwind-merge": "^2.5.4",
|
|
39
40
|
"tailwindcss-animate": "^1.0.7",
|
|
41
|
+
"types": "^0.1.1",
|
|
40
42
|
"xregexp": "^5.1.1",
|
|
41
43
|
"zustand": "^5.0.0"
|
|
42
44
|
},
|