akeyless-client-commons 1.1.21 → 1.1.23
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.css +3 -0
- package/dist/components/index.css.map +1 -1
- package/dist/components/index.js +315 -6
- package/dist/components/index.mjs +315 -6
- package/dist/helpers/index.d.mts +53 -4
- package/dist/helpers/index.d.ts +53 -4
- package/dist/helpers/index.js +469 -7
- package/dist/helpers/index.mjs +447 -5
- package/dist/hooks/index.d.mts +27 -8
- package/dist/hooks/index.d.ts +27 -8
- package/dist/hooks/index.js +621 -66
- package/dist/hooks/index.mjs +611 -64
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +5 -2
package/dist/helpers/index.js
CHANGED
|
@@ -39,6 +39,25 @@ 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
|
+
}
|
|
42
61
|
function _define_property(obj, key, value) {
|
|
43
62
|
if (key in obj) {
|
|
44
63
|
Object.defineProperty(obj, key, {
|
|
@@ -365,9 +384,21 @@ __export(index_exports, {
|
|
|
365
384
|
colorRegex: function() {
|
|
366
385
|
return colorRegex;
|
|
367
386
|
},
|
|
387
|
+
createAttachmentFromBlob: function() {
|
|
388
|
+
return createAttachmentFromBlob;
|
|
389
|
+
},
|
|
390
|
+
createAttachmentFromUrl: function() {
|
|
391
|
+
return createAttachmentFromUrl;
|
|
392
|
+
},
|
|
368
393
|
createSelectors: function() {
|
|
369
394
|
return createSelectors;
|
|
370
395
|
},
|
|
396
|
+
dataSocketDomain: function() {
|
|
397
|
+
return dataSocketDomain;
|
|
398
|
+
},
|
|
399
|
+
dataSyncDomain: function() {
|
|
400
|
+
return dataSyncDomain;
|
|
401
|
+
},
|
|
371
402
|
db: function() {
|
|
372
403
|
return db;
|
|
373
404
|
},
|
|
@@ -416,8 +447,8 @@ __export(index_exports, {
|
|
|
416
447
|
getAddressByGeo: function() {
|
|
417
448
|
return getAddressByGeo;
|
|
418
449
|
},
|
|
419
|
-
|
|
420
|
-
return
|
|
450
|
+
getFileUrlFromStorage: function() {
|
|
451
|
+
return getFileUrlFromStorage;
|
|
421
452
|
},
|
|
422
453
|
getFixedNumber: function() {
|
|
423
454
|
return getFixedNumber;
|
|
@@ -557,6 +588,9 @@ __export(index_exports, {
|
|
|
557
588
|
snapshotDocument: function() {
|
|
558
589
|
return snapshotDocument;
|
|
559
590
|
},
|
|
591
|
+
socketServiceInstance: function() {
|
|
592
|
+
return socketServiceInstance;
|
|
593
|
+
},
|
|
560
594
|
sort_by_timestamp: function() {
|
|
561
595
|
return sort_by_timestamp;
|
|
562
596
|
},
|
|
@@ -1818,7 +1852,7 @@ var validateUserStatusAndPermissions = function(user, app2) {
|
|
|
1818
1852
|
}
|
|
1819
1853
|
return userPermissions;
|
|
1820
1854
|
};
|
|
1821
|
-
var
|
|
1855
|
+
var getFileUrlFromStorage = /*#__PURE__*/ function() {
|
|
1822
1856
|
var _ref = _async_to_generator(function(filePath) {
|
|
1823
1857
|
var fileRef, downloadURL, error;
|
|
1824
1858
|
return _ts_generator(this, function(_state) {
|
|
@@ -1844,7 +1878,10 @@ var getFileFromStorage = /*#__PURE__*/ function() {
|
|
|
1844
1878
|
case 2:
|
|
1845
1879
|
error = _state.sent();
|
|
1846
1880
|
console.error("Error getting file from storage: ".concat(filePath), error);
|
|
1847
|
-
|
|
1881
|
+
return [
|
|
1882
|
+
2,
|
|
1883
|
+
""
|
|
1884
|
+
];
|
|
1848
1885
|
case 3:
|
|
1849
1886
|
return [
|
|
1850
1887
|
2
|
|
@@ -1852,7 +1889,7 @@ var getFileFromStorage = /*#__PURE__*/ function() {
|
|
|
1852
1889
|
}
|
|
1853
1890
|
});
|
|
1854
1891
|
});
|
|
1855
|
-
return function
|
|
1892
|
+
return function getFileUrlFromStorage(filePath) {
|
|
1856
1893
|
return _ref.apply(this, arguments);
|
|
1857
1894
|
};
|
|
1858
1895
|
}();
|
|
@@ -1888,7 +1925,10 @@ var uploadFileToStorage = /*#__PURE__*/ function() {
|
|
|
1888
1925
|
case 3:
|
|
1889
1926
|
error = _state.sent();
|
|
1890
1927
|
console.error("Error uploading file to storage: ".concat(filePath), error);
|
|
1891
|
-
|
|
1928
|
+
return [
|
|
1929
|
+
2,
|
|
1930
|
+
""
|
|
1931
|
+
];
|
|
1892
1932
|
case 4:
|
|
1893
1933
|
return [
|
|
1894
1934
|
2
|
|
@@ -2271,6 +2311,8 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
2271
2311
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
2272
2312
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
2273
2313
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
2314
|
+
var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
|
|
2315
|
+
var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
|
|
2274
2316
|
var akeylessOnlineDomain = mode === "qa" ? "https://akeyless-online.xyz" : "https://akeyless-online.info";
|
|
2275
2317
|
var nxApiCall = /*#__PURE__*/ function() {
|
|
2276
2318
|
var _ref = _async_to_generator(function(serverName, method, url, data) {
|
|
@@ -2301,6 +2343,12 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2301
2343
|
case "call-center-geo":
|
|
2302
2344
|
urlResult = "".concat(callCenterGeoDomain, "/").concat(url);
|
|
2303
2345
|
break;
|
|
2346
|
+
case "data-socket":
|
|
2347
|
+
urlResult = "".concat(dataSocketDomain, "/").concat(url);
|
|
2348
|
+
break;
|
|
2349
|
+
case "data-sync":
|
|
2350
|
+
urlResult = "".concat(dataSyncDomain, "/").concat(url);
|
|
2351
|
+
break;
|
|
2304
2352
|
default:
|
|
2305
2353
|
break;
|
|
2306
2354
|
}
|
|
@@ -2350,6 +2398,415 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2350
2398
|
return _ref.apply(this, arguments);
|
|
2351
2399
|
};
|
|
2352
2400
|
}();
|
|
2401
|
+
// src/helpers/emails.ts
|
|
2402
|
+
var import_axios3 = __toESM(require("axios"));
|
|
2403
|
+
var createAttachmentFromBlob = /*#__PURE__*/ function() {
|
|
2404
|
+
var _ref = _async_to_generator(function(blob, filename, mimeType) {
|
|
2405
|
+
var disposition, arrayBuffer, base64Content, uint8Array, chunkSize, binary, i, error;
|
|
2406
|
+
var _arguments = arguments;
|
|
2407
|
+
return _ts_generator(this, function(_state) {
|
|
2408
|
+
switch(_state.label){
|
|
2409
|
+
case 0:
|
|
2410
|
+
disposition = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : "attachment";
|
|
2411
|
+
_state.label = 1;
|
|
2412
|
+
case 1:
|
|
2413
|
+
_state.trys.push([
|
|
2414
|
+
1,
|
|
2415
|
+
3,
|
|
2416
|
+
,
|
|
2417
|
+
4
|
|
2418
|
+
]);
|
|
2419
|
+
return [
|
|
2420
|
+
4,
|
|
2421
|
+
blob.arrayBuffer()
|
|
2422
|
+
];
|
|
2423
|
+
case 2:
|
|
2424
|
+
arrayBuffer = _state.sent();
|
|
2425
|
+
if (typeof Buffer !== "undefined") {
|
|
2426
|
+
base64Content = Buffer.from(arrayBuffer).toString("base64");
|
|
2427
|
+
} else {
|
|
2428
|
+
uint8Array = new Uint8Array(arrayBuffer);
|
|
2429
|
+
chunkSize = 32768;
|
|
2430
|
+
binary = "";
|
|
2431
|
+
for(i = 0; i < uint8Array.length; i += chunkSize){
|
|
2432
|
+
binary += String.fromCharCode.apply(null, uint8Array.subarray(i, i + chunkSize));
|
|
2433
|
+
}
|
|
2434
|
+
base64Content = btoa(binary);
|
|
2435
|
+
}
|
|
2436
|
+
return [
|
|
2437
|
+
2,
|
|
2438
|
+
{
|
|
2439
|
+
content: base64Content,
|
|
2440
|
+
filename: filename,
|
|
2441
|
+
type: mimeType || blob.type || "application/pdf",
|
|
2442
|
+
disposition: disposition
|
|
2443
|
+
}
|
|
2444
|
+
];
|
|
2445
|
+
case 3:
|
|
2446
|
+
error = _state.sent();
|
|
2447
|
+
console.error("Error creating attachment from blob", {
|
|
2448
|
+
error: error,
|
|
2449
|
+
filename: filename
|
|
2450
|
+
});
|
|
2451
|
+
throw error;
|
|
2452
|
+
case 4:
|
|
2453
|
+
return [
|
|
2454
|
+
2
|
|
2455
|
+
];
|
|
2456
|
+
}
|
|
2457
|
+
});
|
|
2458
|
+
});
|
|
2459
|
+
return function createAttachmentFromBlob(blob, filename, mimeType) {
|
|
2460
|
+
return _ref.apply(this, arguments);
|
|
2461
|
+
};
|
|
2462
|
+
}();
|
|
2463
|
+
var getFilenameFromUrl = function(url) {
|
|
2464
|
+
try {
|
|
2465
|
+
var urlObj = new URL(url);
|
|
2466
|
+
var pathname = urlObj.pathname;
|
|
2467
|
+
var filename = pathname.split("/").pop() || "download";
|
|
2468
|
+
return filename.includes(".") ? filename : "".concat(filename, ".txt");
|
|
2469
|
+
} catch (e) {
|
|
2470
|
+
return "download.txt";
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
var createAttachmentFromUrl = /*#__PURE__*/ function() {
|
|
2474
|
+
var _ref = _async_to_generator(function(url, filename) {
|
|
2475
|
+
var response, blob, finalFilename;
|
|
2476
|
+
return _ts_generator(this, function(_state) {
|
|
2477
|
+
switch(_state.label){
|
|
2478
|
+
case 0:
|
|
2479
|
+
return [
|
|
2480
|
+
4,
|
|
2481
|
+
import_axios3.default.get("/api/proxy-file?url=".concat(encodeURIComponent(url)), {
|
|
2482
|
+
responseType: "blob"
|
|
2483
|
+
})
|
|
2484
|
+
];
|
|
2485
|
+
case 1:
|
|
2486
|
+
response = _state.sent();
|
|
2487
|
+
blob = response.data;
|
|
2488
|
+
finalFilename = filename !== null && filename !== void 0 ? filename : getFilenameFromUrl(url);
|
|
2489
|
+
return [
|
|
2490
|
+
4,
|
|
2491
|
+
createAttachmentFromBlob(blob, finalFilename)
|
|
2492
|
+
];
|
|
2493
|
+
case 2:
|
|
2494
|
+
return [
|
|
2495
|
+
2,
|
|
2496
|
+
_state.sent()
|
|
2497
|
+
];
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
});
|
|
2501
|
+
return function createAttachmentFromUrl(url, filename) {
|
|
2502
|
+
return _ref.apply(this, arguments);
|
|
2503
|
+
};
|
|
2504
|
+
}();
|
|
2505
|
+
// src/helpers/socket.ts
|
|
2506
|
+
var import_socket = require("socket.io-client");
|
|
2507
|
+
var SESSION_STORAGE_KEY = "sessionId";
|
|
2508
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
2509
|
+
"use strict";
|
|
2510
|
+
function _SocketService() {
|
|
2511
|
+
_class_call_check(this, _SocketService);
|
|
2512
|
+
this.socket = null;
|
|
2513
|
+
this.connectCallbacks = [];
|
|
2514
|
+
this.disconnectCallbacks = [];
|
|
2515
|
+
this.authToken = null;
|
|
2516
|
+
}
|
|
2517
|
+
_create_class(_SocketService, [
|
|
2518
|
+
{
|
|
2519
|
+
/// Initialize the socket connection
|
|
2520
|
+
key: "initSocket",
|
|
2521
|
+
value: function initSocket() {
|
|
2522
|
+
var _this = this;
|
|
2523
|
+
if (!this.socket) {
|
|
2524
|
+
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
2525
|
+
this.socket = (0, import_socket.io)(socketUrl, {
|
|
2526
|
+
path: "/api/data-socket/connect",
|
|
2527
|
+
auth: function(cb) {
|
|
2528
|
+
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
2529
|
+
var token = _this.authToken;
|
|
2530
|
+
var authPayload = {};
|
|
2531
|
+
if (token) authPayload.token = token;
|
|
2532
|
+
if (sessionId) authPayload.sessionId = sessionId;
|
|
2533
|
+
cb(authPayload);
|
|
2534
|
+
},
|
|
2535
|
+
transports: [
|
|
2536
|
+
"websocket"
|
|
2537
|
+
],
|
|
2538
|
+
reconnection: true,
|
|
2539
|
+
reconnectionAttempts: 30,
|
|
2540
|
+
reconnectionDelay: 2 * 1e3
|
|
2541
|
+
});
|
|
2542
|
+
this.socket.on("connect", function() {
|
|
2543
|
+
var _this_socket, _this_socket1;
|
|
2544
|
+
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, ")"));
|
|
2545
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
2546
|
+
return cb();
|
|
2547
|
+
});
|
|
2548
|
+
});
|
|
2549
|
+
this.socket.on("disconnect", function(reason) {
|
|
2550
|
+
console.log("Socket disconnected:", reason);
|
|
2551
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2552
|
+
return cb();
|
|
2553
|
+
});
|
|
2554
|
+
});
|
|
2555
|
+
this.socket.on("session", function(param) {
|
|
2556
|
+
var session_id = param.session_id;
|
|
2557
|
+
if (session_id) {
|
|
2558
|
+
localStorage.setItem(SESSION_STORAGE_KEY, session_id);
|
|
2559
|
+
}
|
|
2560
|
+
});
|
|
2561
|
+
this.socket.on("connect_error", function(error) {
|
|
2562
|
+
console.error("Socket connection error:", error);
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
},
|
|
2567
|
+
{
|
|
2568
|
+
/// get socket instance
|
|
2569
|
+
key: "getSocketInstance",
|
|
2570
|
+
value: function getSocketInstance() {
|
|
2571
|
+
if (!this.socket) {
|
|
2572
|
+
this.initSocket();
|
|
2573
|
+
}
|
|
2574
|
+
if (!this.socket) {
|
|
2575
|
+
throw new Error("Socket not initialized");
|
|
2576
|
+
}
|
|
2577
|
+
if (!this.socket.connected) {
|
|
2578
|
+
this.socket.connect();
|
|
2579
|
+
}
|
|
2580
|
+
return this.socket;
|
|
2581
|
+
}
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
/// connection management methods
|
|
2585
|
+
key: "startSession",
|
|
2586
|
+
value: function startSession(token) {
|
|
2587
|
+
this.setAuthToken(token);
|
|
2588
|
+
this.initSocket();
|
|
2589
|
+
}
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
key: "onConnect",
|
|
2593
|
+
value: function onConnect(callback) {
|
|
2594
|
+
var _this = this;
|
|
2595
|
+
var _this_socket;
|
|
2596
|
+
if (!this.connectCallbacks.includes(callback)) {
|
|
2597
|
+
this.connectCallbacks.push(callback);
|
|
2598
|
+
}
|
|
2599
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
2600
|
+
callback();
|
|
2601
|
+
}
|
|
2602
|
+
return function() {
|
|
2603
|
+
return _this.offConnect(callback);
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
key: "offConnect",
|
|
2609
|
+
value: function offConnect(callback) {
|
|
2610
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
2611
|
+
return cb !== callback;
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
},
|
|
2615
|
+
{
|
|
2616
|
+
key: "onDisconnect",
|
|
2617
|
+
value: function onDisconnect(callback) {
|
|
2618
|
+
var _this = this;
|
|
2619
|
+
if (!this.disconnectCallbacks.includes(callback)) {
|
|
2620
|
+
this.disconnectCallbacks.push(callback);
|
|
2621
|
+
}
|
|
2622
|
+
if (this.socket && !this.socket.connected) {
|
|
2623
|
+
callback();
|
|
2624
|
+
}
|
|
2625
|
+
return function() {
|
|
2626
|
+
return _this.offDisconnect(callback);
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
key: "offDisconnect",
|
|
2632
|
+
value: function offDisconnect(callback) {
|
|
2633
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
2634
|
+
return cb !== callback;
|
|
2635
|
+
});
|
|
2636
|
+
}
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
key: "isConnected",
|
|
2640
|
+
value: function isConnected() {
|
|
2641
|
+
var _this_socket;
|
|
2642
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
2643
|
+
}
|
|
2644
|
+
},
|
|
2645
|
+
{
|
|
2646
|
+
key: "setAuthToken",
|
|
2647
|
+
value: function setAuthToken(token) {
|
|
2648
|
+
this.authToken = token;
|
|
2649
|
+
if (this.socket) {
|
|
2650
|
+
this.socket.connect();
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
key: "disconnectSocket",
|
|
2656
|
+
value: function disconnectSocket() {
|
|
2657
|
+
if (this.socket) {
|
|
2658
|
+
this.socket.io.engine.close();
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
/// subscribe to collections
|
|
2664
|
+
key: "subscribeToCollections",
|
|
2665
|
+
value: function subscribeToCollections(config) {
|
|
2666
|
+
var _this = this;
|
|
2667
|
+
if (config.length === 0) {
|
|
2668
|
+
return function() {};
|
|
2669
|
+
}
|
|
2670
|
+
var s = this.getSocketInstance();
|
|
2671
|
+
var collectionsNames = config.map(function(c) {
|
|
2672
|
+
return c.collectionName;
|
|
2673
|
+
});
|
|
2674
|
+
var eventHandlers = [];
|
|
2675
|
+
config.forEach(function(configuration) {
|
|
2676
|
+
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;
|
|
2677
|
+
var attach = function(eventName, handler) {
|
|
2678
|
+
_this.socket.off(eventName, handler);
|
|
2679
|
+
_this.socket.on(eventName, handler);
|
|
2680
|
+
eventHandlers.push({
|
|
2681
|
+
eventName: eventName,
|
|
2682
|
+
handler: handler
|
|
2683
|
+
});
|
|
2684
|
+
};
|
|
2685
|
+
attach("initial:".concat(collectionName), onFirstTime);
|
|
2686
|
+
attach("add:".concat(collectionName), onAdd);
|
|
2687
|
+
attach("update:".concat(collectionName), onModify);
|
|
2688
|
+
attach("delete:".concat(collectionName), onRemove);
|
|
2689
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
2690
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
2691
|
+
attach("initial:".concat(collectionName), extraOnFirstTime);
|
|
2692
|
+
attach("add:".concat(collectionName), extraOnAdd);
|
|
2693
|
+
attach("update:".concat(collectionName), extraOnModify);
|
|
2694
|
+
attach("delete:".concat(collectionName), extraOnRemove);
|
|
2695
|
+
});
|
|
2696
|
+
});
|
|
2697
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
2698
|
+
if (callback.success) {
|
|
2699
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
2700
|
+
} else {
|
|
2701
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
2702
|
+
}
|
|
2703
|
+
});
|
|
2704
|
+
return function() {
|
|
2705
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
2706
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
2707
|
+
eventHandlers.forEach(function(eh) {
|
|
2708
|
+
s.off(eh.eventName, eh.handler);
|
|
2709
|
+
});
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
/// set data
|
|
2715
|
+
key: "setData",
|
|
2716
|
+
value: function setData(payload) {
|
|
2717
|
+
var s = this.getSocketInstance();
|
|
2718
|
+
return new Promise(function(resolve, reject) {
|
|
2719
|
+
s.emit("set_data", payload, function(callback) {
|
|
2720
|
+
if (callback.success) {
|
|
2721
|
+
console.log("Data saved successfully:", payload);
|
|
2722
|
+
console.log("ack", callback);
|
|
2723
|
+
resolve(callback);
|
|
2724
|
+
} else {
|
|
2725
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
},
|
|
2731
|
+
{
|
|
2732
|
+
/// get data
|
|
2733
|
+
key: "getCollectionData",
|
|
2734
|
+
value: function getCollectionData(payload) {
|
|
2735
|
+
var s = this.getSocketInstance();
|
|
2736
|
+
s.emit("get_data", {
|
|
2737
|
+
collection_name: payload.collection_name
|
|
2738
|
+
}, function(socketCallback) {
|
|
2739
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2740
|
+
payload.callback(socketCallback.data);
|
|
2741
|
+
} else {
|
|
2742
|
+
payload.callback(payload.defaultValue);
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
{
|
|
2748
|
+
key: "getDocumentData",
|
|
2749
|
+
value: function getDocumentData(payload) {
|
|
2750
|
+
var s = this.getSocketInstance();
|
|
2751
|
+
s.emit("get_data", {
|
|
2752
|
+
collection_name: payload.collection_name,
|
|
2753
|
+
key: payload.key
|
|
2754
|
+
}, function(socketCallback) {
|
|
2755
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2756
|
+
payload.callback(socketCallback.data);
|
|
2757
|
+
} else {
|
|
2758
|
+
payload.callback(payload.defaultValue);
|
|
2759
|
+
}
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
/// delete data
|
|
2765
|
+
key: "deleteData",
|
|
2766
|
+
value: function deleteData(payload) {
|
|
2767
|
+
var s = this.getSocketInstance();
|
|
2768
|
+
return new Promise(function(resolve, reject) {
|
|
2769
|
+
s.emit("delete_data", payload, function(callback) {
|
|
2770
|
+
if (callback.success) {
|
|
2771
|
+
console.log("Data deleted successfully:", payload);
|
|
2772
|
+
console.log("delete ack", callback);
|
|
2773
|
+
resolve(callback);
|
|
2774
|
+
} else {
|
|
2775
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
},
|
|
2781
|
+
{
|
|
2782
|
+
key: "clearAllRedisData",
|
|
2783
|
+
value: function clearAllRedisData() {
|
|
2784
|
+
var s = this.getSocketInstance();
|
|
2785
|
+
return new Promise(function(resolve, reject) {
|
|
2786
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
2787
|
+
if (ack.success) {
|
|
2788
|
+
resolve(ack);
|
|
2789
|
+
} else {
|
|
2790
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
2791
|
+
}
|
|
2792
|
+
});
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
], [
|
|
2797
|
+
{
|
|
2798
|
+
key: "getInstance",
|
|
2799
|
+
value: function getInstance() {
|
|
2800
|
+
if (!_SocketService.instance) {
|
|
2801
|
+
_SocketService.instance = new _SocketService();
|
|
2802
|
+
}
|
|
2803
|
+
return _SocketService.instance;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
]);
|
|
2807
|
+
return _SocketService;
|
|
2808
|
+
}();
|
|
2809
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
2353
2810
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2354
2811
|
0 && (module.exports = {
|
|
2355
2812
|
addAuditRecord: addAuditRecord,
|
|
@@ -2372,7 +2829,11 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2372
2829
|
cn: cn,
|
|
2373
2830
|
collections: collections,
|
|
2374
2831
|
colorRegex: colorRegex,
|
|
2832
|
+
createAttachmentFromBlob: createAttachmentFromBlob,
|
|
2833
|
+
createAttachmentFromUrl: createAttachmentFromUrl,
|
|
2375
2834
|
createSelectors: createSelectors,
|
|
2835
|
+
dataSocketDomain: dataSocketDomain,
|
|
2836
|
+
dataSyncDomain: dataSyncDomain,
|
|
2376
2837
|
db: db,
|
|
2377
2838
|
delete_document: delete_document,
|
|
2378
2839
|
devicesDomain: devicesDomain,
|
|
@@ -2389,7 +2850,7 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2389
2850
|
fire_base_TIME_TEMP: fire_base_TIME_TEMP,
|
|
2390
2851
|
formatCarNumber: formatCarNumber,
|
|
2391
2852
|
getAddressByGeo: getAddressByGeo,
|
|
2392
|
-
|
|
2853
|
+
getFileUrlFromStorage: getFileUrlFromStorage,
|
|
2393
2854
|
getFixedNumber: getFixedNumber,
|
|
2394
2855
|
getFormCheckboxValue: getFormCheckboxValue,
|
|
2395
2856
|
getFormElementValue: getFormElementValue,
|
|
@@ -2436,6 +2897,7 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2436
2897
|
simpleExtractData: simpleExtractData,
|
|
2437
2898
|
snapshot: snapshot,
|
|
2438
2899
|
snapshotDocument: snapshotDocument,
|
|
2900
|
+
socketServiceInstance: socketServiceInstance,
|
|
2439
2901
|
sort_by_timestamp: sort_by_timestamp,
|
|
2440
2902
|
storage: storage,
|
|
2441
2903
|
textNumbersRegex: textNumbersRegex,
|