~sircmpwn/todo.sr.ht

todo.sr.ht/api/graph/schema.graphqls -rw-r--r-- 11.0 KiB
395c3a6cDrew DeVault API: clarify schema license 17 days ago
                                                                                
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# This schema definition is available in the public domain, or under the terms
# of CC-0, at your choice.
scalar Cursor
scalar Time

# Used to provide a human-friendly description of an access scope
directive @scopehelp(details: String!) on ENUM_VALUE

enum AccessScope {
  PROFILE       @scopehelp(details: "profile information")
  TRACKERS      @scopehelp(details: "trackers")
  TICKETS       @scopehelp(details: "tickets")
  ACLS          @scopehelp(details: "access control lists")
  EVENTS        @scopehelp(details: "events")
  SUBSCRIPTIONS @scopehelp(details: "tracker & ticket subscriptions")
}

enum AccessKind {
  RO @scopehelp(details: "read")
  RW @scopehelp(details: "read and write")
}

# Decorates fields for which access requires a particular OAuth 2.0 scope with
# read or write access.
directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION

# https://semver.org
type Version {
  major: Int!
  minor: Int!
  patch: Int!

  # If this API version is scheduled for deprecation, this is the date on which
  # it will stop working; or null if this API version is not scheduled for
  # deprecation.
  deprecationDate: Time
}

interface Entity {
  canonicalName: String!
}

type User implements Entity {
  id: Int!
  created: Time!
  updated: Time!
  canonicalName: String!
  username: String!
  email: String!
  url: String
  location: String
  bio: String

  trackers(cursor: Cursor): TrackerCursor! @access(scope: TRACKERS, kind: RO)
}

type EmailAddress implements Entity {
  canonicalName: String!

  # "jdoe@example.org" of "Jane Doe <jdoe@example.org>"
  mailbox: String!
  # "Jane Doe" of "Jane Doe <jdoe@example.org>"
  name: String
}

type ExternalUser implements Entity {
  canonicalName: String!

  # <service>:<service specific details...>
  # e.g. github:ddevault
  externalId: String!
  # The canonical external URL for this user, e.g. https://github.com/ddevault
  externalUrl: String
}

type Tracker {
  id: Int!
  created: Time!
  updated: Time!
  owner: Entity! @access(scope: PROFILE, kind: RO)
  name: String!
  description: String

  tickets(cursor: Cursor): TicketCursor! @access(scope: TICKETS, kind: RO)
  labels(cursor: Cursor): LabelCursor!

  # Only available to the tracker owner:
  acls(cursor: Cursor): ACLCursor! @access(scope: ACLS, kind: RO)

  # If the authenticated user is subscribed to this tracker, this is that
  # subscription.
  subscription: TrackerSubscription @access(scope: SUBSCRIPTIONS, kind: RO)

  # The access control list entry (or the default ACL) which describes the
  # authenticated user's permissions with respect to this tracker.
  acl: ACL
}

enum TicketStatus {
  REPORTED
  CONFIRMED
  IN_PROGRESS
  PENDING
  RESOLVED
}

enum TicketResolution {
  UNRESOLVED
  FIXED
  IMPLEMENTED
  WONT_FIX
  BY_DESIGN
  INVALID
  DUPLICATE
  NOT_OUR_BUG
}

enum Authenticity {
  # The server vouches for this information as entered verbatim by the
  # attributed entity.
  AUTHENTIC
  # The server does not vouch for this information as entered by the attributed
  # entity, no authentication was provided.
  UNAUTHENTICATED
  # The server has evidence that the information has likely been manipulated by
  # a third-party.
  TAMPERED
}

type Ticket {
  id: Int!
  created: Time!
  updated: Time!
  submitter: Entity! @access(scope: PROFILE, kind: RO)
  tracker: Tracker! @access(scope: TRACKERS, kind: RO)

  # Canonical ticket reference string; may be used in comments to identify the
  # ticket from anywhere.
  ref: String!

  subject: String!
  body: String
  status: TicketStatus!
  resolution: TicketResolution!
  authenticity: Authenticity!

  labels: [Label]!
  assignees: [Entity]! @access(scope: PROFILE, kind: RO)
  events(cursor: Cursor): EventCursor! @access(scope: EVENTS, kind: RO)

  # If the authenticated user is subscribed to this ticket, this is that
  # subscription.
  subscription: TicketSubscription @access(scope: SUBSCRIPTIONS, kind: RO)

  # The access control list entry (or the default ACL) which describes the
  # authenticated user's permissions with respect to this ticket.
  acl: ACL
}

interface ACL {
  # Permission to view tickets
  browse: Boolean!
  # Permission to submit tickets
  submit: Boolean!
  # Permission to comment on tickets
  comment: Boolean!
  # Permission to edit tickets
  edit: Boolean!
  # Permission to resolve, re-open, transfer, or label tickets
  triage: Boolean!
}

# These ACLs are configured for specific entities, and may be used to expand or
# constrain the rights of a participant.
type TrackerACL implements ACL {
  id: Int!
  created: Time!
  tracker: Tracker! @access(scope: TRACKERS, kind: RO)
  entity: Entity! @access(scope: PROFILE, kind: RO)

  browse: Boolean!
  submit: Boolean!
  comment: Boolean!
  edit: Boolean!
  triage: Boolean!
}

# These ACL policies are applied non-specifically, e.g. the default ACL for all
# authenticated users.
type DefaultACL implements ACL {
  browse: Boolean!
  submit: Boolean!
  comment: Boolean!
  edit: Boolean!
  triage: Boolean!
}

type Label {
  id: Int!
  created: Time!
  name: String!
  tracker: Tracker! @access(scope: TRACKERS, kind: RO)

  # In CSS hexadecimal format
  backgroundColor: String!
  foregroundColor: String!

  tickets(cursor: Cursor): TicketCursor! @access(scope: TICKETS, kind: RO)
}

enum EventType {
  CREATED
  COMMENT
  STATUS_CHANGE
  LABEL_ADDED
  LABEL_REMOVED
  ASSIGNED_USER
  UNASSIGNED_USER
  USER_MENTIONED
  TICKET_MENTIONED
}

# Represents an event which affects a ticket. Multiple changes can occur in a
# single event, and are enumerated in the "changes" field.
type Event {
  id: Int!
  created: Time!
  changes: [EventDetail]!

  ticket: Ticket! @access(scope: TICKETS, kind: RO)
}

interface EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
}

type Created implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  author: Entity! @access(scope: PROFILE, kind: RO)
}

type Assignment implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)

  assigner: Entity! @access(scope: PROFILE, kind: RO)
  assignee: Entity! @access(scope: PROFILE, kind: RO)
}

type Comment implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  author: Entity! @access(scope: PROFILE, kind: RO)

  text: String!
  authenticity: Authenticity!

  # If this comment has been edited, this field points to the new revision.
  supersededBy: Comment
}

type LabelUpdate implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  labeler: Entity! @access(scope: PROFILE, kind: RO)
  label: Label!
}

type StatusChange implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  editor: Entity! @access(scope: PROFILE, kind: RO)

  oldStatus: TicketStatus!
  newStatus: TicketStatus!
  oldResolution: TicketResolution!
  newResolution: TicketResolution!
}

type UserMention implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  author: Entity! @access(scope: PROFILE, kind: RO)
  mentioned: Entity! @access(scope: PROFILE, kind: RO)
}

type TicketMention implements EventDetail {
  eventType: EventType!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
  author: Entity! @access(scope: PROFILE, kind: RO)
  mentioned: Ticket! @access(scope: TICKETS, kind: RO)
}

interface Subscription {
  id: Int!
  created: Time!
}

# A tracker subscription will notify a participant of all activity for a
# tracker, including all new tickets and their events.
type TrackerSubscription implements Subscription {
  id: Int!
  created: Time!
  tracker: Tracker! @access(scope: TRACKERS, kind: RO)
}

# A ticket subscription will notify a participant when activity occurs on a
# ticket.
type TicketSubscription implements Subscription {
  id: Int!
  created: Time!
  ticket: Ticket! @access(scope: TICKETS, kind: RO)
}

# A cursor for enumerating trackers
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type TrackerCursor {
  results: [Tracker]!
  cursor: Cursor
}

# A cursor for enumerating tickets
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type TicketCursor {
  results: [Ticket]!
  cursor: Cursor
}

# A cursor for enumerating labels
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type LabelCursor {
  results: [Label]!
  cursor: Cursor
}

# A cursor for enumerating access control list entries
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type ACLCursor {
  results: [TrackerACL]!
  cursor: Cursor
}

# A cursor for enumerating events
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type EventCursor {
  results: [Event]!
  cursor: Cursor
}

# A cursor for enumerating subscriptions
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
type SubscriptionCursor {
  results: [Subscription]!
  cursor: Cursor
}

type Query {
  # Returns API version information.
  version: Version!

  # Returns the authenticated user.
  me: User! @access(scope: PROFILE, kind: RO)

  # Returns a specific user.
  user(username: String!): User @access(scope: PROFILE, kind: RO)

  # Returns trackers that the authenticated user has access to.
  #
  # NOTE: in this version of the API, only trackers owned by the authenticated
  # user are returned, but in the future the default behavior will be to return
  # all trackers that the user either (1) has been given explicit access to via
  # ACLs or (2) has implicit access to either by ownership or group membership.
  trackers(cursor: Cursor): TrackerCursor @access(scope: TRACKERS, kind: RO)

  tracker(id: Int!): Tracker @access(scope: TRACKERS, kind: RO)

  # Returns a specific tracker, owned by the authenticated user.
  trackerByName(name: String!): Tracker @access(scope: TRACKERS, kind: RO)

  # Returns a specific tracker, owned by the given canonical name (e.g.
  # "~sircmpwn").
  trackerByOwner(owner: String!, tracker: String!): Tracker @access(scope: TRACKERS, kind: RO)

  # List of events which the authenticated user is subscribed to or implicated
  # in, ordered by the event date (recent events first).
  events(cursor: Cursor): EventCursor @access(scope: EVENTS, kind: RO)

  # List of subscriptions of the authenticated user.
  subscriptions(cursor: Cursor): SubscriptionCursor @access(scope: SUBSCRIPTIONS, kind: RO)
}