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.
@@ -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, {
@@ -1458,7 +1477,7 @@ var validateUserStatusAndPermissions = function(user, app2) {
1458
1477
  }
1459
1478
  return userPermissions;
1460
1479
  };
1461
- var getFileFromStorage = /*#__PURE__*/ function() {
1480
+ var getFileUrlFromStorage = /*#__PURE__*/ function() {
1462
1481
  var _ref = _async_to_generator(function(filePath) {
1463
1482
  var fileRef, downloadURL, error;
1464
1483
  return _ts_generator(this, function(_state) {
@@ -1484,7 +1503,10 @@ var getFileFromStorage = /*#__PURE__*/ function() {
1484
1503
  case 2:
1485
1504
  error = _state.sent();
1486
1505
  console.error("Error getting file from storage: ".concat(filePath), error);
1487
- throw new Error("Failed to get file from storage: ".concat(filePath));
1506
+ return [
1507
+ 2,
1508
+ ""
1509
+ ];
1488
1510
  case 3:
1489
1511
  return [
1490
1512
  2
@@ -1492,7 +1514,7 @@ var getFileFromStorage = /*#__PURE__*/ function() {
1492
1514
  }
1493
1515
  });
1494
1516
  });
1495
- return function getFileFromStorage(filePath) {
1517
+ return function getFileUrlFromStorage(filePath) {
1496
1518
  return _ref.apply(this, arguments);
1497
1519
  };
1498
1520
  }();
@@ -1528,7 +1550,10 @@ var uploadFileToStorage = /*#__PURE__*/ function() {
1528
1550
  case 3:
1529
1551
  error = _state.sent();
1530
1552
  console.error("Error uploading file to storage: ".concat(filePath), error);
1531
- throw new Error("Failed to upload file to storage: ".concat(filePath));
1553
+ return [
1554
+ 2,
1555
+ ""
1556
+ ];
1532
1557
  case 4:
1533
1558
  return [
1534
1559
  2
@@ -1910,6 +1935,8 @@ var biDomain = isLocal ? "http://localhost:9002/api/bi" : baseDomain + "/bi";
1910
1935
  var notificationsDomain = isLocal ? "http://localhost:9006/api/notifications" : baseDomain + "/notifications";
1911
1936
  var callCenterGeoDomain = isLocal ? "http://localhost:9007/api/call-center/geo" : baseDomain + "/call-center/geo";
1912
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";
1913
1940
  var akeylessOnlineDomain = mode === "qa" ? "https://akeyless-online.xyz" : "https://akeyless-online.info";
1914
1941
  var nxApiCall = /*#__PURE__*/ function() {
1915
1942
  var _ref = _async_to_generator(function(serverName, method, url, data) {
@@ -1940,6 +1967,12 @@ var nxApiCall = /*#__PURE__*/ function() {
1940
1967
  case "call-center-geo":
1941
1968
  urlResult = "".concat(callCenterGeoDomain, "/").concat(url);
1942
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;
1943
1976
  default:
1944
1977
  break;
1945
1978
  }
@@ -1989,5 +2022,414 @@ var nxApiCall = /*#__PURE__*/ function() {
1989
2022
  return _ref.apply(this, arguments);
1990
2023
  };
1991
2024
  }();
1992
- 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, durationToSeconds, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFileFromStorage, 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, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
2025
+ // src/helpers/emails.ts
2026
+ import axios3 from "axios";
2027
+ var createAttachmentFromBlob = /*#__PURE__*/ function() {
2028
+ var _ref = _async_to_generator(function(blob, filename, mimeType) {
2029
+ var disposition, arrayBuffer, base64Content, uint8Array, chunkSize, binary, i, error;
2030
+ var _arguments = arguments;
2031
+ return _ts_generator(this, function(_state) {
2032
+ switch(_state.label){
2033
+ case 0:
2034
+ disposition = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : "attachment";
2035
+ _state.label = 1;
2036
+ case 1:
2037
+ _state.trys.push([
2038
+ 1,
2039
+ 3,
2040
+ ,
2041
+ 4
2042
+ ]);
2043
+ return [
2044
+ 4,
2045
+ blob.arrayBuffer()
2046
+ ];
2047
+ case 2:
2048
+ arrayBuffer = _state.sent();
2049
+ if (typeof Buffer !== "undefined") {
2050
+ base64Content = Buffer.from(arrayBuffer).toString("base64");
2051
+ } else {
2052
+ uint8Array = new Uint8Array(arrayBuffer);
2053
+ chunkSize = 32768;
2054
+ binary = "";
2055
+ for(i = 0; i < uint8Array.length; i += chunkSize){
2056
+ binary += String.fromCharCode.apply(null, uint8Array.subarray(i, i + chunkSize));
2057
+ }
2058
+ base64Content = btoa(binary);
2059
+ }
2060
+ return [
2061
+ 2,
2062
+ {
2063
+ content: base64Content,
2064
+ filename: filename,
2065
+ type: mimeType || blob.type || "application/pdf",
2066
+ disposition: disposition
2067
+ }
2068
+ ];
2069
+ case 3:
2070
+ error = _state.sent();
2071
+ console.error("Error creating attachment from blob", {
2072
+ error: error,
2073
+ filename: filename
2074
+ });
2075
+ throw error;
2076
+ case 4:
2077
+ return [
2078
+ 2
2079
+ ];
2080
+ }
2081
+ });
2082
+ });
2083
+ return function createAttachmentFromBlob(blob, filename, mimeType) {
2084
+ return _ref.apply(this, arguments);
2085
+ };
2086
+ }();
2087
+ var getFilenameFromUrl = function(url) {
2088
+ try {
2089
+ var urlObj = new URL(url);
2090
+ var pathname = urlObj.pathname;
2091
+ var filename = pathname.split("/").pop() || "download";
2092
+ return filename.includes(".") ? filename : "".concat(filename, ".txt");
2093
+ } catch (e) {
2094
+ return "download.txt";
2095
+ }
2096
+ };
2097
+ var createAttachmentFromUrl = /*#__PURE__*/ function() {
2098
+ var _ref = _async_to_generator(function(url, filename) {
2099
+ var response, blob, finalFilename;
2100
+ return _ts_generator(this, function(_state) {
2101
+ switch(_state.label){
2102
+ case 0:
2103
+ return [
2104
+ 4,
2105
+ axios3.get("/api/proxy-file?url=".concat(encodeURIComponent(url)), {
2106
+ responseType: "blob"
2107
+ })
2108
+ ];
2109
+ case 1:
2110
+ response = _state.sent();
2111
+ blob = response.data;
2112
+ finalFilename = filename !== null && filename !== void 0 ? filename : getFilenameFromUrl(url);
2113
+ return [
2114
+ 4,
2115
+ createAttachmentFromBlob(blob, finalFilename)
2116
+ ];
2117
+ case 2:
2118
+ return [
2119
+ 2,
2120
+ _state.sent()
2121
+ ];
2122
+ }
2123
+ });
2124
+ });
2125
+ return function createAttachmentFromUrl(url, filename) {
2126
+ return _ref.apply(this, arguments);
2127
+ };
2128
+ }();
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 };
1993
2435
  //# sourceMappingURL=index.mjs.map
@@ -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 useDocumentTitle: (title: string) => any;
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 useSetUserCountry: (setUserCountry: Dispatch<SetStateAction<CountryOptions>>, changLang: (lang: string) => void) => any;
33
-
34
- declare function useSafeEffect(callback: () => void, dependencies: any[], error_message?: string): void;
35
- declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
36
- declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
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, useSnapshotBulk };
57
+ export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };
@@ -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 useDocumentTitle: (title: string) => any;
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 useSetUserCountry: (setUserCountry: Dispatch<SetStateAction<CountryOptions>>, changLang: (lang: string) => void) => any;
33
-
34
- declare function useSafeEffect(callback: () => void, dependencies: any[], error_message?: string): void;
35
- declare const useDeepCompareMemo: <T>(factory: () => T, dependencies: any[]) => T;
36
- declare function useDeepCompareEffect(effect: EffectCallback, dependencies: any[]): void;
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, useSnapshotBulk };
57
+ export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };