Skip to content

Commit 8acff5c

Browse files
committed
Remove from other files
1 parent acbd973 commit 8acff5c

24 files changed

+15
-1705
lines changed

extensions/ql-vscode/src/databases/config/db-config-store.ts

Lines changed: 1 addition & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import { pathExists, outputJSON, readJSON, readJSONSync } from "fs-extra";
22
import { join } from "path";
33
import {
4-
clearLocalDbConfig,
54
cloneDbConfig,
65
DbConfig,
7-
initializeLocalDbConfig,
8-
removeLocalDb,
9-
removeLocalList,
106
removeRemoteList,
117
removeRemoteOwner,
128
removeRemoteRepo,
13-
renameLocalDb,
14-
renameLocalList,
159
renameRemoteList,
1610
SelectedDbItem,
1711
DB_CONFIG_VERSION,
@@ -30,13 +24,7 @@ import {
3024
DbConfigValidationErrorKind,
3125
} from "../db-validation-errors";
3226
import { ValueResult } from "../../common/value-result";
33-
import {
34-
LocalDatabaseDbItem,
35-
LocalListDbItem,
36-
RemoteUserDefinedListDbItem,
37-
DbItem,
38-
DbItemKind,
39-
} from "../db-item";
27+
import { RemoteUserDefinedListDbItem, DbItem, DbItemKind } from "../db-item";
4028

4129
export class DbConfigStore extends DisposableObject {
4230
public static readonly databaseConfigFileName = "databases.json";
@@ -119,20 +107,9 @@ export class DbConfigStore extends DisposableObject {
119107
let config: DbConfig;
120108

121109
switch (dbItem.kind) {
122-
case DbItemKind.LocalList:
123-
config = removeLocalList(this.config, dbItem.listName);
124-
break;
125110
case DbItemKind.RemoteUserDefinedList:
126111
config = removeRemoteList(this.config, dbItem.listName);
127112
break;
128-
case DbItemKind.LocalDatabase:
129-
// When we start using local databases these need to be removed from disk as well.
130-
config = removeLocalDb(
131-
this.config,
132-
dbItem.databaseName,
133-
dbItem.parentListName,
134-
);
135-
break;
136113
case DbItemKind.RemoteRepo:
137114
config = removeRemoteRepo(
138115
this.config,
@@ -229,22 +206,6 @@ export class DbConfigStore extends DisposableObject {
229206
await this.writeConfig(config);
230207
}
231208

232-
public async addLocalList(listName: string): Promise<void> {
233-
if (!this.config) {
234-
throw Error("Cannot add local list if config is not loaded");
235-
}
236-
237-
this.validateLocalListName(listName);
238-
239-
const config = cloneDbConfig(this.config);
240-
config.databases.local.lists.push({
241-
name: listName,
242-
databases: [],
243-
});
244-
245-
await this.writeConfig(config);
246-
}
247-
248209
public async addRemoteList(listName: string): Promise<void> {
249210
if (!this.config) {
250211
throw Error("Cannot add variant analysis list if config is not loaded");
@@ -261,25 +222,6 @@ export class DbConfigStore extends DisposableObject {
261222
await this.writeConfig(config);
262223
}
263224

264-
public async renameLocalList(
265-
currentDbItem: LocalListDbItem,
266-
newName: string,
267-
) {
268-
if (!this.config) {
269-
throw Error("Cannot rename local list if config is not loaded");
270-
}
271-
272-
this.validateLocalListName(newName);
273-
274-
const updatedConfig = renameLocalList(
275-
this.config,
276-
currentDbItem.listName,
277-
newName,
278-
);
279-
280-
await this.writeConfig(updatedConfig);
281-
}
282-
283225
public async renameRemoteList(
284226
currentDbItem: RemoteUserDefinedListDbItem,
285227
newName: string,
@@ -301,27 +243,6 @@ export class DbConfigStore extends DisposableObject {
301243
await this.writeConfig(updatedConfig);
302244
}
303245

304-
public async renameLocalDb(
305-
currentDbItem: LocalDatabaseDbItem,
306-
newName: string,
307-
parentListName?: string,
308-
): Promise<void> {
309-
if (!this.config) {
310-
throw Error("Cannot rename local db if config is not loaded");
311-
}
312-
313-
this.validateLocalDbName(newName);
314-
315-
const updatedConfig = renameLocalDb(
316-
this.config,
317-
currentDbItem.databaseName,
318-
newName,
319-
parentListName,
320-
);
321-
322-
await this.writeConfig(updatedConfig);
323-
}
324-
325246
public doesRemoteListExist(listName: string): boolean {
326247
if (!this.config) {
327248
throw Error(
@@ -334,31 +255,6 @@ export class DbConfigStore extends DisposableObject {
334255
);
335256
}
336257

337-
public doesLocalListExist(listName: string): boolean {
338-
if (!this.config) {
339-
throw Error("Cannot check local list existence if config is not loaded");
340-
}
341-
342-
return this.config.databases.local.lists.some((l) => l.name === listName);
343-
}
344-
345-
public doesLocalDbExist(dbName: string, listName?: string): boolean {
346-
if (!this.config) {
347-
throw Error(
348-
"Cannot check variant analysis repository existence if config is not loaded",
349-
);
350-
}
351-
352-
if (listName) {
353-
return this.config.databases.local.lists.some(
354-
(l) =>
355-
l.name === listName && l.databases.some((d) => d.name === dbName),
356-
);
357-
}
358-
359-
return this.config.databases.local.databases.some((d) => d.name === dbName);
360-
}
361-
362258
public doesRemoteDbExist(dbName: string, listName?: string): boolean {
363259
if (!this.config) {
364260
throw Error(
@@ -384,7 +280,6 @@ export class DbConfigStore extends DisposableObject {
384280
}
385281

386282
private async writeConfig(config: DbConfig): Promise<void> {
387-
clearLocalDbConfig(config);
388283
await outputJSON(this.configPath, config, {
389284
spaces: 2,
390285
});
@@ -416,7 +311,6 @@ export class DbConfigStore extends DisposableObject {
416311
}
417312

418313
if (newConfig) {
419-
initializeLocalDbConfig(newConfig);
420314
this.configErrors = this.configValidator.validate(newConfig);
421315
}
422316

@@ -451,7 +345,6 @@ export class DbConfigStore extends DisposableObject {
451345
}
452346

453347
if (newConfig) {
454-
initializeLocalDbConfig(newConfig);
455348
this.configErrors = this.configValidator.validate(newConfig);
456349
}
457350

@@ -499,10 +392,6 @@ export class DbConfigStore extends DisposableObject {
499392
owners: [],
500393
repositories: [],
501394
},
502-
local: {
503-
lists: [],
504-
databases: [],
505-
},
506395
},
507396
selected: {
508397
kind: SelectedDbItemKind.VariantAnalysisSystemDefinedList,
@@ -511,16 +400,6 @@ export class DbConfigStore extends DisposableObject {
511400
};
512401
}
513402

514-
private validateLocalListName(listName: string): void {
515-
if (listName === "") {
516-
throw Error("List name cannot be empty");
517-
}
518-
519-
if (this.doesLocalListExist(listName)) {
520-
throw Error(`A local list with the name '${listName}' already exists`);
521-
}
522-
}
523-
524403
private validateRemoteListName(listName: string): void {
525404
if (listName === "") {
526405
throw Error("List name cannot be empty");
@@ -532,14 +411,4 @@ export class DbConfigStore extends DisposableObject {
532411
);
533412
}
534413
}
535-
536-
private validateLocalDbName(dbName: string): void {
537-
if (dbName === "") {
538-
throw Error("Database name cannot be empty");
539-
}
540-
541-
if (this.doesLocalDbExist(dbName)) {
542-
throw Error(`A local database with the name '${dbName}' already exists`);
543-
}
544-
}
545414
}

extensions/ql-vscode/src/databases/config/db-config-validator.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readJsonSync } from "fs-extra";
22
import { resolve } from "path";
33
import Ajv, { ValidateFunction } from "ajv";
4-
import { clearLocalDbConfig, DbConfig } from "./db-config";
4+
import { DbConfig } from "./db-config";
55
import { findDuplicateStrings } from "../../common/text-utils";
66
import {
77
DbConfigValidationError,
@@ -19,8 +19,6 @@ export class DbConfigValidator {
1919
}
2020

2121
public validate(dbConfig: DbConfig): DbConfigValidationError[] {
22-
const localDbs = clearLocalDbConfig(dbConfig);
23-
2422
this.validateSchemaFn(dbConfig);
2523

2624
if (this.validateSchemaFn.errors) {
@@ -30,13 +28,6 @@ export class DbConfigValidator {
3028
}));
3129
}
3230

33-
// Add any local db config back so that we have a config
34-
// object that respects its type and validation can happen
35-
// as normal.
36-
if (localDbs) {
37-
dbConfig.databases.local = localDbs;
38-
}
39-
4031
return [
4132
...this.validateDbListNames(dbConfig),
4233
...this.validateDbNames(dbConfig),
@@ -55,14 +46,6 @@ export class DbConfigValidator {
5546
)}`,
5647
});
5748

58-
const duplicateLocalDbLists = findDuplicateStrings(
59-
dbConfig.databases.local.lists.map((n) => n.name),
60-
);
61-
62-
if (duplicateLocalDbLists.length > 0) {
63-
errors.push(buildError(duplicateLocalDbLists));
64-
}
65-
6649
const duplicateRemoteDbLists = findDuplicateStrings(
6750
dbConfig.databases.variantAnalysis.repositoryLists.map((n) => n.name),
6851
);
@@ -81,14 +64,6 @@ export class DbConfigValidator {
8164
message: `There are databases with the same name: ${dups.join(", ")}`,
8265
});
8366

84-
const duplicateLocalDbs = findDuplicateStrings(
85-
dbConfig.databases.local.databases.map((d) => d.name),
86-
);
87-
88-
if (duplicateLocalDbs.length > 0) {
89-
errors.push(buildError(duplicateLocalDbs));
90-
}
91-
9267
const duplicateRemoteDbs = findDuplicateStrings(
9368
dbConfig.databases.variantAnalysis.repositories,
9469
);
@@ -111,13 +86,6 @@ export class DbConfigValidator {
11186
)}`,
11287
});
11388

114-
for (const list of dbConfig.databases.local.lists) {
115-
const dups = findDuplicateStrings(list.databases.map((d) => d.name));
116-
if (dups.length > 0) {
117-
errors.push(buildError(list.name, dups));
118-
}
119-
}
120-
12189
for (const list of dbConfig.databases.variantAnalysis.repositoryLists) {
12290
const dups = findDuplicateStrings(list.repositories);
12391
if (dups.length > 0) {

0 commit comments

Comments
 (0)