akeyless-client-commons 1.1.6 → 1.1.8
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.d.mts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +279 -8
- package/dist/components/index.mjs +279 -8
- package/dist/helpers/index.d.mts +36 -2
- package/dist/helpers/index.d.ts +36 -2
- package/dist/helpers/index.js +294 -0
- package/dist/helpers/index.mjs +291 -1
- package/dist/hooks/index.d.mts +15 -1
- package/dist/hooks/index.d.ts +15 -1
- package/dist/hooks/index.js +459 -1
- package/dist/hooks/index.mjs +451 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +4 -2
package/dist/helpers/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { FirebaseStorage } from 'firebase/storage';
|
|
|
3
3
|
import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
|
|
4
4
|
import { AppCheck } from 'firebase/app-check';
|
|
5
5
|
import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentData, Timestamp, DocumentSnapshot } from 'firebase/firestore';
|
|
6
|
-
import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client } from 'akeyless-types-commons';
|
|
6
|
+
import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client, RedisUpdateType, RedisUpdatePayload, SocketCallbackResponse } from 'akeyless-types-commons';
|
|
7
7
|
import React, { Dispatch, SetStateAction } from 'react';
|
|
8
8
|
import { ClassValue } from 'clsx';
|
|
9
9
|
|
|
@@ -31,6 +31,8 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
31
31
|
fieldName: string;
|
|
32
32
|
direction: "asc" | "desc";
|
|
33
33
|
}[];
|
|
34
|
+
parseAs?: "object" | "array";
|
|
35
|
+
subscribeTo?: "cache" | "db";
|
|
34
36
|
}
|
|
35
37
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
36
38
|
collectionName: string;
|
|
@@ -258,4 +260,36 @@ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray,
|
|
|
258
260
|
permissions: TObject<TObject<boolean>>;
|
|
259
261
|
}>;
|
|
260
262
|
|
|
261
|
-
|
|
263
|
+
interface GetDataPayload<T = any> {
|
|
264
|
+
key: string;
|
|
265
|
+
collection_name: string;
|
|
266
|
+
callback: (value: T) => void;
|
|
267
|
+
defaultValue: T;
|
|
268
|
+
}
|
|
269
|
+
declare class SocketService {
|
|
270
|
+
private static instance;
|
|
271
|
+
private socket;
|
|
272
|
+
private connectCallbacks;
|
|
273
|
+
private disconnectCallbacks;
|
|
274
|
+
private initSocket;
|
|
275
|
+
private constructor();
|
|
276
|
+
static getInstance(): SocketService;
|
|
277
|
+
private getSocketInstance;
|
|
278
|
+
subscribeToCollections(config: OnSnapshotConfig[]): () => void;
|
|
279
|
+
setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
|
|
280
|
+
getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
|
|
281
|
+
getDocumentData<T>(payload: GetDataPayload<T>): void;
|
|
282
|
+
deleteData(payload: {
|
|
283
|
+
key: string;
|
|
284
|
+
collection_name: string;
|
|
285
|
+
}): Promise<SocketCallbackResponse>;
|
|
286
|
+
clearAllRedisData(): Promise<SocketCallbackResponse>;
|
|
287
|
+
onConnect(callback: () => void): void;
|
|
288
|
+
offConnect(callback: () => void): void;
|
|
289
|
+
onDisconnect(callback: () => void): void;
|
|
290
|
+
offDisconnect(callback: () => void): void;
|
|
291
|
+
isConnected(): boolean;
|
|
292
|
+
}
|
|
293
|
+
declare const socketServiceInstance: SocketService;
|
|
294
|
+
|
|
295
|
+
export { type ValidationType, 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, 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, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FirebaseStorage } from 'firebase/storage';
|
|
|
3
3
|
import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
|
|
4
4
|
import { AppCheck } from 'firebase/app-check';
|
|
5
5
|
import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentData, Timestamp, DocumentSnapshot } from 'firebase/firestore';
|
|
6
|
-
import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client } from 'akeyless-types-commons';
|
|
6
|
+
import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client, RedisUpdateType, RedisUpdatePayload, SocketCallbackResponse } from 'akeyless-types-commons';
|
|
7
7
|
import React, { Dispatch, SetStateAction } from 'react';
|
|
8
8
|
import { ClassValue } from 'clsx';
|
|
9
9
|
|
|
@@ -31,6 +31,8 @@ interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
|
31
31
|
fieldName: string;
|
|
32
32
|
direction: "asc" | "desc";
|
|
33
33
|
}[];
|
|
34
|
+
parseAs?: "object" | "array";
|
|
35
|
+
subscribeTo?: "cache" | "db";
|
|
34
36
|
}
|
|
35
37
|
interface OnSnapshotConfigDocument extends Omit<OnSnapshotParsers, "onAdd"> {
|
|
36
38
|
collectionName: string;
|
|
@@ -258,4 +260,36 @@ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray,
|
|
|
258
260
|
permissions: TObject<TObject<boolean>>;
|
|
259
261
|
}>;
|
|
260
262
|
|
|
261
|
-
|
|
263
|
+
interface GetDataPayload<T = any> {
|
|
264
|
+
key: string;
|
|
265
|
+
collection_name: string;
|
|
266
|
+
callback: (value: T) => void;
|
|
267
|
+
defaultValue: T;
|
|
268
|
+
}
|
|
269
|
+
declare class SocketService {
|
|
270
|
+
private static instance;
|
|
271
|
+
private socket;
|
|
272
|
+
private connectCallbacks;
|
|
273
|
+
private disconnectCallbacks;
|
|
274
|
+
private initSocket;
|
|
275
|
+
private constructor();
|
|
276
|
+
static getInstance(): SocketService;
|
|
277
|
+
private getSocketInstance;
|
|
278
|
+
subscribeToCollections(config: OnSnapshotConfig[]): () => void;
|
|
279
|
+
setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
|
|
280
|
+
getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
|
|
281
|
+
getDocumentData<T>(payload: GetDataPayload<T>): void;
|
|
282
|
+
deleteData(payload: {
|
|
283
|
+
key: string;
|
|
284
|
+
collection_name: string;
|
|
285
|
+
}): Promise<SocketCallbackResponse>;
|
|
286
|
+
clearAllRedisData(): Promise<SocketCallbackResponse>;
|
|
287
|
+
onConnect(callback: () => void): void;
|
|
288
|
+
offConnect(callback: () => void): void;
|
|
289
|
+
onDisconnect(callback: () => void): void;
|
|
290
|
+
offDisconnect(callback: () => void): void;
|
|
291
|
+
isConnected(): boolean;
|
|
292
|
+
}
|
|
293
|
+
declare const socketServiceInstance: SocketService;
|
|
294
|
+
|
|
295
|
+
export { type ValidationType, 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, 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, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
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, {
|
|
@@ -554,6 +573,9 @@ __export(index_exports, {
|
|
|
554
573
|
snapshotDocument: function() {
|
|
555
574
|
return snapshotDocument;
|
|
556
575
|
},
|
|
576
|
+
socketServiceInstance: function() {
|
|
577
|
+
return socketServiceInstance;
|
|
578
|
+
},
|
|
557
579
|
sort_by_timestamp: function() {
|
|
558
580
|
return sort_by_timestamp;
|
|
559
581
|
},
|
|
@@ -2261,6 +2283,277 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2261
2283
|
return _ref.apply(this, arguments);
|
|
2262
2284
|
};
|
|
2263
2285
|
}();
|
|
2286
|
+
// src/helpers/socket.ts
|
|
2287
|
+
var import_socket = require("socket.io-client");
|
|
2288
|
+
var SocketService = /*#__PURE__*/ function() {
|
|
2289
|
+
"use strict";
|
|
2290
|
+
function _SocketService() {
|
|
2291
|
+
_class_call_check(this, _SocketService);
|
|
2292
|
+
this.socket = null;
|
|
2293
|
+
this.connectCallbacks = [];
|
|
2294
|
+
this.disconnectCallbacks = [];
|
|
2295
|
+
}
|
|
2296
|
+
_create_class(_SocketService, [
|
|
2297
|
+
{
|
|
2298
|
+
/// Initialize the socket connection
|
|
2299
|
+
key: "initSocket",
|
|
2300
|
+
value: function initSocket() {
|
|
2301
|
+
var _this = this;
|
|
2302
|
+
if (!this.socket) {
|
|
2303
|
+
var SOCKET_SERVER_URL = "http://localhost:9009";
|
|
2304
|
+
var SOCKET_PATH = "/api/data-socket/connect";
|
|
2305
|
+
this.socket = (0, import_socket.io)(SOCKET_SERVER_URL, {
|
|
2306
|
+
path: SOCKET_PATH,
|
|
2307
|
+
transports: [
|
|
2308
|
+
"websocket"
|
|
2309
|
+
]
|
|
2310
|
+
});
|
|
2311
|
+
this.socket.on("connect", function() {
|
|
2312
|
+
var _this_socket;
|
|
2313
|
+
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
2314
|
+
_this.connectCallbacks.forEach(function(cb) {
|
|
2315
|
+
return cb();
|
|
2316
|
+
});
|
|
2317
|
+
});
|
|
2318
|
+
this.socket.on("disconnect", function(reason) {
|
|
2319
|
+
console.log("Socket disconnected:", reason);
|
|
2320
|
+
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2321
|
+
return cb();
|
|
2322
|
+
});
|
|
2323
|
+
});
|
|
2324
|
+
this.socket.on("connect_error", function(error) {
|
|
2325
|
+
console.error("Socket connection error:", error);
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
},
|
|
2330
|
+
{
|
|
2331
|
+
/// get socket instance
|
|
2332
|
+
key: "getSocketInstance",
|
|
2333
|
+
value: function getSocketInstance() {
|
|
2334
|
+
if (!this.socket) {
|
|
2335
|
+
this.initSocket();
|
|
2336
|
+
}
|
|
2337
|
+
if (!this.socket) {
|
|
2338
|
+
throw new Error("Socket not initialized");
|
|
2339
|
+
}
|
|
2340
|
+
if (!this.socket.connected) {
|
|
2341
|
+
this.socket.connect();
|
|
2342
|
+
}
|
|
2343
|
+
return this.socket;
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
/// subscribe to collections
|
|
2348
|
+
key: "subscribeToCollections",
|
|
2349
|
+
value: function subscribeToCollections(config) {
|
|
2350
|
+
var s = this.getSocketInstance();
|
|
2351
|
+
var collectionsNames = config.map(function(c) {
|
|
2352
|
+
return c.collectionName;
|
|
2353
|
+
});
|
|
2354
|
+
var eventHandlers = [];
|
|
2355
|
+
config.forEach(function(configuration) {
|
|
2356
|
+
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;
|
|
2357
|
+
s.on("initial:".concat(collectionName), onFirstTime);
|
|
2358
|
+
eventHandlers.push({
|
|
2359
|
+
eventName: "initial:".concat(collectionName),
|
|
2360
|
+
handler: onFirstTime
|
|
2361
|
+
});
|
|
2362
|
+
s.on("add:".concat(collectionName), onAdd);
|
|
2363
|
+
eventHandlers.push({
|
|
2364
|
+
eventName: "add:".concat(collectionName),
|
|
2365
|
+
handler: onAdd
|
|
2366
|
+
});
|
|
2367
|
+
s.on("update:".concat(collectionName), onModify);
|
|
2368
|
+
eventHandlers.push({
|
|
2369
|
+
eventName: "update:".concat(collectionName),
|
|
2370
|
+
handler: onModify
|
|
2371
|
+
});
|
|
2372
|
+
s.on("delete:".concat(collectionName), onRemove);
|
|
2373
|
+
eventHandlers.push({
|
|
2374
|
+
eventName: "delete:".concat(collectionName),
|
|
2375
|
+
handler: onRemove
|
|
2376
|
+
});
|
|
2377
|
+
extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
|
|
2378
|
+
var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
|
|
2379
|
+
s.on("initial:".concat(collectionName), extraOnFirstTime);
|
|
2380
|
+
eventHandlers.push({
|
|
2381
|
+
eventName: "initial:".concat(collectionName),
|
|
2382
|
+
handler: extraOnFirstTime
|
|
2383
|
+
});
|
|
2384
|
+
s.on("add:".concat(collectionName), extraOnAdd);
|
|
2385
|
+
eventHandlers.push({
|
|
2386
|
+
eventName: "add:".concat(collectionName),
|
|
2387
|
+
handler: extraOnAdd
|
|
2388
|
+
});
|
|
2389
|
+
s.on("update:".concat(collectionName), extraOnModify);
|
|
2390
|
+
eventHandlers.push({
|
|
2391
|
+
eventName: "update:".concat(collectionName),
|
|
2392
|
+
handler: extraOnModify
|
|
2393
|
+
});
|
|
2394
|
+
s.on("delete:".concat(collectionName), extraOnRemove);
|
|
2395
|
+
eventHandlers.push({
|
|
2396
|
+
eventName: "delete:".concat(collectionName),
|
|
2397
|
+
handler: extraOnRemove
|
|
2398
|
+
});
|
|
2399
|
+
});
|
|
2400
|
+
});
|
|
2401
|
+
s.emit("subscribe_collections", collectionsNames, function(callback) {
|
|
2402
|
+
if (callback.success) {
|
|
2403
|
+
console.log("Successfully subscribed to: ".concat(collectionsNames.join(", ")));
|
|
2404
|
+
} else {
|
|
2405
|
+
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
2406
|
+
}
|
|
2407
|
+
});
|
|
2408
|
+
return function() {
|
|
2409
|
+
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
2410
|
+
s.emit("unsubscribe_collections", collectionsNames);
|
|
2411
|
+
eventHandlers.forEach(function(eh) {
|
|
2412
|
+
s.off(eh.eventName, eh.handler);
|
|
2413
|
+
});
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
/// set data
|
|
2419
|
+
key: "setData",
|
|
2420
|
+
value: function setData(payload) {
|
|
2421
|
+
var s = this.getSocketInstance();
|
|
2422
|
+
return new Promise(function(resolve, reject) {
|
|
2423
|
+
s.emit("set_data", payload, function(callback) {
|
|
2424
|
+
if (callback.success) {
|
|
2425
|
+
console.log("Data saved successfully:", payload);
|
|
2426
|
+
console.log("ack", callback);
|
|
2427
|
+
resolve(callback);
|
|
2428
|
+
} else {
|
|
2429
|
+
reject(new Error(callback.message || "Save operation failed"));
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
},
|
|
2435
|
+
{
|
|
2436
|
+
/// get data
|
|
2437
|
+
key: "getCollectionData",
|
|
2438
|
+
value: function getCollectionData(payload) {
|
|
2439
|
+
var s = this.getSocketInstance();
|
|
2440
|
+
s.emit("get_data", {
|
|
2441
|
+
collection_name: payload.collection_name
|
|
2442
|
+
}, function(socketCallback) {
|
|
2443
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2444
|
+
payload.callback(socketCallback.data);
|
|
2445
|
+
} else {
|
|
2446
|
+
payload.callback(payload.defaultValue);
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
},
|
|
2451
|
+
{
|
|
2452
|
+
key: "getDocumentData",
|
|
2453
|
+
value: function getDocumentData(payload) {
|
|
2454
|
+
var s = this.getSocketInstance();
|
|
2455
|
+
s.emit("get_data", {
|
|
2456
|
+
collection_name: payload.collection_name,
|
|
2457
|
+
key: payload.key
|
|
2458
|
+
}, function(socketCallback) {
|
|
2459
|
+
if (socketCallback.success && socketCallback.data) {
|
|
2460
|
+
payload.callback(socketCallback.data);
|
|
2461
|
+
} else {
|
|
2462
|
+
payload.callback(payload.defaultValue);
|
|
2463
|
+
}
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
/// delete data
|
|
2469
|
+
key: "deleteData",
|
|
2470
|
+
value: function deleteData(payload) {
|
|
2471
|
+
var s = this.getSocketInstance();
|
|
2472
|
+
return new Promise(function(resolve, reject) {
|
|
2473
|
+
s.emit("delete_data", payload, function(callback) {
|
|
2474
|
+
if (callback.success) {
|
|
2475
|
+
console.log("Data deleted successfully:", payload);
|
|
2476
|
+
console.log("delete ack", callback);
|
|
2477
|
+
resolve(callback);
|
|
2478
|
+
} else {
|
|
2479
|
+
reject(new Error(callback.message || "Delete operation failed"));
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
key: "clearAllRedisData",
|
|
2487
|
+
value: function clearAllRedisData() {
|
|
2488
|
+
var s = this.getSocketInstance();
|
|
2489
|
+
return new Promise(function(resolve, reject) {
|
|
2490
|
+
s.emit("clear_all_redis_data", function(ack) {
|
|
2491
|
+
if (ack.success) {
|
|
2492
|
+
resolve(ack);
|
|
2493
|
+
} else {
|
|
2494
|
+
reject(new Error(ack.message || "Clear all Redis data operation failed"));
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
},
|
|
2500
|
+
{
|
|
2501
|
+
/// connection management methods
|
|
2502
|
+
key: "onConnect",
|
|
2503
|
+
value: function onConnect(callback) {
|
|
2504
|
+
var _this_socket;
|
|
2505
|
+
this.connectCallbacks.push(callback);
|
|
2506
|
+
if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
|
|
2507
|
+
callback();
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
},
|
|
2511
|
+
{
|
|
2512
|
+
key: "offConnect",
|
|
2513
|
+
value: function offConnect(callback) {
|
|
2514
|
+
this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
|
|
2515
|
+
return cb !== callback;
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
},
|
|
2519
|
+
{
|
|
2520
|
+
key: "onDisconnect",
|
|
2521
|
+
value: function onDisconnect(callback) {
|
|
2522
|
+
this.disconnectCallbacks.push(callback);
|
|
2523
|
+
if (this.socket && !this.socket.connected) {
|
|
2524
|
+
callback();
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
key: "offDisconnect",
|
|
2530
|
+
value: function offDisconnect(callback) {
|
|
2531
|
+
this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
|
|
2532
|
+
return cb !== callback;
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
key: "isConnected",
|
|
2538
|
+
value: function isConnected() {
|
|
2539
|
+
var _this_socket;
|
|
2540
|
+
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
], [
|
|
2544
|
+
{
|
|
2545
|
+
key: "getInstance",
|
|
2546
|
+
value: function getInstance() {
|
|
2547
|
+
if (!_SocketService.instance) {
|
|
2548
|
+
_SocketService.instance = new _SocketService();
|
|
2549
|
+
}
|
|
2550
|
+
return _SocketService.instance;
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
]);
|
|
2554
|
+
return _SocketService;
|
|
2555
|
+
}();
|
|
2556
|
+
var socketServiceInstance = SocketService.getInstance();
|
|
2264
2557
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2265
2558
|
0 && (module.exports = {
|
|
2266
2559
|
addAuditRecord: addAuditRecord,
|
|
@@ -2346,6 +2639,7 @@ var nxApiCall = /*#__PURE__*/ function() {
|
|
|
2346
2639
|
simpleExtractData: simpleExtractData,
|
|
2347
2640
|
snapshot: snapshot,
|
|
2348
2641
|
snapshotDocument: snapshotDocument,
|
|
2642
|
+
socketServiceInstance: socketServiceInstance,
|
|
2349
2643
|
sort_by_timestamp: sort_by_timestamp,
|
|
2350
2644
|
storage: storage,
|
|
2351
2645
|
textNumbersRegex: textNumbersRegex,
|