akeyless-client-commons 1.1.128 → 1.1.130
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 +245 -53
- package/dist/components/index.mjs +189 -42
- package/dist/helpers/index.d.mts +6 -2
- package/dist/helpers/index.d.ts +6 -2
- package/dist/helpers/index.js +317 -200
- package/dist/helpers/index.mjs +305 -192
- package/dist/hooks/index.d.mts +5 -2
- package/dist/hooks/index.d.ts +5 -2
- package/dist/hooks/index.js +228 -103
- package/dist/hooks/index.mjs +219 -94
- package/package.json +2 -2
|
@@ -524,6 +524,61 @@ function timestamp_to_string(firebaseTimestamp, options) {
|
|
|
524
524
|
return moment.utc(date).format(format);
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
+
// src/helpers/global.ts
|
|
528
|
+
import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
|
|
529
|
+
import axios from "axios";
|
|
530
|
+
import { isEqual } from "lodash";
|
|
531
|
+
var renderOnce = function() {
|
|
532
|
+
return true;
|
|
533
|
+
};
|
|
534
|
+
var propsAreEqual = function(prevProps, nextProps) {
|
|
535
|
+
return isEqual(prevProps, nextProps);
|
|
536
|
+
};
|
|
537
|
+
var getLocationUrl = function(lng, lat) {
|
|
538
|
+
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
539
|
+
};
|
|
540
|
+
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
541
|
+
var _ref = {
|
|
542
|
+
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
543
|
+
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
544
|
+
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
545
|
+
var getFixedNumber = function() {
|
|
546
|
+
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
547
|
+
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
548
|
+
return String(sum_value);
|
|
549
|
+
};
|
|
550
|
+
var checkConditions = function(document2, conditions) {
|
|
551
|
+
if (!conditions || conditions.length === 0) return true;
|
|
552
|
+
return conditions.every(function(condition) {
|
|
553
|
+
var fieldValue = document2[condition.field_name];
|
|
554
|
+
switch(condition.operator){
|
|
555
|
+
case "==":
|
|
556
|
+
return fieldValue === condition.value;
|
|
557
|
+
case "!=":
|
|
558
|
+
return fieldValue !== condition.value;
|
|
559
|
+
case "<":
|
|
560
|
+
return fieldValue < condition.value;
|
|
561
|
+
case "<=":
|
|
562
|
+
return fieldValue <= condition.value;
|
|
563
|
+
case ">":
|
|
564
|
+
return fieldValue > condition.value;
|
|
565
|
+
case ">=":
|
|
566
|
+
return fieldValue >= condition.value;
|
|
567
|
+
case "in":
|
|
568
|
+
return Array.isArray(condition.value) && condition.value.includes(fieldValue);
|
|
569
|
+
case "not-in":
|
|
570
|
+
return Array.isArray(condition.value) && !condition.value.includes(fieldValue);
|
|
571
|
+
case "array-contains":
|
|
572
|
+
return Array.isArray(fieldValue) && fieldValue.includes(condition.value);
|
|
573
|
+
case "array-contains-any":
|
|
574
|
+
return Array.isArray(fieldValue) && Array.isArray(condition.value) && condition.value.some(function(v) {
|
|
575
|
+
return fieldValue.includes(v);
|
|
576
|
+
});
|
|
577
|
+
default:
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
};
|
|
527
582
|
// src/helpers/firebase.ts
|
|
528
583
|
var initApp = function() {
|
|
529
584
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
@@ -902,29 +957,6 @@ var validateUserStatusAndPermissions = function(user, app2) {
|
|
|
902
957
|
}
|
|
903
958
|
return userPermissions;
|
|
904
959
|
};
|
|
905
|
-
// src/helpers/global.ts
|
|
906
|
-
import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
|
|
907
|
-
import axios from "axios";
|
|
908
|
-
import { isEqual } from "lodash";
|
|
909
|
-
var renderOnce = function() {
|
|
910
|
-
return true;
|
|
911
|
-
};
|
|
912
|
-
var propsAreEqual = function(prevProps, nextProps) {
|
|
913
|
-
return isEqual(prevProps, nextProps);
|
|
914
|
-
};
|
|
915
|
-
var getLocationUrl = function(lng, lat) {
|
|
916
|
-
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
917
|
-
};
|
|
918
|
-
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
919
|
-
var _ref = {
|
|
920
|
-
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
921
|
-
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
922
|
-
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
923
|
-
var getFixedNumber = function() {
|
|
924
|
-
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
925
|
-
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
926
|
-
return String(sum_value);
|
|
927
|
-
};
|
|
928
960
|
// src/helpers/forms.ts
|
|
929
961
|
import XRegExp from "xregexp";
|
|
930
962
|
var textRegex = XRegExp(String.raw(_templateObject()), "gu");
|
|
@@ -1071,6 +1103,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1071
1103
|
this.disconnectCallbacks = [];
|
|
1072
1104
|
this.authToken = null;
|
|
1073
1105
|
this.isDisconnected = true;
|
|
1106
|
+
/// the data-socket keeps one subscription per collection per socket, so a second condition set
|
|
1107
|
+
/// for a collection never reaches it and would silently receive the first one's documents
|
|
1108
|
+
this.activeConditions = /* @__PURE__ */ new Map();
|
|
1074
1109
|
this.handleDisconnect = function(source, reason) {
|
|
1075
1110
|
var _this_socket;
|
|
1076
1111
|
if (_this.isDisconnected) {
|
|
@@ -1238,6 +1273,39 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1238
1273
|
}
|
|
1239
1274
|
}
|
|
1240
1275
|
},
|
|
1276
|
+
{
|
|
1277
|
+
key: "registerConditions",
|
|
1278
|
+
value: function registerConditions(collectionName) {
|
|
1279
|
+
var conditions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
1280
|
+
var signature = JSON.stringify(conditions);
|
|
1281
|
+
var active = this.activeConditions.get(collectionName);
|
|
1282
|
+
if (!active) {
|
|
1283
|
+
this.activeConditions.set(collectionName, {
|
|
1284
|
+
signature: signature,
|
|
1285
|
+
conditions: conditions,
|
|
1286
|
+
count: 1
|
|
1287
|
+
});
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
active.count++;
|
|
1291
|
+
if (active.signature !== signature) {
|
|
1292
|
+
console.error('[socket] "'.concat(collectionName, '" is already subscribed with different conditions, and a collection supports one condition set at a time. The active set stays in effect, so this subscription receives its documents instead of its own. active: ').concat(active.signature, " requested: ").concat(signature));
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
key: "releaseConditions",
|
|
1298
|
+
value: function releaseConditions(collectionName) {
|
|
1299
|
+
var active = this.activeConditions.get(collectionName);
|
|
1300
|
+
if (!active) {
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
active.count--;
|
|
1304
|
+
if (active.count <= 0) {
|
|
1305
|
+
this.activeConditions.delete(collectionName);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1241
1309
|
{
|
|
1242
1310
|
key: "disconnectSocket",
|
|
1243
1311
|
value: function disconnectSocket() {
|
|
@@ -1249,6 +1317,8 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1249
1317
|
},
|
|
1250
1318
|
{
|
|
1251
1319
|
/// subscribe to collections
|
|
1320
|
+
/// conditions are derived from OnSnapshotConfig.conditions, never passed in, so a caller cannot
|
|
1321
|
+
/// set them in a second place and have them silently overwritten
|
|
1252
1322
|
key: "subscribeToCollections",
|
|
1253
1323
|
value: function subscribeToCollections(config, options) {
|
|
1254
1324
|
var _this = this;
|
|
@@ -1261,26 +1331,77 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1261
1331
|
});
|
|
1262
1332
|
var eventHandlers = [];
|
|
1263
1333
|
config.forEach(function(configuration) {
|
|
1264
|
-
var collectionName = configuration.collectionName,
|
|
1334
|
+
var collectionName = configuration.collectionName, conditions = configuration.conditions;
|
|
1335
|
+
var parsers = [
|
|
1336
|
+
configuration
|
|
1337
|
+
].concat(_to_consumable_array(configuration.extraParsers || []));
|
|
1338
|
+
var matchedIds = /* @__PURE__ */ new Set();
|
|
1265
1339
|
var attach = function(eventName, handler) {
|
|
1266
|
-
if (!handler) return;
|
|
1267
|
-
_this.socket.off(eventName, handler);
|
|
1268
1340
|
_this.socket.on(eventName, handler);
|
|
1269
1341
|
eventHandlers.push({
|
|
1270
1342
|
eventName: eventName,
|
|
1271
1343
|
handler: handler
|
|
1272
1344
|
});
|
|
1273
1345
|
};
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1346
|
+
var toDocs = function(payload) {
|
|
1347
|
+
return Array.isArray(payload) ? payload : payload ? [
|
|
1348
|
+
payload
|
|
1349
|
+
] : [];
|
|
1350
|
+
};
|
|
1351
|
+
var run = function(op, docs) {
|
|
1352
|
+
return parsers.forEach(function(parser) {
|
|
1353
|
+
var _parser_op;
|
|
1354
|
+
return (_parser_op = parser[op]) === null || _parser_op === void 0 ? void 0 : _parser_op.call(parser, docs, configuration);
|
|
1355
|
+
});
|
|
1356
|
+
};
|
|
1357
|
+
var runIfAny = function(op, docs) {
|
|
1358
|
+
if (docs.length) {
|
|
1359
|
+
run(op, docs);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
attach("initial:".concat(collectionName), function(payload) {
|
|
1363
|
+
var docs = toDocs(payload).filter(function(doc2) {
|
|
1364
|
+
return checkConditions(doc2, conditions);
|
|
1365
|
+
});
|
|
1366
|
+
matchedIds.clear();
|
|
1367
|
+
docs.forEach(function(doc2) {
|
|
1368
|
+
return matchedIds.add(doc2.id);
|
|
1369
|
+
});
|
|
1370
|
+
run("onFirstTime", docs);
|
|
1371
|
+
});
|
|
1372
|
+
var handleUpsert = function(payload, defaultOp) {
|
|
1373
|
+
var added = [];
|
|
1374
|
+
var modified = [];
|
|
1375
|
+
var removed = [];
|
|
1376
|
+
toDocs(payload).forEach(function(doc2) {
|
|
1377
|
+
if (!(conditions === null || conditions === void 0 ? void 0 : conditions.length)) {
|
|
1378
|
+
(defaultOp === "onAdd" ? added : modified).push(doc2);
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
var wasMatching = matchedIds.has(doc2.id);
|
|
1382
|
+
if (checkConditions(doc2, conditions)) {
|
|
1383
|
+
matchedIds.add(doc2.id);
|
|
1384
|
+
(wasMatching ? modified : added).push(doc2);
|
|
1385
|
+
} else if (wasMatching) {
|
|
1386
|
+
matchedIds.delete(doc2.id);
|
|
1387
|
+
removed.push(doc2);
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
runIfAny("onAdd", added);
|
|
1391
|
+
runIfAny("onModify", modified);
|
|
1392
|
+
runIfAny("onRemove", removed);
|
|
1393
|
+
};
|
|
1394
|
+
attach("add:".concat(collectionName), function(payload) {
|
|
1395
|
+
return handleUpsert(payload, "onAdd");
|
|
1396
|
+
});
|
|
1397
|
+
attach("update:".concat(collectionName), function(payload) {
|
|
1398
|
+
return handleUpsert(payload, "onModify");
|
|
1399
|
+
});
|
|
1400
|
+
attach("delete:".concat(collectionName), function(payload) {
|
|
1401
|
+
var docs = toDocs(payload).filter(function(doc2) {
|
|
1402
|
+
return !(conditions === null || conditions === void 0 ? void 0 : conditions.length) || matchedIds.delete(doc2.id);
|
|
1403
|
+
});
|
|
1404
|
+
runIfAny("onRemove", docs);
|
|
1284
1405
|
});
|
|
1285
1406
|
});
|
|
1286
1407
|
var acknowledge = function(callback) {
|
|
@@ -1290,12 +1411,28 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1290
1411
|
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
1291
1412
|
}
|
|
1292
1413
|
};
|
|
1293
|
-
|
|
1294
|
-
|
|
1414
|
+
config.forEach(function(c) {
|
|
1415
|
+
return _this.registerConditions(c.collectionName, c.conditions);
|
|
1416
|
+
});
|
|
1417
|
+
var conditionsByCollection = config.reduce(function(acc, c) {
|
|
1418
|
+
var active = _this.activeConditions.get(c.collectionName);
|
|
1419
|
+
if (active === null || active === void 0 ? void 0 : active.conditions.length) {
|
|
1420
|
+
acc[c.collectionName] = active.conditions;
|
|
1421
|
+
}
|
|
1422
|
+
return acc;
|
|
1423
|
+
}, {});
|
|
1424
|
+
var subscribeOptions = Object.keys(conditionsByCollection).length ? _object_spread_props(_object_spread({}, options), {
|
|
1425
|
+
conditions: conditionsByCollection
|
|
1426
|
+
}) : options;
|
|
1427
|
+
if (subscribeOptions) {
|
|
1428
|
+
s.emit("subscribe_options", subscribeOptions);
|
|
1295
1429
|
}
|
|
1296
1430
|
s.emit("subscribe_collections", collectionsNames, acknowledge);
|
|
1297
1431
|
return function() {
|
|
1298
1432
|
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
1433
|
+
collectionsNames.forEach(function(name) {
|
|
1434
|
+
return _this.releaseConditions(name);
|
|
1435
|
+
});
|
|
1299
1436
|
s.emit("unsubscribe_collections", collectionsNames);
|
|
1300
1437
|
eventHandlers.forEach(function(eh) {
|
|
1301
1438
|
s.off(eh.eventName, eh.handler);
|
|
@@ -5165,15 +5302,25 @@ function SearchSelect(param) {
|
|
|
5165
5302
|
});
|
|
5166
5303
|
}
|
|
5167
5304
|
// src/helpers/excel.tsx
|
|
5168
|
-
import ExcelJS from "exceljs";
|
|
5169
|
-
import { saveAs } from "file-saver";
|
|
5170
5305
|
var exportToExcel = /*#__PURE__*/ function() {
|
|
5171
5306
|
var _ref = _async_to_generator(function(param) {
|
|
5172
|
-
var columns, data, headline, fileName, cellStyle, direction, workbook, worksheet, titleRow, buffer, blob;
|
|
5307
|
+
var columns, data, headline, fileName, cellStyle, direction, _ref, _ref_, ExcelJS, saveAs, workbook, worksheet, titleRow, buffer, blob;
|
|
5173
5308
|
return _ts_generator(this, function(_state) {
|
|
5174
5309
|
switch(_state.label){
|
|
5175
5310
|
case 0:
|
|
5176
5311
|
columns = param.columns, data = param.data, headline = param.headline, fileName = param.fileName, cellStyle = param.cellStyle, direction = param.direction;
|
|
5312
|
+
return [
|
|
5313
|
+
4,
|
|
5314
|
+
Promise.all([
|
|
5315
|
+
import("exceljs"),
|
|
5316
|
+
import("file-saver")
|
|
5317
|
+
])
|
|
5318
|
+
];
|
|
5319
|
+
case 1:
|
|
5320
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
5321
|
+
_state.sent(),
|
|
5322
|
+
2
|
|
5323
|
+
]), _ref_ = _ref[0], ExcelJS = _ref_.default, saveAs = _ref[1].saveAs;
|
|
5177
5324
|
workbook = new ExcelJS.Workbook();
|
|
5178
5325
|
worksheet = workbook.addWorksheet("Report");
|
|
5179
5326
|
worksheet.views = [
|
|
@@ -5225,7 +5372,7 @@ var exportToExcel = /*#__PURE__*/ function() {
|
|
|
5225
5372
|
4,
|
|
5226
5373
|
workbook.xlsx.writeBuffer()
|
|
5227
5374
|
];
|
|
5228
|
-
case
|
|
5375
|
+
case 2:
|
|
5229
5376
|
buffer = _state.sent();
|
|
5230
5377
|
blob = new Blob([
|
|
5231
5378
|
buffer
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -188,6 +188,7 @@ declare const isLocal: boolean;
|
|
|
188
188
|
declare const getFixedNumber: (number?: number, fix?: number) => string;
|
|
189
189
|
declare const getAddressByGeo: ({ lat, lng }: Geo, currentLanguage: LanguageOptions) => Promise<any>;
|
|
190
190
|
declare const validateAndCast: <T extends unknown>(variable: any, condition: Boolean) => variable is T;
|
|
191
|
+
declare const checkConditions: (document: TObject<any>, conditions?: WhereCondition[]) => boolean;
|
|
191
192
|
|
|
192
193
|
declare const textRegex: RegExp;
|
|
193
194
|
declare const numbersRegex: RegExp;
|
|
@@ -333,6 +334,7 @@ declare class SocketService {
|
|
|
333
334
|
private disconnectCallbacks;
|
|
334
335
|
private authToken;
|
|
335
336
|
private isDisconnected;
|
|
337
|
+
private activeConditions;
|
|
336
338
|
private handleDisconnect;
|
|
337
339
|
private initSocket;
|
|
338
340
|
private constructor();
|
|
@@ -345,8 +347,10 @@ declare class SocketService {
|
|
|
345
347
|
offDisconnect(callback: () => void): void;
|
|
346
348
|
isConnected(): boolean;
|
|
347
349
|
setAuthToken(token: string): void;
|
|
350
|
+
private registerConditions;
|
|
351
|
+
private releaseConditions;
|
|
348
352
|
disconnectSocket(): void;
|
|
349
|
-
subscribeToCollections(config: OnSnapshotConfig[], options?: SubscribeCollectionsOptions): () => void;
|
|
353
|
+
subscribeToCollections(config: OnSnapshotConfig[], options?: Omit<SubscribeCollectionsOptions, "conditions">): () => void;
|
|
350
354
|
setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
|
|
351
355
|
getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
|
|
352
356
|
getDocumentData<T>(payload: GetDataPayload<T>): void;
|
|
@@ -361,4 +365,4 @@ declare const multiply: (a: number, b: number) => number;
|
|
|
361
365
|
declare const add: (a: number, b: number) => number;
|
|
362
366
|
declare const subtract: (a: number, b: number) => number;
|
|
363
367
|
|
|
364
|
-
export { type EmailAttachment, type EmailData, type ValidationType, add, addAuditRecord, addLoginAudit, addNxProblem, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chargeDomain, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createAttachmentFromBlob, createAttachmentFromUrl, createSelectors, dataSocketDomain, dataSyncDomain, db, delete_document, devicesDomain, displayFormatPhoneNumber, durationToSeconds, emailRegex, endUsersDomain, 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, isFixedOrServiceNumber, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, isSimProviderCelcom, isSimProviderMonogoto, isSimProviderPartner, isSimProviderPelephone, is_iccid, local_israel_phone_format, longShortPhoneNumbers, mode, multiStringFormat, multiply, notificationsDomain, numbersOnlyRegex, numbersRegex, nxApiCall, parseMultiSelectInput, parsePermissions, parseSnapshotAsArray, parseSnapshotAsObject, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, secondsToDuration, sendEmail, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, subtract, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
|
368
|
+
export { type EmailAttachment, type EmailData, type ValidationType, add, addAuditRecord, addLoginAudit, addNxProblem, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chargeDomain, chartsRegex, checkConditions, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createAttachmentFromBlob, createAttachmentFromUrl, createSelectors, dataSocketDomain, dataSyncDomain, db, delete_document, devicesDomain, displayFormatPhoneNumber, durationToSeconds, emailRegex, endUsersDomain, 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, isFixedOrServiceNumber, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, isSimProviderCelcom, isSimProviderMonogoto, isSimProviderPartner, isSimProviderPelephone, is_iccid, local_israel_phone_format, longShortPhoneNumbers, mode, multiStringFormat, multiply, notificationsDomain, numbersOnlyRegex, numbersRegex, nxApiCall, parseMultiSelectInput, parsePermissions, parseSnapshotAsArray, parseSnapshotAsObject, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, secondsToDuration, sendEmail, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, subtract, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -188,6 +188,7 @@ declare const isLocal: boolean;
|
|
|
188
188
|
declare const getFixedNumber: (number?: number, fix?: number) => string;
|
|
189
189
|
declare const getAddressByGeo: ({ lat, lng }: Geo, currentLanguage: LanguageOptions) => Promise<any>;
|
|
190
190
|
declare const validateAndCast: <T extends unknown>(variable: any, condition: Boolean) => variable is T;
|
|
191
|
+
declare const checkConditions: (document: TObject<any>, conditions?: WhereCondition[]) => boolean;
|
|
191
192
|
|
|
192
193
|
declare const textRegex: RegExp;
|
|
193
194
|
declare const numbersRegex: RegExp;
|
|
@@ -333,6 +334,7 @@ declare class SocketService {
|
|
|
333
334
|
private disconnectCallbacks;
|
|
334
335
|
private authToken;
|
|
335
336
|
private isDisconnected;
|
|
337
|
+
private activeConditions;
|
|
336
338
|
private handleDisconnect;
|
|
337
339
|
private initSocket;
|
|
338
340
|
private constructor();
|
|
@@ -345,8 +347,10 @@ declare class SocketService {
|
|
|
345
347
|
offDisconnect(callback: () => void): void;
|
|
346
348
|
isConnected(): boolean;
|
|
347
349
|
setAuthToken(token: string): void;
|
|
350
|
+
private registerConditions;
|
|
351
|
+
private releaseConditions;
|
|
348
352
|
disconnectSocket(): void;
|
|
349
|
-
subscribeToCollections(config: OnSnapshotConfig[], options?: SubscribeCollectionsOptions): () => void;
|
|
353
|
+
subscribeToCollections(config: OnSnapshotConfig[], options?: Omit<SubscribeCollectionsOptions, "conditions">): () => void;
|
|
350
354
|
setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
|
|
351
355
|
getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
|
|
352
356
|
getDocumentData<T>(payload: GetDataPayload<T>): void;
|
|
@@ -361,4 +365,4 @@ declare const multiply: (a: number, b: number) => number;
|
|
|
361
365
|
declare const add: (a: number, b: number) => number;
|
|
362
366
|
declare const subtract: (a: number, b: number) => number;
|
|
363
367
|
|
|
364
|
-
export { type EmailAttachment, type EmailData, type ValidationType, add, addAuditRecord, addLoginAudit, addNxProblem, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chargeDomain, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createAttachmentFromBlob, createAttachmentFromUrl, createSelectors, dataSocketDomain, dataSyncDomain, db, delete_document, devicesDomain, displayFormatPhoneNumber, durationToSeconds, emailRegex, endUsersDomain, 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, isFixedOrServiceNumber, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, isSimProviderCelcom, isSimProviderMonogoto, isSimProviderPartner, isSimProviderPelephone, is_iccid, local_israel_phone_format, longShortPhoneNumbers, mode, multiStringFormat, multiply, notificationsDomain, numbersOnlyRegex, numbersRegex, nxApiCall, parseMultiSelectInput, parsePermissions, parseSnapshotAsArray, parseSnapshotAsObject, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, secondsToDuration, sendEmail, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, subtract, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|
|
368
|
+
export { type EmailAttachment, type EmailData, type ValidationType, add, addAuditRecord, addLoginAudit, addNxProblem, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterEventsDomain, callCenterGeoDomain, carsRegex, chargeDomain, chartsRegex, checkConditions, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createAttachmentFromBlob, createAttachmentFromUrl, createSelectors, dataSocketDomain, dataSyncDomain, db, delete_document, devicesDomain, displayFormatPhoneNumber, durationToSeconds, emailRegex, endUsersDomain, 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, isFixedOrServiceNumber, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, isSimProviderCelcom, isSimProviderMonogoto, isSimProviderPartner, isSimProviderPelephone, is_iccid, local_israel_phone_format, longShortPhoneNumbers, mode, multiStringFormat, multiply, notificationsDomain, numbersOnlyRegex, numbersRegex, nxApiCall, parseMultiSelectInput, parsePermissions, parseSnapshotAsArray, parseSnapshotAsObject, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, secondsToDuration, sendEmail, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, socketServiceInstance, sort_by_timestamp, storage, subtract, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, uploadFileToStorage, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateAndCast, validateUserStatusAndPermissions };
|