akeyless-client-commons 1.1.17-test.9 → 1.1.19
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 +10 -314
- package/dist/components/index.mjs +10 -314
- package/dist/helpers/index.d.mts +3 -43
- package/dist/helpers/index.d.ts +3 -43
- package/dist/helpers/index.js +0 -341
- package/dist/helpers/index.mjs +1 -330
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +8 -27
- package/dist/hooks/index.d.ts +8 -27
- package/dist/hooks/index.js +64 -614
- package/dist/hooks/index.mjs +62 -604
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/types/index.d.mts +0 -2
- package/dist/types/index.d.ts +0 -2
- package/package.json +2 -5
package/dist/hooks/index.js
CHANGED
|
@@ -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,
|
|
@@ -317,9 +240,6 @@ var __toCommonJS = function(mod) {
|
|
|
317
240
|
// src/hooks/index.ts
|
|
318
241
|
var index_exports = {};
|
|
319
242
|
__export(index_exports, {
|
|
320
|
-
useDbSnapshots: function() {
|
|
321
|
-
return useDbSnapshots;
|
|
322
|
-
},
|
|
323
243
|
useDeepCompareEffect: function() {
|
|
324
244
|
return useDeepCompareEffect;
|
|
325
245
|
},
|
|
@@ -335,17 +255,14 @@ __export(index_exports, {
|
|
|
335
255
|
useSetUserCountry: function() {
|
|
336
256
|
return useSetUserCountry;
|
|
337
257
|
},
|
|
338
|
-
|
|
339
|
-
return
|
|
340
|
-
},
|
|
341
|
-
useSocketSnapshots: function() {
|
|
342
|
-
return useSocketSnapshots;
|
|
258
|
+
useSnapshotBulk: function() {
|
|
259
|
+
return useSnapshotBulk;
|
|
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
|
|
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;
|
|
@@ -518,11 +391,11 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
|
|
|
518
391
|
collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.orderBy)(order.fieldName, order.direction));
|
|
519
392
|
});
|
|
520
393
|
}
|
|
521
|
-
var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(
|
|
394
|
+
var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot2) {
|
|
522
395
|
if (!snapshotsFirstTime.includes(config.collectionName)) {
|
|
523
396
|
var _config_onFirstTime, _config_extraParsers;
|
|
524
397
|
snapshotsFirstTime.push(config.collectionName);
|
|
525
|
-
var documents =
|
|
398
|
+
var documents = snapshot2.docs.map(function(doc2) {
|
|
526
399
|
return simpleExtractData(doc2);
|
|
527
400
|
});
|
|
528
401
|
(_config_onFirstTime = config.onFirstTime) === null || _config_onFirstTime === void 0 ? void 0 : _config_onFirstTime.call(config, documents, config);
|
|
@@ -536,7 +409,7 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
|
|
|
536
409
|
var addedDocs = [];
|
|
537
410
|
var modifiedDocs = [];
|
|
538
411
|
var removedDocs = [];
|
|
539
|
-
|
|
412
|
+
snapshot2.docChanges().forEach(function(change) {
|
|
540
413
|
if (change.type === "added") {
|
|
541
414
|
addedDocs.push(simpleExtractData(change.doc));
|
|
542
415
|
} else if (change.type === "modified") {
|
|
@@ -640,358 +513,11 @@ 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 SESSION_STORAGE_KEY = "sessionId";
|
|
648
|
-
var SocketService = /*#__PURE__*/ function() {
|
|
649
|
-
"use strict";
|
|
650
|
-
function _SocketService() {
|
|
651
|
-
_class_call_check(this, _SocketService);
|
|
652
|
-
this.socket = null;
|
|
653
|
-
this.connectCallbacks = [];
|
|
654
|
-
this.disconnectCallbacks = [];
|
|
655
|
-
this.authToken = null;
|
|
656
|
-
}
|
|
657
|
-
_create_class(_SocketService, [
|
|
658
|
-
{
|
|
659
|
-
/// Initialize the socket connection
|
|
660
|
-
key: "initSocket",
|
|
661
|
-
value: function initSocket() {
|
|
662
|
-
var _this = this;
|
|
663
|
-
if (!this.socket) {
|
|
664
|
-
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
665
|
-
this.socket = (0, import_socket.io)(socketUrl, {
|
|
666
|
-
path: "/api/data-socket/connect",
|
|
667
|
-
auth: function(cb) {
|
|
668
|
-
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
669
|
-
var token = _this.authToken;
|
|
670
|
-
var authPayload = {};
|
|
671
|
-
if (token) authPayload.token = token;
|
|
672
|
-
if (sessionId) authPayload.sessionId = sessionId;
|
|
673
|
-
cb(authPayload);
|
|
674
|
-
},
|
|
675
|
-
reconnection: true,
|
|
676
|
-
reconnectionAttempts: 30,
|
|
677
|
-
reconnectionDelay: 2 * 1e3
|
|
678
|
-
});
|
|
679
|
-
this.socket.on("connect", function() {
|
|
680
|
-
var _this_socket, _this_socket1;
|
|
681
|
-
console.log("\uD83D\uDFE2 Socket connected: ".concat((_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id, " (recovered - ").concat((_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.recovered, ")"));
|
|
682
|
-
_this.connectCallbacks.forEach(function(cb) {
|
|
683
|
-
return cb();
|
|
684
|
-
});
|
|
685
|
-
});
|
|
686
|
-
this.socket.on("disconnect", function(reason) {
|
|
687
|
-
console.log("Socket disconnected:", reason);
|
|
688
|
-
_this.disconnectCallbacks.forEach(function(cb) {
|
|
689
|
-
return cb();
|
|
690
|
-
});
|
|
691
|
-
});
|
|
692
|
-
this.socket.on("session", function(param) {
|
|
693
|
-
var sessionId = param.sessionId;
|
|
694
|
-
if (sessionId) {
|
|
695
|
-
localStorage.setItem(SESSION_STORAGE_KEY, sessionId);
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
this.socket.on("connect_error", function(error) {
|
|
699
|
-
console.error("Socket connection error:", error);
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
/// get socket instance
|
|
706
|
-
key: "getSocketInstance",
|
|
707
|
-
value: function getSocketInstance() {
|
|
708
|
-
if (!this.socket) {
|
|
709
|
-
this.initSocket();
|
|
710
|
-
}
|
|
711
|
-
if (!this.socket) {
|
|
712
|
-
throw new Error("Socket not initialized");
|
|
713
|
-
}
|
|
714
|
-
if (!this.socket.connected) {
|
|
715
|
-
this.socket.connect();
|
|
716
|
-
}
|
|
717
|
-
return this.socket;
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
/// connection management methods
|
|
722
|
-
key: "startSession",
|
|
723
|
-
value: function startSession(token) {
|
|
724
|
-
this.setAuthToken(token);
|
|
725
|
-
this.initSocket();
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
key: "onConnect",
|
|
730
|
-
value: function onConnect(callback) {
|
|
731
|
-
var _this = this;
|
|
732
|
-
var _this_socket;
|
|
733
|
-
if (!this.connectCallbacks.includes(callback)) {
|
|
734
|
-
this.connectCallbacks.push(callback);
|
|
735
|
-
}
|
|
736
|
-
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
737
|
-
callback();
|
|
738
|
-
}
|
|
739
|
-
return function() {
|
|
740
|
-
return _this.offConnect(callback);
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
key: "offConnect",
|
|
746
|
-
value: function offConnect(callback) {
|
|
747
|
-
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
748
|
-
return cb !== callback;
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
key: "onDisconnect",
|
|
754
|
-
value: function onDisconnect(callback) {
|
|
755
|
-
var _this = this;
|
|
756
|
-
if (!this.disconnectCallbacks.includes(callback)) {
|
|
757
|
-
this.disconnectCallbacks.push(callback);
|
|
758
|
-
}
|
|
759
|
-
if (this.socket && !this.socket.connected) {
|
|
760
|
-
callback();
|
|
761
|
-
}
|
|
762
|
-
return function() {
|
|
763
|
-
return _this.offDisconnect(callback);
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
key: "offDisconnect",
|
|
769
|
-
value: function offDisconnect(callback) {
|
|
770
|
-
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
771
|
-
return cb !== callback;
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
},
|
|
775
|
-
{
|
|
776
|
-
key: "isConnected",
|
|
777
|
-
value: function isConnected() {
|
|
778
|
-
var _this_socket;
|
|
779
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
key: "setAuthToken",
|
|
784
|
-
value: function setAuthToken(token) {
|
|
785
|
-
this.authToken = token;
|
|
786
|
-
if (this.socket) {
|
|
787
|
-
this.socket.connect();
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
key: "disconnectSocket",
|
|
793
|
-
value: function disconnectSocket() {
|
|
794
|
-
if (this.socket) {
|
|
795
|
-
this.socket.io.engine.close();
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
/// subscribe to collections
|
|
801
|
-
key: "subscribeToCollections",
|
|
802
|
-
value: function subscribeToCollections(config) {
|
|
803
|
-
var _this = this;
|
|
804
|
-
if (config.length === 0) {
|
|
805
|
-
return function() {};
|
|
806
|
-
}
|
|
807
|
-
var s = this.getSocketInstance();
|
|
808
|
-
var collectionsNames = config.map(function(c) {
|
|
809
|
-
return c.collectionName;
|
|
810
|
-
});
|
|
811
|
-
var eventHandlers = [];
|
|
812
|
-
config.forEach(function(configuration) {
|
|
813
|
-
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;
|
|
814
|
-
var attach = function(eventName, handler) {
|
|
815
|
-
_this.socket.off(eventName, handler);
|
|
816
|
-
_this.socket.on(eventName, handler);
|
|
817
|
-
eventHandlers.push({
|
|
818
|
-
eventName: eventName,
|
|
819
|
-
handler: handler
|
|
820
|
-
});
|
|
821
|
-
};
|
|
822
|
-
attach("initial:".concat(collectionName), onFirstTime);
|
|
823
|
-
attach("add:".concat(collectionName), onAdd);
|
|
824
|
-
attach("update:".concat(collectionName), onModify);
|
|
825
|
-
attach("delete:".concat(collectionName), onRemove);
|
|
826
|
-
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
827
|
-
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
828
|
-
attach("initial:".concat(collectionName), extraOnFirstTime);
|
|
829
|
-
attach("add:".concat(collectionName), extraOnAdd);
|
|
830
|
-
attach("update:".concat(collectionName), extraOnModify);
|
|
831
|
-
attach("delete:".concat(collectionName), extraOnRemove);
|
|
832
|
-
});
|
|
833
|
-
});
|
|
834
|
-
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
835
|
-
if (callback.success) {
|
|
836
|
-
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
837
|
-
} else {
|
|
838
|
-
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
return function() {
|
|
842
|
-
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
843
|
-
s.emit("unsubscribe_collections", collectionsNames);
|
|
844
|
-
eventHandlers.forEach(function(eh) {
|
|
845
|
-
s.off(eh.eventName, eh.handler);
|
|
846
|
-
});
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
/// set data
|
|
852
|
-
key: "setData",
|
|
853
|
-
value: function setData(payload) {
|
|
854
|
-
var s = this.getSocketInstance();
|
|
855
|
-
return new Promise(function(resolve, reject) {
|
|
856
|
-
s.emit("set_data", payload, function(callback) {
|
|
857
|
-
if (callback.success) {
|
|
858
|
-
console.log("Data saved successfully:", payload);
|
|
859
|
-
console.log("ack", callback);
|
|
860
|
-
resolve(callback);
|
|
861
|
-
} else {
|
|
862
|
-
reject(new Error(callback.message || "Save operation failed"));
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
/// get data
|
|
870
|
-
key: "getCollectionData",
|
|
871
|
-
value: function getCollectionData(payload) {
|
|
872
|
-
var s = this.getSocketInstance();
|
|
873
|
-
s.emit("get_data", {
|
|
874
|
-
collection_name: payload.collection_name
|
|
875
|
-
}, function(socketCallback) {
|
|
876
|
-
if (socketCallback.success && socketCallback.data) {
|
|
877
|
-
payload.callback(socketCallback.data);
|
|
878
|
-
} else {
|
|
879
|
-
payload.callback(payload.defaultValue);
|
|
880
|
-
}
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
},
|
|
884
|
-
{
|
|
885
|
-
key: "getDocumentData",
|
|
886
|
-
value: function getDocumentData(payload) {
|
|
887
|
-
var s = this.getSocketInstance();
|
|
888
|
-
s.emit("get_data", {
|
|
889
|
-
collection_name: payload.collection_name,
|
|
890
|
-
key: payload.key
|
|
891
|
-
}, function(socketCallback) {
|
|
892
|
-
if (socketCallback.success && socketCallback.data) {
|
|
893
|
-
payload.callback(socketCallback.data);
|
|
894
|
-
} else {
|
|
895
|
-
payload.callback(payload.defaultValue);
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
},
|
|
900
|
-
{
|
|
901
|
-
/// delete data
|
|
902
|
-
key: "deleteData",
|
|
903
|
-
value: function deleteData(payload) {
|
|
904
|
-
var s = this.getSocketInstance();
|
|
905
|
-
return new Promise(function(resolve, reject) {
|
|
906
|
-
s.emit("delete_data", payload, function(callback) {
|
|
907
|
-
if (callback.success) {
|
|
908
|
-
console.log("Data deleted successfully:", payload);
|
|
909
|
-
console.log("delete ack", callback);
|
|
910
|
-
resolve(callback);
|
|
911
|
-
} else {
|
|
912
|
-
reject(new Error(callback.message || "Delete operation failed"));
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
{
|
|
919
|
-
key: "clearAllRedisData",
|
|
920
|
-
value: function clearAllRedisData() {
|
|
921
|
-
var s = this.getSocketInstance();
|
|
922
|
-
return new Promise(function(resolve, reject) {
|
|
923
|
-
s.emit("clear_all_redis_data", function(ack) {
|
|
924
|
-
if (ack.success) {
|
|
925
|
-
resolve(ack);
|
|
926
|
-
} else {
|
|
927
|
-
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
], [
|
|
934
|
-
{
|
|
935
|
-
key: "getInstance",
|
|
936
|
-
value: function getInstance() {
|
|
937
|
-
if (!_SocketService.instance) {
|
|
938
|
-
_SocketService.instance = new _SocketService();
|
|
939
|
-
}
|
|
940
|
-
return _SocketService.instance;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
]);
|
|
944
|
-
return _SocketService;
|
|
945
|
-
}();
|
|
946
|
-
var socketServiceInstance = SocketService.getInstance();
|
|
947
|
-
// src/hooks/global.ts
|
|
948
|
-
var useDocumentTitle = function(title) {
|
|
949
|
-
(0, import_react2.useEffect)(function() {
|
|
950
|
-
document.title = title;
|
|
951
|
-
}, [
|
|
952
|
-
title
|
|
953
|
-
]);
|
|
954
|
-
return null;
|
|
955
|
-
};
|
|
956
|
-
var useSetUserCountry = function(setUserCountry, changLang) {
|
|
957
|
-
(0, import_react2.useLayoutEffect)(function() {
|
|
958
|
-
var currentCountry = localStorage.getItem("userCountry");
|
|
959
|
-
if (!currentCountry) {
|
|
960
|
-
var updateCountry = /*#__PURE__*/ function() {
|
|
961
|
-
var _ref = _async_to_generator(function() {
|
|
962
|
-
var country;
|
|
963
|
-
return _ts_generator(this, function(_state) {
|
|
964
|
-
switch(_state.label){
|
|
965
|
-
case 0:
|
|
966
|
-
return [
|
|
967
|
-
4,
|
|
968
|
-
getUserCountryByIp()
|
|
969
|
-
];
|
|
970
|
-
case 1:
|
|
971
|
-
country = _state.sent();
|
|
972
|
-
changLang(country === import_akeyless_types_commons2.CountryOptions.IL ? "he" : "en");
|
|
973
|
-
setUserCountry(country);
|
|
974
|
-
localStorage.setItem("userCountry", country);
|
|
975
|
-
return [
|
|
976
|
-
2
|
|
977
|
-
];
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
});
|
|
981
|
-
return function updateCountry() {
|
|
982
|
-
return _ref.apply(this, arguments);
|
|
983
|
-
};
|
|
984
|
-
}();
|
|
985
|
-
updateCountry();
|
|
986
|
-
}
|
|
987
|
-
}, []);
|
|
988
|
-
return null;
|
|
989
|
-
};
|
|
990
516
|
// src/hooks/react.ts
|
|
991
517
|
var import_lodash2 = require("lodash");
|
|
992
|
-
var
|
|
518
|
+
var import_react2 = require("react");
|
|
993
519
|
function useSafeEffect(callback, dependencies, error_message) {
|
|
994
|
-
(0,
|
|
520
|
+
(0, import_react2.useEffect)(function() {
|
|
995
521
|
try {
|
|
996
522
|
callback();
|
|
997
523
|
} catch (error) {
|
|
@@ -1000,105 +526,37 @@ function useSafeEffect(callback, dependencies, error_message) {
|
|
|
1000
526
|
}, dependencies);
|
|
1001
527
|
}
|
|
1002
528
|
var useDeepCompareMemo = function(factory, dependencies) {
|
|
1003
|
-
var previousDepsRef = (0,
|
|
529
|
+
var previousDepsRef = (0, import_react2.useRef)([]);
|
|
1004
530
|
if (!(0, import_lodash2.isEqual)(dependencies, previousDepsRef.current)) {
|
|
1005
531
|
previousDepsRef.current = dependencies;
|
|
1006
532
|
}
|
|
1007
|
-
return (0,
|
|
533
|
+
return (0, import_react2.useMemo)(factory, previousDepsRef.current);
|
|
1008
534
|
};
|
|
1009
535
|
function useDeepCompareEffect(effect, dependencies) {
|
|
1010
|
-
var previousDepsRef = (0,
|
|
536
|
+
var previousDepsRef = (0, import_react2.useRef)();
|
|
1011
537
|
if (!(0, import_lodash2.isEqual)(previousDepsRef.current, dependencies)) {
|
|
1012
538
|
previousDepsRef.current = dependencies;
|
|
1013
539
|
}
|
|
1014
|
-
(0,
|
|
540
|
+
(0, import_react2.useEffect)(effect, [
|
|
1015
541
|
previousDepsRef.current
|
|
1016
542
|
]);
|
|
1017
543
|
}
|
|
1018
|
-
// src/hooks/
|
|
1019
|
-
var
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
var useSocketSnapshots = function(configs, label, settings) {
|
|
1023
|
-
var _auth_currentUser;
|
|
1024
|
-
var _ref = _sliced_to_array((0, import_react5.useState)(socketServiceInstance.isConnected()), 2), socketConnected = _ref[0], setSocketConnected = _ref[1];
|
|
1025
|
-
var _ref1 = _sliced_to_array((0, import_react5.useState)([]), 2), cleanupSubscriptions = _ref1[0], setCleanupSubscriptions = _ref1[1];
|
|
1026
|
-
var socketStarted = (0, import_react5.useRef)(false);
|
|
1027
|
-
useDeepCompareEffect(function() {
|
|
1028
|
-
if (!auth.currentUser) {
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
var subscribe = function() {
|
|
1032
|
-
if (configs.length === 0) {
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
var disposer = socketServiceInstance.subscribeToCollections(configs);
|
|
1036
|
-
setCleanupSubscriptions(function(prev) {
|
|
1037
|
-
return _to_consumable_array(prev).concat([
|
|
1038
|
-
disposer
|
|
1039
|
-
]);
|
|
1040
|
-
});
|
|
1041
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
1042
|
-
console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
|
|
1043
|
-
return c.collectionName;
|
|
1044
|
-
}).join(", ")));
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
if (socketServiceInstance.isConnected()) {
|
|
1048
|
-
setSocketConnected(true);
|
|
1049
|
-
subscribe();
|
|
1050
|
-
} else if (!socketStarted.current) {
|
|
1051
|
-
socketStarted.current = true;
|
|
1052
|
-
auth.currentUser.getIdToken().then(function(token) {
|
|
1053
|
-
socketServiceInstance.startSession(token);
|
|
1054
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
1055
|
-
console.log("==> ".concat(label || "Cache snapshots", " started... "));
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
var offConnect = socketServiceInstance.onConnect(function() {
|
|
1060
|
-
setSocketConnected(true);
|
|
1061
|
-
socketStarted.current = false;
|
|
1062
|
-
subscribe();
|
|
1063
|
-
});
|
|
1064
|
-
var offDisconnect = socketServiceInstance.onDisconnect(function() {
|
|
1065
|
-
setSocketConnected(false);
|
|
1066
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
1067
|
-
return cleanup();
|
|
1068
|
-
});
|
|
1069
|
-
});
|
|
1070
|
-
return function() {
|
|
1071
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
1072
|
-
return cleanup();
|
|
1073
|
-
});
|
|
1074
|
-
offConnect === null || offConnect === void 0 ? void 0 : offConnect();
|
|
1075
|
-
offDisconnect === null || offDisconnect === void 0 ? void 0 : offDisconnect();
|
|
1076
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
1077
|
-
console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
544
|
+
// src/hooks/global.ts
|
|
545
|
+
var useDocumentTitle = function(title) {
|
|
546
|
+
(0, import_react3.useEffect)(function() {
|
|
547
|
+
document.title = title;
|
|
1080
548
|
}, [
|
|
1081
|
-
|
|
1082
|
-
(_auth_currentUser = auth.currentUser) === null || _auth_currentUser === void 0 ? void 0 : _auth_currentUser.uid
|
|
549
|
+
title
|
|
1083
550
|
]);
|
|
1084
|
-
|
|
1085
|
-
return function() {
|
|
1086
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
1087
|
-
return cleanup();
|
|
1088
|
-
});
|
|
1089
|
-
};
|
|
1090
|
-
}, []);
|
|
1091
|
-
return {
|
|
1092
|
-
socketConnected: socketConnected
|
|
1093
|
-
};
|
|
551
|
+
return null;
|
|
1094
552
|
};
|
|
1095
|
-
var
|
|
1096
|
-
var snapshotsFirstTime = (0,
|
|
1097
|
-
var unsubscribeFunctions = (0,
|
|
553
|
+
var useSnapshotBulk = function(configs, label, settings) {
|
|
554
|
+
var snapshotsFirstTime = (0, import_react3.useRef)([]);
|
|
555
|
+
var unsubscribeFunctions = (0, import_react3.useRef)([]);
|
|
1098
556
|
useDeepCompareEffect(function() {
|
|
1099
557
|
var start = performance.now();
|
|
1100
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
1101
|
-
console.log("==> ".concat(label || "
|
|
558
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
559
|
+
console.log("==> ".concat(label || "Custom snapshots", " started... "));
|
|
1102
560
|
}
|
|
1103
561
|
var snapshotResults = configs.map(function(config) {
|
|
1104
562
|
return snapshot(config, snapshotsFirstTime.current, settings);
|
|
@@ -1109,8 +567,8 @@ var useDbSnapshots = function(configs, label, settings) {
|
|
|
1109
567
|
Promise.all(snapshotResults.map(function(result) {
|
|
1110
568
|
return result.promise;
|
|
1111
569
|
})).then(function() {
|
|
1112
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
1113
|
-
console.log("==> ".concat(label || "
|
|
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"));
|
|
1114
572
|
}
|
|
1115
573
|
});
|
|
1116
574
|
if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
|
|
@@ -1120,8 +578,8 @@ var useDbSnapshots = function(configs, label, settings) {
|
|
|
1120
578
|
unsubscribe();
|
|
1121
579
|
}
|
|
1122
580
|
});
|
|
1123
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
1124
|
-
console.log("==> ".concat(label || "
|
|
581
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
582
|
+
console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
|
|
1125
583
|
}
|
|
1126
584
|
};
|
|
1127
585
|
}
|
|
@@ -1130,7 +588,7 @@ var useDbSnapshots = function(configs, label, settings) {
|
|
|
1130
588
|
label,
|
|
1131
589
|
settings
|
|
1132
590
|
]);
|
|
1133
|
-
(0,
|
|
591
|
+
(0, import_react3.useEffect)(function() {
|
|
1134
592
|
return function() {
|
|
1135
593
|
unsubscribeFunctions.current.forEach(function(unsubscribe) {
|
|
1136
594
|
if (unsubscribe) {
|
|
@@ -1138,62 +596,54 @@ var useDbSnapshots = function(configs, label, settings) {
|
|
|
1138
596
|
}
|
|
1139
597
|
});
|
|
1140
598
|
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
1141
|
-
console.log("==> ".concat(label || "
|
|
599
|
+
console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
|
|
1142
600
|
}
|
|
1143
601
|
};
|
|
1144
602
|
}, []);
|
|
1145
603
|
};
|
|
1146
|
-
var
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
604
|
+
var useSetUserCountry = function(setUserCountry, changLang) {
|
|
605
|
+
(0, import_react3.useLayoutEffect)(function() {
|
|
606
|
+
var currentCountry = localStorage.getItem("userCountry");
|
|
607
|
+
if (!currentCountry) {
|
|
608
|
+
var updateCountry = /*#__PURE__*/ function() {
|
|
609
|
+
var _ref = _async_to_generator(function() {
|
|
610
|
+
var country;
|
|
611
|
+
return _ts_generator(this, function(_state) {
|
|
612
|
+
switch(_state.label){
|
|
613
|
+
case 0:
|
|
614
|
+
return [
|
|
615
|
+
4,
|
|
616
|
+
getUserCountryByIp()
|
|
617
|
+
];
|
|
618
|
+
case 1:
|
|
619
|
+
country = _state.sent();
|
|
620
|
+
changLang(country === import_akeyless_types_commons2.CountryOptions.IL ? "he" : "en");
|
|
621
|
+
setUserCountry(country);
|
|
622
|
+
localStorage.setItem("userCountry", country);
|
|
623
|
+
return [
|
|
624
|
+
2
|
|
625
|
+
];
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
return function updateCountry() {
|
|
630
|
+
return _ref.apply(this, arguments);
|
|
631
|
+
};
|
|
632
|
+
}();
|
|
633
|
+
updateCountry();
|
|
1162
634
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
configs.forEach(function(cfg) {
|
|
1166
|
-
var collectionName = cfg.collectionName, _cfg_subscribeTo = cfg.subscribeTo, subscribeTo = _cfg_subscribeTo === void 0 ? "cache" : _cfg_subscribeTo;
|
|
1167
|
-
if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName]) {
|
|
1168
|
-
configForCache.push(cfg);
|
|
1169
|
-
} else {
|
|
1170
|
-
configForDb.push(cfg);
|
|
1171
|
-
}
|
|
1172
|
-
});
|
|
1173
|
-
return {
|
|
1174
|
-
configForDb: configForDb,
|
|
1175
|
-
configForCache: configForCache
|
|
1176
|
-
};
|
|
1177
|
-
}, [
|
|
1178
|
-
configs,
|
|
1179
|
-
cacheCollectionsConfig
|
|
1180
|
-
]);
|
|
1181
|
-
useDbSnapshots(groupedConfig.configForDb, label, settings);
|
|
1182
|
-
var socketConnected = useSocketSnapshots(groupedConfig.configForCache, label, settings).socketConnected;
|
|
1183
|
-
return {
|
|
1184
|
-
groupedConfig: groupedConfig,
|
|
1185
|
-
socketConnected: socketConnected
|
|
1186
|
-
};
|
|
635
|
+
}, []);
|
|
636
|
+
return null;
|
|
1187
637
|
};
|
|
638
|
+
// src/hooks/WebWorker.ts
|
|
639
|
+
var import_react5 = require("react");
|
|
1188
640
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1189
641
|
0 && (module.exports = {
|
|
1190
|
-
useDbSnapshots: useDbSnapshots,
|
|
1191
642
|
useDeepCompareEffect: useDeepCompareEffect,
|
|
1192
643
|
useDeepCompareMemo: useDeepCompareMemo,
|
|
1193
644
|
useDocumentTitle: useDocumentTitle,
|
|
1194
645
|
useSafeEffect: useSafeEffect,
|
|
1195
646
|
useSetUserCountry: useSetUserCountry,
|
|
1196
|
-
|
|
1197
|
-
useSocketSnapshots: useSocketSnapshots
|
|
647
|
+
useSnapshotBulk: useSnapshotBulk
|
|
1198
648
|
});
|
|
1199
649
|
//# sourceMappingURL=index.js.map
|