akeyless-client-commons 1.1.22 → 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.map +1 -1
- package/dist/components/index.js +313 -6
- package/dist/components/index.mjs +313 -6
- package/dist/helpers/index.d.mts +43 -3
- package/dist/helpers/index.d.ts +43 -3
- package/dist/helpers/index.js +344 -0
- package/dist/helpers/index.mjs +333 -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
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, {
|
|
@@ -1916,6 +1935,8 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
|
|
|
1916
1935
|
var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
|
|
1917
1936
|
var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
|
|
1918
1937
|
var callCenterEventsDomain = isLocal ? "http://localhost:9008/api/call-center/events" : baseDomain + "/call-center/events";
|
|
1938
|
+
var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseDomain + "/data-socket";
|
|
1939
|
+
var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
|
|
1919
1940
|
var akeylessOnlineDomain = mode === "qa" ? "https://akeyless-online.xyz" : "https://akeyless-online.info";
|
|
1920
1941
|
var nxApiCall = /*#__PURE__*/ function() {
|
|
1921
1942
|
var _ref = _async_to_generator(function(serverName, method, url, data) {
|
|
@@ -1946,6 +1967,12 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
1946
1967
|
case "call-center-geo":
|
|
1947
1968
|
urlResult = "".concat(callCenterGeoDomain, "/").concat(url);
|
|
1948
1969
|
break;
|
|
1970
|
+
case "data-socket":
|
|
1971
|
+
urlResult = "".concat(dataSocketDomain, "/").concat(url);
|
|
1972
|
+
break;
|
|
1973
|
+
case "data-sync":
|
|
1974
|
+
urlResult = "".concat(dataSyncDomain, "/").concat(url);
|
|
1975
|
+
break;
|
|
1949
1976
|
default:
|
|
1950
1977
|
break;
|
|
1951
1978
|
}
|
|
@@ -2099,5 +2126,310 @@ var createAttachmentFromUrl = /*#__PURE__*/ function() {
|
|
|
2099
2126
|
return _ref.apply(this, arguments);
|
|
2100
2127
|
};
|
|
2101
2128
|
}();
|
|
2102
|
-
|
|
2129
|
+
// src/helpers/socket.ts
|
|
2130
|
+
import { io } from "socket.io-client";
|
|
2131
|
+
var SESSION_STORAGE_KEY = "sessionId";
|
|
2132
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
2133
|
+
"use strict";
|
|
2134
|
+
function _SocketService() {
|
|
2135
|
+
_class_call_check(this, _SocketService);
|
|
2136
|
+
this.socket = null;
|
|
2137
|
+
this.connectCallbacks = [];
|
|
2138
|
+
this.disconnectCallbacks = [];
|
|
2139
|
+
this.authToken = null;
|
|
2140
|
+
}
|
|
2141
|
+
_create_class(_SocketService, [
|
|
2142
|
+
{
|
|
2143
|
+
/// Initialize the socket connection
|
|
2144
|
+
key: "initSocket",
|
|
2145
|
+
value: function initSocket() {
|
|
2146
|
+
var _this = this;
|
|
2147
|
+
if (!this.socket) {
|
|
2148
|
+
var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
|
|
2149
|
+
this.socket = io(socketUrl, {
|
|
2150
|
+
path: "/api/data-socket/connect",
|
|
2151
|
+
auth: function(cb) {
|
|
2152
|
+
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
2153
|
+
var token = _this.authToken;
|
|
2154
|
+
var authPayload = {};
|
|
2155
|
+
if (token) authPayload.token = token;
|
|
2156
|
+
if (sessionId) authPayload.sessionId = sessionId;
|
|
2157
|
+
cb(authPayload);
|
|
2158
|
+
},
|
|
2159
|
+
transports: [
|
|
2160
|
+
"websocket"
|
|
2161
|
+
],
|
|
2162
|
+
reconnection: true,
|
|
2163
|
+
reconnectionAttempts: 30,
|
|
2164
|
+
reconnectionDelay: 2 * 1e3
|
|
2165
|
+
});
|
|
2166
|
+
this.socket.on("connect", function() {
|
|
2167
|
+
var _this_socket, _this_socket1;
|
|
2168
|
+
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, ")"));
|
|
2169
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
2170
|
+
return cb();
|
|
2171
|
+
});
|
|
2172
|
+
});
|
|
2173
|
+
this.socket.on("disconnect", function(reason) {
|
|
2174
|
+
console.log("Socket disconnected:", reason);
|
|
2175
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2176
|
+
return cb();
|
|
2177
|
+
});
|
|
2178
|
+
});
|
|
2179
|
+
this.socket.on("session", function(param) {
|
|
2180
|
+
var session_id = param.session_id;
|
|
2181
|
+
if (session_id) {
|
|
2182
|
+
localStorage.setItem(SESSION_STORAGE_KEY, session_id);
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
this.socket.on("connect_error", function(error) {
|
|
2186
|
+
console.error("Socket connection error:", error);
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
},
|
|
2191
|
+
{
|
|
2192
|
+
/// get socket instance
|
|
2193
|
+
key: "getSocketInstance",
|
|
2194
|
+
value: function getSocketInstance() {
|
|
2195
|
+
if (!this.socket) {
|
|
2196
|
+
this.initSocket();
|
|
2197
|
+
}
|
|
2198
|
+
if (!this.socket) {
|
|
2199
|
+
throw new Error("Socket not initialized");
|
|
2200
|
+
}
|
|
2201
|
+
if (!this.socket.connected) {
|
|
2202
|
+
this.socket.connect();
|
|
2203
|
+
}
|
|
2204
|
+
return this.socket;
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
/// connection management methods
|
|
2209
|
+
key: "startSession",
|
|
2210
|
+
value: function startSession(token) {
|
|
2211
|
+
this.setAuthToken(token);
|
|
2212
|
+
this.initSocket();
|
|
2213
|
+
}
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
key: "onConnect",
|
|
2217
|
+
value: function onConnect(callback) {
|
|
2218
|
+
var _this = this;
|
|
2219
|
+
var _this_socket;
|
|
2220
|
+
if (!this.connectCallbacks.includes(callback)) {
|
|
2221
|
+
this.connectCallbacks.push(callback);
|
|
2222
|
+
}
|
|
2223
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
2224
|
+
callback();
|
|
2225
|
+
}
|
|
2226
|
+
return function() {
|
|
2227
|
+
return _this.offConnect(callback);
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
},
|
|
2231
|
+
{
|
|
2232
|
+
key: "offConnect",
|
|
2233
|
+
value: function offConnect(callback) {
|
|
2234
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
2235
|
+
return cb !== callback;
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
key: "onDisconnect",
|
|
2241
|
+
value: function onDisconnect(callback) {
|
|
2242
|
+
var _this = this;
|
|
2243
|
+
if (!this.disconnectCallbacks.includes(callback)) {
|
|
2244
|
+
this.disconnectCallbacks.push(callback);
|
|
2245
|
+
}
|
|
2246
|
+
if (this.socket && !this.socket.connected) {
|
|
2247
|
+
callback();
|
|
2248
|
+
}
|
|
2249
|
+
return function() {
|
|
2250
|
+
return _this.offDisconnect(callback);
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
key: "offDisconnect",
|
|
2256
|
+
value: function offDisconnect(callback) {
|
|
2257
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
2258
|
+
return cb !== callback;
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
key: "isConnected",
|
|
2264
|
+
value: function isConnected() {
|
|
2265
|
+
var _this_socket;
|
|
2266
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
2267
|
+
}
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
key: "setAuthToken",
|
|
2271
|
+
value: function setAuthToken(token) {
|
|
2272
|
+
this.authToken = token;
|
|
2273
|
+
if (this.socket) {
|
|
2274
|
+
this.socket.connect();
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
key: "disconnectSocket",
|
|
2280
|
+
value: function disconnectSocket() {
|
|
2281
|
+
if (this.socket) {
|
|
2282
|
+
this.socket.io.engine.close();
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
/// subscribe to collections
|
|
2288
|
+
key: "subscribeToCollections",
|
|
2289
|
+
value: function subscribeToCollections(config) {
|
|
2290
|
+
var _this = this;
|
|
2291
|
+
if (config.length === 0) {
|
|
2292
|
+
return function() {};
|
|
2293
|
+
}
|
|
2294
|
+
var s = this.getSocketInstance();
|
|
2295
|
+
var collectionsNames = config.map(function(c) {
|
|
2296
|
+
return c.collectionName;
|
|
2297
|
+
});
|
|
2298
|
+
var eventHandlers = [];
|
|
2299
|
+
config.forEach(function(configuration) {
|
|
2300
|
+
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;
|
|
2301
|
+
var attach = function(eventName, handler) {
|
|
2302
|
+
_this.socket.off(eventName, handler);
|
|
2303
|
+
_this.socket.on(eventName, handler);
|
|
2304
|
+
eventHandlers.push({
|
|
2305
|
+
eventName: eventName,
|
|
2306
|
+
handler: handler
|
|
2307
|
+
});
|
|
2308
|
+
};
|
|
2309
|
+
attach("initial:".concat(collectionName), onFirstTime);
|
|
2310
|
+
attach("add:".concat(collectionName), onAdd);
|
|
2311
|
+
attach("update:".concat(collectionName), onModify);
|
|
2312
|
+
attach("delete:".concat(collectionName), onRemove);
|
|
2313
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
2314
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
2315
|
+
attach("initial:".concat(collectionName), extraOnFirstTime);
|
|
2316
|
+
attach("add:".concat(collectionName), extraOnAdd);
|
|
2317
|
+
attach("update:".concat(collectionName), extraOnModify);
|
|
2318
|
+
attach("delete:".concat(collectionName), extraOnRemove);
|
|
2319
|
+
});
|
|
2320
|
+
});
|
|
2321
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
2322
|
+
if (callback.success) {
|
|
2323
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
2324
|
+
} else {
|
|
2325
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
return function() {
|
|
2329
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
2330
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
2331
|
+
eventHandlers.forEach(function(eh) {
|
|
2332
|
+
s.off(eh.eventName, eh.handler);
|
|
2333
|
+
});
|
|
2334
|
+
};
|
|
2335
|
+
}
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
/// set data
|
|
2339
|
+
key: "setData",
|
|
2340
|
+
value: function setData(payload) {
|
|
2341
|
+
var s = this.getSocketInstance();
|
|
2342
|
+
return new Promise(function(resolve, reject) {
|
|
2343
|
+
s.emit("set_data", payload, function(callback) {
|
|
2344
|
+
if (callback.success) {
|
|
2345
|
+
console.log("Data saved successfully:", payload);
|
|
2346
|
+
console.log("ack", callback);
|
|
2347
|
+
resolve(callback);
|
|
2348
|
+
} else {
|
|
2349
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
/// get data
|
|
2357
|
+
key: "getCollectionData",
|
|
2358
|
+
value: function getCollectionData(payload) {
|
|
2359
|
+
var s = this.getSocketInstance();
|
|
2360
|
+
s.emit("get_data", {
|
|
2361
|
+
collection_name: payload.collection_name
|
|
2362
|
+
}, function(socketCallback) {
|
|
2363
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2364
|
+
payload.callback(socketCallback.data);
|
|
2365
|
+
} else {
|
|
2366
|
+
payload.callback(payload.defaultValue);
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
key: "getDocumentData",
|
|
2373
|
+
value: function getDocumentData(payload) {
|
|
2374
|
+
var s = this.getSocketInstance();
|
|
2375
|
+
s.emit("get_data", {
|
|
2376
|
+
collection_name: payload.collection_name,
|
|
2377
|
+
key: payload.key
|
|
2378
|
+
}, function(socketCallback) {
|
|
2379
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2380
|
+
payload.callback(socketCallback.data);
|
|
2381
|
+
} else {
|
|
2382
|
+
payload.callback(payload.defaultValue);
|
|
2383
|
+
}
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
/// delete data
|
|
2389
|
+
key: "deleteData",
|
|
2390
|
+
value: function deleteData(payload) {
|
|
2391
|
+
var s = this.getSocketInstance();
|
|
2392
|
+
return new Promise(function(resolve, reject) {
|
|
2393
|
+
s.emit("delete_data", payload, function(callback) {
|
|
2394
|
+
if (callback.success) {
|
|
2395
|
+
console.log("Data deleted successfully:", payload);
|
|
2396
|
+
console.log("delete ack", callback);
|
|
2397
|
+
resolve(callback);
|
|
2398
|
+
} else {
|
|
2399
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
key: "clearAllRedisData",
|
|
2407
|
+
value: function clearAllRedisData() {
|
|
2408
|
+
var s = this.getSocketInstance();
|
|
2409
|
+
return new Promise(function(resolve, reject) {
|
|
2410
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
2411
|
+
if (ack.success) {
|
|
2412
|
+
resolve(ack);
|
|
2413
|
+
} else {
|
|
2414
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
], [
|
|
2421
|
+
{
|
|
2422
|
+
key: "getInstance",
|
|
2423
|
+
value: function getInstance() {
|
|
2424
|
+
if (!_SocketService.instance) {
|
|
2425
|
+
_SocketService.instance = new _SocketService();
|
|
2426
|
+
}
|
|
2427
|
+
return _SocketService.instance;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
]);
|
|
2431
|
+
return _SocketService;
|
|
2432
|
+
}();
|
|
2433
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
2434
|
+
export { addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createAttachmentFromBlob, createAttachmentFromUrl, createSelectors, dataSocketDomain, dataSyncDomain, db, delete_document, devicesDomain, displayFormatPhoneNumber, durationToSeconds, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFileUrlFromStorage, 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, secondsToDuration, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
|
2103
2435
|
//# sourceMappingURL=index.mjs.map
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -2,6 +2,13 @@ import { CountryOptions } from 'akeyless-types-commons';
|
|
|
2
2
|
import { Dispatch, SetStateAction, EffectCallback } from 'react';
|
|
3
3
|
import { WhereFilterOp } from 'firebase/firestore';
|
|
4
4
|
|
|
5
|
+
declare const useDocumentTitle: (title: string) => any;
|
|
6
|
+
declare const useSetUserCountry: (setUserCountry: Dispatch<SetStateAction<CountryOptions>>, changLang: (lang: string) => void) => any;
|
|
7
|
+
|
|
8
|
+
declare function useSafeEffect(callback: () => void, dependencies: any[], error_message?: string): void;
|
|
9
|
+
declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
|
|
10
|
+
declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
|
|
11
|
+
|
|
5
12
|
type OnSnapshotCallback = (documents: any[], config: OnSnapshotConfig) => void;
|
|
6
13
|
interface OnSnapshotParsers {
|
|
7
14
|
onFirstTime?: OnSnapshotCallback;
|
|
@@ -22,17 +29,29 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
22
29
|
fieldName: string;
|
|
23
30
|
direction: "asc" | "desc";
|
|
24
31
|
}[];
|
|
32
|
+
parseAs?: "object" | "array";
|
|
33
|
+
subscribeTo?: "cache" | "db";
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
declare const
|
|
28
|
-
declare const useSnapshotBulk: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
36
|
+
declare const useDbSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
29
37
|
cleanupForConfigChange?: boolean;
|
|
30
38
|
disableLogs?: boolean;
|
|
31
39
|
}) => void;
|
|
32
|
-
declare const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
declare const useSmartSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
41
|
+
cleanupForConfigChange?: boolean;
|
|
42
|
+
disableLogs?: boolean;
|
|
43
|
+
}) => {
|
|
44
|
+
groupedConfig: {
|
|
45
|
+
configForDb: OnSnapshotConfig[];
|
|
46
|
+
configForCache: OnSnapshotConfig[];
|
|
47
|
+
};
|
|
48
|
+
socketConnected: boolean;
|
|
49
|
+
};
|
|
50
|
+
declare const useSocketSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
51
|
+
cleanupForConfigChange?: boolean;
|
|
52
|
+
disableLogs?: boolean;
|
|
53
|
+
}) => {
|
|
54
|
+
socketConnected: boolean;
|
|
55
|
+
};
|
|
37
56
|
|
|
38
|
-
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry,
|
|
57
|
+
export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { CountryOptions } from 'akeyless-types-commons';
|
|
|
2
2
|
import { Dispatch, SetStateAction, EffectCallback } from 'react';
|
|
3
3
|
import { WhereFilterOp } from 'firebase/firestore';
|
|
4
4
|
|
|
5
|
+
declare const useDocumentTitle: (title: string) => any;
|
|
6
|
+
declare const useSetUserCountry: (setUserCountry: Dispatch<SetStateAction<CountryOptions>>, changLang: (lang: string) => void) => any;
|
|
7
|
+
|
|
8
|
+
declare function useSafeEffect(callback: () => void, dependencies: any[], error_message?: string): void;
|
|
9
|
+
declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
|
|
10
|
+
declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
|
|
11
|
+
|
|
5
12
|
type OnSnapshotCallback = (documents: any[], config: OnSnapshotConfig) => void;
|
|
6
13
|
interface OnSnapshotParsers {
|
|
7
14
|
onFirstTime?: OnSnapshotCallback;
|
|
@@ -22,17 +29,29 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
22
29
|
fieldName: string;
|
|
23
30
|
direction: "asc" | "desc";
|
|
24
31
|
}[];
|
|
32
|
+
parseAs?: "object" | "array";
|
|
33
|
+
subscribeTo?: "cache" | "db";
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
declare const
|
|
28
|
-
declare const useSnapshotBulk: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
36
|
+
declare const useDbSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
29
37
|
cleanupForConfigChange?: boolean;
|
|
30
38
|
disableLogs?: boolean;
|
|
31
39
|
}) => void;
|
|
32
|
-
declare const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
declare const useSmartSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
41
|
+
cleanupForConfigChange?: boolean;
|
|
42
|
+
disableLogs?: boolean;
|
|
43
|
+
}) => {
|
|
44
|
+
groupedConfig: {
|
|
45
|
+
configForDb: OnSnapshotConfig[];
|
|
46
|
+
configForCache: OnSnapshotConfig[];
|
|
47
|
+
};
|
|
48
|
+
socketConnected: boolean;
|
|
49
|
+
};
|
|
50
|
+
declare const useSocketSnapshots: (configs: OnSnapshotConfig[], label?: string, settings?: {
|
|
51
|
+
cleanupForConfigChange?: boolean;
|
|
52
|
+
disableLogs?: boolean;
|
|
53
|
+
}) => {
|
|
54
|
+
socketConnected: boolean;
|
|
55
|
+
};
|
|
37
56
|
|
|
38
|
-
export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry,
|
|
57
|
+
export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };
|