akeyless-client-commons 1.1.129 → 1.1.131
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.d.mts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +189 -52
- package/dist/components/index.mjs +180 -43
- 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
package/dist/components/index.js
CHANGED
|
@@ -791,17 +791,73 @@ function timestamp_to_string(firebaseTimestamp, options) {
|
|
|
791
791
|
return import_moment_timezone.default.utc(date).format(format);
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
|
-
// src/helpers/
|
|
794
|
+
// src/helpers/global.ts
|
|
795
|
+
var import_akeyless_types_commons = require("akeyless-types-commons");
|
|
796
|
+
var import_axios = __toESM(require("axios"));
|
|
797
|
+
var import_lodash = require("lodash");
|
|
795
798
|
var import_meta = {};
|
|
799
|
+
var renderOnce = function() {
|
|
800
|
+
return true;
|
|
801
|
+
};
|
|
802
|
+
var propsAreEqual = function(prevProps, nextProps) {
|
|
803
|
+
return (0, import_lodash.isEqual)(prevProps, nextProps);
|
|
804
|
+
};
|
|
805
|
+
var getLocationUrl = function(lng, lat) {
|
|
806
|
+
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
807
|
+
};
|
|
808
|
+
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
809
|
+
var _ref = {
|
|
810
|
+
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta.env.VITE_MODE,
|
|
811
|
+
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta.env.VITE_is_local) === "true"
|
|
812
|
+
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
813
|
+
var getFixedNumber = function() {
|
|
814
|
+
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
815
|
+
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
816
|
+
return String(sum_value);
|
|
817
|
+
};
|
|
818
|
+
var checkConditions = function(document2, conditions) {
|
|
819
|
+
if (!conditions || conditions.length === 0) return true;
|
|
820
|
+
return conditions.every(function(condition) {
|
|
821
|
+
var fieldValue = document2[condition.field_name];
|
|
822
|
+
switch(condition.operator){
|
|
823
|
+
case "==":
|
|
824
|
+
return fieldValue === condition.value;
|
|
825
|
+
case "!=":
|
|
826
|
+
return fieldValue !== condition.value;
|
|
827
|
+
case "<":
|
|
828
|
+
return fieldValue < condition.value;
|
|
829
|
+
case "<=":
|
|
830
|
+
return fieldValue <= condition.value;
|
|
831
|
+
case ">":
|
|
832
|
+
return fieldValue > condition.value;
|
|
833
|
+
case ">=":
|
|
834
|
+
return fieldValue >= condition.value;
|
|
835
|
+
case "in":
|
|
836
|
+
return Array.isArray(condition.value) && condition.value.includes(fieldValue);
|
|
837
|
+
case "not-in":
|
|
838
|
+
return Array.isArray(condition.value) && !condition.value.includes(fieldValue);
|
|
839
|
+
case "array-contains":
|
|
840
|
+
return Array.isArray(fieldValue) && fieldValue.includes(condition.value);
|
|
841
|
+
case "array-contains-any":
|
|
842
|
+
return Array.isArray(fieldValue) && Array.isArray(condition.value) && condition.value.some(function(v) {
|
|
843
|
+
return fieldValue.includes(v);
|
|
844
|
+
});
|
|
845
|
+
default:
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
// src/helpers/firebase.ts
|
|
851
|
+
var import_meta2 = {};
|
|
796
852
|
var initApp = function() {
|
|
797
853
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
798
854
|
var firebaseConfig = {
|
|
799
|
-
apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY :
|
|
800
|
-
authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN :
|
|
801
|
-
projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID :
|
|
802
|
-
storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET :
|
|
803
|
-
messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID :
|
|
804
|
-
appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID :
|
|
855
|
+
apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY : import_meta2.env.VITE_API_KEY,
|
|
856
|
+
authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN : import_meta2.env.VITE_AUTH_DOMAIN,
|
|
857
|
+
projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID : import_meta2.env.VITE_PROJECT_ID,
|
|
858
|
+
storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET : import_meta2.env.VITE_STORAGE_BUCKET,
|
|
859
|
+
messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID : import_meta2.env.VITE_MESSAGING_SENDER_ID,
|
|
860
|
+
appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID : import_meta2.env.VITE_APP_ID
|
|
805
861
|
};
|
|
806
862
|
try {
|
|
807
863
|
var app2 = (0, import_app.initializeApp)(firebaseConfig);
|
|
@@ -810,7 +866,7 @@ var initApp = function() {
|
|
|
810
866
|
var db2 = (0, import_firestore2.getFirestore)(app2);
|
|
811
867
|
var storage2 = (0, import_storage.getStorage)(app2);
|
|
812
868
|
var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
|
|
813
|
-
var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY :
|
|
869
|
+
var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta2.env.VITE_RECAPTCHA_SITE_KEY;
|
|
814
870
|
var result = {
|
|
815
871
|
db: db2,
|
|
816
872
|
auth: auth2,
|
|
@@ -1170,30 +1226,6 @@ var validateUserStatusAndPermissions = function(user, app2) {
|
|
|
1170
1226
|
}
|
|
1171
1227
|
return userPermissions;
|
|
1172
1228
|
};
|
|
1173
|
-
// src/helpers/global.ts
|
|
1174
|
-
var import_akeyless_types_commons = require("akeyless-types-commons");
|
|
1175
|
-
var import_axios = __toESM(require("axios"));
|
|
1176
|
-
var import_lodash = require("lodash");
|
|
1177
|
-
var import_meta2 = {};
|
|
1178
|
-
var renderOnce = function() {
|
|
1179
|
-
return true;
|
|
1180
|
-
};
|
|
1181
|
-
var propsAreEqual = function(prevProps, nextProps) {
|
|
1182
|
-
return (0, import_lodash.isEqual)(prevProps, nextProps);
|
|
1183
|
-
};
|
|
1184
|
-
var getLocationUrl = function(lng, lat) {
|
|
1185
|
-
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
1186
|
-
};
|
|
1187
|
-
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
1188
|
-
var _ref = {
|
|
1189
|
-
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta2.env.VITE_MODE,
|
|
1190
|
-
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta2.env.VITE_is_local) === "true"
|
|
1191
|
-
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
1192
|
-
var getFixedNumber = function() {
|
|
1193
|
-
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
1194
|
-
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
1195
|
-
return String(sum_value);
|
|
1196
|
-
};
|
|
1197
1229
|
// src/helpers/forms.ts
|
|
1198
1230
|
var import_xregexp = __toESM(require("xregexp"));
|
|
1199
1231
|
var textRegex = (0, import_xregexp.default)(String.raw(_templateObject()), "gu");
|
|
@@ -1340,6 +1372,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1340
1372
|
this.disconnectCallbacks = [];
|
|
1341
1373
|
this.authToken = null;
|
|
1342
1374
|
this.isDisconnected = true;
|
|
1375
|
+
/// the data-socket keeps one subscription per collection per socket, so a second condition set
|
|
1376
|
+
/// for a collection never reaches it and would silently receive the first one's documents
|
|
1377
|
+
this.activeConditions = /* @__PURE__ */ new Map();
|
|
1343
1378
|
this.handleDisconnect = function(source, reason) {
|
|
1344
1379
|
var _this_socket;
|
|
1345
1380
|
if (_this.isDisconnected) {
|
|
@@ -1507,6 +1542,39 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1507
1542
|
}
|
|
1508
1543
|
}
|
|
1509
1544
|
},
|
|
1545
|
+
{
|
|
1546
|
+
key: "registerConditions",
|
|
1547
|
+
value: function registerConditions(collectionName) {
|
|
1548
|
+
var conditions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
1549
|
+
var signature = JSON.stringify(conditions);
|
|
1550
|
+
var active = this.activeConditions.get(collectionName);
|
|
1551
|
+
if (!active) {
|
|
1552
|
+
this.activeConditions.set(collectionName, {
|
|
1553
|
+
signature: signature,
|
|
1554
|
+
conditions: conditions,
|
|
1555
|
+
count: 1
|
|
1556
|
+
});
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
active.count++;
|
|
1560
|
+
if (active.signature !== signature) {
|
|
1561
|
+
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));
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
{
|
|
1566
|
+
key: "releaseConditions",
|
|
1567
|
+
value: function releaseConditions(collectionName) {
|
|
1568
|
+
var active = this.activeConditions.get(collectionName);
|
|
1569
|
+
if (!active) {
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
active.count--;
|
|
1573
|
+
if (active.count <= 0) {
|
|
1574
|
+
this.activeConditions.delete(collectionName);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1510
1578
|
{
|
|
1511
1579
|
key: "disconnectSocket",
|
|
1512
1580
|
value: function disconnectSocket() {
|
|
@@ -1518,6 +1586,8 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1518
1586
|
},
|
|
1519
1587
|
{
|
|
1520
1588
|
/// subscribe to collections
|
|
1589
|
+
/// conditions are derived from OnSnapshotConfig.conditions, never passed in, so a caller cannot
|
|
1590
|
+
/// set them in a second place and have them silently overwritten
|
|
1521
1591
|
key: "subscribeToCollections",
|
|
1522
1592
|
value: function subscribeToCollections(config, options) {
|
|
1523
1593
|
var _this = this;
|
|
@@ -1530,26 +1600,77 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1530
1600
|
});
|
|
1531
1601
|
var eventHandlers = [];
|
|
1532
1602
|
config.forEach(function(configuration) {
|
|
1533
|
-
var collectionName = configuration.collectionName,
|
|
1603
|
+
var collectionName = configuration.collectionName, conditions = configuration.conditions;
|
|
1604
|
+
var parsers = [
|
|
1605
|
+
configuration
|
|
1606
|
+
].concat(_to_consumable_array(configuration.extraParsers || []));
|
|
1607
|
+
var matchedIds = /* @__PURE__ */ new Set();
|
|
1534
1608
|
var attach = function(eventName, handler) {
|
|
1535
|
-
if (!handler) return;
|
|
1536
|
-
_this.socket.off(eventName, handler);
|
|
1537
1609
|
_this.socket.on(eventName, handler);
|
|
1538
1610
|
eventHandlers.push({
|
|
1539
1611
|
eventName: eventName,
|
|
1540
1612
|
handler: handler
|
|
1541
1613
|
});
|
|
1542
1614
|
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1615
|
+
var toDocs = function(payload) {
|
|
1616
|
+
return Array.isArray(payload) ? payload : payload ? [
|
|
1617
|
+
payload
|
|
1618
|
+
] : [];
|
|
1619
|
+
};
|
|
1620
|
+
var run = function(op, docs) {
|
|
1621
|
+
return parsers.forEach(function(parser) {
|
|
1622
|
+
var _parser_op;
|
|
1623
|
+
return (_parser_op = parser[op]) === null || _parser_op === void 0 ? void 0 : _parser_op.call(parser, docs, configuration);
|
|
1624
|
+
});
|
|
1625
|
+
};
|
|
1626
|
+
var runIfAny = function(op, docs) {
|
|
1627
|
+
if (docs.length) {
|
|
1628
|
+
run(op, docs);
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
attach("initial:".concat(collectionName), function(payload) {
|
|
1632
|
+
var docs = toDocs(payload).filter(function(doc2) {
|
|
1633
|
+
return checkConditions(doc2, conditions);
|
|
1634
|
+
});
|
|
1635
|
+
matchedIds.clear();
|
|
1636
|
+
docs.forEach(function(doc2) {
|
|
1637
|
+
return matchedIds.add(doc2.id);
|
|
1638
|
+
});
|
|
1639
|
+
run("onFirstTime", docs);
|
|
1640
|
+
});
|
|
1641
|
+
var handleUpsert = function(payload, defaultOp) {
|
|
1642
|
+
var added = [];
|
|
1643
|
+
var modified = [];
|
|
1644
|
+
var removed = [];
|
|
1645
|
+
toDocs(payload).forEach(function(doc2) {
|
|
1646
|
+
if (!(conditions === null || conditions === void 0 ? void 0 : conditions.length)) {
|
|
1647
|
+
(defaultOp === "onAdd" ? added : modified).push(doc2);
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
var wasMatching = matchedIds.has(doc2.id);
|
|
1651
|
+
if (checkConditions(doc2, conditions)) {
|
|
1652
|
+
matchedIds.add(doc2.id);
|
|
1653
|
+
(wasMatching ? modified : added).push(doc2);
|
|
1654
|
+
} else if (wasMatching) {
|
|
1655
|
+
matchedIds.delete(doc2.id);
|
|
1656
|
+
removed.push(doc2);
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
runIfAny("onAdd", added);
|
|
1660
|
+
runIfAny("onModify", modified);
|
|
1661
|
+
runIfAny("onRemove", removed);
|
|
1662
|
+
};
|
|
1663
|
+
attach("add:".concat(collectionName), function(payload) {
|
|
1664
|
+
return handleUpsert(payload, "onAdd");
|
|
1665
|
+
});
|
|
1666
|
+
attach("update:".concat(collectionName), function(payload) {
|
|
1667
|
+
return handleUpsert(payload, "onModify");
|
|
1668
|
+
});
|
|
1669
|
+
attach("delete:".concat(collectionName), function(payload) {
|
|
1670
|
+
var docs = toDocs(payload).filter(function(doc2) {
|
|
1671
|
+
return !(conditions === null || conditions === void 0 ? void 0 : conditions.length) || matchedIds.delete(doc2.id);
|
|
1672
|
+
});
|
|
1673
|
+
runIfAny("onRemove", docs);
|
|
1553
1674
|
});
|
|
1554
1675
|
});
|
|
1555
1676
|
var acknowledge = function(callback) {
|
|
@@ -1559,12 +1680,28 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1559
1680
|
console.error("Failed to subscribe to ".concat(config.join(", "), ": ").concat(callback.message));
|
|
1560
1681
|
}
|
|
1561
1682
|
};
|
|
1562
|
-
|
|
1563
|
-
|
|
1683
|
+
config.forEach(function(c) {
|
|
1684
|
+
return _this.registerConditions(c.collectionName, c.conditions);
|
|
1685
|
+
});
|
|
1686
|
+
var conditionsByCollection = config.reduce(function(acc, c) {
|
|
1687
|
+
var active = _this.activeConditions.get(c.collectionName);
|
|
1688
|
+
if (active === null || active === void 0 ? void 0 : active.conditions.length) {
|
|
1689
|
+
acc[c.collectionName] = active.conditions;
|
|
1690
|
+
}
|
|
1691
|
+
return acc;
|
|
1692
|
+
}, {});
|
|
1693
|
+
var subscribeOptions = Object.keys(conditionsByCollection).length ? _object_spread_props(_object_spread({}, options), {
|
|
1694
|
+
conditions: conditionsByCollection
|
|
1695
|
+
}) : options;
|
|
1696
|
+
if (subscribeOptions) {
|
|
1697
|
+
s.emit("subscribe_options", subscribeOptions);
|
|
1564
1698
|
}
|
|
1565
1699
|
s.emit("subscribe_collections", collectionsNames, acknowledge);
|
|
1566
1700
|
return function() {
|
|
1567
1701
|
console.log("Cleaning up subscriptions for: ".concat(collectionsNames.join(", ")));
|
|
1702
|
+
collectionsNames.forEach(function(name) {
|
|
1703
|
+
return _this.releaseConditions(name);
|
|
1704
|
+
});
|
|
1568
1705
|
s.emit("unsubscribe_collections", collectionsNames);
|
|
1569
1706
|
eventHandlers.forEach(function(eh) {
|
|
1570
1707
|
s.off(eh.eventName, eh.handler);
|
|
@@ -2162,7 +2299,7 @@ var TableProvider = function(props) {
|
|
|
2162
2299
|
rowStyles, rowStyles = _props_rowStyles === void 0 ? {} : _props_rowStyles, rowClassName = props.rowClassName, // cell style
|
|
2163
2300
|
cellClassName = props.cellClassName, _props_cellStyle = props.cellStyle, cellStyle = _props_cellStyle === void 0 ? {} : _props_cellStyle, _props_headerStyle = props.// header styles
|
|
2164
2301
|
headerStyle, headerStyle = _props_headerStyle === void 0 ? {} : _props_headerStyle, headerCellStyle = props.headerCellStyle, _props_searchInputStyle = props.searchInputStyle, searchInputStyle = _props_searchInputStyle === void 0 ? {} : _props_searchInputStyle, _props_searchInputClassName = props.// search
|
|
2165
|
-
searchInputClassName, searchInputClassName = _props_searchInputClassName === void 0 ? "" : _props_searchInputClassName, includeSearch = props.includeSearch, searchPlaceHolder = props.searchPlaceHolder, _props_autoFocus = props.autoFocus, autoFocus = _props_autoFocus === void 0 ? true : _props_autoFocus, // sort
|
|
2302
|
+
searchInputClassName, searchInputClassName = _props_searchInputClassName === void 0 ? "" : _props_searchInputClassName, includeSearch = props.includeSearch, defaultSearchQuery = props.defaultSearchQuery, searchPlaceHolder = props.searchPlaceHolder, _props_autoFocus = props.autoFocus, autoFocus = _props_autoFocus === void 0 ? true : _props_autoFocus, // sort
|
|
2166
2303
|
sortKeys = props.sortKeys, _props_sortLabel = props.sortLabel, sortLabel = _props_sortLabel === void 0 ? "Sort by" : _props_sortLabel, _props_filterableColumns = props.// filter
|
|
2167
2304
|
filterableColumns, filterableColumns = _props_filterableColumns === void 0 ? [] : _props_filterableColumns, _props_filterLabel = props.filterLabel, filterLabel = _props_filterLabel === void 0 ? "Filter by" : _props_filterLabel, // export to excel
|
|
2168
2305
|
exportToExcelKeys = props.exportToExcelKeys, dataToAddToExcelTable = props.dataToAddToExcelTable, _props_exportExcelTitle = props.exportExcelTitle, exportExcelTitle = _props_exportExcelTitle === void 0 ? "Export to excel" : _props_exportExcelTitle, excelFileName = props.excelFileName, // summary
|
|
@@ -2170,7 +2307,7 @@ var TableProvider = function(props) {
|
|
|
2170
2307
|
maxRows, maxRows = _props_maxRows === void 0 ? data.length : _props_maxRows, _props_noneSearchKeys = props.noneSearchKeys, noneSearchKeys = _props_noneSearchKeys === void 0 ? [] : _props_noneSearchKeys, showDisplayAllRowsButton = props.showDisplayAllRowsButton;
|
|
2171
2308
|
var _useSort = useSort(), sortColumn = _useSort.sortColumn, sortOrder = _useSort.sortOrder, handleSort = _useSort.handleSort, clearSort = _useSort.clearSort;
|
|
2172
2309
|
var _useDisplayToggle = useDisplayToggle(), displayAllRows = _useDisplayToggle.displayAllRows, setDisplayAllRows = _useDisplayToggle.setDisplayAllRows;
|
|
2173
|
-
var _useSearch = useSearch(), searchQuery = _useSearch.searchQuery, handleSearch = _useSearch.handleSearch, debouncedSearchQuery = _useSearch.debouncedSearchQuery;
|
|
2310
|
+
var _useSearch = useSearch(300, defaultSearchQuery), searchQuery = _useSearch.searchQuery, handleSearch = _useSearch.handleSearch, debouncedSearchQuery = _useSearch.debouncedSearchQuery;
|
|
2174
2311
|
var _useFilter = useFilter({
|
|
2175
2312
|
data: data,
|
|
2176
2313
|
filterableColumns: filterableColumns
|
|
@@ -2418,9 +2555,9 @@ var useDisplayToggle = function() {
|
|
|
2418
2555
|
};
|
|
2419
2556
|
};
|
|
2420
2557
|
var useSearch = function() {
|
|
2421
|
-
var debounceDelay = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 300;
|
|
2422
|
-
var _ref = _sliced_to_array((0, import_react6.useState)(
|
|
2423
|
-
var _ref1 = _sliced_to_array((0, import_react6.useState)(
|
|
2558
|
+
var debounceDelay = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 300, initialQuery = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
2559
|
+
var _ref = _sliced_to_array((0, import_react6.useState)(initialQuery), 2), searchQuery = _ref[0], setSearchQuery = _ref[1];
|
|
2560
|
+
var _ref1 = _sliced_to_array((0, import_react6.useState)(initialQuery), 2), debouncedSearchQuery = _ref1[0], setDebouncedSearchQuery = _ref1[1];
|
|
2424
2561
|
var debouncedUpdate = (0, import_react6.useMemo)(function() {
|
|
2425
2562
|
return (0, import_lodash3.debounce)(function(query2) {
|
|
2426
2563
|
setDebouncedSearchQuery(query2);
|
|
@@ -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);
|
|
@@ -1893,7 +2030,7 @@ var TableProvider = function(props) {
|
|
|
1893
2030
|
rowStyles, rowStyles = _props_rowStyles === void 0 ? {} : _props_rowStyles, rowClassName = props.rowClassName, // cell style
|
|
1894
2031
|
cellClassName = props.cellClassName, _props_cellStyle = props.cellStyle, cellStyle = _props_cellStyle === void 0 ? {} : _props_cellStyle, _props_headerStyle = props.// header styles
|
|
1895
2032
|
headerStyle, headerStyle = _props_headerStyle === void 0 ? {} : _props_headerStyle, headerCellStyle = props.headerCellStyle, _props_searchInputStyle = props.searchInputStyle, searchInputStyle = _props_searchInputStyle === void 0 ? {} : _props_searchInputStyle, _props_searchInputClassName = props.// search
|
|
1896
|
-
searchInputClassName, searchInputClassName = _props_searchInputClassName === void 0 ? "" : _props_searchInputClassName, includeSearch = props.includeSearch, searchPlaceHolder = props.searchPlaceHolder, _props_autoFocus = props.autoFocus, autoFocus = _props_autoFocus === void 0 ? true : _props_autoFocus, // sort
|
|
2033
|
+
searchInputClassName, searchInputClassName = _props_searchInputClassName === void 0 ? "" : _props_searchInputClassName, includeSearch = props.includeSearch, defaultSearchQuery = props.defaultSearchQuery, searchPlaceHolder = props.searchPlaceHolder, _props_autoFocus = props.autoFocus, autoFocus = _props_autoFocus === void 0 ? true : _props_autoFocus, // sort
|
|
1897
2034
|
sortKeys = props.sortKeys, _props_sortLabel = props.sortLabel, sortLabel = _props_sortLabel === void 0 ? "Sort by" : _props_sortLabel, _props_filterableColumns = props.// filter
|
|
1898
2035
|
filterableColumns, filterableColumns = _props_filterableColumns === void 0 ? [] : _props_filterableColumns, _props_filterLabel = props.filterLabel, filterLabel = _props_filterLabel === void 0 ? "Filter by" : _props_filterLabel, // export to excel
|
|
1899
2036
|
exportToExcelKeys = props.exportToExcelKeys, dataToAddToExcelTable = props.dataToAddToExcelTable, _props_exportExcelTitle = props.exportExcelTitle, exportExcelTitle = _props_exportExcelTitle === void 0 ? "Export to excel" : _props_exportExcelTitle, excelFileName = props.excelFileName, // summary
|
|
@@ -1901,7 +2038,7 @@ var TableProvider = function(props) {
|
|
|
1901
2038
|
maxRows, maxRows = _props_maxRows === void 0 ? data.length : _props_maxRows, _props_noneSearchKeys = props.noneSearchKeys, noneSearchKeys = _props_noneSearchKeys === void 0 ? [] : _props_noneSearchKeys, showDisplayAllRowsButton = props.showDisplayAllRowsButton;
|
|
1902
2039
|
var _useSort = useSort(), sortColumn = _useSort.sortColumn, sortOrder = _useSort.sortOrder, handleSort = _useSort.handleSort, clearSort = _useSort.clearSort;
|
|
1903
2040
|
var _useDisplayToggle = useDisplayToggle(), displayAllRows = _useDisplayToggle.displayAllRows, setDisplayAllRows = _useDisplayToggle.setDisplayAllRows;
|
|
1904
|
-
var _useSearch = useSearch(), searchQuery = _useSearch.searchQuery, handleSearch = _useSearch.handleSearch, debouncedSearchQuery = _useSearch.debouncedSearchQuery;
|
|
2041
|
+
var _useSearch = useSearch(300, defaultSearchQuery), searchQuery = _useSearch.searchQuery, handleSearch = _useSearch.handleSearch, debouncedSearchQuery = _useSearch.debouncedSearchQuery;
|
|
1905
2042
|
var _useFilter = useFilter({
|
|
1906
2043
|
data: data,
|
|
1907
2044
|
filterableColumns: filterableColumns
|
|
@@ -2149,9 +2286,9 @@ var useDisplayToggle = function() {
|
|
|
2149
2286
|
};
|
|
2150
2287
|
};
|
|
2151
2288
|
var useSearch = function() {
|
|
2152
|
-
var debounceDelay = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 300;
|
|
2153
|
-
var _useState3 = _sliced_to_array(useState3(
|
|
2154
|
-
var _useState31 = _sliced_to_array(useState3(
|
|
2289
|
+
var debounceDelay = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 300, initialQuery = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
2290
|
+
var _useState3 = _sliced_to_array(useState3(initialQuery), 2), searchQuery = _useState3[0], setSearchQuery = _useState3[1];
|
|
2291
|
+
var _useState31 = _sliced_to_array(useState3(initialQuery), 2), debouncedSearchQuery = _useState31[0], setDebouncedSearchQuery = _useState31[1];
|
|
2155
2292
|
var debouncedUpdate = useMemo2(function() {
|
|
2156
2293
|
return debounce(function(query2) {
|
|
2157
2294
|
setDebouncedSearchQuery(query2);
|