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.
- package/dist/components/index.js +6 -300
- package/dist/components/index.mjs +6 -300
- package/dist/helpers/index.d.mts +3 -42
- package/dist/helpers/index.d.ts +3 -42
- package/dist/helpers/index.js +0 -331
- package/dist/helpers/index.mjs +1 -320
- package/dist/hooks/index.d.mts +1 -20
- package/dist/hooks/index.d.ts +1 -20
- package/dist/hooks/index.js +15 -549
- package/dist/hooks/index.mjs +12 -538
- 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.mjs
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
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
|
-
}
|
|
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,20 +80,6 @@ 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
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
153
|
-
if (!o) return;
|
|
154
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
155
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
156
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
157
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
158
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
159
|
-
}
|
|
160
83
|
function _ts_generator(thisArg, body) {
|
|
161
84
|
var f, y, t, g, _ = {
|
|
162
85
|
label: 0,
|
|
@@ -253,7 +176,7 @@ function _ts_generator(thisArg, body) {
|
|
|
253
176
|
}
|
|
254
177
|
}
|
|
255
178
|
import { CountryOptions as CountryOptions2 } from "akeyless-types-commons";
|
|
256
|
-
import { useEffect as
|
|
179
|
+
import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2 } from "react";
|
|
257
180
|
// src/helpers/firebase.ts
|
|
258
181
|
import moment from "moment";
|
|
259
182
|
import { initializeApp } from "firebase/app";
|
|
@@ -356,50 +279,6 @@ var simpleExtractData = function(doc2) {
|
|
|
356
279
|
id: doc2.id
|
|
357
280
|
});
|
|
358
281
|
};
|
|
359
|
-
var get_document_by_id = /*#__PURE__*/ function() {
|
|
360
|
-
var _ref = _async_to_generator(function(collection_path, doc_id) {
|
|
361
|
-
var doc_ref, doc_snap, error;
|
|
362
|
-
return _ts_generator(this, function(_state) {
|
|
363
|
-
switch(_state.label){
|
|
364
|
-
case 0:
|
|
365
|
-
_state.trys.push([
|
|
366
|
-
0,
|
|
367
|
-
2,
|
|
368
|
-
,
|
|
369
|
-
3
|
|
370
|
-
]);
|
|
371
|
-
doc_ref = doc(db, collection_path, doc_id);
|
|
372
|
-
return [
|
|
373
|
-
4,
|
|
374
|
-
getDoc(doc_ref)
|
|
375
|
-
];
|
|
376
|
-
case 1:
|
|
377
|
-
doc_snap = _state.sent();
|
|
378
|
-
if (!doc_snap.exists()) {
|
|
379
|
-
throw new Error("Document not found, document id: " + doc_id);
|
|
380
|
-
}
|
|
381
|
-
return [
|
|
382
|
-
2,
|
|
383
|
-
simpleExtractData(doc_snap)
|
|
384
|
-
];
|
|
385
|
-
case 2:
|
|
386
|
-
error = _state.sent();
|
|
387
|
-
console.error("Error from get_document_by_id", error);
|
|
388
|
-
return [
|
|
389
|
-
2,
|
|
390
|
-
null
|
|
391
|
-
];
|
|
392
|
-
case 3:
|
|
393
|
-
return [
|
|
394
|
-
2
|
|
395
|
-
];
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
return function get_document_by_id(collection_path, doc_id) {
|
|
400
|
-
return _ref.apply(this, arguments);
|
|
401
|
-
};
|
|
402
|
-
}();
|
|
403
282
|
var snapshot = function(config, snapshotsFirstTime, settings) {
|
|
404
283
|
var resolvePromise;
|
|
405
284
|
var isResolved = false;
|
|
@@ -546,300 +425,6 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
546
425
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
547
426
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
548
427
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
549
|
-
var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
|
|
550
|
-
var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
|
|
551
|
-
// src/helpers/socket.ts
|
|
552
|
-
import { io } from "socket.io-client";
|
|
553
|
-
var SocketService = /*#__PURE__*/ function() {
|
|
554
|
-
"use strict";
|
|
555
|
-
function _SocketService() {
|
|
556
|
-
_class_call_check(this, _SocketService);
|
|
557
|
-
this.socket = null;
|
|
558
|
-
this.connectCallbacks = [];
|
|
559
|
-
this.disconnectCallbacks = [];
|
|
560
|
-
this.authToken = null;
|
|
561
|
-
}
|
|
562
|
-
_create_class(_SocketService, [
|
|
563
|
-
{
|
|
564
|
-
/// Initialize the socket connection
|
|
565
|
-
key: "initSocket",
|
|
566
|
-
value: function initSocket() {
|
|
567
|
-
var _this = this;
|
|
568
|
-
if (!this.socket) {
|
|
569
|
-
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
570
|
-
this.socket = io(socketUrl, {
|
|
571
|
-
path: "/api/data-socket/connect",
|
|
572
|
-
transports: [
|
|
573
|
-
"websocket"
|
|
574
|
-
],
|
|
575
|
-
auth: this.authToken ? {
|
|
576
|
-
token: this.authToken
|
|
577
|
-
} : void 0
|
|
578
|
-
});
|
|
579
|
-
this.socket.on("connect", function() {
|
|
580
|
-
var _this_socket;
|
|
581
|
-
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
582
|
-
});
|
|
583
|
-
this.connectCallbacks.forEach(function(cb) {
|
|
584
|
-
return cb();
|
|
585
|
-
});
|
|
586
|
-
this.socket.on("disconnect", function(reason) {
|
|
587
|
-
console.log("Socket disconnected:", reason);
|
|
588
|
-
_this.disconnectCallbacks.forEach(function(cb) {
|
|
589
|
-
return cb();
|
|
590
|
-
});
|
|
591
|
-
});
|
|
592
|
-
this.socket.on("connect_error", function(error) {
|
|
593
|
-
console.error("Socket connection error:", error);
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
/// get socket instance
|
|
600
|
-
key: "getSocketInstance",
|
|
601
|
-
value: function getSocketInstance() {
|
|
602
|
-
if (!this.socket) {
|
|
603
|
-
this.initSocket();
|
|
604
|
-
}
|
|
605
|
-
if (!this.socket) {
|
|
606
|
-
throw new Error("Socket not initialized");
|
|
607
|
-
}
|
|
608
|
-
if (!this.socket.connected) {
|
|
609
|
-
this.socket.connect();
|
|
610
|
-
}
|
|
611
|
-
return this.socket;
|
|
612
|
-
}
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
/// subscribe to collections
|
|
616
|
-
key: "subscribeToCollections",
|
|
617
|
-
value: function subscribeToCollections(config) {
|
|
618
|
-
if (config.length === 0) {
|
|
619
|
-
return function() {};
|
|
620
|
-
}
|
|
621
|
-
var s = this.getSocketInstance();
|
|
622
|
-
var collectionsNames = config.map(function(c) {
|
|
623
|
-
return c.collectionName;
|
|
624
|
-
});
|
|
625
|
-
var eventHandlers = [];
|
|
626
|
-
config.forEach(function(configuration) {
|
|
627
|
-
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;
|
|
628
|
-
s.on("initial:".concat(collectionName), onFirstTime);
|
|
629
|
-
eventHandlers.push({
|
|
630
|
-
eventName: "initial:".concat(collectionName),
|
|
631
|
-
handler: onFirstTime
|
|
632
|
-
});
|
|
633
|
-
s.on("add:".concat(collectionName), onAdd);
|
|
634
|
-
eventHandlers.push({
|
|
635
|
-
eventName: "add:".concat(collectionName),
|
|
636
|
-
handler: onAdd
|
|
637
|
-
});
|
|
638
|
-
s.on("update:".concat(collectionName), onModify);
|
|
639
|
-
eventHandlers.push({
|
|
640
|
-
eventName: "update:".concat(collectionName),
|
|
641
|
-
handler: onModify
|
|
642
|
-
});
|
|
643
|
-
s.on("delete:".concat(collectionName), onRemove);
|
|
644
|
-
eventHandlers.push({
|
|
645
|
-
eventName: "delete:".concat(collectionName),
|
|
646
|
-
handler: onRemove
|
|
647
|
-
});
|
|
648
|
-
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
649
|
-
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
650
|
-
s.on("initial:".concat(collectionName), extraOnFirstTime);
|
|
651
|
-
eventHandlers.push({
|
|
652
|
-
eventName: "initial:".concat(collectionName),
|
|
653
|
-
handler: extraOnFirstTime
|
|
654
|
-
});
|
|
655
|
-
s.on("add:".concat(collectionName), extraOnAdd);
|
|
656
|
-
eventHandlers.push({
|
|
657
|
-
eventName: "add:".concat(collectionName),
|
|
658
|
-
handler: extraOnAdd
|
|
659
|
-
});
|
|
660
|
-
s.on("update:".concat(collectionName), extraOnModify);
|
|
661
|
-
eventHandlers.push({
|
|
662
|
-
eventName: "update:".concat(collectionName),
|
|
663
|
-
handler: extraOnModify
|
|
664
|
-
});
|
|
665
|
-
s.on("delete:".concat(collectionName), extraOnRemove);
|
|
666
|
-
eventHandlers.push({
|
|
667
|
-
eventName: "delete:".concat(collectionName),
|
|
668
|
-
handler: extraOnRemove
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
673
|
-
if (callback.success) {
|
|
674
|
-
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
675
|
-
} else {
|
|
676
|
-
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
return function() {
|
|
680
|
-
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
681
|
-
s.emit("unsubscribe_collections", collectionsNames);
|
|
682
|
-
eventHandlers.forEach(function(eh) {
|
|
683
|
-
s.off(eh.eventName, eh.handler);
|
|
684
|
-
});
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
/// set data
|
|
690
|
-
key: "setData",
|
|
691
|
-
value: function setData(payload) {
|
|
692
|
-
var s = this.getSocketInstance();
|
|
693
|
-
return new Promise(function(resolve, reject) {
|
|
694
|
-
s.emit("set_data", payload, function(callback) {
|
|
695
|
-
if (callback.success) {
|
|
696
|
-
console.log("Data saved successfully:", payload);
|
|
697
|
-
console.log("ack", callback);
|
|
698
|
-
resolve(callback);
|
|
699
|
-
} else {
|
|
700
|
-
reject(new Error(callback.message || "Save operation failed"));
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
/// get data
|
|
708
|
-
key: "getCollectionData",
|
|
709
|
-
value: function getCollectionData(payload) {
|
|
710
|
-
var s = this.getSocketInstance();
|
|
711
|
-
s.emit("get_data", {
|
|
712
|
-
collection_name: payload.collection_name
|
|
713
|
-
}, function(socketCallback) {
|
|
714
|
-
if (socketCallback.success && socketCallback.data) {
|
|
715
|
-
payload.callback(socketCallback.data);
|
|
716
|
-
} else {
|
|
717
|
-
payload.callback(payload.defaultValue);
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
key: "getDocumentData",
|
|
724
|
-
value: function getDocumentData(payload) {
|
|
725
|
-
var s = this.getSocketInstance();
|
|
726
|
-
s.emit("get_data", {
|
|
727
|
-
collection_name: payload.collection_name,
|
|
728
|
-
key: payload.key
|
|
729
|
-
}, function(socketCallback) {
|
|
730
|
-
if (socketCallback.success && socketCallback.data) {
|
|
731
|
-
payload.callback(socketCallback.data);
|
|
732
|
-
} else {
|
|
733
|
-
payload.callback(payload.defaultValue);
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
},
|
|
738
|
-
{
|
|
739
|
-
/// delete data
|
|
740
|
-
key: "deleteData",
|
|
741
|
-
value: function deleteData(payload) {
|
|
742
|
-
var s = this.getSocketInstance();
|
|
743
|
-
return new Promise(function(resolve, reject) {
|
|
744
|
-
s.emit("delete_data", payload, function(callback) {
|
|
745
|
-
if (callback.success) {
|
|
746
|
-
console.log("Data deleted successfully:", payload);
|
|
747
|
-
console.log("delete ack", callback);
|
|
748
|
-
resolve(callback);
|
|
749
|
-
} else {
|
|
750
|
-
reject(new Error(callback.message || "Delete operation failed"));
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
key: "clearAllRedisData",
|
|
758
|
-
value: function clearAllRedisData() {
|
|
759
|
-
var s = this.getSocketInstance();
|
|
760
|
-
return new Promise(function(resolve, reject) {
|
|
761
|
-
s.emit("clear_all_redis_data", function(ack) {
|
|
762
|
-
if (ack.success) {
|
|
763
|
-
resolve(ack);
|
|
764
|
-
} else {
|
|
765
|
-
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
},
|
|
771
|
-
{
|
|
772
|
-
/// connection management methods
|
|
773
|
-
key: "onConnect",
|
|
774
|
-
value: function onConnect(callback) {
|
|
775
|
-
var _this_socket;
|
|
776
|
-
this.connectCallbacks.push(callback);
|
|
777
|
-
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
778
|
-
callback();
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
key: "offConnect",
|
|
784
|
-
value: function offConnect(callback) {
|
|
785
|
-
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
786
|
-
return cb !== callback;
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
key: "onDisconnect",
|
|
792
|
-
value: function onDisconnect(callback) {
|
|
793
|
-
this.disconnectCallbacks.push(callback);
|
|
794
|
-
if (this.socket && !this.socket.connected) {
|
|
795
|
-
callback();
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
key: "offDisconnect",
|
|
801
|
-
value: function offDisconnect(callback) {
|
|
802
|
-
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
803
|
-
return cb !== callback;
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
key: "isConnected",
|
|
809
|
-
value: function isConnected() {
|
|
810
|
-
var _this_socket;
|
|
811
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
812
|
-
}
|
|
813
|
-
},
|
|
814
|
-
{
|
|
815
|
-
key: "setAuthToken",
|
|
816
|
-
value: function setAuthToken(token) {
|
|
817
|
-
this.authToken = token;
|
|
818
|
-
if (this.socket) {
|
|
819
|
-
this.socket.auth = {
|
|
820
|
-
token: token
|
|
821
|
-
};
|
|
822
|
-
if (this.socket.connected) {
|
|
823
|
-
this.socket.disconnect();
|
|
824
|
-
}
|
|
825
|
-
this.socket.connect();
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
], [
|
|
830
|
-
{
|
|
831
|
-
key: "getInstance",
|
|
832
|
-
value: function getInstance() {
|
|
833
|
-
if (!_SocketService.instance) {
|
|
834
|
-
_SocketService.instance = new _SocketService();
|
|
835
|
-
}
|
|
836
|
-
return _SocketService.instance;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
]);
|
|
840
|
-
return _SocketService;
|
|
841
|
-
}();
|
|
842
|
-
var socketServiceInstance = SocketService.getInstance();
|
|
843
428
|
// src/hooks/react.ts
|
|
844
429
|
import { isEqual as isEqual2 } from "lodash";
|
|
845
430
|
import { useEffect, useMemo, useRef } from "react";
|
|
@@ -868,78 +453,9 @@ function useDeepCompareEffect(effect, dependencies) {
|
|
|
868
453
|
previousDepsRef.current
|
|
869
454
|
]);
|
|
870
455
|
}
|
|
871
|
-
// src/hooks/socket.ts
|
|
872
|
-
import { useEffect as useEffect2, useState } from "react";
|
|
873
|
-
var useSocketSubscription = function(configs, label, settings) {
|
|
874
|
-
var _useState = _sliced_to_array(useState(socketServiceInstance.isConnected()), 2), socketConnected = _useState[0], setSocketConnected = _useState[1];
|
|
875
|
-
var _useState1 = _sliced_to_array(useState([]), 2), cleanupSubscriptions = _useState1[0], setCleanupSubscriptions = _useState1[1];
|
|
876
|
-
useDeepCompareEffect(function() {
|
|
877
|
-
if (!auth.currentUser) {
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
if (socketConnected) {
|
|
881
|
-
setCleanupSubscriptions(function(prev) {
|
|
882
|
-
return _to_consumable_array(prev).concat([
|
|
883
|
-
socketServiceInstance.subscribeToCollections(configs)
|
|
884
|
-
]);
|
|
885
|
-
});
|
|
886
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
887
|
-
console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
|
|
888
|
-
return c.collectionName;
|
|
889
|
-
}).join(", ")));
|
|
890
|
-
}
|
|
891
|
-
} else {
|
|
892
|
-
auth.currentUser.getIdToken().then(function(token) {
|
|
893
|
-
socketServiceInstance.setAuthToken(token);
|
|
894
|
-
socketServiceInstance.getSocketInstance();
|
|
895
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
896
|
-
console.log("==> ".concat(label || "Cache snapshots", " started... "));
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
var uiOnConnect = function() {
|
|
901
|
-
setSocketConnected(true);
|
|
902
|
-
};
|
|
903
|
-
var uiOnDisconnect = function() {
|
|
904
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
905
|
-
return cleanup();
|
|
906
|
-
});
|
|
907
|
-
setSocketConnected(false);
|
|
908
|
-
};
|
|
909
|
-
socketServiceInstance.onConnect(uiOnConnect);
|
|
910
|
-
socketServiceInstance.onDisconnect(uiOnDisconnect);
|
|
911
|
-
setSocketConnected(socketServiceInstance.isConnected());
|
|
912
|
-
return function() {
|
|
913
|
-
if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
|
|
914
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
915
|
-
return cleanup();
|
|
916
|
-
});
|
|
917
|
-
socketServiceInstance.offConnect(uiOnConnect);
|
|
918
|
-
socketServiceInstance.offDisconnect(uiOnDisconnect);
|
|
919
|
-
}
|
|
920
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
921
|
-
console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
}, [
|
|
925
|
-
socketConnected,
|
|
926
|
-
configs,
|
|
927
|
-
auth
|
|
928
|
-
]);
|
|
929
|
-
useEffect2(function() {
|
|
930
|
-
return function() {
|
|
931
|
-
cleanupSubscriptions.forEach(function(cleanup) {
|
|
932
|
-
return cleanup();
|
|
933
|
-
});
|
|
934
|
-
};
|
|
935
|
-
}, []);
|
|
936
|
-
return {
|
|
937
|
-
socketConnected: socketConnected
|
|
938
|
-
};
|
|
939
|
-
};
|
|
940
456
|
// src/hooks/global.ts
|
|
941
457
|
var useDocumentTitle = function(title) {
|
|
942
|
-
|
|
458
|
+
useEffect2(function() {
|
|
943
459
|
document.title = title;
|
|
944
460
|
}, [
|
|
945
461
|
title
|
|
@@ -951,8 +467,8 @@ var useSnapshotBulk = function(configs, label, settings) {
|
|
|
951
467
|
var unsubscribeFunctions = useRef2([]);
|
|
952
468
|
useDeepCompareEffect(function() {
|
|
953
469
|
var start = performance.now();
|
|
954
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
955
|
-
console.log("==> ".concat(label || "
|
|
470
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
471
|
+
console.log("==> ".concat(label || "Custom snapshots", " started... "));
|
|
956
472
|
}
|
|
957
473
|
var snapshotResults = configs.map(function(config) {
|
|
958
474
|
return snapshot(config, snapshotsFirstTime.current, settings);
|
|
@@ -963,8 +479,8 @@ var useSnapshotBulk = function(configs, label, settings) {
|
|
|
963
479
|
Promise.all(snapshotResults.map(function(result) {
|
|
964
480
|
return result.promise;
|
|
965
481
|
})).then(function() {
|
|
966
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
967
|
-
console.log("==> ".concat(label || "
|
|
482
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
483
|
+
console.log("==> ".concat(label || "Custom snapshots", " ended. It took ").concat((performance.now() - start).toFixed(2), " ms"));
|
|
968
484
|
}
|
|
969
485
|
});
|
|
970
486
|
if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
|
|
@@ -974,8 +490,8 @@ var useSnapshotBulk = function(configs, label, settings) {
|
|
|
974
490
|
unsubscribe();
|
|
975
491
|
}
|
|
976
492
|
});
|
|
977
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)
|
|
978
|
-
console.log("==> ".concat(label || "
|
|
493
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
494
|
+
console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
|
|
979
495
|
}
|
|
980
496
|
};
|
|
981
497
|
}
|
|
@@ -984,7 +500,7 @@ var useSnapshotBulk = function(configs, label, settings) {
|
|
|
984
500
|
label,
|
|
985
501
|
settings
|
|
986
502
|
]);
|
|
987
|
-
|
|
503
|
+
useEffect2(function() {
|
|
988
504
|
return function() {
|
|
989
505
|
unsubscribeFunctions.current.forEach(function(unsubscribe) {
|
|
990
506
|
if (unsubscribe) {
|
|
@@ -992,53 +508,11 @@ var useSnapshotBulk = function(configs, label, settings) {
|
|
|
992
508
|
}
|
|
993
509
|
});
|
|
994
510
|
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
|
|
995
|
-
console.log("==> ".concat(label || "
|
|
511
|
+
console.log("==> ".concat(label || "Custom snapshots", " unsubscribed"));
|
|
996
512
|
}
|
|
997
513
|
};
|
|
998
514
|
}, []);
|
|
999
515
|
};
|
|
1000
|
-
var useSmartSnapshot = function(configs, label, settings) {
|
|
1001
|
-
var _useState2 = _sliced_to_array(useState2(null), 2), cacheCollectionsConfig = _useState2[0], setCacheCollectionsConfig = _useState2[1];
|
|
1002
|
-
useEffect3(function() {
|
|
1003
|
-
get_document_by_id("nx-settings", "cache_collections_config").then(function(res) {
|
|
1004
|
-
return setCacheCollectionsConfig(res);
|
|
1005
|
-
});
|
|
1006
|
-
return function() {
|
|
1007
|
-
return setCacheCollectionsConfig(null);
|
|
1008
|
-
};
|
|
1009
|
-
}, []);
|
|
1010
|
-
var groupedConfig = useMemo2(function() {
|
|
1011
|
-
if (!cacheCollectionsConfig) {
|
|
1012
|
-
return {
|
|
1013
|
-
configForDb: [],
|
|
1014
|
-
configForCache: []
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
var configForDb = [];
|
|
1018
|
-
var configForCache = [];
|
|
1019
|
-
configs.forEach(function(cfg) {
|
|
1020
|
-
var collectionName = cfg.collectionName, _cfg_subscribeTo = cfg.subscribeTo, subscribeTo = _cfg_subscribeTo === void 0 ? "cache" : _cfg_subscribeTo;
|
|
1021
|
-
if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName]) {
|
|
1022
|
-
configForCache.push(cfg);
|
|
1023
|
-
} else {
|
|
1024
|
-
configForDb.push(cfg);
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
return {
|
|
1028
|
-
configForDb: configForDb,
|
|
1029
|
-
configForCache: configForCache
|
|
1030
|
-
};
|
|
1031
|
-
}, [
|
|
1032
|
-
configs,
|
|
1033
|
-
cacheCollectionsConfig
|
|
1034
|
-
]);
|
|
1035
|
-
useSnapshotBulk(groupedConfig.configForDb, label, settings);
|
|
1036
|
-
var socketConnected = useSocketSubscription(groupedConfig.configForCache, label, settings).socketConnected;
|
|
1037
|
-
return {
|
|
1038
|
-
groupedConfig: groupedConfig,
|
|
1039
|
-
socketConnected: socketConnected
|
|
1040
|
-
};
|
|
1041
|
-
};
|
|
1042
516
|
var useSetUserCountry = function(setUserCountry, changLang) {
|
|
1043
517
|
useLayoutEffect(function() {
|
|
1044
518
|
var currentCountry = localStorage.getItem("userCountry");
|
|
@@ -1074,6 +548,6 @@ var useSetUserCountry = function(setUserCountry, changLang) {
|
|
|
1074
548
|
return null;
|
|
1075
549
|
};
|
|
1076
550
|
// src/hooks/WebWorker.ts
|
|
1077
|
-
import { useCallback as useCallback2, useEffect as
|
|
1078
|
-
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry,
|
|
551
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
552
|
+
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSnapshotBulk };
|
|
1079
553
|
//# sourceMappingURL=index.mjs.map
|
package/dist/types/index.d.mts
CHANGED
|
@@ -97,8 +97,6 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
97
97
|
fieldName: string;
|
|
98
98
|
direction: "asc" | "desc";
|
|
99
99
|
}[];
|
|
100
|
-
parseAs?: "object" | "array";
|
|
101
|
-
subscribeTo?: "cache" | "db";
|
|
102
100
|
}
|
|
103
101
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
104
102
|
collectionName: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -97,8 +97,6 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
97
97
|
fieldName: string;
|
|
98
98
|
direction: "asc" | "desc";
|
|
99
99
|
}[];
|
|
100
|
-
parseAs?: "object" | "array";
|
|
101
|
-
subscribeTo?: "cache" | "db";
|
|
102
100
|
}
|
|
103
101
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
104
102
|
collectionName: string;
|