Skip to content

Commit

Permalink
DA-374 package size inconsistency (#382)
Browse files Browse the repository at this point in the history
## Describe the problem this PR is solving


## Short description of the changes
-
  • Loading branch information
lokesh-couchbase authored May 17, 2024
1 parent cd7afc1 commit 7744e1c
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ vsc-extension-quickstart.md
node_modules/
.github/
Makefile
webpack.config.json
webpack.config.json
.git/**
**/cmake*/
**/cmake*
**/cb-vscode-extension*/
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-couchbase",
"displayName": "Couchbase",
"description": "",
"version": "2.0.1",
"version": "2.0.2",
"engines": {
"vscode": "^1.63.1"
},
Expand Down Expand Up @@ -83,6 +83,7 @@
"sass": "^1.72.0",
"sass-loader": "^14.1.1",
"style-loader": "^3.3.4",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.1.2",
"ts-loader": "^9.5.1",
"typescript": "^5.4.3",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/collections/removeCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const removeCollection = async (node: CollectionNode) => {
}

// Remove any document filter if set
Memory.state.update(`filterDocuments-${node.connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`, '');
Memory.state.update(`filterDocuments-${connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`, '');

const collectionManager = await connection.cluster
?.bucket(node.bucketName)
Expand Down
7 changes: 6 additions & 1 deletion src/commands/documents/clearDocumentFilter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import CollectionNode from "../../model/CollectionNode";
import { getActiveConnection } from "../../util/connections";
import { Memory } from "../../util/util";

export const clearDocumentFilter = async (node: CollectionNode) => {
const connection = getActiveConnection();
if(!connection){
return;
}
Memory.state.update(
`filterDocuments-${node.connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`,
`filterDocuments-${connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`,
""
);
};
4 changes: 2 additions & 2 deletions src/commands/documents/filterDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const filterDocuments = async (node: CollectionNode) => {
}

const docFilter = Memory.state.get<IFilterDocuments>(
`filterDocuments-${node.connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`
`filterDocuments-${connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`
);
const filterStmt: string = docFilter ? docFilter.filter : "";
let collectionName = node.collectionName;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const filterDocuments = async (node: CollectionNode) => {
filter: newDocFilterStmt.trim(),
};
Memory.state.update(
`filterDocuments-${node.connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`,
`filterDocuments-${connection.connectionIdentifier}-${node.bucketName}-${node.scopeName}-${node.collectionName}`,
newDocFilter
);
};
34 changes: 23 additions & 11 deletions src/commands/indexes/checkAndCreatePrimaryIndex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode';
import { logger } from '../../logger/logger';
import { Commands } from '../extensionCommands/commands';
import * as vscode from "vscode";
import { logger } from "../../logger/logger";
import { Commands } from "../extensionCommands/commands";
import { getActiveConnection } from "../../util/connections";

export const checkAndCreatePrimaryIndex = async (elementData: any) => {
const answer = await vscode.window.showWarningMessage(
Expand All @@ -10,16 +11,27 @@ export const checkAndCreatePrimaryIndex = async (elementData: any) => {
"No"
);
if (answer === "Yes") {
try{
try {
const connection = getActiveConnection();
if (!connection) {
return;
}
vscode.window.showInformationMessage("Creating primary index");
await elementData.connection.cluster?.query(
await connection.cluster?.query(
`CREATE PRIMARY INDEX ON \`${elementData.bucketName}\`.\`${elementData.scopeName}\`.\`${elementData.collectionName}\` USING GSI`
);
logger.info(`Created Primay Index on ${elementData.bucketName} ${elementData.scopeName} ${elementData.collectionName} USING GSI`);
vscode.commands.executeCommand(Commands.refreshCollection, elementData.parentNode);
} catch(e){
vscode.window.showErrorMessage("Error while creating primary index "+e);
logger.error("Error while creating primary index "+ e);
logger.info(
`Created Primay Index on ${elementData.bucketName} ${elementData.scopeName} ${elementData.collectionName} USING GSI`
);
vscode.commands.executeCommand(
Commands.refreshCollection,
elementData.parentNode
);
} catch (e) {
vscode.window.showErrorMessage(
"Error while creating primary index " + e
);
logger.error("Error while creating primary index " + e);
}
}
};
};
14 changes: 7 additions & 7 deletions src/commands/iq/iqLoginhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ const getSessionsJwt = async (formData: IFormData): Promise<string> => {

export const iqLoginHandler = async (formData: IFormData) => {
try {
// Check for remember me
if (formData.rememberMe === true) {
Global.state.update(Constants.IQ_USER_ID, formData.username);
const secretService = SecretService.getInstance();
await secretService.store(`${Constants.IQ_PASSWORD}-${formData.username}`, formData.password);
}

// Return organization select page data
const jwtToken = await getSessionsJwt(formData);
Memory.state.update("vscode-couchbase.iq.jwtToken", jwtToken);
const organizations = await iqRestApiService.loadOrganizations(
jwtToken
);

// Check for remember me
if (formData.rememberMe === true) {
Global.state.update(Constants.IQ_USER_ID, formData.username);
const secretService = SecretService.getInstance();
await secretService.store(`${Constants.IQ_PASSWORD}-${formData.username}`, formData.password);
}
return organizations;
} catch (error: any) {
throw new Error(error.message.toString());
Expand Down
12 changes: 6 additions & 6 deletions src/handlers/handleCLIDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-macos_x86_64.zip",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-macos_x86_64.zip",
this.TOOL_IMPORT_EXPORT,
OSUtil.MACOS_64
)
Expand Down Expand Up @@ -125,7 +125,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-macos_arm64.zip",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-macos_arm64.zip",
this.TOOL_IMPORT_EXPORT,
OSUtil.MACOS_ARM
)
Expand Down Expand Up @@ -158,7 +158,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-windows_amd64.zip",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-windows_amd64.zip",
this.TOOL_IMPORT_EXPORT,
OSUtil.WINDOWS_64
)
Expand Down Expand Up @@ -191,7 +191,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-windows_amd64.zip",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-windows_amd64.zip",
this.TOOL_IMPORT_EXPORT,
OSUtil.WINDOWS_ARM
)
Expand Down Expand Up @@ -224,7 +224,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-linux_x86_64.tar.gz",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-linux_x86_64.tar.gz",
this.TOOL_IMPORT_EXPORT,
OSUtil.LINUX_64
)
Expand Down Expand Up @@ -257,7 +257,7 @@ class DependenciesDownloader {
map.set(
this.TOOL_IMPORT_EXPORT,
this.getToolSpec(
"https://packages.couchbase.com/releases/7.2.0/couchbase-server-tools_7.2.0-linux_aarch64.tar.gz",
"https://packages.couchbase.com/releases/7.6.0/couchbase-server-tools_7.6.0-linux_aarch64.tar.gz",
this.TOOL_IMPORT_EXPORT,
OSUtil.LINUX_ARM
)
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/versionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const config = {
TOOLS_VERSION: "7.2",
CBMIGRATE_VERSION: "1",
SHELL_VERSION: "1",
CBIMPORT_EXPORT_VERSION: "7.2",
CBIMPORT_EXPORT_VERSION: "7.6",
};
2 changes: 0 additions & 2 deletions src/model/BucketNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { CacheService } from "../../src/util/cacheService/cacheService"
export class BucketNode implements INode {
constructor(
public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly bucketName: string,
public readonly isScopesandCollections: boolean,
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
Expand Down Expand Up @@ -74,7 +73,6 @@ export class BucketNode implements INode {
nodes.push(
new ScopeNode(
this,
this.connection,
scope.name,
this.bucketName,
scope.collections,
Expand Down
1 change: 0 additions & 1 deletion src/model/ClusterConnectionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class ClusterConnectionNode implements INode {
nodes.push(
new BucketNode(
this,
this.connection,
bucket.name,
isScopesandCollections,
vscode.TreeItemCollapsibleState.None,
Expand Down
6 changes: 1 addition & 5 deletions src/model/CollectionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { Constants } from "../util/constants";
export default class CollectionNode implements INode {
constructor(
public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly scopeName: string,
public readonly documentCount: number,
public readonly bucketName: string,
Expand Down Expand Up @@ -130,7 +129,6 @@ export default class CollectionNode implements INode {
// Index directory to contains list of indexes
const indexItem = new IndexDirectory(
this,
this.connection,
"Indexes",
this.bucketName,
this.scopeName,
Expand All @@ -150,7 +148,6 @@ export default class CollectionNode implements INode {
documentList.push(
new SchemaDirectory(
this,
this.connection,
"Schema",
this.bucketName,
this.scopeName,
Expand All @@ -164,7 +161,7 @@ export default class CollectionNode implements INode {
// An index is required for database querying. If one is present, a result will be obtained.
// If not, the user will be prompted to create a index before querying.
let docFilter = Memory.state.get<IFilterDocuments>(
`filterDocuments-${this.connection.connectionIdentifier}-${this.bucketName}-${this.scopeName}-${this.collectionName}`
`filterDocuments-${connection.connectionIdentifier}-${this.bucketName}-${this.scopeName}-${this.collectionName}`
);
let filter: string = "";
if (docFilter && docFilter.filter.length > 0) {
Expand Down Expand Up @@ -209,7 +206,6 @@ export default class CollectionNode implements INode {
const documentTreeItem = new DocumentNode(
this,
documentName,
this.connection,
this.scopeName,
this.bucketName,
this.collectionName,
Expand Down
1 change: 0 additions & 1 deletion src/model/DocumentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default class DocumentNode extends vscode.TreeItem {
constructor(
public readonly parentNode: INode,
public readonly documentName: string,
public readonly connection: IConnection,
public readonly scopeName: string,
public readonly bucketName: string,
public readonly collectionName: string,
Expand Down
2 changes: 0 additions & 2 deletions src/model/IndexDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { CacheService } from "../util/cacheService/cacheService";
export class IndexDirectory implements INode {
constructor(
public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly itemName: string,
public readonly bucketName: string,
public readonly scopeName: string,
Expand Down Expand Up @@ -69,7 +68,6 @@ export class IndexDirectory implements INode {
if (query.scopeName === this.scopeName || this.scopeName === "_default") {
const indexNode = new IndexNode(
this,
this.connection,
this.scopeName,
this.bucketName,
`${query.name[0] === '#' ? query.name.substring(1) : query.name}${(query.collectionName ? ("_" + query.collectionName) : "")}`,
Expand Down
1 change: 0 additions & 1 deletion src/model/IndexNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { INode } from "../types/INode";
export default class IndexNode extends vscode.TreeItem {
constructor(
public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly scopeName: string,
public readonly bucketName: string,
public readonly indexName: string,
Expand Down
1 change: 0 additions & 1 deletion src/model/SchemaDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Constants } from "../util/constants";

export class SchemaDirectory implements INode {
constructor(public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly itemName: string,
public readonly bucketName: string,
public readonly scopeName: string,
Expand Down
4 changes: 1 addition & 3 deletions src/model/ScopeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { CacheService } from "../../src/util/cacheService/cacheService"
export class ScopeNode implements INode {
constructor(
public readonly parentNode: INode,
public readonly connection: IConnection,
public readonly scopeName: string,
public readonly bucketName: string,
public readonly collections: any[],
Expand Down Expand Up @@ -78,7 +77,7 @@ export class ScopeNode implements INode {
for (const collection of this.collections) {
try {
const docFilter = Memory.state.get<IFilterDocuments>(
`filterDocuments-${this.connection.connectionIdentifier}-${this.bucketName}-${this.scopeName}-${collection.name}`
`filterDocuments-${connection.connectionIdentifier}-${this.bucketName}-${this.scopeName}-${collection.name}`
);
const filter: string =
docFilter && docFilter.filter.length > 0 ? docFilter.filter : "";
Expand Down Expand Up @@ -107,7 +106,6 @@ export class ScopeNode implements INode {

const collectionTreeItem = new CollectionNode(
this,
this.connection,
this.scopeName,
rowCount,
this.bucketName,
Expand Down
Loading

0 comments on commit 7744e1c

Please sign in to comment.