From b19486ea03c56e412c1fd53cbdb7baa7fe001dd6 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 29 Feb 2024 19:53:38 +0530 Subject: [PATCH] refactor: update provider method signatures + cleanup --- .../src/services/new-workspace/index.ts | 4 ++-- .../src/services/new-workspace/provider.ts | 4 ++-- .../new-workspace/providers/personal.workspace.ts | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/hoppscotch-common/src/services/new-workspace/index.ts b/packages/hoppscotch-common/src/services/new-workspace/index.ts index c1c370b10..156fa0952 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/index.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/index.ts @@ -175,7 +175,7 @@ export class NewWorkspaceService extends Service { public async createRESTRootCollection( workspaceHandle: HandleRef, - newCollection: Partial + newCollection: Partial> & { name: string } ): Promise< E.Either< WorkspaceError<"INVALID_HANDLE" | "INVALID_PROVIDER">, @@ -208,7 +208,7 @@ export class NewWorkspaceService extends Service { public async createRESTChildCollection( parentCollectionHandle: HandleRef, - newChildCollection: Partial + newChildCollection: Partial & { name: string } ): Promise< E.Either< WorkspaceError<"INVALID_HANDLE" | "INVALID_PROVIDER">, diff --git a/packages/hoppscotch-common/src/services/new-workspace/provider.ts b/packages/hoppscotch-common/src/services/new-workspace/provider.ts index af34b5f07..79c2a487e 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/provider.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/provider.ts @@ -49,11 +49,11 @@ export interface WorkspaceProvider { createRESTRootCollection( workspaceHandle: HandleRef, - newCollection: Partial + newCollection: Partial> & { name: string } ): Promise>> createRESTChildCollection( parentCollectionHandle: HandleRef, - newChildCollection: Partial + newChildCollection: Partial & { name: string } ): Promise>> updateRESTCollection( collectionHandle: HandleRef, diff --git a/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts b/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts index faae27f88..0da00120f 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts @@ -112,18 +112,17 @@ export class PersonalWorkspaceProviderService public createRESTRootCollection( workspaceHandle: HandleRef, - newCollection: Partial + newCollection: Partial> & { name: string } ): Promise>> { if (!isValidWorkspaceHandle(workspaceHandle, this.providerID, "personal")) { return Promise.resolve(E.left("INVALID_WORKSPACE_HANDLE" as const)) } - const newCollectionName = newCollection.name as string + const newCollectionName = newCollection.name const newCollectionID = this.restCollectionState.value.state.length.toString() const newRootCollection = makeCollection({ - name: newCollectionName, folders: [], requests: [], headers: [], @@ -131,6 +130,7 @@ export class PersonalWorkspaceProviderService authType: "inherit", authActive: false, }, + ...newCollection, }) addRESTCollection(newRootCollection) @@ -173,7 +173,7 @@ export class PersonalWorkspaceProviderService public createRESTChildCollection( parentCollectionHandle: HandleRef, - newChildCollection: Partial + newChildCollection: Partial & { name: string } ): Promise>> { if ( !isValidCollectionHandle( @@ -188,7 +188,7 @@ export class PersonalWorkspaceProviderService const { collectionID, providerID, workspaceID } = parentCollectionHandle.value.data - const newCollectionName = newChildCollection.name as string + const newCollectionName = newChildCollection.name addRESTFolder(newCollectionName, collectionID) platform.analytics?.logEvent({