Debian Codegraph @

srht/hgsrht/schema.graphqls

raw
1 scalar Cursor
2 scalar Time
3 scalar Upload
4
5 "Used to provide a human-friendly description of an access scope"
6 directive @scopehelp(details: String!) on ENUM_VALUE
7
8 """
9 This is used to decorate fields which are only accessible with a personal
10 access token, and are not available to clients using OAuth 2.0 access tokens.
11 """
12 directive @private on FIELD_DEFINITION
13
14 """
15 This used to decorate fields which are for internal use, and are not
16 available to normal API users.
17 """
18 directive @internal on FIELD_DEFINITION
19
20 enum AccessScope {
21 PROFILE @scopehelp(details: "profile information")
22 REPOSITORIES @scopehelp(details: "repository metadata")
23 REVISIONS @scopehelp(details: "hg revisions & data")
24 ACLS @scopehelp(details: "access control lists")
25 }
26
27 enum AccessKind {
28 RO @scopehelp(details: "read")
29 RW @scopehelp(details: "read and write")
30 }
31
32 """
33 Decorates fields for which access requires a particular OAuth 2.0 scope with
34 read or write access. For the meta.sr.ht API, you have access to all public
35 information without any special permissions - user profile information,
36 public keys, and so on.
37 """
38 directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION
39
40 # https://semver.org
41 type Version {
42 major: Int!
43 minor: Int!
44 patch: Int!
45 buildVersion: String!
46 buildDate: String!
47
48 """
49 If this API version is scheduled for deprecation, this is the date on which
50 it will stop working; or null if this API version is not scheduled for
51 deprecation.
52 """
53 deprecationDate: Time
54
55 "Optional features"
56 features: Features!
57
58 "Config settings"
59 settings: Settings!
60 }
61
62 "Describes the status of optional features"
63 type Features {
64 artifacts: Boolean!
65 }
66
67 "Instance specific settings"
68 type Settings {
69 sshUser: String!
70 }
71
72 enum AccessMode {
73 "Read-only"
74 RO
75 "Read/write"
76 RW
77 }
78
79 enum Visibility {
80 "Visible to everyone, listed on your profile"
81 PUBLIC
82 "Visible to everyone (if they know the URL), not listed on your profile"
83 UNLISTED
84 "Not visible to anyone except those explicitly added to the access list"
85 PRIVATE
86 }
87
88 interface Entity {
89 id: Int!
90 created: Time!
91 updated: Time!
92 """
93 The canonical name of this entity. For users, this is their username
94 prefixed with '~'. Additional entity types will be supported in the future.
95 """
96 canonicalName: String!
97
98 "Returns a specific repository owned by the entity."
99 repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
100
101 "Returns a list of repositories owned by the entity."
102 repositories(cursor: Cursor): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
103 }
104
105 type User implements Entity {
106 id: Int!
107 created: Time!
108 updated: Time!
109 canonicalName: String!
110 username: String!
111 email: String!
112 url: String
113 location: String
114 bio: String
115
116 repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
117 repositories(cursor: Cursor): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
118 }
119
120 type Repository {
121 id: Int!
122 rid: ID!
123 created: Time!
124 updated: Time!
125 owner: Entity! @access(scope: PROFILE, kind: RO)
126 name: String!
127 description: String
128 visibility: Visibility!
129
130 """
131 The repository's custom README, if set.
132
133 NOTICE: This returns unsanitized HTML. It is the client's responsibility to
134 sanitize this for display on the web, if so desired.
135 """
136 readme: String
137
138 "Whether or not this repository is a non-publishing repository."
139 nonPublishing: Boolean!
140
141 accessControlList(cursor: Cursor): ACLCursor! @access(scope: ACLS, kind: RO)
142
143 # Mercurial API
144
145 "The tip reference for this repository (latest commit)"
146 tip: Revision @access(scope: REVISIONS, kind: RO)
147
148 """
149 Returns the list of open heads in the repository (like `hg heads`)
150 If `rev` is specified, return only open heads on the branch associated with
151 the given revision (like `hg heads REV`)
152 """
153 heads(cursor: Cursor, rev: String): RevisionCursor! @access(scope: REVISIONS, kind: RO)
154
155 """
156 Returns a list of commits (like `hg log`)
157 If `rev` is specified, only show the given commit (like `hg log --rev REV`)
158 """
159 log(cursor: Cursor, rev: String): RevisionCursor! @access(scope: REVISIONS, kind: RO)
160
161 "Returns a list of bookmarks"
162 bookmarks(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
163
164 "Returns a list of branches"
165 branches(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
166
167 "Returns a list of tags"
168 tags(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
169
170 "Returns a list of files matching the given path"
171 files(path: String!, revspec: String, cursor: Cursor) : FileCursor! @access(scope: REVISIONS, kind: RO)
172
173 "Returns the contents of a file given a relative path and an optional revset"
174 cat(path: String!, revspec: String) : String @access(scope: REVISIONS, kind: RO)
175 }
176
177 type OAuthClient {
178 uuid: String!
179 }
180
181 enum WebhookEvent {
182 REPO_CREATED
183 REPO_UPDATE
184 REPO_DELETED
185 }
186
187 interface WebhookSubscription {
188 id: Int!
189 events: [WebhookEvent!]!
190 query: String!
191 url: String!
192
193 """
194 If this webhook was registered by an authorized OAuth 2.0 client, this
195 field is non-null.
196 """
197 client: OAuthClient @private
198
199 "All deliveries which have been sent to this webhook."
200 deliveries(cursor: Cursor): WebhookDeliveryCursor!
201
202 "Returns a sample payload for this subscription, for testing purposes"
203 sample(event: WebhookEvent!): String!
204 }
205
206 type UserWebhookSubscription implements WebhookSubscription {
207 id: Int!
208 events: [WebhookEvent!]!
209 query: String!
210 url: String!
211 client: OAuthClient @private
212 deliveries(cursor: Cursor): WebhookDeliveryCursor!
213 sample(event: WebhookEvent!): String!
214 }
215
216 type WebhookDelivery {
217 uuid: String!
218 date: Time!
219 event: WebhookEvent!
220 subscription: WebhookSubscription!
221 requestBody: String!
222
223 """
224 These details are provided only after a response is received from the
225 remote server. If a response is sent whose Content-Type is not text/*, or
226 cannot be decoded as UTF-8, the response body will be null. It will be
227 truncated after 64 KiB.
228 """
229 responseBody: String
230 responseHeaders: String
231 responseStatus: Int
232 }
233
234 interface WebhookPayload {
235 uuid: String!
236 event: WebhookEvent!
237 date: Time!
238 }
239
240 type RepositoryEvent implements WebhookPayload {
241 uuid: String!
242 event: WebhookEvent!
243 date: Time!
244
245 repository: Repository!
246 }
247
248 """
249 A cursor for enumerating a list of repositories
250
251 If there are additional results available, the cursor object may be passed
252 back into the same endpoint to retrieve another page. If the cursor is null,
253 there are no remaining results to return.
254 """
255 type RepositoryCursor {
256 results: [Repository]!
257 cursor: Cursor
258 }
259
260 """
261 A cursor for enumerating access control list entries
262
263 If there are additional results available, the cursor object may be passed
264 back into the same endpoint to retrieve another page. If the cursor is null,
265 there are no remaining results to return.
266 """
267 type ACLCursor {
268 results: [ACL]!
269 cursor: Cursor
270 }
271
272 """
273 A cursor for enumerating revisions
274
275 If there are additional results available, the cursor object may be passed
276 back into the same endpoint to retrieve another page. If the cursor is null,
277 there are no remaining results to return.
278 """
279 type RevisionCursor {
280 results: [Revision]!
281 cursor: Cursor
282 }
283
284 """
285 A cursor for enumerating bookmarks, tags, and branches
286
287 If there are additional results available, the cursor object may be passed
288 back into the same endpoint to retrieve another page. If the cursor is null,
289 there are no remaining results to return.
290 """
291 type NamedRevisionCursor {
292 results: [NamedRevision]!
293 cursor: Cursor
294 }
295
296 """
297 A cursor for enumerating files in a repository
298
299 If there are additional results available, the cursor object may be passed
300 back into the same endpoint to retrieve another page. If the cursor is null,
301 there are no remaining results to return.
302 """
303 type FileCursor {
304 results: [File!]!
305 cursor: Cursor
306 }
307
308 """
309 A cursor for enumerating a list of webhook deliveries
310
311 If there are additional results available, the cursor object may be passed
312 back into the same endpoint to retrieve another page. If the cursor is null,
313 there are no remaining results to return.
314 """
315 type WebhookDeliveryCursor {
316 results: [WebhookDelivery!]!
317 cursor: Cursor
318 }
319
320 """
321 A cursor for enumerating a list of webhook subscriptions
322
323 If there are additional results available, the cursor object may be passed
324 back into the same endpoint to retrieve another page. If the cursor is null,
325 there are no remaining results to return.
326 """
327 type WebhookSubscriptionCursor {
328 results: [WebhookSubscription!]!
329 cursor: Cursor
330 }
331
332 type ACL {
333 id: Int!
334 created: Time!
335 repository: Repository!
336 entity: Entity! @access(scope: PROFILE, kind: RO)
337 mode: AccessMode
338 }
339
340 type Revision {
341 id: String!
342 branch: String!
343 tags: [String]!
344 author: String!
345 description: String!
346 }
347
348 type NamedRevision {
349 name: String!
350 id: String!
351 }
352
353 type File {
354 name: String!
355 }
356
357 type Tag {
358 name: String!
359 id: String!
360 }
361
362 type Query {
363 "Returns API version information."
364 version: Version!
365
366 "Returns the authenticated user."
367 me: User! @access(scope: PROFILE, kind: RO)
368
369 "Returns a specific user."
370 user(username: String!): User @access(scope: PROFILE, kind: RO)
371
372 "Looks up a repository by its resource ID."
373 repository(rid: ID!): Repository @access(scope: REPOSITORIES, kind: RO)
374
375 """
376 Returns repositories that the authenticated user has access to.
377
378 NOTE: in this version of the API, only repositories owned by the
379 authenticated user are returned, but in the future the default behavior
380 will be to return all repositories that the user either (1) has been given
381 explicit access to via ACLs or (2) has implicit access to either by
382 ownership or group membership.
383 """
384 repositories(cursor: Cursor): RepositoryCursor @access(scope: REPOSITORIES, kind: RO)
385
386 """
387 Returns a list of user webhook subscriptions. For clients
388 authenticated with a personal access token, this returns all webhooks
389 configured by all GraphQL clients for your account. For clients
390 authenticated with an OAuth 2.0 access token, this returns only webhooks
391 registered for your client.
392 """
393 userWebhooks(cursor: Cursor): WebhookSubscriptionCursor!
394
395 "Returns details of a user webhook subscription by its ID."
396 userWebhook(id: Int!): WebhookSubscription
397
398 """
399 Returns information about the webhook currently being processed. This is
400 not valid during normal queries over HTTP, and will return an error if used
401 outside of a webhook context.
402 """
403 webhook: WebhookPayload!
404 }
405
406 input RepoInput {
407 """
408 Omit these fields to leave them unchanged, or set them to null to clear
409 their value.
410 """
411 name: String
412 description: String
413 visibility: Visibility
414
415 """
416 Updates the custom README associated with this repository. Note that the
417 provided HTML will be sanitized when displayed on the web; see
418 https://man.sr.ht/markdown/#post-processing
419 """
420 readme: String
421
422 "Controls whether this repository is a non-publishing repository."
423 nonPublishing: Boolean
424 }
425
426 input UserWebhookInput {
427 url: String!
428 events: [WebhookEvent!]!
429 query: String!
430 }
431
432 type Mutation {
433 "Creates a new mercurial repository"
434 createRepository(name: String!, visibility: Visibility!, description: String): Repository! @access(scope: REPOSITORIES, kind: RW)
435
436 "Updates the metadata for a mercurial repository"
437 updateRepository(id: Int!, input: RepoInput!): Repository! @access(scope: REPOSITORIES, kind: RW)
438
439 "Deletes a mercurial repository"
440 deleteRepository(id: Int!): Repository! @access(scope: REPOSITORIES, kind: RW)
441
442 "Adds or updates a user in the access control list"
443 updateACL(repoId: Int!, mode: AccessMode!, entity: String!): ACL! @access(scope: ACLS, kind: RW)
444
445 "Deletes an entry from the access control list"
446 deleteACL(id: Int!): ACL! @access(scope: ACLS, kind: RW)
447
448 """
449 Creates a new user webhook subscription. When an event from the
450 provided list of events occurs, the 'query' parameter (a GraphQL query)
451 will be evaluated and the results will be sent to the provided URL as the
452 body of an HTTP POST request. The list of events must include at least one
453 event, and no duplicates.
454
455 This query is evaluated in the webhook context, such that query { webhook }
456 may be used to access details of the event which trigged the webhook. The
457 query may not make any mutations.
458 """
459 createUserWebhook(config: UserWebhookInput!): WebhookSubscription!
460
461 """
462 Deletes a user webhook. Any events already queued may still be
463 delivered after this request completes. Clients authenticated with a
464 personal access token may delete any webhook registered for their account,
465 but authorized OAuth 2.0 clients may only delete their own webhooks.
466 Manually deleting a webhook configured by a third-party client may cause
467 unexpected behavior with the third-party integration.
468 """
469 deleteUserWebhook(id: Int!): WebhookSubscription!
470
471 """
472 Deletes the authenticated user's account. Internal use only.
473 """
474 deleteUser: Int! @internal
475 }