From 894a3002dcaf273f19103c31cf1656e84431c00e Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Wed, 10 Jul 2024 13:23:33 +0200 Subject: [PATCH] RavenDB-22581 npm update --- src/Raven.Studio/package-lock.json | 9 ++- src/Raven.Studio/package.json | 3 +- .../cmpXchg/saveCompareExchangeItemCommand.ts | 2 +- .../dbGroup/startReshardingCommand.ts | 2 +- .../debug/recordTransactionsCommand.ts | 2 +- .../saveConflictSolverConfigurationCommand.ts | 2 +- .../database/tasks/delayBackupCommand.ts | 2 +- .../getPeriodicBackupConfigurationCommand.ts | 2 +- .../tasks/saveSubscriptionTaskCommand.ts | 2 +- .../resources/getDatabaseRecordCommand.ts | 2 +- .../resources/saveDatabaseLockModeCommand.ts | 2 +- .../wizard/getSetupLocalNodeIpsCommand.ts | 4 +- src/Raven.Studio/typescript/common/appUrl.ts | 10 ++-- .../bindingHelpers/aceEditorBindingHandler.ts | 2 +- .../typescript/common/changeVectorUtils.ts | 10 ++-- .../typescript/common/colorsManager.ts | 4 +- .../typescript/common/downloader.ts | 2 +- .../typescript/common/generalUtils.ts | 9 +-- .../helpers/database/collectionsTracker.ts | 7 +-- .../database/documentPropertyProvider.ts | 2 +- .../common/helpers/graph/graphHelper.ts | 3 +- .../common/helpers/graph/rangeAggregator.ts | 2 +- .../common/helpers/view/viewHelpers.ts | 6 +- .../notifications/models/virtualBulkInsert.ts | 3 +- .../notifications/notificationCenter.ts | 3 +- .../protractedCommandsDetector.ts | 4 +- .../typescript/common/rqlLanguageService.ts | 1 - .../common/settings/abstractSettings.ts | 11 ++-- .../common/settings/studioSetting.ts | 4 +- .../common/settings/studioSettings.ts | 2 +- .../typescript/common/shell/accessManager.ts | 6 +- .../common/shell/clusterTopologyManager.ts | 2 +- .../common/storage/mergedIndexesStorage.ts | 2 +- .../common/storage/starredDocumentsStorage.ts | 2 +- .../typescript/common/timingsChart.ts | 5 +- .../typescript/common/typeUtils.ts | 55 +++++++++++++++++++ .../typescript/components/common/Form.tsx | 4 +- .../database/indexes/list/useIndexesPage.tsx | 6 +- .../unusedDatabaseIds/useUnusedDatabaseIds.ts | 3 +- .../tasks/ongoingTasks/OngoingTasksPage.tsx | 6 +- .../typescript/components/utils/common.ts | 5 +- .../components/utils/licenseLimitsUtils.tsx | 2 +- .../models/auth/certificateModel.ts | 9 +-- .../database/cluster/clusterTopology.ts | 10 ++-- .../database/dbGroup/databaseGroupGraph.ts | 7 ++- .../models/database/documents/document.ts | 2 +- .../database/documents/documentMetadata.ts | 4 +- .../documents/timeSeriesConfigurationEntry.ts | 2 +- .../models/database/index/indexDefinition.ts | 16 ++---- .../database/index/indexErrorInfoModel.ts | 2 +- .../database/index/indexFieldOptions.ts | 2 +- .../models/database/index/testIndex.ts | 2 +- .../connectionStringElasticSearchEtlModel.ts | 2 +- .../settings/connectionStringKafkaModel.ts | 9 ++- .../settings/connectionStringRavenEtlModel.ts | 2 +- .../stats/etlScriptDefinitionCache.ts | 2 +- .../models/database/status/ioStatsGraph.ts | 3 +- .../database/tasks/sql/abstractSqlTable.ts | 4 +- .../models/database/tasks/sql/sqlMigration.ts | 11 ++-- .../timeSeries/timeSeriesEntryModel.ts | 5 +- .../timeSeries/timeSeriesQueryResult.ts | 4 +- .../resources/clusterDashboard/lineChart.ts | 3 +- .../models/resources/nonShardedDatabase.ts | 3 +- .../typescript/models/resources/shard.ts | 2 +- .../models/resources/shardedDatabase.ts | 2 +- .../models/wizard/certificateInfo.ts | 2 +- .../typescript/models/wizard/serverSetup.ts | 2 +- .../alerts/conflictExceededDetails.ts | 2 +- .../operations/compactDatabaseDetails.ts | 2 +- .../enforceRevisionsConfigurationDetails.ts | 2 +- .../operations/revertRevisionsDetails.ts | 2 +- .../operations/smugglerDatabaseDetails.ts | 2 +- .../operations/sqlMigrationDetails.ts | 4 +- .../performanceHint/hugeDocumentsDetails.ts | 4 +- .../performanceHint/indexingDetails.ts | 4 +- .../performanceHint/pagingDetails.ts | 4 +- .../performanceHint/requestLatencyDetails.ts | 4 +- .../performanceHint/slowIoDetails.ts | 2 +- .../viewmodels/common/showDataDialog.ts | 2 +- .../common/timeSeriesPlotDetails.ts | 17 +++--- .../viewmodels/database/cmpXchg/cmpXchg.ts | 2 +- .../database/cmpXchg/editCmpXchg.ts | 2 +- .../database/conflicts/conflicts.ts | 2 +- .../database/documents/documents.ts | 2 +- .../database/documents/revisionsBin.ts | 2 +- .../database/identities/identities.ts | 5 +- .../database/indexes/deleteIndexesConfirm.ts | 2 +- .../viewmodels/database/indexes/editIndex.ts | 6 +- .../database/indexes/indexErrors.ts | 9 +-- .../database/indexes/indexPerformance.ts | 5 +- .../database/indexes/visualizer/visualizer.ts | 5 +- .../visualizer/visualizerGraphDetails.ts | 2 +- .../visualizer/visualizerTreeExplorer.ts | 2 +- .../viewmodels/database/patch/patch.ts | 2 +- .../database/patch/patchDebugActions.ts | 2 +- .../viewmodels/database/query/query.ts | 14 ++--- .../database/settings/databaseSettings.ts | 5 +- .../database/settings/timeSeries.ts | 6 +- .../database/status/ongoingTasksStats.ts | 35 ++++++------ .../tasks/editElasticSearchEtlTask.ts | 5 +- .../tasks/editExternalReplicationTask.ts | 3 +- .../database/tasks/editKafkaEtlTask.ts | 5 +- .../database/tasks/editKafkaSinkTask.ts | 3 +- .../database/tasks/editOlapEtlTask.ts | 5 +- .../database/tasks/editRabbitMqEtlTask.ts | 5 +- .../database/tasks/editRabbitMqSinkTask.ts | 3 +- .../database/tasks/editRavenEtlTask.ts | 7 ++- .../database/tasks/editReplicationSinkTask.ts | 3 +- .../database/tasks/editSqlEtlTask.ts | 7 ++- .../database/tasks/editSubscriptionTask.ts | 6 +- .../database/timeSeries/editTimeSeries.ts | 9 +-- .../timeSeries/editTimeSeriesEntry.ts | 3 +- .../typescript/viewmodels/manage/adminLogs.ts | 2 +- .../viewmodels/manage/captureStackTraces.ts | 7 ++- .../viewmodels/manage/certificates.ts | 12 ++-- .../typescript/viewmodels/manage/cluster.ts | 7 ++- .../manage/debugAdvancedMemoryMappedFiles.ts | 7 ++- .../manage/debugAdvancedObserverLog.ts | 2 +- .../viewmodels/manage/runningQueries.ts | 2 +- .../viewmodels/manage/serverSettings.ts | 3 +- .../viewmodels/manage/serverWideTasks.ts | 6 +- .../viewmodels/partial/columnsSelector.ts | 13 +++-- .../resources/addNewNodeToDatabaseGroup.ts | 2 +- .../addNewOrchestatorToDatabaseGroup.ts | 2 +- .../typescript/viewmodels/shell.ts | 2 +- .../typescript/viewmodels/wizard/welcome.ts | 4 +- .../typescript/widgets/listView/listView.ts | 3 +- .../widgets/listView/virtualListRow.ts | 2 +- .../virtualGrid/columnPreviewPlugin.ts | 2 +- .../virtualGrid/columns/actionColumn.ts | 2 +- .../columns/iconsPlusTextColumn.ts | 2 +- .../providers/documentBasedColumnsProvider.ts | 20 +++---- .../widgets/virtualGrid/columns/textColumn.ts | 15 ++--- .../widgets/virtualGrid/virtualGrid.ts | 2 +- .../database/tasks/referenceUsageDialog.html | 2 +- 135 files changed, 384 insertions(+), 291 deletions(-) create mode 100644 src/Raven.Studio/typescript/common/typeUtils.ts diff --git a/src/Raven.Studio/package-lock.json b/src/Raven.Studio/package-lock.json index 9373d97cfbc..2def4ef3a2b 100644 --- a/src/Raven.Studio/package-lock.json +++ b/src/Raven.Studio/package-lock.json @@ -97,7 +97,6 @@ "@types/knockout.validation": "^0.0.42", "@types/leaflet": "^1.7.11", "@types/leaflet.markercluster": "^1.5.1", - "@types/lodash": "^4.14.182", "@types/node-forge": "^1.3.11", "@types/prismjs": "^1.26.0", "@types/rbush": "^2.0.1", @@ -144,7 +143,7 @@ "terser-webpack-plugin": "^5.3.3", "ts-jest": "^29.1.5", "ts-loader": "^9.5.1", - "typescript": "^5.4.5", + "typescript": "^5.5.3", "webfonts-loader": "^8.0.0", "webpack": "^5.92.1", "webpack-bundle-analyzer": "^4.10.2", @@ -25159,9 +25158,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/src/Raven.Studio/package.json b/src/Raven.Studio/package.json index 07fc950962a..41b5a0fabd4 100644 --- a/src/Raven.Studio/package.json +++ b/src/Raven.Studio/package.json @@ -49,7 +49,6 @@ "@types/knockout.validation": "^0.0.42", "@types/leaflet": "^1.7.11", "@types/leaflet.markercluster": "^1.5.1", - "@types/lodash": "^4.14.182", "@types/node-forge": "^1.3.11", "@types/prismjs": "^1.26.0", "@types/rbush": "^2.0.1", @@ -96,7 +95,7 @@ "terser-webpack-plugin": "^5.3.3", "ts-jest": "^29.1.5", "ts-loader": "^9.5.1", - "typescript": "^5.4.5", + "typescript": "^5.5.3", "webfonts-loader": "^8.0.0", "webpack": "^5.92.1", "webpack-bundle-analyzer": "^4.10.2", diff --git a/src/Raven.Studio/typescript/commands/database/cmpXchg/saveCompareExchangeItemCommand.ts b/src/Raven.Studio/typescript/commands/database/cmpXchg/saveCompareExchangeItemCommand.ts index 9cdecc4b7cf..e7c950b273b 100644 --- a/src/Raven.Studio/typescript/commands/database/cmpXchg/saveCompareExchangeItemCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/cmpXchg/saveCompareExchangeItemCommand.ts @@ -19,7 +19,7 @@ class saveCompareExchangeItemCommand extends commandBase { Object: this.valueData }; - if (!_.isUndefined(this.metadata)) { + if (this.metadata !== undefined) { payload["@metadata"] = this.metadata; } diff --git a/src/Raven.Studio/typescript/commands/database/dbGroup/startReshardingCommand.ts b/src/Raven.Studio/typescript/commands/database/dbGroup/startReshardingCommand.ts index f1ef30803eb..d168818b498 100644 --- a/src/Raven.Studio/typescript/commands/database/dbGroup/startReshardingCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/dbGroup/startReshardingCommand.ts @@ -14,7 +14,7 @@ class startReshardingCommand extends commandBase { constructor(db: database | string, range: Range, targetShard: number) { super(); - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = typeof db === "string" ? db : db.name; this.range = range; this.targetShard = targetShard; } diff --git a/src/Raven.Studio/typescript/commands/database/debug/recordTransactionsCommand.ts b/src/Raven.Studio/typescript/commands/database/debug/recordTransactionsCommand.ts index 67f1600df18..72e37aaa65e 100644 --- a/src/Raven.Studio/typescript/commands/database/debug/recordTransactionsCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/debug/recordTransactionsCommand.ts @@ -15,7 +15,7 @@ class recordTransactionsCommand extends commandBase { }; return this.post(url, JSON.stringify(payload), this.db, { dataType: undefined }) - .done(() => this.reportSuccess("Transaction Commands Recoding was started for database: " + (_.isString(this.db) ? this.db : this.db.name))) + .done(() => this.reportSuccess("Transaction Commands Recoding was started for database: " + (typeof this.db === "string" ? this.db : this.db.name))) .fail((response: JQueryXHR) => this.reportError("Failed to start recording transaction commands", response.responseText, response.statusText)); } diff --git a/src/Raven.Studio/typescript/commands/database/documents/saveConflictSolverConfigurationCommand.ts b/src/Raven.Studio/typescript/commands/database/documents/saveConflictSolverConfigurationCommand.ts index 5de1c65e56e..cc2efd8ef0f 100644 --- a/src/Raven.Studio/typescript/commands/database/documents/saveConflictSolverConfigurationCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/documents/saveConflictSolverConfigurationCommand.ts @@ -8,7 +8,7 @@ class saveConflictSolverConfigurationCommand extends commandBase { constructor(db: database | string, configuration: Raven.Client.ServerWide.ConflictSolver) { super(); - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = typeof db === "string" ? db : db.name; this.configuration = configuration; } diff --git a/src/Raven.Studio/typescript/commands/database/tasks/delayBackupCommand.ts b/src/Raven.Studio/typescript/commands/database/tasks/delayBackupCommand.ts index 5b4505be3be..843b7fff482 100644 --- a/src/Raven.Studio/typescript/commands/database/tasks/delayBackupCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/tasks/delayBackupCommand.ts @@ -13,7 +13,7 @@ class delayBackupCommand extends commandBase { super(); this.duration = duration; this.taskId = taskId; - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = (typeof db === "string" ? db : db.name); } execute(): JQueryPromise { diff --git a/src/Raven.Studio/typescript/commands/database/tasks/getPeriodicBackupConfigurationCommand.ts b/src/Raven.Studio/typescript/commands/database/tasks/getPeriodicBackupConfigurationCommand.ts index c4ea24cd25c..2ad2bc4c856 100644 --- a/src/Raven.Studio/typescript/commands/database/tasks/getPeriodicBackupConfigurationCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/tasks/getPeriodicBackupConfigurationCommand.ts @@ -8,7 +8,7 @@ class getPeriodicBackupConfigurationCommand extends commandBase { constructor( db: database | string, taskId: number) { super(); - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = (typeof db === "string" ? db : db.name); this.taskId = taskId; } diff --git a/src/Raven.Studio/typescript/commands/database/tasks/saveSubscriptionTaskCommand.ts b/src/Raven.Studio/typescript/commands/database/tasks/saveSubscriptionTaskCommand.ts index a23d4e2199f..ec42bf4d66f 100644 --- a/src/Raven.Studio/typescript/commands/database/tasks/saveSubscriptionTaskCommand.ts +++ b/src/Raven.Studio/typescript/commands/database/tasks/saveSubscriptionTaskCommand.ts @@ -9,7 +9,7 @@ class saveSubscriptionTaskCommand extends commandBase { constructor( db: database | string, payload: Raven.Client.Documents.Subscriptions.SubscriptionCreationOptions, taskId?: number) { super(); - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = (typeof db === "string" ? db : db.name); this.taskId = taskId; this.payload = payload; } diff --git a/src/Raven.Studio/typescript/commands/resources/getDatabaseRecordCommand.ts b/src/Raven.Studio/typescript/commands/resources/getDatabaseRecordCommand.ts index dd1c3acb0a6..0c506f470b5 100644 --- a/src/Raven.Studio/typescript/commands/resources/getDatabaseRecordCommand.ts +++ b/src/Raven.Studio/typescript/commands/resources/getDatabaseRecordCommand.ts @@ -10,7 +10,7 @@ class getDatabaseRecordCommand extends commandBase { constructor(db: database | string, reportRefreshProgress = false) { super(); - this.databaseName = (_.isString(db) ? db : db.name); + this.databaseName = (typeof db === "string" ? db : db.name); this.reportRefreshProgress = reportRefreshProgress; } diff --git a/src/Raven.Studio/typescript/commands/resources/saveDatabaseLockModeCommand.ts b/src/Raven.Studio/typescript/commands/resources/saveDatabaseLockModeCommand.ts index b1d2e598851..5180f9921c4 100644 --- a/src/Raven.Studio/typescript/commands/resources/saveDatabaseLockModeCommand.ts +++ b/src/Raven.Studio/typescript/commands/resources/saveDatabaseLockModeCommand.ts @@ -16,7 +16,7 @@ class saveDatabaseLockModeCommand extends commandBase { execute(): JQueryPromise { const payload: Raven.Client.ServerWide.Operations.SetDatabasesLockOperation.Parameters = { - DatabaseNames: this.dbs.map(x => (_.isString(x) ? x : x.name)), + DatabaseNames: this.dbs.map(x => (typeof x === "string" ? x : x.name)), Mode: this.lockMode }; diff --git a/src/Raven.Studio/typescript/commands/wizard/getSetupLocalNodeIpsCommand.ts b/src/Raven.Studio/typescript/commands/wizard/getSetupLocalNodeIpsCommand.ts index 5401a7ac02d..d8ec4fa9113 100644 --- a/src/Raven.Studio/typescript/commands/wizard/getSetupLocalNodeIpsCommand.ts +++ b/src/Raven.Studio/typescript/commands/wizard/getSetupLocalNodeIpsCommand.ts @@ -3,10 +3,10 @@ import endpoints = require("endpoints"); class getSetupLocalNodeIpsCommand extends commandBase { - execute(): JQueryPromise> { + execute(): JQueryPromise { const url = endpoints.global.setup.setupIps; - return this.query>(url, null, null, x => _.flatMap(x.NetworkInterfaces.map((i: any) => i.Addresses))) + return this.query(url, null, null, x => x.NetworkInterfaces.flatMap((i: any) => i.Addresses)) .fail((response: JQueryXHR) => this.reportError("Failed to get the setup nodes ips", response.responseText, response.statusText)); } } diff --git a/src/Raven.Studio/typescript/common/appUrl.ts b/src/Raven.Studio/typescript/common/appUrl.ts index ecfd9a29102..02117b77f36 100644 --- a/src/Raven.Studio/typescript/common/appUrl.ts +++ b/src/Raven.Studio/typescript/common/appUrl.ts @@ -141,7 +141,7 @@ class appUrl { } static forDebugAdvancedRecordTransactionCommands(databaseToHighlight: string = undefined): string { - const dbPart = _.isUndefined(databaseToHighlight) ? "" : "?highlight=" + encodeURIComponent(databaseToHighlight); + const dbPart = databaseToHighlight === undefined ? "" : "?highlight=" + encodeURIComponent(databaseToHighlight); return "#admin/settings/debug/advanced/recordTransactionCommands" + dbPart; } @@ -154,7 +154,7 @@ class appUrl { } static forTrafficWatch(initialFilter: string = undefined): string { - const filter = _.isUndefined(initialFilter) ? "" : "?filter=" + encodeURIComponent(initialFilter); + const filter = initialFilter === undefined ? "" : "?filter=" + encodeURIComponent(initialFilter); return "#admin/settings/trafficWatch" + filter; } @@ -514,7 +514,7 @@ class appUrl { static forDatabaseQuery(db: database | string): string { if (db) { - return appUrl.baseUrl + "/databases/" + (_.isString(db) ? db : db.name); + return appUrl.baseUrl + "/databases/" + (typeof db === "string" ? db : db.name); } return this.baseUrl; @@ -666,7 +666,7 @@ class appUrl { } static forEssentialStatsRawData(db: database | string): string { - return window.location.protocol + "//" + window.location.host + "/databases/" + (_.isString(db) ? db : db.name) + "/stats/essential"; + return window.location.protocol + "//" + window.location.host + "/databases/" + (typeof db === "string" ? db : db.name) + "/stats/essential"; } static forIndexesRawData(db: database): string { @@ -747,7 +747,7 @@ class appUrl { return ""; } - return "&database=" + encodeURIComponent(_.isString(db) ? db : db.name); + return "&database=" + encodeURIComponent(typeof db === "string" ? db : db.name); } private static getEncodedIndexNamePart(indexName?: string) { diff --git a/src/Raven.Studio/typescript/common/bindingHelpers/aceEditorBindingHandler.ts b/src/Raven.Studio/typescript/common/bindingHelpers/aceEditorBindingHandler.ts index 86fa8968289..84d21c279c6 100644 --- a/src/Raven.Studio/typescript/common/bindingHelpers/aceEditorBindingHandler.ts +++ b/src/Raven.Studio/typescript/common/bindingHelpers/aceEditorBindingHandler.ts @@ -204,7 +204,7 @@ class aceEditorBindingHandler { if ('rules' in code && ko.isObservable(code.rules)) { const rules = ko.unwrap(code.rules); - if (_.some(rules, x => x.rule === "aceValidation")) { + if (rules.some(x => x.rule === "aceValidation")) { const firstError = annotations.find(x => x.type === "error"); if (firstError) { diff --git a/src/Raven.Studio/typescript/common/changeVectorUtils.ts b/src/Raven.Studio/typescript/common/changeVectorUtils.ts index 8ff464920cc..6f31a8508c1 100644 --- a/src/Raven.Studio/typescript/common/changeVectorUtils.ts +++ b/src/Raven.Studio/typescript/common/changeVectorUtils.ts @@ -1,13 +1,15 @@ /// +import { sortBy } from "common/typeUtils"; + class changeVectorUtils { static shouldUseLongFormat(changeVectors: string[]) { - const parsedVectors = _.flatMap(changeVectors, x => changeVectorUtils.parse(x)); + const parsedVectors = changeVectors.flatMap(x => changeVectorUtils.parse(x)); - const byTag = _.groupBy(parsedVectors, x => x.tag); + const byTag = _.groupBy(parsedVectors, (x: { tag: string}) => x.tag); - return _.some(byTag, forTag => forTag.map(x => x.dbId).length > 1); + return byTag.some((forTag: any) => forTag.map((x: typeof parsedVectors[0]) => x.dbId).length > 1); } private static parse(input: string) { @@ -18,7 +20,7 @@ class changeVectorUtils { let tokens = input.split(",") .map(cvEntry => changeVectorUtils.parseChangeVectorEntry(cvEntry)); - tokens = _.sortBy(tokens, x => x.tag); + tokens = sortBy(tokens, x => x.tag); return tokens; } diff --git a/src/Raven.Studio/typescript/common/colorsManager.ts b/src/Raven.Studio/typescript/common/colorsManager.ts index a94fe2afabe..763b16dfb5b 100644 --- a/src/Raven.Studio/typescript/common/colorsManager.ts +++ b/src/Raven.Studio/typescript/common/colorsManager.ts @@ -25,8 +25,8 @@ class colorsManager { const sourceKeys = Object.keys(source); const targetKeys = Object.keys(target); - const onlyInTarget = _.without(targetKeys, ...sourceKeys); - const onlyInSource = _.without(sourceKeys, ...targetKeys); + const onlyInTarget = targetKeys.filter(x => !sourceKeys.includes(x)); + const onlyInSource = sourceKeys.filter(x => !targetKeys.includes(x)); if (onlyInSource.length) { console.warn("Found missing color definitions (in TS file): " + onlyInSource.join(", ") + ", at path: /" + path.join("/")); diff --git a/src/Raven.Studio/typescript/common/downloader.ts b/src/Raven.Studio/typescript/common/downloader.ts index 9c15aaeaac8..afeeb114690 100644 --- a/src/Raven.Studio/typescript/common/downloader.ts +++ b/src/Raven.Studio/typescript/common/downloader.ts @@ -31,7 +31,7 @@ class downloader { Object.keys(object).forEach(key => { const value = object[key]; - if (_.isArray(value)) { + if (Array.isArray(value)) { value.forEach(v => addField(key, v)); } else { addField(key, value); diff --git a/src/Raven.Studio/typescript/common/generalUtils.ts b/src/Raven.Studio/typescript/common/generalUtils.ts index c35d1164aa7..b0d001158c0 100644 --- a/src/Raven.Studio/typescript/common/generalUtils.ts +++ b/src/Raven.Studio/typescript/common/generalUtils.ts @@ -2,6 +2,7 @@ import pluralizeHelpers = require("common/helpers/text/pluralizeHelpers"); import moment = require("moment"); import { MouseEvent } from "react"; +import { isBoolean } from "common/typeUtils"; type SelectionState = "AllSelected" | "SomeSelected" | "Empty"; @@ -493,9 +494,9 @@ class genUtils { if (stripNullAndEmptyValues) { return JSON.stringify(obj, (key, val) => { - const isNull = _.isNull(val); - const isEmptyObj = _.isEqual(val, {}); - const isEmptyArray = _.isEqual(val, []); + const isNull = val === null; + const isEmptyObj = val instanceof Object && Object.keys(val).length === 0; + const isEmptyArray = Array.isArray(val) && val.length === 0; return isNull || isEmptyObj || isEmptyArray ? undefined : val; @@ -563,7 +564,7 @@ class genUtils { internalCallback: (result: { isValid: boolean, message: string } | boolean) => void) => { func(val, params, (currentValue, result) => { if (currentValue === val) { - if (_.isBoolean(result)) { + if (isBoolean(result)) { internalCallback(result); } else if (result) { internalCallback({ isValid: false, message: result}); diff --git a/src/Raven.Studio/typescript/common/helpers/database/collectionsTracker.ts b/src/Raven.Studio/typescript/common/helpers/database/collectionsTracker.ts index af48590bf1b..ed920563a3d 100644 --- a/src/Raven.Studio/typescript/common/helpers/database/collectionsTracker.ts +++ b/src/Raven.Studio/typescript/common/helpers/database/collectionsTracker.ts @@ -47,9 +47,8 @@ class collectionsTracker { } private collectionsLoaded(collectionsStats: collectionsStats) { - const collections = collectionsStats.collections; - - _.remove(collections, c => !c.documentCount()); + const collections = collectionsStats.collections.filter(x => !x.documentCount()); + collections.sort((a, b) => this.sortAlphaNumericCollection(a.name, b.name)); const allDocsCollection = collection.createAllDocumentsCollection(collectionsStats.numberOfDocuments()); @@ -69,7 +68,7 @@ class collectionsTracker { } getCollectionColorIndex(collectionName: string) { - return (_.findIndex(collectionsTracker.default.collections(), x => x.name === collectionName) + 5) % 6; + return (collectionsTracker.default.collections().findIndex( x => x.name === collectionName) + 5) % 6; // 6 is the number of classes that I have defined in etl.less for colors... } diff --git a/src/Raven.Studio/typescript/common/helpers/database/documentPropertyProvider.ts b/src/Raven.Studio/typescript/common/helpers/database/documentPropertyProvider.ts index 921abee5579..0f75a177d56 100644 --- a/src/Raven.Studio/typescript/common/helpers/database/documentPropertyProvider.ts +++ b/src/Raven.Studio/typescript/common/helpers/database/documentPropertyProvider.ts @@ -35,7 +35,7 @@ class documentPropertyProvider { private needsToFetchValue(doc: document, column: textColumn): boolean { const valueAccessor = column.valueAccessor; - if (_.isFunction(valueAccessor)) { + if (typeof valueAccessor === "function") { if (column instanceof customColumn) { return !column.tryGuessRequiredProperties().every(p => this.hasEntireValue(doc, p)); } else { diff --git a/src/Raven.Studio/typescript/common/helpers/graph/graphHelper.ts b/src/Raven.Studio/typescript/common/helpers/graph/graphHelper.ts index 2615c43ecf9..e8453ce80a9 100644 --- a/src/Raven.Studio/typescript/common/helpers/graph/graphHelper.ts +++ b/src/Raven.Studio/typescript/common/helpers/graph/graphHelper.ts @@ -1,6 +1,7 @@ /// import colorsManager = require("common/colorsManager"); +import { sortBy } from "common/typeUtils"; class graphHelper { @@ -224,7 +225,7 @@ class graphHelper { const mapping = new Map(); - _.sortBy(items.map((item, idx) => ({ idx: idx, value: item.x })), x => x.value).forEach((v, k) => { + sortBy(items.map((item, idx) => ({ idx: idx, value: item.x })), x => x.value).forEach((v, k) => { mapping.set(k, v.idx); }); diff --git a/src/Raven.Studio/typescript/common/helpers/graph/rangeAggregator.ts b/src/Raven.Studio/typescript/common/helpers/graph/rangeAggregator.ts index 21d0edc76d8..654452696df 100644 --- a/src/Raven.Studio/typescript/common/helpers/graph/rangeAggregator.ts +++ b/src/Raven.Studio/typescript/common/helpers/graph/rangeAggregator.ts @@ -48,7 +48,7 @@ class rangeAggregator { // 1. Find appropriate start position for the new element - this.ptrStart = _.sortedIndexBy(this.workData, { pointInTime: startTime } as workData, x => x.pointInTime); + this.ptrStart = _.sortedIndexBy(this.workData, { pointInTime: startTime } as workData, (x: workData) => x.pointInTime); let previousValue = (this.ptrStart === 0) ? this.workData[0].numberOfItems : this.workData[this.ptrStart - 1].numberOfItems; diff --git a/src/Raven.Studio/typescript/common/helpers/view/viewHelpers.ts b/src/Raven.Studio/typescript/common/helpers/view/viewHelpers.ts index 86f0342b2f0..b2771ee99f7 100644 --- a/src/Raven.Studio/typescript/common/helpers/view/viewHelpers.ts +++ b/src/Raven.Studio/typescript/common/helpers/view/viewHelpers.ts @@ -59,7 +59,7 @@ class viewHelpers { const deferred = $.Deferred(); const validationGroup = (context as any)(); - const keys = _.keys(validationGroup); + const keys = Object.keys(validationGroup); const asyncValidations: Array> = []; @@ -69,7 +69,7 @@ class viewHelpers { } }); - if (asyncValidations.length === 0 || _.every(asyncValidations, x => !x())) { + if (asyncValidations.length === 0 || asyncValidations.every(x => !x())) { cb(); deferred.resolve(); return deferred.promise(); @@ -80,7 +80,7 @@ class viewHelpers { let subscriptions: KnockoutSubscription[] = []; const onUpdate = () => { - if (_.every(asyncValidations, x => !x())) { + if (asyncValidations.every(x => !x())) { // all validators completed its work, clean up and call callback subscriptions.forEach(x => x.dispose()); cb(); diff --git a/src/Raven.Studio/typescript/common/notifications/models/virtualBulkInsert.ts b/src/Raven.Studio/typescript/common/notifications/models/virtualBulkInsert.ts index b00cd241d50..77d223c2b6a 100644 --- a/src/Raven.Studio/typescript/common/notifications/models/virtualBulkInsert.ts +++ b/src/Raven.Studio/typescript/common/notifications/models/virtualBulkInsert.ts @@ -3,6 +3,7 @@ import database = require("models/resources/database"); import pluralizeHelpers = require("common/helpers/text/pluralizeHelpers"); import moment = require("moment"); import groupedVirtualNotification from "common/notifications/models/groupedVirtualNotification"; +import { sumBy } from "common/typeUtils"; class virtualBulkInsert extends groupedVirtualNotification { @@ -51,7 +52,7 @@ class virtualBulkInsert extends groupedVirtualNotification x.totalItemsProcessed); + const totalItemsCount = sumBy(this.operations(), x => x.totalItemsProcessed); this.message(pluralizeHelpers.pluralize(this.operations().length, "bulk insert", "bulk inserts") + " to database " + this.database.name + " completed successfully. " diff --git a/src/Raven.Studio/typescript/common/notifications/notificationCenter.ts b/src/Raven.Studio/typescript/common/notifications/notificationCenter.ts index 3fcacdf32d3..161a8a09935 100644 --- a/src/Raven.Studio/typescript/common/notifications/notificationCenter.ts +++ b/src/Raven.Studio/typescript/common/notifications/notificationCenter.ts @@ -69,6 +69,7 @@ import complexFieldsAlertDetails import cpuCreditsBalanceDetails from "viewmodels/common/notificationCenter/detailViewer/alerts/cpuCreditsBalanceDetails"; import groupedVirtualNotification from "common/notifications/models/groupedVirtualNotification"; +import { sortBy } from "common/typeUtils"; interface detailsProvider { supportsDetailsFor(notification: abstractNotification): boolean; showDetailsFor(notification: abstractNotification, notificationCenter: notificationCenter): JQueryPromise | void; @@ -212,7 +213,7 @@ class notificationCenter { const mergedNotifications = globalNotifications.concat(databaseNotifications); - return _.sortBy(mergedNotifications, x => -1 * x.displayDate().unix()); + return sortBy(mergedNotifications, x => -1 * x.displayDate().unix()); }); this.visibleNotifications = ko.pureComputed(() => { diff --git a/src/Raven.Studio/typescript/common/notifications/protractedCommandsDetector.ts b/src/Raven.Studio/typescript/common/notifications/protractedCommandsDetector.ts index 72b155cde1f..6d050c91f57 100644 --- a/src/Raven.Studio/typescript/common/notifications/protractedCommandsDetector.ts +++ b/src/Raven.Studio/typescript/common/notifications/protractedCommandsDetector.ts @@ -21,9 +21,9 @@ class protractedCommandsDetector { } private sync() { - this.showSpinner(_.some(this.requestsInProgress, x => x.spinnerVisible)); + this.showSpinner(this.requestsInProgress.some(x => x.spinnerVisible)); - _.remove(this.requestsInProgress, x => x.completed); + this.requestsInProgress = this.requestsInProgress.filter(x => x.completed); } private showServerNotRespondingAlert() { diff --git a/src/Raven.Studio/typescript/common/rqlLanguageService.ts b/src/Raven.Studio/typescript/common/rqlLanguageService.ts index 01990f909fc..8e4e60fae21 100644 --- a/src/Raven.Studio/typescript/common/rqlLanguageService.ts +++ b/src/Raven.Studio/typescript/common/rqlLanguageService.ts @@ -27,7 +27,6 @@ class rqlLanguageService implements LanguageService { _.bindAll(this, "complete"); - this.pendingMessages = new Map void>(); this.configure(); diff --git a/src/Raven.Studio/typescript/common/settings/abstractSettings.ts b/src/Raven.Studio/typescript/common/settings/abstractSettings.ts index ab4687a5d31..b6f43f7ae0f 100644 --- a/src/Raven.Studio/typescript/common/settings/abstractSettings.ts +++ b/src/Raven.Studio/typescript/common/settings/abstractSettings.ts @@ -21,8 +21,7 @@ abstract class abstractSettings { private serializeSettings(location: studio.settings.saveLocation) { const settings: any = {}; - - _.forIn(this, (value, name) => { + Object.entries(this).forEach(([name, value]) => { if (value instanceof studioSetting && value.saveLocation === location) { settings[studioSetting.propertyNameInStorage(name, location)] = value.prepareValueForSave(); } @@ -34,11 +33,11 @@ abstract class abstractSettings { protected findPropertyName(item: studioSetting): string { let settingName: string = null; - _.forIn(this, (value, name) => { + Object.entries(this).map(([name, value]) => { if (value instanceof studioSetting && value.saveLocation === item.saveLocation && value === item) { settingName = name; } - }); + }) return settingName; } @@ -65,7 +64,7 @@ abstract class abstractSettings { } protected readSettings(remoteSettings: any, localSettings: any) { - _.forIn(this, (value, name) => { + Object.entries(this).forEach(([name, value]) => { if (value instanceof studioSetting) { if (value.saveLocation === "remote") { value.loadUsingValue(remoteSettings ? remoteSettings[_.upperFirst(name)] : undefined); @@ -102,7 +101,7 @@ abstract class abstractSettings { const localTask = this.saveLocalSettings(localSettings); // notify handlers that settings may change - _.forIn(this, (value, name) => { + Object.entries(this).forEach(([name, value]) => { if (value instanceof studioSetting) { this.onSettingChanged(name, value); } diff --git a/src/Raven.Studio/typescript/common/settings/studioSetting.ts b/src/Raven.Studio/typescript/common/settings/studioSetting.ts index f9097049b47..0eb05436fc9 100644 --- a/src/Raven.Studio/typescript/common/settings/studioSetting.ts +++ b/src/Raven.Studio/typescript/common/settings/studioSetting.ts @@ -30,13 +30,13 @@ abstract class studioSetting { loadUsingValue(value: any) { if (this.saveLocation === "local") { - if (_.isUndefined(value)) { + if (value === undefined) { this.value = this.defaultValue; return; } this.value = JSON.parse(value); } else { - if (_.isUndefined(value)) { + if (value === undefined) { this.value = this.defaultValue; } else { this.value = value; diff --git a/src/Raven.Studio/typescript/common/settings/studioSettings.ts b/src/Raven.Studio/typescript/common/settings/studioSettings.ts index d6bc2c3d4fc..50da04932f3 100644 --- a/src/Raven.Studio/typescript/common/settings/studioSettings.ts +++ b/src/Raven.Studio/typescript/common/settings/studioSettings.ts @@ -71,7 +71,7 @@ class studioSettings { } private onSettingsChanged(container: abstractSettings, settingsDto: any) { - _.forIn(settingsDto, (value, key) => { + Object.entries(settingsDto).forEach(([key, value]) => { const setting = (container as any)[key]; if (setting && setting instanceof studioSetting && setting.prepareValueForSave() !== value) { setting.loadUsingValue(value); diff --git a/src/Raven.Studio/typescript/common/shell/accessManager.ts b/src/Raven.Studio/typescript/common/shell/accessManager.ts index bf0d03ba162..267af1ac8b7 100644 --- a/src/Raven.Studio/typescript/common/shell/accessManager.ts +++ b/src/Raven.Studio/typescript/common/shell/accessManager.ts @@ -96,7 +96,7 @@ class accessManager { readOnlyOrAboveForDatabase(db: database | string) { if (db) { - const accessLevel = this.getEffectiveDatabaseAccessLevel((_.isString(db) ? db : db.name)); + const accessLevel = this.getEffectiveDatabaseAccessLevel(typeof db === "string" ? db : db.name); return accessLevel === "DatabaseRead"; } return null; @@ -104,7 +104,7 @@ class accessManager { readWriteAccessOrAboveForDatabase(db: database | string) { if (db) { - const accessLevel = this.getEffectiveDatabaseAccessLevel((_.isString(db) ? db : db.name)); + const accessLevel = this.getEffectiveDatabaseAccessLevel(typeof db === "string" ? db : db.name); return accessLevel === "DatabaseReadWrite" || accessLevel === "DatabaseAdmin"; } return null; @@ -112,7 +112,7 @@ class accessManager { adminAccessOrAboveForDatabase(db: database | string) { if (db) { - const accessLevel = this.getEffectiveDatabaseAccessLevel((_.isString(db) ? db : db.name)); + const accessLevel = this.getEffectiveDatabaseAccessLevel(typeof db === "string" ? db : db.name); return accessLevel === "DatabaseAdmin"; } return null; diff --git a/src/Raven.Studio/typescript/common/shell/clusterTopologyManager.ts b/src/Raven.Studio/typescript/common/shell/clusterTopologyManager.ts index 6c068bf0488..c1cfc27c1fc 100644 --- a/src/Raven.Studio/typescript/common/shell/clusterTopologyManager.ts +++ b/src/Raven.Studio/typescript/common/shell/clusterTopologyManager.ts @@ -92,7 +92,7 @@ class clusterTopologyManager { }); this.localNodeUrl = ko.pureComputed(() => { - const localNode = _.find(this.topology().nodes(), x => x.tag() === this.localNodeTag()); + const localNode = this.topology().nodes().find(x => x.tag() === this.localNodeTag()); return localNode ? localNode.serverUrl() : null; }); diff --git a/src/Raven.Studio/typescript/common/storage/mergedIndexesStorage.ts b/src/Raven.Studio/typescript/common/storage/mergedIndexesStorage.ts index ff21fafa549..218ccd2fd10 100644 --- a/src/Raven.Studio/typescript/common/storage/mergedIndexesStorage.ts +++ b/src/Raven.Studio/typescript/common/storage/mergedIndexesStorage.ts @@ -50,7 +50,7 @@ class mergedIndexesStorage { } static getLocalStorageKey(db: database | string, id: string) { - return mergedIndexesStorage.getStoragePrefixForDatabase((_.isString(db) ? db : db.name)) + "." + id; + return mergedIndexesStorage.getStoragePrefixForDatabase(typeof db === "string" ? db : db.name) + "." + id; } static onDatabaseDeleted(qualifier: string, name: string) { diff --git a/src/Raven.Studio/typescript/common/storage/starredDocumentsStorage.ts b/src/Raven.Studio/typescript/common/storage/starredDocumentsStorage.ts index 6ed4f6e56e4..bd5bfb3ced6 100644 --- a/src/Raven.Studio/typescript/common/storage/starredDocumentsStorage.ts +++ b/src/Raven.Studio/typescript/common/storage/starredDocumentsStorage.ts @@ -23,7 +23,7 @@ class starredDocumentsStorage { return new verifyDocumentsIDsCommand(starred, db) .execute() .done((verifiedIds) => { - const invalidIds = _.difference(starred, verifiedIds); + const invalidIds = starred.filter(x => !verifiedIds.includes(x)); if (invalidIds.length) { starredDocumentsStorage.saveToLocalStorage(db, verifiedIds); } diff --git a/src/Raven.Studio/typescript/common/timingsChart.ts b/src/Raven.Studio/typescript/common/timingsChart.ts index 2456b0c11ee..c8612c5764d 100644 --- a/src/Raven.Studio/typescript/common/timingsChart.ts +++ b/src/Raven.Studio/typescript/common/timingsChart.ts @@ -1,6 +1,7 @@ /// import d3 = require("d3"); +import { sumBy } from "common/typeUtils"; interface graphNode extends d3.layout.partition.Node { name: string; @@ -166,8 +167,8 @@ class timingsChart { } private convertHierarchy(name: string, data: Raven.Client.Documents.Queries.Timings.QueryTimings): graphNode { - const mappedTimings = _.map(data.Timings, (value, key) => this.convertHierarchy(key, value)); - const remainingTime = data.DurationInMs - _.sumBy(mappedTimings, x => x.duration); + const mappedTimings = Object.entries(data.Timings).map(([key, value]) => this.convertHierarchy(key, value)); + const remainingTime = data.DurationInMs - sumBy(mappedTimings, x => x.duration); let children: Array = null; if (data.Timings) { diff --git a/src/Raven.Studio/typescript/common/typeUtils.ts b/src/Raven.Studio/typescript/common/typeUtils.ts new file mode 100644 index 00000000000..65107a359cb --- /dev/null +++ b/src/Raven.Studio/typescript/common/typeUtils.ts @@ -0,0 +1,55 @@ + +export function isBoolean(value: any): value is boolean { + return value === !!value; +} + +export function range(start: number, end?: number, increment?: number) { + // if the end is not defined... + const isEndDef = typeof end !== 'undefined'; + // ...the first argument should be the end of the range... + end = isEndDef ? end : start; + // ...and 0 should be the start + start = isEndDef ? start : 0; + + // if the increment is not defined, we could need a +1 or -1 + // depending on whether we are going up or down + if (typeof increment === 'undefined') { + increment = Math.sign(end - start); + } + + // calculating the lenght of the array, which has always to be positive + const length = Math.abs((end - start) / (increment || 1)); + + // In order to return the right result, we need to create a new array + // with the calculated length and fill it with the items starting from + // the start value + the value of increment. + const { result } = Array.from<{ current: number, result: number[] }>({ length }).reduce( + ({ result, current }) => ({ + // append the current value to the result array + result: [...result, current], + // adding the increment to the current item + // to be used in the next iteration + current: current + increment, + }), + { current: start, result: [] } + ) + + return result; +} + +export function sumBy(array: T[], valuesAccessor: (value: T) => number): number { + return array.reduce((p, c) => p + valuesAccessor(c), 0); +} + +export function sortBy(array: T[], valueAccessor: (value: T) => any): T[] { + return _.sortBy(array, valueAccessor); +} + + +export function compareSets(set1: T[], set2: T[]): boolean { + if (set1.length !== set2.length) { + return false; + } + + return set1.every(x => set2.includes(x)); +} diff --git a/src/Raven.Studio/typescript/components/common/Form.tsx b/src/Raven.Studio/typescript/components/common/Form.tsx index d3a5ccc1ee0..3217b4645fc 100644 --- a/src/Raven.Studio/typescript/components/common/Form.tsx +++ b/src/Raven.Studio/typescript/components/common/Form.tsx @@ -143,8 +143,8 @@ export function getFormSelectedOptions