akeyless-client-commons 1.1.1 → 1.1.3

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.
@@ -446,6 +446,9 @@ __export(index_exports, {
446
446
  DisplayAllRowsButton: function() {
447
447
  return DisplayAllRowsButton;
448
448
  },
449
+ DurationPicker: function() {
450
+ return DurationPicker;
451
+ },
449
452
  DurationUI: function() {
450
453
  return DurationUI;
451
454
  },
@@ -1155,278 +1158,6 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
1155
1158
  var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
1156
1159
  var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
1157
1160
  var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
1158
- // src/helpers/socket.ts
1159
- var import_socket = require("socket.io-client");
1160
- var SocketService = /*#__PURE__*/ function() {
1161
- "use strict";
1162
- function _SocketService() {
1163
- _class_call_check(this, _SocketService);
1164
- this.socket = null;
1165
- this.connectCallbacks = [];
1166
- this.disconnectCallbacks = [];
1167
- this.initSocket();
1168
- }
1169
- _create_class(_SocketService, [
1170
- {
1171
- /// Initialize the socket connection
1172
- key: "initSocket",
1173
- value: function initSocket() {
1174
- var _this = this;
1175
- if (!this.socket) {
1176
- var SOCKET_SERVER_URL = "http://localhost:9009";
1177
- var SOCKET_PATH = "/api/data-socket/connect";
1178
- this.socket = (0, import_socket.io)(SOCKET_SERVER_URL, {
1179
- path: SOCKET_PATH,
1180
- transports: [
1181
- "websocket"
1182
- ]
1183
- });
1184
- this.socket.on("connect", function() {
1185
- var _this_socket;
1186
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
1187
- _this.connectCallbacks.forEach(function(cb) {
1188
- return cb();
1189
- });
1190
- });
1191
- this.socket.on("disconnect", function(reason) {
1192
- console.log("Socket disconnected:", reason);
1193
- _this.disconnectCallbacks.forEach(function(cb) {
1194
- return cb();
1195
- });
1196
- });
1197
- this.socket.on("connect_error", function(error) {
1198
- console.error("Socket connection error:", error);
1199
- });
1200
- }
1201
- }
1202
- },
1203
- {
1204
- /// get socket instance
1205
- key: "getSocketInstance",
1206
- value: function getSocketInstance() {
1207
- if (!this.socket) {
1208
- this.initSocket();
1209
- }
1210
- if (!this.socket) {
1211
- throw new Error("Socket not initialized");
1212
- }
1213
- if (!this.socket.connected) {
1214
- this.socket.connect();
1215
- }
1216
- return this.socket;
1217
- }
1218
- },
1219
- {
1220
- /// subscribe to collections
1221
- key: "subscribeToCollections",
1222
- value: function subscribeToCollections(config) {
1223
- var s = this.getSocketInstance();
1224
- var collectionsNames = config.map(function(c) {
1225
- return c.collectionName;
1226
- });
1227
- var eventHandlers = [];
1228
- config.forEach(function(configuration) {
1229
- 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;
1230
- s.on("initial:".concat(collectionName), onFirstTime);
1231
- eventHandlers.push({
1232
- eventName: "initial:".concat(collectionName),
1233
- handler: onFirstTime
1234
- });
1235
- s.on("add:".concat(collectionName), onAdd);
1236
- eventHandlers.push({
1237
- eventName: "add:".concat(collectionName),
1238
- handler: onAdd
1239
- });
1240
- s.on("update:".concat(collectionName), onModify);
1241
- eventHandlers.push({
1242
- eventName: "update:".concat(collectionName),
1243
- handler: onModify
1244
- });
1245
- s.on("delete:".concat(collectionName), onRemove);
1246
- eventHandlers.push({
1247
- eventName: "delete:".concat(collectionName),
1248
- handler: onRemove
1249
- });
1250
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1251
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1252
- s.on("initial:".concat(collectionName), extraOnFirstTime);
1253
- eventHandlers.push({
1254
- eventName: "initial:".concat(collectionName),
1255
- handler: extraOnFirstTime
1256
- });
1257
- s.on("add:".concat(collectionName), extraOnAdd);
1258
- eventHandlers.push({
1259
- eventName: "add:".concat(collectionName),
1260
- handler: extraOnAdd
1261
- });
1262
- s.on("update:".concat(collectionName), extraOnModify);
1263
- eventHandlers.push({
1264
- eventName: "update:".concat(collectionName),
1265
- handler: extraOnModify
1266
- });
1267
- s.on("delete:".concat(collectionName), extraOnRemove);
1268
- eventHandlers.push({
1269
- eventName: "delete:".concat(collectionName),
1270
- handler: extraOnRemove
1271
- });
1272
- });
1273
- });
1274
- s.emit("subscribe_collections", collectionsNames, function(callback) {
1275
- if (callback.success) {
1276
- console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
1277
- } else {
1278
- console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
1279
- }
1280
- });
1281
- return function() {
1282
- console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
1283
- s.emit("unsubscribe_collections", collectionsNames);
1284
- eventHandlers.forEach(function(eh) {
1285
- s.off(eh.eventName, eh.handler);
1286
- });
1287
- };
1288
- }
1289
- },
1290
- {
1291
- /// set data
1292
- key: "setData",
1293
- value: function setData(payload) {
1294
- var s = this.getSocketInstance();
1295
- return new Promise(function(resolve, reject) {
1296
- s.emit("set_data", payload, function(callback) {
1297
- if (callback.success) {
1298
- console.log("Data saved successfully:", payload);
1299
- console.log("ack", callback);
1300
- resolve(callback);
1301
- } else {
1302
- reject(new Error(callback.message || "Save operation failed"));
1303
- }
1304
- });
1305
- });
1306
- }
1307
- },
1308
- {
1309
- /// get data
1310
- key: "getCollectionData",
1311
- value: function getCollectionData(payload) {
1312
- var s = this.getSocketInstance();
1313
- s.emit("get_data", {
1314
- collection_name: payload.collection_name
1315
- }, function(socketCallback) {
1316
- if (socketCallback.success && socketCallback.data) {
1317
- payload.callback(socketCallback.data);
1318
- } else {
1319
- payload.callback(payload.defaultValue);
1320
- }
1321
- });
1322
- }
1323
- },
1324
- {
1325
- key: "getDocumentData",
1326
- value: function getDocumentData(payload) {
1327
- var s = this.getSocketInstance();
1328
- s.emit("get_data", {
1329
- collection_name: payload.collection_name,
1330
- key: payload.key
1331
- }, function(socketCallback) {
1332
- if (socketCallback.success && socketCallback.data) {
1333
- payload.callback(socketCallback.data);
1334
- } else {
1335
- payload.callback(payload.defaultValue);
1336
- }
1337
- });
1338
- }
1339
- },
1340
- {
1341
- /// delete data
1342
- key: "deleteData",
1343
- value: function deleteData(payload) {
1344
- var s = this.getSocketInstance();
1345
- return new Promise(function(resolve, reject) {
1346
- s.emit("delete_data", payload, function(callback) {
1347
- if (callback.success) {
1348
- console.log("Data deleted successfully:", payload);
1349
- console.log("delete ack", callback);
1350
- resolve(callback);
1351
- } else {
1352
- reject(new Error(callback.message || "Delete operation failed"));
1353
- }
1354
- });
1355
- });
1356
- }
1357
- },
1358
- {
1359
- key: "clearAllRedisData",
1360
- value: function clearAllRedisData() {
1361
- var s = this.getSocketInstance();
1362
- return new Promise(function(resolve, reject) {
1363
- s.emit("clear_all_redis_data", function(ack) {
1364
- if (ack.success) {
1365
- resolve(ack);
1366
- } else {
1367
- reject(new Error(ack.message || "Clear all Redis data operation failed"));
1368
- }
1369
- });
1370
- });
1371
- }
1372
- },
1373
- {
1374
- /// connection management methods
1375
- key: "onConnect",
1376
- value: function onConnect(callback) {
1377
- var _this_socket;
1378
- this.connectCallbacks.push(callback);
1379
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1380
- callback();
1381
- }
1382
- }
1383
- },
1384
- {
1385
- key: "offConnect",
1386
- value: function offConnect(callback) {
1387
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1388
- return cb !== callback;
1389
- });
1390
- }
1391
- },
1392
- {
1393
- key: "onDisconnect",
1394
- value: function onDisconnect(callback) {
1395
- this.disconnectCallbacks.push(callback);
1396
- if (this.socket && !this.socket.connected) {
1397
- callback();
1398
- }
1399
- }
1400
- },
1401
- {
1402
- key: "offDisconnect",
1403
- value: function offDisconnect(callback) {
1404
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1405
- return cb !== callback;
1406
- });
1407
- }
1408
- },
1409
- {
1410
- key: "isConnected",
1411
- value: function isConnected() {
1412
- var _this_socket;
1413
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1414
- }
1415
- }
1416
- ], [
1417
- {
1418
- key: "getInstance",
1419
- value: function getInstance() {
1420
- if (!_SocketService.instance) {
1421
- _SocketService.instance = new _SocketService();
1422
- }
1423
- return _SocketService.instance;
1424
- }
1425
- }
1426
- ]);
1427
- return _SocketService;
1428
- }();
1429
- var socketServiceInstance = SocketService.getInstance();
1430
1161
  // src/components/utils/Checkboxes.tsx
1431
1162
  var import_react2 = require("react");
1432
1163
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -3969,14 +3700,14 @@ function rectsAreEqual(a, b) {
3969
3700
  return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3970
3701
  }
3971
3702
  function observeMove(element, onMove) {
3972
- var io2 = null;
3703
+ var io = null;
3973
3704
  var timeoutId;
3974
3705
  var root = getDocumentElement(element);
3975
3706
  function cleanup() {
3976
3707
  var _io;
3977
3708
  clearTimeout(timeoutId);
3978
- (_io = io2) == null || _io.disconnect();
3979
- io2 = null;
3709
+ (_io = io) == null || _io.disconnect();
3710
+ io = null;
3980
3711
  }
3981
3712
  function refresh(skip, threshold) {
3982
3713
  if (skip === void 0) {
@@ -4024,14 +3755,14 @@ function observeMove(element, onMove) {
4024
3755
  isFirstUpdate = false;
4025
3756
  }
4026
3757
  try {
4027
- io2 = new IntersectionObserver(handleObserve, _object_spread_props(_object_spread({}, options), {
3758
+ io = new IntersectionObserver(handleObserve, _object_spread_props(_object_spread({}, options), {
4028
3759
  // Handle <iframe>s
4029
3760
  root: root.ownerDocument
4030
3761
  }));
4031
3762
  } catch (e) {
4032
- io2 = new IntersectionObserver(handleObserve, options);
3763
+ io = new IntersectionObserver(handleObserve, options);
4033
3764
  }
4034
- io2.observe(element);
3765
+ io.observe(element);
4035
3766
  }
4036
3767
  refresh(true);
4037
3768
  return cleanup;
@@ -6366,6 +6097,90 @@ var CheckboxContainer = function(param) {
6366
6097
  })
6367
6098
  }));
6368
6099
  };
6100
+ var DurationPicker = function(param) {
6101
+ var _param_name = param.name, name = _param_name === void 0 ? "" : _param_name, _param_labelContent = param.labelContent, labelContent = _param_labelContent === void 0 ? "" : _param_labelContent, _param_containerClassName = param.containerClassName, containerClassName = _param_containerClassName === void 0 ? "h-12" : _param_containerClassName, _param_labelClassName = param.labelClassName, labelClassName = _param_labelClassName === void 0 ? "" : _param_labelClassName, _param_elementClassName = param.elementClassName, elementClassName = _param_elementClassName === void 0 ? "" : _param_elementClassName, _param_required = param.required, required = _param_required === void 0 ? false : _param_required, direction = param.direction, onChange = param.onChange, labelWithDots = param.labelWithDots, labelsCommonClassName = param.labelsCommonClassName, title = param.title, labelStyle = param.labelStyle, value = param.value, _param_options = param.options, options = _param_options === void 0 ? [
6102
+ "days",
6103
+ "hours",
6104
+ "minutes",
6105
+ "seconds"
6106
+ ] : _param_options, _param_hideLabels = param.hideLabels, hideLabels = _param_hideLabels === void 0 ? false : _param_hideLabels;
6107
+ var containerProps = (0, import_react15.useMemo)(function() {
6108
+ return {
6109
+ containerClassName: containerClassName,
6110
+ direction: direction,
6111
+ labelClassName: labelClassName,
6112
+ labelContent: labelContent,
6113
+ labelWithDots: labelWithDots,
6114
+ labelsCommonClassName: labelsCommonClassName,
6115
+ name: name,
6116
+ required: required,
6117
+ labelStyle: labelStyle
6118
+ };
6119
+ }, [
6120
+ containerClassName,
6121
+ direction,
6122
+ labelClassName,
6123
+ labelContent,
6124
+ labelWithDots,
6125
+ labelsCommonClassName,
6126
+ name,
6127
+ required,
6128
+ labelStyle
6129
+ ]);
6130
+ var _ref = _sliced_to_array((0, import_react15.useState)(value || {
6131
+ days: 0,
6132
+ hours: 0,
6133
+ minutes: 0,
6134
+ seconds: 0
6135
+ }), 2), duration = _ref[0], setDuration = _ref[1];
6136
+ var handleField = function(field, range) {
6137
+ return function(e) {
6138
+ var raw = parseInt(e.target.value, 10);
6139
+ var clamped = isNaN(raw) ? 0 : Math.min(range[1], Math.max(range[0], raw));
6140
+ setDuration(_object_spread_props(_object_spread({}, duration), _define_property({}, field, clamped)));
6141
+ onChange === null || onChange === void 0 ? void 0 : onChange(_object_spread_props(_object_spread({}, duration), _define_property({}, field, clamped)));
6142
+ };
6143
+ };
6144
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FormElementContainer, _object_spread_props(_object_spread({}, containerProps), {
6145
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", {
6146
+ className: cn("flex gap-1.5 text-sm", elementClassName),
6147
+ dir: "ltr",
6148
+ children: [
6149
+ Array.from(new Set(options)).map(function(field) {
6150
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", {
6151
+ className: "flex flex-col border p-0.5 rounded-md",
6152
+ children: [
6153
+ !hideLabels && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", {
6154
+ className: "mb-1 ps-1 capitalize text-start border-b-[1px] border-b-gray-300",
6155
+ children: field.slice(0, 1)
6156
+ }),
6157
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", {
6158
+ type: "number",
6159
+ inputMode: "numeric",
6160
+ min: 0,
6161
+ max: field === "days" ? 30 : 59,
6162
+ value: duration[field],
6163
+ onChange: handleField(field, field === "days" ? [
6164
+ 0,
6165
+ 30
6166
+ ] : [
6167
+ 0,
6168
+ field === "hours" ? 23 : 59
6169
+ ]),
6170
+ className: cn("text-center w-8 ")
6171
+ })
6172
+ ]
6173
+ }, field);
6174
+ }),
6175
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", {
6176
+ name: name,
6177
+ type: "hidden",
6178
+ value: JSON.stringify(duration)
6179
+ })
6180
+ ]
6181
+ })
6182
+ }));
6183
+ };
6369
6184
  var FormElementContainer = function(param) {
6370
6185
  var containerClassName = param.containerClassName, direction = param.direction, labelClassName = param.labelClassName, labelContent = param.labelContent, labelWithDots = param.labelWithDots, labelsCommonClassName = param.labelsCommonClassName, name = param.name, required = param.required, children = param.children, _param_defaultContainerClassName = param.defaultContainerClassName, defaultContainerClassName = _param_defaultContainerClassName === void 0 ? true : _param_defaultContainerClassName, labelStyle = param.labelStyle;
6371
6186
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", {
@@ -6866,6 +6681,7 @@ function Slot2(props) {
6866
6681
  ConfirmForm: ConfirmForm,
6867
6682
  DatePicker: DatePicker,
6868
6683
  DisplayAllRowsButton: DisplayAllRowsButton,
6684
+ DurationPicker: DurationPicker,
6869
6685
  DurationUI: DurationUI,
6870
6686
  ElementLabel: ElementLabel,
6871
6687
  ElementsContainer: ElementsContainer,