File size: 1,882 Bytes
01d5a5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { Request } from '../utils/request';
import type { CommonResponse, EmptyResponse } from '../types/responseModal';

export interface SpaceMessage {
  id: string;
  content: string;
  create_time: string;
  message_type: string;
  role: string;
  round: number;
  sender_endpoint: string;
  space_id: string;
}

export interface ParticipantInfo {
  url: string;
  role_description?: string;
}

export interface SpaceInfo {
  conclusion: string | null;
  create_time: string;
  host: string;
  id: string;
  objective: string;
  participants: string[];
  participants_info?: ParticipantInfo[];
  title: string;
  status?: number; // 1-Initialized 2-In Discussion 3-Discussion Interrupted 4-Discussion Ended
  messages?: SpaceMessage[];
}

interface CreateSpaceReq {
  title: string;
  objective: string;
  host: string;
  participants: string[];
}

interface IShareSpace {
  space: SpaceInfo;
  space_share_id: string;
}

export const createSpace = (data: CreateSpaceReq) => {
  return Request<CommonResponse<SpaceInfo>>({
    method: 'POST',
    url: '/api/space/create',
    data
  });
};

export const getSpaceDetail = (space_id: string) => {
  return Request<CommonResponse<SpaceInfo>>({
    method: 'GET',
    url: `/api/space/${space_id}`
  });
};

export const getAllSpaces = () => {
  return Request<CommonResponse<SpaceInfo[]>>({
    method: 'GET',
    url: '/api/space/all'
  });
};

export const startSpace = (space_id: string) => {
  return Request<CommonResponse<SpaceInfo>>({
    method: 'POST',
    url: `/api/space/${space_id}/start`
  });
};

export const deleteSpace = (space_id: string) => {
  return Request<EmptyResponse>({
    method: 'DELETE',
    url: `/api/space/${space_id}`
  });
};

export const shareSpace = (space_id: string) => {
  return Request<CommonResponse<IShareSpace>>({
    method: 'POST',
    url: `/api/space/${space_id}/share`
  });
};