akeyless-client-commons 1.1.22 → 1.1.24
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 +315 -6
- package/dist/components/index.mjs +315 -6
- package/dist/components/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +44 -4
- package/dist/helpers/index.d.ts +44 -4
- package/dist/helpers/index.js +346 -0
- package/dist/helpers/index.mjs +335 -1
- package/dist/hooks/index.d.mts +27 -8
- package/dist/hooks/index.d.ts +27 -8
- package/dist/hooks/index.js +619 -66
- package/dist/hooks/index.mjs +609 -64
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +5 -2
|
@@ -944,6 +944,8 @@ function timestamp_to_string(firebaseTimestamp, options) {
|
|
|
944
944
|
date = firebaseTimestamp.toDate();
|
|
945
945
|
} else if (_instanceof(firebaseTimestamp, Date)) {
|
|
946
946
|
date = firebaseTimestamp;
|
|
947
|
+
} else if (firebaseTimestamp._seconds && firebaseTimestamp._nanoseconds) {
|
|
948
|
+
date = new Date(firebaseTimestamp._seconds * 1e3 + firebaseTimestamp._nanoseconds / 1e6);
|
|
947
949
|
} else if (typeof firebaseTimestamp === "string") {
|
|
948
950
|
date = moment2.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
|
|
949
951
|
if (isNaN(date.getTime())) {
|
|
@@ -968,8 +970,315 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
968
970
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
969
971
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
970
972
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
973
|
+
var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
|
|
974
|
+
var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
|
|
971
975
|
// src/helpers/emails.ts
|
|
972
976
|
import axios3 from "axios";
|
|
977
|
+
// src/helpers/socket.ts
|
|
978
|
+
import { io } from "socket.io-client";
|
|
979
|
+
var SESSION_STORAGE_KEY = "sessionId";
|
|
980
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
981
|
+
"use strict";
|
|
982
|
+
function _SocketService() {
|
|
983
|
+
_class_call_check(this, _SocketService);
|
|
984
|
+
this.socket = null;
|
|
985
|
+
this.connectCallbacks = [];
|
|
986
|
+
this.disconnectCallbacks = [];
|
|
987
|
+
this.authToken = null;
|
|
988
|
+
}
|
|
989
|
+
_create_class(_SocketService, [
|
|
990
|
+
{
|
|
991
|
+
/// Initialize the socket connection
|
|
992
|
+
key: "initSocket",
|
|
993
|
+
value: function initSocket() {
|
|
994
|
+
var _this = this;
|
|
995
|
+
if (!this.socket) {
|
|
996
|
+
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
997
|
+
this.socket = io(socketUrl, {
|
|
998
|
+
path: "/api/data-socket/connect",
|
|
999
|
+
auth: function(cb) {
|
|
1000
|
+
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
1001
|
+
var token = _this.authToken;
|
|
1002
|
+
var authPayload = {};
|
|
1003
|
+
if (token) authPayload.token = token;
|
|
1004
|
+
if (sessionId) authPayload.sessionId = sessionId;
|
|
1005
|
+
cb(authPayload);
|
|
1006
|
+
},
|
|
1007
|
+
transports: [
|
|
1008
|
+
"websocket"
|
|
1009
|
+
],
|
|
1010
|
+
reconnection: true,
|
|
1011
|
+
reconnectionAttempts: 30,
|
|
1012
|
+
reconnectionDelay: 2 * 1e3
|
|
1013
|
+
});
|
|
1014
|
+
this.socket.on("connect", function() {
|
|
1015
|
+
var _this_socket, _this_socket1;
|
|
1016
|
+
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, ")"));
|
|
1017
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
1018
|
+
return cb();
|
|
1019
|
+
});
|
|
1020
|
+
});
|
|
1021
|
+
this.socket.on("disconnect", function(reason) {
|
|
1022
|
+
console.log("Socket disconnected:", reason);
|
|
1023
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
1024
|
+
return cb();
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
this.socket.on("session", function(param) {
|
|
1028
|
+
var session_id = param.session_id;
|
|
1029
|
+
if (session_id) {
|
|
1030
|
+
localStorage.setItem(SESSION_STORAGE_KEY, session_id);
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
this.socket.on("connect_error", function(error) {
|
|
1034
|
+
console.error("Socket connection error:", error);
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
/// get socket instance
|
|
1041
|
+
key: "getSocketInstance",
|
|
1042
|
+
value: function getSocketInstance() {
|
|
1043
|
+
if (!this.socket) {
|
|
1044
|
+
this.initSocket();
|
|
1045
|
+
}
|
|
1046
|
+
if (!this.socket) {
|
|
1047
|
+
throw new Error("Socket not initialized");
|
|
1048
|
+
}
|
|
1049
|
+
if (!this.socket.connected) {
|
|
1050
|
+
this.socket.connect();
|
|
1051
|
+
}
|
|
1052
|
+
return this.socket;
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
/// connection management methods
|
|
1057
|
+
key: "startSession",
|
|
1058
|
+
value: function startSession(token) {
|
|
1059
|
+
this.setAuthToken(token);
|
|
1060
|
+
this.initSocket();
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
key: "onConnect",
|
|
1065
|
+
value: function onConnect(callback) {
|
|
1066
|
+
var _this = this;
|
|
1067
|
+
var _this_socket;
|
|
1068
|
+
if (!this.connectCallbacks.includes(callback)) {
|
|
1069
|
+
this.connectCallbacks.push(callback);
|
|
1070
|
+
}
|
|
1071
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
1072
|
+
callback();
|
|
1073
|
+
}
|
|
1074
|
+
return function() {
|
|
1075
|
+
return _this.offConnect(callback);
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
key: "offConnect",
|
|
1081
|
+
value: function offConnect(callback) {
|
|
1082
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
1083
|
+
return cb !== callback;
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
key: "onDisconnect",
|
|
1089
|
+
value: function onDisconnect(callback) {
|
|
1090
|
+
var _this = this;
|
|
1091
|
+
if (!this.disconnectCallbacks.includes(callback)) {
|
|
1092
|
+
this.disconnectCallbacks.push(callback);
|
|
1093
|
+
}
|
|
1094
|
+
if (this.socket && !this.socket.connected) {
|
|
1095
|
+
callback();
|
|
1096
|
+
}
|
|
1097
|
+
return function() {
|
|
1098
|
+
return _this.offDisconnect(callback);
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
key: "offDisconnect",
|
|
1104
|
+
value: function offDisconnect(callback) {
|
|
1105
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
1106
|
+
return cb !== callback;
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
key: "isConnected",
|
|
1112
|
+
value: function isConnected() {
|
|
1113
|
+
var _this_socket;
|
|
1114
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
key: "setAuthToken",
|
|
1119
|
+
value: function setAuthToken(token) {
|
|
1120
|
+
this.authToken = token;
|
|
1121
|
+
if (this.socket) {
|
|
1122
|
+
this.socket.connect();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
key: "disconnectSocket",
|
|
1128
|
+
value: function disconnectSocket() {
|
|
1129
|
+
if (this.socket) {
|
|
1130
|
+
this.socket.io.engine.close();
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
/// subscribe to collections
|
|
1136
|
+
key: "subscribeToCollections",
|
|
1137
|
+
value: function subscribeToCollections(config) {
|
|
1138
|
+
var _this = this;
|
|
1139
|
+
if (config.length === 0) {
|
|
1140
|
+
return function() {};
|
|
1141
|
+
}
|
|
1142
|
+
var s = this.getSocketInstance();
|
|
1143
|
+
var collectionsNames = config.map(function(c) {
|
|
1144
|
+
return c.collectionName;
|
|
1145
|
+
});
|
|
1146
|
+
var eventHandlers = [];
|
|
1147
|
+
config.forEach(function(configuration) {
|
|
1148
|
+
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;
|
|
1149
|
+
var attach = function(eventName, handler) {
|
|
1150
|
+
_this.socket.off(eventName, handler);
|
|
1151
|
+
_this.socket.on(eventName, handler);
|
|
1152
|
+
eventHandlers.push({
|
|
1153
|
+
eventName: eventName,
|
|
1154
|
+
handler: handler
|
|
1155
|
+
});
|
|
1156
|
+
};
|
|
1157
|
+
attach("initial:".concat(collectionName), onFirstTime);
|
|
1158
|
+
attach("add:".concat(collectionName), onAdd);
|
|
1159
|
+
attach("update:".concat(collectionName), onModify);
|
|
1160
|
+
attach("delete:".concat(collectionName), onRemove);
|
|
1161
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
1162
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
1163
|
+
attach("initial:".concat(collectionName), extraOnFirstTime);
|
|
1164
|
+
attach("add:".concat(collectionName), extraOnAdd);
|
|
1165
|
+
attach("update:".concat(collectionName), extraOnModify);
|
|
1166
|
+
attach("delete:".concat(collectionName), extraOnRemove);
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
1170
|
+
if (callback.success) {
|
|
1171
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
1172
|
+
} else {
|
|
1173
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
return function() {
|
|
1177
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
1178
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
1179
|
+
eventHandlers.forEach(function(eh) {
|
|
1180
|
+
s.off(eh.eventName, eh.handler);
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
/// set data
|
|
1187
|
+
key: "setData",
|
|
1188
|
+
value: function setData(payload) {
|
|
1189
|
+
var s = this.getSocketInstance();
|
|
1190
|
+
return new Promise(function(resolve, reject) {
|
|
1191
|
+
s.emit("set_data", payload, function(callback) {
|
|
1192
|
+
if (callback.success) {
|
|
1193
|
+
console.log("Data saved successfully:", payload);
|
|
1194
|
+
console.log("ack", callback);
|
|
1195
|
+
resolve(callback);
|
|
1196
|
+
} else {
|
|
1197
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
/// get data
|
|
1205
|
+
key: "getCollectionData",
|
|
1206
|
+
value: function getCollectionData(payload) {
|
|
1207
|
+
var s = this.getSocketInstance();
|
|
1208
|
+
s.emit("get_data", {
|
|
1209
|
+
collection_name: payload.collection_name
|
|
1210
|
+
}, function(socketCallback) {
|
|
1211
|
+
if (socketCallback.success && socketCallback.data) {
|
|
1212
|
+
payload.callback(socketCallback.data);
|
|
1213
|
+
} else {
|
|
1214
|
+
payload.callback(payload.defaultValue);
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
key: "getDocumentData",
|
|
1221
|
+
value: function getDocumentData(payload) {
|
|
1222
|
+
var s = this.getSocketInstance();
|
|
1223
|
+
s.emit("get_data", {
|
|
1224
|
+
collection_name: payload.collection_name,
|
|
1225
|
+
key: payload.key
|
|
1226
|
+
}, function(socketCallback) {
|
|
1227
|
+
if (socketCallback.success && socketCallback.data) {
|
|
1228
|
+
payload.callback(socketCallback.data);
|
|
1229
|
+
} else {
|
|
1230
|
+
payload.callback(payload.defaultValue);
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
/// delete data
|
|
1237
|
+
key: "deleteData",
|
|
1238
|
+
value: function deleteData(payload) {
|
|
1239
|
+
var s = this.getSocketInstance();
|
|
1240
|
+
return new Promise(function(resolve, reject) {
|
|
1241
|
+
s.emit("delete_data", payload, function(callback) {
|
|
1242
|
+
if (callback.success) {
|
|
1243
|
+
console.log("Data deleted successfully:", payload);
|
|
1244
|
+
console.log("delete ack", callback);
|
|
1245
|
+
resolve(callback);
|
|
1246
|
+
} else {
|
|
1247
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
key: "clearAllRedisData",
|
|
1255
|
+
value: function clearAllRedisData() {
|
|
1256
|
+
var s = this.getSocketInstance();
|
|
1257
|
+
return new Promise(function(resolve, reject) {
|
|
1258
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
1259
|
+
if (ack.success) {
|
|
1260
|
+
resolve(ack);
|
|
1261
|
+
} else {
|
|
1262
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
], [
|
|
1269
|
+
{
|
|
1270
|
+
key: "getInstance",
|
|
1271
|
+
value: function getInstance() {
|
|
1272
|
+
if (!_SocketService.instance) {
|
|
1273
|
+
_SocketService.instance = new _SocketService();
|
|
1274
|
+
}
|
|
1275
|
+
return _SocketService.instance;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
]);
|
|
1279
|
+
return _SocketService;
|
|
1280
|
+
}();
|
|
1281
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
973
1282
|
// src/components/utils/Checkboxes.tsx
|
|
974
1283
|
import { useEffect, useState } from "react";
|
|
975
1284
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -3522,14 +3831,14 @@ function rectsAreEqual(a, b) {
|
|
|
3522
3831
|
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
3523
3832
|
}
|
|
3524
3833
|
function observeMove(element, onMove) {
|
|
3525
|
-
var
|
|
3834
|
+
var io2 = null;
|
|
3526
3835
|
var timeoutId;
|
|
3527
3836
|
var root = getDocumentElement(element);
|
|
3528
3837
|
function cleanup() {
|
|
3529
3838
|
var _io;
|
|
3530
3839
|
clearTimeout(timeoutId);
|
|
3531
|
-
(_io =
|
|
3532
|
-
|
|
3840
|
+
(_io = io2) == null || _io.disconnect();
|
|
3841
|
+
io2 = null;
|
|
3533
3842
|
}
|
|
3534
3843
|
function refresh(skip, threshold) {
|
|
3535
3844
|
if (skip === void 0) {
|
|
@@ -3577,14 +3886,14 @@ function observeMove(element, onMove) {
|
|
|
3577
3886
|
isFirstUpdate = false;
|
|
3578
3887
|
}
|
|
3579
3888
|
try {
|
|
3580
|
-
|
|
3889
|
+
io2 = new IntersectionObserver(handleObserve, _object_spread_props(_object_spread({}, options), {
|
|
3581
3890
|
// Handle <iframe>s
|
|
3582
3891
|
root: root.ownerDocument
|
|
3583
3892
|
}));
|
|
3584
3893
|
} catch (e) {
|
|
3585
|
-
|
|
3894
|
+
io2 = new IntersectionObserver(handleObserve, options);
|
|
3586
3895
|
}
|
|
3587
|
-
|
|
3896
|
+
io2.observe(element);
|
|
3588
3897
|
}
|
|
3589
3898
|
refresh(true);
|
|
3590
3899
|
return cleanup;
|