-
Notifications
You must be signed in to change notification settings - Fork 373
/
api_doc.go
272 lines (232 loc) · 7.2 KB
/
api_doc.go
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// Copyright (c) 2021 Terminus, Inc.
//
// This program is free software: you can use, redistribute, and/or modify
// it under the terms of the GNU Affero General Public License, version 3
// or later ("AGPL"), as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package apistructs
import (
"encoding/json"
"fmt"
"time"
)
type NodeType string
const (
NodeTypeDir NodeType = "d"
NodeTypeFile NodeType = "f"
)
type APIDocLockModel struct {
ID uint64 `json:"id"`
CreatedAt time.Time `json:"createAt"`
UpdatedAt time.Time `json:"updatedAt"`
SessionID string `json:"sessionID"`
IsLocked bool `json:"isLocked"`
ExpiredAt time.Time `json:"expiredAt"`
ApplicationID uint64 `json:"applicationID"`
BranchName string `json:"branchName"`
DocName string `json:"docName"`
CreatorID string `json:"creatorID"`
UpdaterID string `json:"updaterID"`
}
func (m APIDocLockModel) TableName() string {
return "dice_api_doc_lock"
}
type APIDocTmpContentModel struct {
ID uint64 `json:"id"`
CreatedAt time.Time `json:"createAt"`
UpdatedAt time.Time `json:"updatedAt"`
ApplicationID uint64 `json:"applicationID"`
BranchName string `json:"branchName"`
DocName string `json:"docName"`
Content string `json:"content"`
CreatorID string `json:"creatorID"`
UpdaterID string `json:"updaterID"`
}
func (m APIDocTmpContentModel) TableName() string {
return "dice_api_doc_tmp_content"
}
type APIDocCreateNodeReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
Body *APIDocCreateUpdateNodeBody
}
type APIDocCreateUpdateNodeBody struct {
Type NodeType `json:"type"`
Pinode string `json:"pinode"`
Name string `json:"name"`
Meta json.RawMessage `json:"meta,omitempty"`
}
type APIDocDeleteNodeReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
}
type APIDocUpdateNodeReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
Body *RenameAPIDocBody
}
type FileTreeNodeRspData struct {
Type NodeType `json:"type"`
Inode string `json:"inode"`
Pinode string `json:"pinode"`
Scope string `json:"scope"`
ScopeID string `json:"scopeID"`
Name string `json:"name"`
CreatorID string `json:"creatorID"`
UpdaterID string `json:"updaterID"`
Meta json.RawMessage `json:"meta,omitempty"`
}
type APIDocMvCpNodeReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeActionURI
Body *APIDocMvCpNodeReqBody
}
type APIDocMvCpNodeReqBody struct {
Pinode string `json:"pinode"`
}
// 子节点列表
type APIDocListChildrenReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
QueryParams *FileTreeQueryParameters
}
type FileTreeQueryParameters struct {
Pinode string `json:"pinode"`
Scope string `json:"scope"`
ScopeID string `json:"scopeID"`
}
type APIDocNodeDetailReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
}
type FileTreeDetailURI struct {
TreeName string
Inode string
}
type FileTreeActionURI struct {
TreeName string
Inode string
Action string
}
type CreateAPIDocMeta struct {
Content string `json:"content"`
}
type RenameAPIDocBody struct {
Name string `json:"name"`
}
type APIDocMeta struct {
Lock *APIDocMetaLock `json:"lock,omitempty"`
Asset *APIDocMetaAssetInfo `json:"asset"`
Tree *GittarTreeRspData `json:"tree,omitempty"`
Blob *GittarBlobRspData `json:"blob,omitempty"`
ReadOnly bool `json:"readOnly"`
Valid bool `json:"valid"`
Error string `json:"error,omitempty"`
}
type APIDocMetaLock struct {
Locked bool `json:"locked"`
UserID string `json:"userID"`
NickName string `json:"nickName"`
}
type APIDocMetaAssetInfo struct {
AssetName string `json:"assetName"`
AssetID string `json:"assetID"`
Major uint64 `json:"major"`
Minor uint64 `json:"minor"`
Patch uint64 `json:"patch"`
}
type BaseResponse struct {
Success bool `json:"success"`
Err *BaseResponseErr `json:"err,omitempty"`
Data json.RawMessage `json:"data"`
}
type BaseResponseErr struct {
Code string `json:"code"`
Msg string `json:"msg"`
}
func (e *BaseResponseErr) Error() string {
if e == nil {
return ""
}
return fmt.Sprintf("code: %s, msg: %s", e.Code, e.Msg)
}
type GittarTreeRspData struct {
Binary bool `json:"binary"`
Commit *GittarTreeRspDataCommit `json:"commit"`
Entries []interface{} `json:"entries"`
Path string `json:"path"`
ReadmeFile string `json:"readmeFile"`
RefName string `json:"refName"`
TreeID string `json:"treeId"`
Type string `json:"type"`
}
type GittarTreeRspDataCommit struct {
ID string `json:"id"`
Author map[string]string `json:"author"`
Committer map[string]string `json:"committer"`
CommitMessage string `json:"commitMessage"`
Parent interface{} `json:"parent"`
}
type GittarBlobRspData struct {
Binary bool `json:"binary"`
Content string `json:"content"`
RefName string `json:"refName"`
Path string `json:"path"`
Size uint64 `json:"size"`
}
type PumpType string
const (
PumpTypeHeartBeat = "heart_beat"
PumpTypeRequestAPIDocContent = "request_api_doc_content"
PumpTypeResponseAPIDocContent = "response_api_doc_content"
PumpTypeRequestAutoSaveAPIDoc = "request_auth_save_api_doc"
PumpTypeResponseAutoSaveAPIDoc = "response_auto_save_api_doc"
PumpTypeRequestCommitAPIDoc = "request_commit_api_doc"
PumpTypeResponseCommitAPIDoc = "response_commit_api_doc"
)
type WebsocketRequest struct {
SessionID string `json:"sessionID"`
MessageID uint64 `json:"messageID"`
Type string `json:"type"`
CreatedAt time.Time `json:"createdAt,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
type WsAPIDocHeartBeatReqData struct {
Pinode string `json:"pinode"`
Inode string `json:"inode"`
}
type WsAPIDocAutoSaveReqData struct {
Pinode string `json:"pinode"`
Inode string `json:"inode"`
Content string `json:"content"`
}
type WsAPIDocHandShakeReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *FileTreeDetailURI
}
type ListSchemasReq struct {
OrgID uint64
Identity *IdentityInfo
QueryParams *ListSchemasQueryParams
}
type ListSchemasQueryParams struct {
// branch 节点的 inode,
// 在实现中, 如果传了 branch 以下节点的 inode, 也会被处理成 branch 节点的 inode
Inode string `json:"inode"`
// 如果不传 inode, 就必须传 appID 和 branch
AppID string `json:"appID"`
Branch string `json:"branch"`
}