hoppscotch
hoppscotch copied to clipboard
refactor: introduce abstractions at the workspace level
Description
This PR introduces abstractions at the workspace level and ports the existing implementation to the new architecture. This will be done in phases, and the changes will be merged into the head branch. On a high level, business logic specific to each workspace is being moved from component sources to the respective provider definitions. The newly revamped workspace service acts as an interface for other parts of the codebase to access methods implemented by the various workspace providers. There is a given set of API methods that each provider (personal
, teams
, file-based
) will implement, starting with personal
initially.
-
Handles - Reference to an entity, say workspace, collection, requests, etc. It also holds the necessary information about the resource being pointed to. It can be invalidated at any point. Hence, it's a
ref
to a resource that, in turn, can hold reactive data (A handle itself can be invalidated and needs to be aware of changes happening to the inner members).export type HandleRef<T, InvalidateReason = unknown> = Ref< { type: "ok"; data: T } | { type: "invalid"; reason: InvalidateReason } >
-
Views - Compiles information about the underlying representation used to render the UI.
export type RESTCollectionViewCollection = { collectionID: string name: string } export type RESTCollectionViewRequest = { collectionID: string requestID: string request: HoppRESTRequest } export type RESTCollectionViewItem = | { type: "collection"; value: RESTCollectionViewCollection } | { type: "request"; value: RESTCollectionViewRequest } export interface RootRESTCollectionView { providerID: string workspaceID: string loading: Ref<boolean> collections: Ref<RESTCollectionViewCollection[]> } export interface RESTCollectionChildrenView { providerID: string workspaceID: string collectionID: string loading: Ref<boolean> content: Ref<RESTCollectionViewItem[]> }
Todos
- Drop
New
prefixes from the newly added components once replacing all instances with newly added components and removing the old ones. - Remove the
emitWithFullCollection
prop from theCollectionsProperties
component after porting all usages. - Replace
workspace-user-collection
withuser-collection
for the typeHoppRESTSaveContext
underhoppscotch-common/src/helpers/rest/document
. - Only keep
requestHandle
under the tabsaveContext
and remove the IDs (requestID
,workspaceID
, etc) at runtime. - Remove
collectionID
fromrequestHandle
since it can be obtained fromrequestID
.
Checks
- [ ] My pull request adheres to the code style of this project
- [ ] All the tests have passed