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/helpers/index.js
CHANGED
|
@@ -39,25 +39,6 @@ function _async_to_generator(fn) {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
}
|
|
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
42
|
function _define_property(obj, key, value) {
|
|
62
43
|
if (key in obj) {
|
|
63
44
|
Object.defineProperty(obj, key, {
|
|
@@ -387,12 +368,6 @@ __export(index_exports, {
|
|
|
387
368
|
createSelectors: function() {
|
|
388
369
|
return createSelectors;
|
|
389
370
|
},
|
|
390
|
-
dataSocketDomain: function() {
|
|
391
|
-
return dataSocketDomain;
|
|
392
|
-
},
|
|
393
|
-
dataSyncDomain: function() {
|
|
394
|
-
return dataSyncDomain;
|
|
395
|
-
},
|
|
396
371
|
db: function() {
|
|
397
372
|
return db;
|
|
398
373
|
},
|
|
@@ -579,9 +554,6 @@ __export(index_exports, {
|
|
|
579
554
|
snapshotDocument: function() {
|
|
580
555
|
return snapshotDocument;
|
|
581
556
|
},
|
|
582
|
-
socketServiceInstance: function() {
|
|
583
|
-
return socketServiceInstance;
|
|
584
|
-
},
|
|
585
557
|
sort_by_timestamp: function() {
|
|
586
558
|
return sort_by_timestamp;
|
|
587
559
|
},
|
|
@@ -2210,8 +2182,6 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
2210
2182
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
2211
2183
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
2212
2184
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
2213
|
-
var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
|
|
2214
|
-
var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
|
|
2215
2185
|
var akeylessOnlineDomain = mode === "qa" ? "https://akeyless-online.xyz" : "https://akeyless-online.info";
|
|
2216
2186
|
var nxApiCall = /*#__PURE__*/ function() {
|
|
2217
2187
|
var _ref = _async_to_generator(function(serverName, method, url, data) {
|
|
@@ -2242,12 +2212,6 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2242
2212
|
case "call-center-geo":
|
|
2243
2213
|
urlResult = "".concat(callCenterGeoDomain, "/").concat(url);
|
|
2244
2214
|
break;
|
|
2245
|
-
case "data-socket":
|
|
2246
|
-
urlResult = "".concat(dataSocketDomain, "/").concat(url);
|
|
2247
|
-
break;
|
|
2248
|
-
case "data-sync":
|
|
2249
|
-
urlResult = "".concat(dataSyncDomain, "/").concat(url);
|
|
2250
|
-
break;
|
|
2251
2215
|
default:
|
|
2252
2216
|
break;
|
|
2253
2217
|
}
|
|
@@ -2297,308 +2261,6 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2297
2261
|
return _ref.apply(this, arguments);
|
|
2298
2262
|
};
|
|
2299
2263
|
}();
|
|
2300
|
-
// src/helpers/socket.ts
|
|
2301
|
-
var import_socket = require("socket.io-client");
|
|
2302
|
-
var SESSION_STORAGE_KEY = "sessionId";
|
|
2303
|
-
var SocketService = /*#__PURE__*/ function() {
|
|
2304
|
-
"use strict";
|
|
2305
|
-
function _SocketService() {
|
|
2306
|
-
_class_call_check(this, _SocketService);
|
|
2307
|
-
this.socket = null;
|
|
2308
|
-
this.connectCallbacks = [];
|
|
2309
|
-
this.disconnectCallbacks = [];
|
|
2310
|
-
this.authToken = null;
|
|
2311
|
-
}
|
|
2312
|
-
_create_class(_SocketService, [
|
|
2313
|
-
{
|
|
2314
|
-
/// Initialize the socket connection
|
|
2315
|
-
key: "initSocket",
|
|
2316
|
-
value: function initSocket() {
|
|
2317
|
-
var _this = this;
|
|
2318
|
-
if (!this.socket) {
|
|
2319
|
-
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
2320
|
-
this.socket = (0, import_socket.io)(socketUrl, {
|
|
2321
|
-
path: "/api/data-socket/connect",
|
|
2322
|
-
auth: function(cb) {
|
|
2323
|
-
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
2324
|
-
var token = _this.authToken;
|
|
2325
|
-
var authPayload = {};
|
|
2326
|
-
if (token) authPayload.token = token;
|
|
2327
|
-
if (sessionId) authPayload.sessionId = sessionId;
|
|
2328
|
-
cb(authPayload);
|
|
2329
|
-
},
|
|
2330
|
-
reconnection: true,
|
|
2331
|
-
reconnectionAttempts: 30,
|
|
2332
|
-
reconnectionDelay: 2 * 1e3
|
|
2333
|
-
});
|
|
2334
|
-
this.socket.on("connect", function() {
|
|
2335
|
-
var _this_socket, _this_socket1;
|
|
2336
|
-
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, ")"));
|
|
2337
|
-
_this.connectCallbacks.forEach(function(cb) {
|
|
2338
|
-
return cb();
|
|
2339
|
-
});
|
|
2340
|
-
});
|
|
2341
|
-
this.socket.on("disconnect", function(reason) {
|
|
2342
|
-
console.log("Socket disconnected:", reason);
|
|
2343
|
-
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2344
|
-
return cb();
|
|
2345
|
-
});
|
|
2346
|
-
});
|
|
2347
|
-
this.socket.on("session", function(param) {
|
|
2348
|
-
var sessionId = param.sessionId;
|
|
2349
|
-
if (sessionId) {
|
|
2350
|
-
localStorage.setItem(SESSION_STORAGE_KEY, sessionId);
|
|
2351
|
-
}
|
|
2352
|
-
});
|
|
2353
|
-
this.socket.on("connect_error", function(error) {
|
|
2354
|
-
console.error("Socket connection error:", error);
|
|
2355
|
-
});
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
},
|
|
2359
|
-
{
|
|
2360
|
-
/// get socket instance
|
|
2361
|
-
key: "getSocketInstance",
|
|
2362
|
-
value: function getSocketInstance() {
|
|
2363
|
-
if (!this.socket) {
|
|
2364
|
-
this.initSocket();
|
|
2365
|
-
}
|
|
2366
|
-
if (!this.socket) {
|
|
2367
|
-
throw new Error("Socket not initialized");
|
|
2368
|
-
}
|
|
2369
|
-
if (!this.socket.connected) {
|
|
2370
|
-
this.socket.connect();
|
|
2371
|
-
}
|
|
2372
|
-
return this.socket;
|
|
2373
|
-
}
|
|
2374
|
-
},
|
|
2375
|
-
{
|
|
2376
|
-
/// connection management methods
|
|
2377
|
-
key: "startSession",
|
|
2378
|
-
value: function startSession(token) {
|
|
2379
|
-
this.setAuthToken(token);
|
|
2380
|
-
this.initSocket();
|
|
2381
|
-
}
|
|
2382
|
-
},
|
|
2383
|
-
{
|
|
2384
|
-
key: "onConnect",
|
|
2385
|
-
value: function onConnect(callback) {
|
|
2386
|
-
var _this = this;
|
|
2387
|
-
var _this_socket;
|
|
2388
|
-
if (!this.connectCallbacks.includes(callback)) {
|
|
2389
|
-
this.connectCallbacks.push(callback);
|
|
2390
|
-
}
|
|
2391
|
-
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
2392
|
-
callback();
|
|
2393
|
-
}
|
|
2394
|
-
return function() {
|
|
2395
|
-
return _this.offConnect(callback);
|
|
2396
|
-
};
|
|
2397
|
-
}
|
|
2398
|
-
},
|
|
2399
|
-
{
|
|
2400
|
-
key: "offConnect",
|
|
2401
|
-
value: function offConnect(callback) {
|
|
2402
|
-
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
2403
|
-
return cb !== callback;
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
},
|
|
2407
|
-
{
|
|
2408
|
-
key: "onDisconnect",
|
|
2409
|
-
value: function onDisconnect(callback) {
|
|
2410
|
-
var _this = this;
|
|
2411
|
-
if (!this.disconnectCallbacks.includes(callback)) {
|
|
2412
|
-
this.disconnectCallbacks.push(callback);
|
|
2413
|
-
}
|
|
2414
|
-
if (this.socket && !this.socket.connected) {
|
|
2415
|
-
callback();
|
|
2416
|
-
}
|
|
2417
|
-
return function() {
|
|
2418
|
-
return _this.offDisconnect(callback);
|
|
2419
|
-
};
|
|
2420
|
-
}
|
|
2421
|
-
},
|
|
2422
|
-
{
|
|
2423
|
-
key: "offDisconnect",
|
|
2424
|
-
value: function offDisconnect(callback) {
|
|
2425
|
-
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
2426
|
-
return cb !== callback;
|
|
2427
|
-
});
|
|
2428
|
-
}
|
|
2429
|
-
},
|
|
2430
|
-
{
|
|
2431
|
-
key: "isConnected",
|
|
2432
|
-
value: function isConnected() {
|
|
2433
|
-
var _this_socket;
|
|
2434
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
2435
|
-
}
|
|
2436
|
-
},
|
|
2437
|
-
{
|
|
2438
|
-
key: "setAuthToken",
|
|
2439
|
-
value: function setAuthToken(token) {
|
|
2440
|
-
this.authToken = token;
|
|
2441
|
-
if (this.socket) {
|
|
2442
|
-
this.socket.connect();
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
},
|
|
2446
|
-
{
|
|
2447
|
-
key: "disconnectSocket",
|
|
2448
|
-
value: function disconnectSocket() {
|
|
2449
|
-
if (this.socket) {
|
|
2450
|
-
this.socket.io.engine.close();
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
},
|
|
2454
|
-
{
|
|
2455
|
-
/// subscribe to collections
|
|
2456
|
-
key: "subscribeToCollections",
|
|
2457
|
-
value: function subscribeToCollections(config) {
|
|
2458
|
-
var _this = this;
|
|
2459
|
-
if (config.length === 0) {
|
|
2460
|
-
return function() {};
|
|
2461
|
-
}
|
|
2462
|
-
var s = this.getSocketInstance();
|
|
2463
|
-
var collectionsNames = config.map(function(c) {
|
|
2464
|
-
return c.collectionName;
|
|
2465
|
-
});
|
|
2466
|
-
var eventHandlers = [];
|
|
2467
|
-
config.forEach(function(configuration) {
|
|
2468
|
-
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;
|
|
2469
|
-
var attach = function(eventName, handler) {
|
|
2470
|
-
_this.socket.off(eventName, handler);
|
|
2471
|
-
_this.socket.on(eventName, handler);
|
|
2472
|
-
eventHandlers.push({
|
|
2473
|
-
eventName: eventName,
|
|
2474
|
-
handler: handler
|
|
2475
|
-
});
|
|
2476
|
-
};
|
|
2477
|
-
attach("initial:".concat(collectionName), onFirstTime);
|
|
2478
|
-
attach("add:".concat(collectionName), onAdd);
|
|
2479
|
-
attach("update:".concat(collectionName), onModify);
|
|
2480
|
-
attach("delete:".concat(collectionName), onRemove);
|
|
2481
|
-
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
2482
|
-
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
2483
|
-
attach("initial:".concat(collectionName), extraOnFirstTime);
|
|
2484
|
-
attach("add:".concat(collectionName), extraOnAdd);
|
|
2485
|
-
attach("update:".concat(collectionName), extraOnModify);
|
|
2486
|
-
attach("delete:".concat(collectionName), extraOnRemove);
|
|
2487
|
-
});
|
|
2488
|
-
});
|
|
2489
|
-
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
2490
|
-
if (callback.success) {
|
|
2491
|
-
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
2492
|
-
} else {
|
|
2493
|
-
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
2494
|
-
}
|
|
2495
|
-
});
|
|
2496
|
-
return function() {
|
|
2497
|
-
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
2498
|
-
s.emit("unsubscribe_collections", collectionsNames);
|
|
2499
|
-
eventHandlers.forEach(function(eh) {
|
|
2500
|
-
s.off(eh.eventName, eh.handler);
|
|
2501
|
-
});
|
|
2502
|
-
};
|
|
2503
|
-
}
|
|
2504
|
-
},
|
|
2505
|
-
{
|
|
2506
|
-
/// set data
|
|
2507
|
-
key: "setData",
|
|
2508
|
-
value: function setData(payload) {
|
|
2509
|
-
var s = this.getSocketInstance();
|
|
2510
|
-
return new Promise(function(resolve, reject) {
|
|
2511
|
-
s.emit("set_data", payload, function(callback) {
|
|
2512
|
-
if (callback.success) {
|
|
2513
|
-
console.log("Data saved successfully:", payload);
|
|
2514
|
-
console.log("ack", callback);
|
|
2515
|
-
resolve(callback);
|
|
2516
|
-
} else {
|
|
2517
|
-
reject(new Error(callback.message || "Save operation failed"));
|
|
2518
|
-
}
|
|
2519
|
-
});
|
|
2520
|
-
});
|
|
2521
|
-
}
|
|
2522
|
-
},
|
|
2523
|
-
{
|
|
2524
|
-
/// get data
|
|
2525
|
-
key: "getCollectionData",
|
|
2526
|
-
value: function getCollectionData(payload) {
|
|
2527
|
-
var s = this.getSocketInstance();
|
|
2528
|
-
s.emit("get_data", {
|
|
2529
|
-
collection_name: payload.collection_name
|
|
2530
|
-
}, function(socketCallback) {
|
|
2531
|
-
if (socketCallback.success && socketCallback.data) {
|
|
2532
|
-
payload.callback(socketCallback.data);
|
|
2533
|
-
} else {
|
|
2534
|
-
payload.callback(payload.defaultValue);
|
|
2535
|
-
}
|
|
2536
|
-
});
|
|
2537
|
-
}
|
|
2538
|
-
},
|
|
2539
|
-
{
|
|
2540
|
-
key: "getDocumentData",
|
|
2541
|
-
value: function getDocumentData(payload) {
|
|
2542
|
-
var s = this.getSocketInstance();
|
|
2543
|
-
s.emit("get_data", {
|
|
2544
|
-
collection_name: payload.collection_name,
|
|
2545
|
-
key: payload.key
|
|
2546
|
-
}, function(socketCallback) {
|
|
2547
|
-
if (socketCallback.success && socketCallback.data) {
|
|
2548
|
-
payload.callback(socketCallback.data);
|
|
2549
|
-
} else {
|
|
2550
|
-
payload.callback(payload.defaultValue);
|
|
2551
|
-
}
|
|
2552
|
-
});
|
|
2553
|
-
}
|
|
2554
|
-
},
|
|
2555
|
-
{
|
|
2556
|
-
/// delete data
|
|
2557
|
-
key: "deleteData",
|
|
2558
|
-
value: function deleteData(payload) {
|
|
2559
|
-
var s = this.getSocketInstance();
|
|
2560
|
-
return new Promise(function(resolve, reject) {
|
|
2561
|
-
s.emit("delete_data", payload, function(callback) {
|
|
2562
|
-
if (callback.success) {
|
|
2563
|
-
console.log("Data deleted successfully:", payload);
|
|
2564
|
-
console.log("delete ack", callback);
|
|
2565
|
-
resolve(callback);
|
|
2566
|
-
} else {
|
|
2567
|
-
reject(new Error(callback.message || "Delete operation failed"));
|
|
2568
|
-
}
|
|
2569
|
-
});
|
|
2570
|
-
});
|
|
2571
|
-
}
|
|
2572
|
-
},
|
|
2573
|
-
{
|
|
2574
|
-
key: "clearAllRedisData",
|
|
2575
|
-
value: function clearAllRedisData() {
|
|
2576
|
-
var s = this.getSocketInstance();
|
|
2577
|
-
return new Promise(function(resolve, reject) {
|
|
2578
|
-
s.emit("clear_all_redis_data", function(ack) {
|
|
2579
|
-
if (ack.success) {
|
|
2580
|
-
resolve(ack);
|
|
2581
|
-
} else {
|
|
2582
|
-
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
2583
|
-
}
|
|
2584
|
-
});
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
}
|
|
2588
|
-
], [
|
|
2589
|
-
{
|
|
2590
|
-
key: "getInstance",
|
|
2591
|
-
value: function getInstance() {
|
|
2592
|
-
if (!_SocketService.instance) {
|
|
2593
|
-
_SocketService.instance = new _SocketService();
|
|
2594
|
-
}
|
|
2595
|
-
return _SocketService.instance;
|
|
2596
|
-
}
|
|
2597
|
-
}
|
|
2598
|
-
]);
|
|
2599
|
-
return _SocketService;
|
|
2600
|
-
}();
|
|
2601
|
-
var socketServiceInstance = SocketService.getInstance();
|
|
2602
2264
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2603
2265
|
0 && (module.exports = {
|
|
2604
2266
|
addAuditRecord: addAuditRecord,
|
|
@@ -2622,8 +2284,6 @@ var socketServiceInstance = SocketService.getInstance();
|
|
|
2622
2284
|
collections: collections,
|
|
2623
2285
|
colorRegex: colorRegex,
|
|
2624
2286
|
createSelectors: createSelectors,
|
|
2625
|
-
dataSocketDomain: dataSocketDomain,
|
|
2626
|
-
dataSyncDomain: dataSyncDomain,
|
|
2627
2287
|
db: db,
|
|
2628
2288
|
delete_document: delete_document,
|
|
2629
2289
|
devicesDomain: devicesDomain,
|
|
@@ -2686,7 +2346,6 @@ var socketServiceInstance = SocketService.getInstance();
|
|
|
2686
2346
|
simpleExtractData: simpleExtractData,
|
|
2687
2347
|
snapshot: snapshot,
|
|
2688
2348
|
snapshotDocument: snapshotDocument,
|
|
2689
|
-
socketServiceInstance: socketServiceInstance,
|
|
2690
2349
|
sort_by_timestamp: sort_by_timestamp,
|
|
2691
2350
|
storage: storage,
|
|
2692
2351
|
textNumbersRegex: textNumbersRegex,
|