akeyless-client-commons 1.0.227 → 1.0.229
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.map +1 -1
- package/dist/components/index.js +280 -9
- package/dist/components/index.mjs +280 -9
- package/dist/helpers/index.d.mts +34 -2
- package/dist/helpers/index.d.ts +34 -2
- package/dist/helpers/index.js +295 -0
- package/dist/helpers/index.mjs +292 -1
- package/dist/hooks/index.d.mts +5 -1
- package/dist/hooks/index.d.ts +5 -1
- package/dist/hooks/index.js +374 -1
- package/dist/hooks/index.mjs +370 -1
- package/package.json +4 -2
package/dist/helpers/index.mjs
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, {
|
|
@@ -1878,5 +1897,277 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
1878
1897
|
return _ref.apply(this, arguments);
|
|
1879
1898
|
};
|
|
1880
1899
|
}();
|
|
1881
|
-
|
|
1900
|
+
// src/helpers/socket.ts
|
|
1901
|
+
import { io } from "socket.io-client";
|
|
1902
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
1903
|
+
"use strict";
|
|
1904
|
+
function _SocketService() {
|
|
1905
|
+
_class_call_check(this, _SocketService);
|
|
1906
|
+
this.socket = null;
|
|
1907
|
+
this.connectCallbacks = [];
|
|
1908
|
+
this.disconnectCallbacks = [];
|
|
1909
|
+
this.initSocket();
|
|
1910
|
+
}
|
|
1911
|
+
_create_class(_SocketService, [
|
|
1912
|
+
{
|
|
1913
|
+
/// Initialize the socket connection
|
|
1914
|
+
key: "initSocket",
|
|
1915
|
+
value: function initSocket() {
|
|
1916
|
+
var _this = this;
|
|
1917
|
+
if (!this.socket) {
|
|
1918
|
+
var SOCKET_SERVER_URL = "http://localhost:9009";
|
|
1919
|
+
var SOCKET_PATH = "/api/data-socket/connect";
|
|
1920
|
+
this.socket = io(SOCKET_SERVER_URL, {
|
|
1921
|
+
path: SOCKET_PATH,
|
|
1922
|
+
transports: [
|
|
1923
|
+
"websocket"
|
|
1924
|
+
]
|
|
1925
|
+
});
|
|
1926
|
+
this.socket.on("connect", function() {
|
|
1927
|
+
var _this_socket;
|
|
1928
|
+
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
1929
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
1930
|
+
return cb();
|
|
1931
|
+
});
|
|
1932
|
+
});
|
|
1933
|
+
this.socket.on("disconnect", function(reason) {
|
|
1934
|
+
console.log("Socket disconnected:", reason);
|
|
1935
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
1936
|
+
return cb();
|
|
1937
|
+
});
|
|
1938
|
+
});
|
|
1939
|
+
this.socket.on("connect_error", function(error) {
|
|
1940
|
+
console.error("Socket connection error:", error);
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
},
|
|
1945
|
+
{
|
|
1946
|
+
/// get socket instance
|
|
1947
|
+
key: "getSocketInstance",
|
|
1948
|
+
value: function getSocketInstance() {
|
|
1949
|
+
if (!this.socket) {
|
|
1950
|
+
this.initSocket();
|
|
1951
|
+
}
|
|
1952
|
+
if (!this.socket) {
|
|
1953
|
+
throw new Error("Socket not initialized");
|
|
1954
|
+
}
|
|
1955
|
+
if (!this.socket.connected) {
|
|
1956
|
+
this.socket.connect();
|
|
1957
|
+
}
|
|
1958
|
+
return this.socket;
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
{
|
|
1962
|
+
/// subscribe to collections
|
|
1963
|
+
key: "subscribeToCollections",
|
|
1964
|
+
value: function subscribeToCollections(config) {
|
|
1965
|
+
var s = this.getSocketInstance();
|
|
1966
|
+
var collectionsNames = config.map(function(c) {
|
|
1967
|
+
return c.collectionName;
|
|
1968
|
+
});
|
|
1969
|
+
var eventHandlers = [];
|
|
1970
|
+
config.forEach(function(configuration) {
|
|
1971
|
+
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;
|
|
1972
|
+
s.on("initial:".concat(collectionName), onFirstTime);
|
|
1973
|
+
eventHandlers.push({
|
|
1974
|
+
eventName: "initial:".concat(collectionName),
|
|
1975
|
+
handler: onFirstTime
|
|
1976
|
+
});
|
|
1977
|
+
s.on("add:".concat(collectionName), onAdd);
|
|
1978
|
+
eventHandlers.push({
|
|
1979
|
+
eventName: "add:".concat(collectionName),
|
|
1980
|
+
handler: onAdd
|
|
1981
|
+
});
|
|
1982
|
+
s.on("update:".concat(collectionName), onModify);
|
|
1983
|
+
eventHandlers.push({
|
|
1984
|
+
eventName: "update:".concat(collectionName),
|
|
1985
|
+
handler: onModify
|
|
1986
|
+
});
|
|
1987
|
+
s.on("delete:".concat(collectionName), onRemove);
|
|
1988
|
+
eventHandlers.push({
|
|
1989
|
+
eventName: "delete:".concat(collectionName),
|
|
1990
|
+
handler: onRemove
|
|
1991
|
+
});
|
|
1992
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
1993
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
1994
|
+
s.on("initial:".concat(collectionName), extraOnFirstTime);
|
|
1995
|
+
eventHandlers.push({
|
|
1996
|
+
eventName: "initial:".concat(collectionName),
|
|
1997
|
+
handler: extraOnFirstTime
|
|
1998
|
+
});
|
|
1999
|
+
s.on("add:".concat(collectionName), extraOnAdd);
|
|
2000
|
+
eventHandlers.push({
|
|
2001
|
+
eventName: "add:".concat(collectionName),
|
|
2002
|
+
handler: extraOnAdd
|
|
2003
|
+
});
|
|
2004
|
+
s.on("update:".concat(collectionName), extraOnModify);
|
|
2005
|
+
eventHandlers.push({
|
|
2006
|
+
eventName: "update:".concat(collectionName),
|
|
2007
|
+
handler: extraOnModify
|
|
2008
|
+
});
|
|
2009
|
+
s.on("delete:".concat(collectionName), extraOnRemove);
|
|
2010
|
+
eventHandlers.push({
|
|
2011
|
+
eventName: "delete:".concat(collectionName),
|
|
2012
|
+
handler: extraOnRemove
|
|
2013
|
+
});
|
|
2014
|
+
});
|
|
2015
|
+
});
|
|
2016
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
2017
|
+
if (callback.success) {
|
|
2018
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
2019
|
+
} else {
|
|
2020
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
return function() {
|
|
2024
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
2025
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
2026
|
+
eventHandlers.forEach(function(eh) {
|
|
2027
|
+
s.off(eh.eventName, eh.handler);
|
|
2028
|
+
});
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
/// set data
|
|
2034
|
+
key: "setData",
|
|
2035
|
+
value: function setData(payload) {
|
|
2036
|
+
var s = this.getSocketInstance();
|
|
2037
|
+
return new Promise(function(resolve, reject) {
|
|
2038
|
+
s.emit("set_data", payload, function(callback) {
|
|
2039
|
+
if (callback.success) {
|
|
2040
|
+
console.log("Data saved successfully:", payload);
|
|
2041
|
+
console.log("ack", callback);
|
|
2042
|
+
resolve(callback);
|
|
2043
|
+
} else {
|
|
2044
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
{
|
|
2051
|
+
/// get data
|
|
2052
|
+
key: "getCollectionData",
|
|
2053
|
+
value: function getCollectionData(payload) {
|
|
2054
|
+
var s = this.getSocketInstance();
|
|
2055
|
+
s.emit("get_data", {
|
|
2056
|
+
collection_name: payload.collection_name
|
|
2057
|
+
}, function(socketCallback) {
|
|
2058
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2059
|
+
payload.callback(socketCallback.data);
|
|
2060
|
+
} else {
|
|
2061
|
+
payload.callback(payload.defaultValue);
|
|
2062
|
+
}
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
key: "getDocumentData",
|
|
2068
|
+
value: function getDocumentData(payload) {
|
|
2069
|
+
var s = this.getSocketInstance();
|
|
2070
|
+
s.emit("get_data", {
|
|
2071
|
+
collection_name: payload.collection_name,
|
|
2072
|
+
key: payload.key
|
|
2073
|
+
}, function(socketCallback) {
|
|
2074
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2075
|
+
payload.callback(socketCallback.data);
|
|
2076
|
+
} else {
|
|
2077
|
+
payload.callback(payload.defaultValue);
|
|
2078
|
+
}
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
/// delete data
|
|
2084
|
+
key: "deleteData",
|
|
2085
|
+
value: function deleteData(payload) {
|
|
2086
|
+
var s = this.getSocketInstance();
|
|
2087
|
+
return new Promise(function(resolve, reject) {
|
|
2088
|
+
s.emit("delete_data", payload, function(callback) {
|
|
2089
|
+
if (callback.success) {
|
|
2090
|
+
console.log("Data deleted successfully:", payload);
|
|
2091
|
+
console.log("delete ack", callback);
|
|
2092
|
+
resolve(callback);
|
|
2093
|
+
} else {
|
|
2094
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
},
|
|
2100
|
+
{
|
|
2101
|
+
key: "clearAllRedisData",
|
|
2102
|
+
value: function clearAllRedisData() {
|
|
2103
|
+
var s = this.getSocketInstance();
|
|
2104
|
+
return new Promise(function(resolve, reject) {
|
|
2105
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
2106
|
+
if (ack.success) {
|
|
2107
|
+
resolve(ack);
|
|
2108
|
+
} else {
|
|
2109
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
/// connection management methods
|
|
2117
|
+
key: "onConnect",
|
|
2118
|
+
value: function onConnect(callback) {
|
|
2119
|
+
var _this_socket;
|
|
2120
|
+
this.connectCallbacks.push(callback);
|
|
2121
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
2122
|
+
callback();
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
key: "offConnect",
|
|
2128
|
+
value: function offConnect(callback) {
|
|
2129
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
2130
|
+
return cb !== callback;
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
key: "onDisconnect",
|
|
2136
|
+
value: function onDisconnect(callback) {
|
|
2137
|
+
this.disconnectCallbacks.push(callback);
|
|
2138
|
+
if (this.socket && !this.socket.connected) {
|
|
2139
|
+
callback();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
key: "offDisconnect",
|
|
2145
|
+
value: function offDisconnect(callback) {
|
|
2146
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
2147
|
+
return cb !== callback;
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
{
|
|
2152
|
+
key: "isConnected",
|
|
2153
|
+
value: function isConnected() {
|
|
2154
|
+
var _this_socket;
|
|
2155
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
], [
|
|
2159
|
+
{
|
|
2160
|
+
key: "getInstance",
|
|
2161
|
+
value: function getInstance() {
|
|
2162
|
+
if (!_SocketService.instance) {
|
|
2163
|
+
_SocketService.instance = new _SocketService();
|
|
2164
|
+
}
|
|
2165
|
+
return _SocketService.instance;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
]);
|
|
2169
|
+
return _SocketService;
|
|
2170
|
+
}();
|
|
2171
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
2172
|
+
export { addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, notificationsDomain, numbersOnlyRegex, numbersRegex, nxApiCall, parseMultiSelectInput, parsePermissions, parseSnapshotAsArray, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
|
1882
2173
|
//# sourceMappingURL=index.mjs.map
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -35,4 +35,8 @@ declare function useSafeEffect(callback: () => void, dependencies: any[], error_
|
|
|
35
35
|
declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
|
|
36
36
|
declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
declare const useSocketSubscription: (config: OnSnapshotConfig[]) => {
|
|
39
|
+
socketConnected: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSnapshotBulk, useSocketSubscription };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -35,4 +35,8 @@ declare function useSafeEffect(callback: () => void, dependencies: any[], error_
|
|
|
35
35
|
declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
|
|
36
36
|
declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
declare const useSocketSubscription: (config: OnSnapshotConfig[]) => {
|
|
39
|
+
socketConnected: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSnapshotBulk, useSocketSubscription };
|