mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 22:18:54 +08:00
feat: getWorkspaces ipc
This commit is contained in:
@@ -48,7 +48,6 @@ export class DataCenter {
|
||||
new TauriIPCProvider({
|
||||
logger: dc._logger,
|
||||
workspaces: dc._workspaces.createScope(),
|
||||
blobs: dc._blobStorage,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@ import {
|
||||
GetDocumentResponse,
|
||||
YDocumentUpdate,
|
||||
} from './types/document';
|
||||
import { CreateWorkspace, CreateWorkspaceResult } from './types/workspace';
|
||||
import {
|
||||
CreateWorkspace,
|
||||
CreateWorkspaceResult,
|
||||
GetWorkspaces,
|
||||
GetWorkspacesResult,
|
||||
} from './types/workspace';
|
||||
import { GetBlob, PutBlob } from './types/blob';
|
||||
|
||||
export const updateYDocument = async (parameters: YDocumentUpdate) =>
|
||||
@@ -21,6 +26,10 @@ export const createWorkspace = async (parameters: CreateWorkspace) =>
|
||||
await invoke<CreateWorkspaceResult>('create_workspace', {
|
||||
parameters,
|
||||
});
|
||||
export const getWorkspaces = async (parameters: GetWorkspaces) =>
|
||||
await invoke<GetWorkspacesResult>('create_workspace', {
|
||||
parameters,
|
||||
});
|
||||
|
||||
export const putBlob = async (parameters: PutBlob) =>
|
||||
await invoke<string>('put_blob', {
|
||||
|
||||
@@ -12,6 +12,26 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["GetWorkspaces"],
|
||||
"properties": {
|
||||
"GetWorkspaces": {
|
||||
"$ref": "#/definitions/GetWorkspaces"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["GetWorkspacesResult"],
|
||||
"properties": {
|
||||
"GetWorkspacesResult": {
|
||||
"$ref": "#/definitions/GetWorkspacesResult"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["UpdateWorkspace"],
|
||||
@@ -60,6 +80,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"GetWorkspaces": {
|
||||
"type": "object",
|
||||
"required": ["user_id"],
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"GetWorkspacesResult": {
|
||||
"type": "object",
|
||||
"required": ["workspaces"],
|
||||
"properties": {
|
||||
"workspaces": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/WorkspaceWithPermission"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionType": {
|
||||
"type": "string",
|
||||
"enum": ["Read", "Write", "Admin", "Owner"]
|
||||
},
|
||||
"UpdateWorkspace": {
|
||||
"type": "object",
|
||||
"required": ["id", "public"],
|
||||
@@ -72,6 +118,32 @@
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"WorkspaceType": {
|
||||
"type": "string",
|
||||
"enum": ["Private", "Normal"]
|
||||
},
|
||||
"WorkspaceWithPermission": {
|
||||
"type": "object",
|
||||
"required": ["created_at", "id", "permission", "public", "type"],
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"permission": {
|
||||
"$ref": "#/definitions/PermissionType"
|
||||
},
|
||||
"public": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"type": {
|
||||
"$ref": "#/definitions/WorkspaceType"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,20 @@ export type IWorkspaceParameters =
|
||||
| {
|
||||
CreateWorkspace: CreateWorkspace;
|
||||
}
|
||||
| {
|
||||
GetWorkspaces: GetWorkspaces;
|
||||
}
|
||||
| {
|
||||
GetWorkspacesResult: GetWorkspacesResult;
|
||||
}
|
||||
| {
|
||||
UpdateWorkspace: UpdateWorkspace;
|
||||
}
|
||||
| {
|
||||
CreateWorkspaceResult: CreateWorkspaceResult;
|
||||
};
|
||||
export type PermissionType = 'Read' | 'Write' | 'Admin' | 'Owner';
|
||||
export type WorkspaceType = 'Private' | 'Normal';
|
||||
|
||||
export interface CreateWorkspace {
|
||||
/**
|
||||
@@ -24,6 +32,22 @@ export interface CreateWorkspace {
|
||||
user_id: number;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface GetWorkspaces {
|
||||
user_id: number;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface GetWorkspacesResult {
|
||||
workspaces: WorkspaceWithPermission[];
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface WorkspaceWithPermission {
|
||||
created_at: number;
|
||||
id: string;
|
||||
permission: PermissionType;
|
||||
public: boolean;
|
||||
type: WorkspaceType;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface UpdateWorkspace {
|
||||
id: number;
|
||||
public: boolean;
|
||||
|
||||
Reference in New Issue
Block a user