-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtypes.ts
More file actions
173 lines (158 loc) · 4.17 KB
/
types.ts
File metadata and controls
173 lines (158 loc) · 4.17 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
export interface InitParams {
clientID: string;
redirectURI?: string;
baseURL?: string;
requestTimeout?: number;
}
export interface OAuthAuthorizationParams {
response_type: 'code';
client_id: string;
redirect_uri: string;
code_challenge_method: 'S256';
code_challenge: string;
state: string;
scope: string;
}
export interface AuthState {
codeVerifier: string;
}
export interface MCUser {
fullName: string;
emailAddress: string;
}
export interface AICreditsUsage {
aiCredits: {
remaining: number;
total: number;
};
}
export interface MCProject {
id: string;
title: string;
}
/**
* MermaidChart diagram document.
*/
export type MCDocument = Document & DiagramDocument;
/**
* MermaidChart document that may contain a diagram.
*/
export interface Document {
projectID: string;
title: string;
}
/**
* MermaidChart diagram document, without any {@link Document} metadata.
*/
export interface DiagramDocument {
/** The id of this diagram, required for `setDocument()` */
id: string;
/** The id of the document that this diagram is linked to. */
documentID: string;
major: number;
minor: number;
/**
* The Mermaid
* [`application/vnd.mermaid`](https://www.iana.org/assignments/media-types/application/vnd.mermaid)
* code for this diagram.
*/
code?: string;
}
export interface AuthorizationData {
url: string;
state: string;
scope: string[];
}
/**
* Request parameters for repairing a diagram.
*/
export interface RepairDiagramRequest {
/** The Mermaid diagram code that needs to be repaired */
code: string;
/** The error message from the broken diagram */
error: string;
/**
* The diagram UUID to associate this repair with, or
* `undefined` if it is not associated with a diagram (e.g. in the playground).
*/
diagramDocumentID?: string;
/**
* The diagram ID associated with this repair.
*/
diagramID?: string;
/**
* The user ID associated with this repair.
*/
userID?: string;
}
/**
* Only the two diagram versions are sent; the server derives user plan and usage from the auth context provided by the access token.
*/
export interface PrSummaryRequest {
originalDiagram: string;
editedDiagram: string;
}
/**
* Public response: suggested PR title and markdown description, branch name, and commit message.
*/
export interface PrSummaryResponse {
title: string;
description: string;
branchName?: string;
commitMessage?: string;
}
/**
* Request parameters for chatting with the Mermaid AI about a diagram.
*/
export interface DiagramChatRequest {
/** The user's chat message / question. */
message: string;
/** The MermaidChart document ID to associate the chat thread with. */
documentID: string;
/** Mermaid diagram code for context. Defaults to an empty string. */
code?: string;
/**
* Existing chat thread ID to continue a conversation.
* Returned from a previous diagramChat() call.
* When provided, the backend automatically fetches the stored conversation
* history from the database so the AI has full context.
*/
documentChatThreadID?: string;
}
/**
* Response from chatting with the Mermaid AI.
*/
export interface DiagramChatResponse {
/** The AI response text, which may contain Mermaid code blocks. */
text: string;
/** Same as the document ID passed in the request. */
documentID: string;
/**
* The chat thread ID created or used for this conversation.
* Pass this back as documentChatThreadID in subsequent calls to continue the thread.
*/
documentChatThreadID?: string;
}
/**
* Response from repairing a diagram.
* Matches OpenAIGenerationResult from collab.
*/
export interface RepairDiagramResponse {
/**
* The status of the repair: 'ok' if successful, 'fail' if not.
* `ok` indicates that a valid mermaid code block was generated.
* It may still fail to render.
*
* `fail` indicates that there were no exceptions/errors, but no valid
* mermaid code block was generated.
*/
result: 'ok' | 'fail';
/**
* Markdown message, that may contain a valid mermaid code block
*/
code: string;
/**
* Whether the diagram repair was successful (only present for repair responses)
*/
solved?: boolean;
}