refactor: create and load workspace will return workspaceUnit

This commit is contained in:
alt0
2023-01-11 23:14:13 +08:00
parent 15bdd2f31e
commit 8e4585495f
11 changed files with 327 additions and 280 deletions

View File

@@ -1,8 +1,8 @@
import { Workspace as BlocksuiteWorkspace, uuidv4 } from '@blocksuite/store';
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import { MessageCenter } from '../message';
import { Logger, User } from '../types';
import type { WorkspaceUnitCollectionScope } from '../workspace-unit-collection';
import type { WorkspaceUnitCtorParams } from '../workspace-unit';
import type { WorkspaceUnitCtorParams, WorkspaceUnit } from '../workspace-unit';
import { Member } from './affine/apis';
const defaultLogger = () => {
@@ -44,12 +44,6 @@ export class BaseProvider {
return;
}
public async createWorkspaceInfo(
params: CreateWorkspaceInfoParams
): Promise<WorkspaceMeta0> {
throw new Error(`provider: ${this.id} createWorkspaceInfo Not implemented`);
}
/**
* auth provider
*/
@@ -87,7 +81,7 @@ export class BaseProvider {
/**
* load workspaces
**/
public async loadWorkspaces(): Promise<WorkspaceMeta0[]> {
public async loadWorkspaces(): Promise<WorkspaceUnit[]> {
throw new Error(`provider: ${this.id} loadWorkSpace Not implemented`);
}
@@ -183,13 +177,18 @@ export class BaseProvider {
/**
* create workspace by workspace meta
* @param {WorkspaceMeta} meta
* @param {CreateWorkspaceInfoParams} meta
*/
public async createWorkspace(
blocksuiteWorkspace: BlocksuiteWorkspace,
meta: WorkspaceMeta0
): Promise<BlocksuiteWorkspace | undefined> {
return blocksuiteWorkspace;
meta: CreateWorkspaceInfoParams
): Promise<WorkspaceUnit | undefined> {
throw new Error(`provider: ${this.id} createWorkspace not implemented`);
}
public async extendWorkspace(
workspaceUnit: WorkspaceUnit
): Promise<WorkspaceUnit | undefined> {
throw new Error(`provider: ${this.id} extendWorkspace not implemented`);
}
/**
@@ -214,16 +213,6 @@ export class BaseProvider {
return workspace;
}
/**
* merge one workspaces to another
* @param workspace
* @returns
*/
public async assign(to: BlocksuiteWorkspace, from: BlocksuiteWorkspace) {
from;
return to;
}
/**
* get workspace members
* @param {string} workspaceId