~sircmpwn/lists.sr.ht

lists.sr.ht/api/graph/schema.graphqls -rw-r--r-- 13.0 KiB
4d09ac43Drew DeVault default_query: write ops are now supported 30 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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# This schema definition is available in the public domain, or under the terms
# of CC-0, at your choice.

# String of the format %Y-%m-%dT%H:%M:%SZ
scalar Time
# Opaque string
scalar Cursor
# URL from which some secondary data may be retrieved. You must provide the
# same Authentication header to this address as you did to the GraphQL resolver
# which provided it. The URL is not guaranteed to be consistent for an extended
# length of time; applications should submit a new GraphQL query each time they
# wish to access the data at the provided URL.
scalar URL

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

enum AccessScope {
  ACLS          @scopehelp(details: "access control lists")
  EMAILS        @scopehelp(details: "emails")
  LISTS         @scopehelp(details: "mailing lists")
  PATCHES       @scopehelp(details: "patches")
  PROFILE       @scopehelp(details: "profile information")
  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!
}

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

  lists(cursor: Cursor): MailingListCursor @access(scope: LISTS, kind: RO)
  emails(cursor: Cursor): EmailCursor @access(scope: EMAILS, kind: RO)
  threads(cursor: Cursor): ThreadCursor @access(scope: EMAILS, kind: RO)
  patches(cursor: Cursor): PatchsetCursor @access(scope: PATCHES, kind: RO)
}

# A mailbox not associated with a registered user
type Mailbox implements Entity {
  canonicalName: String!
  name: String!
  address: String!
}

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

  # Markdown
  description: String

  # List of globs for permitted or rejected mimetypes on this list
  # e.g. text/*
  permitMime: [String!]!
  rejectMime: [String!]!

  # List of threads on this list in order of most recently bumped
  threads(cursor: Cursor): ThreadCursor! @access(scope: EMAILS, kind: RO)
  # List of emails received on this list in reverse chronological order
  emails(cursor: Cursor): EmailCursor! @access(scope: EMAILS, kind: RO)
  # List of patches received on this list in order of most recently bumped
  patches(cursor: Cursor): PatchsetCursor! @access(scope: PATCHES, kind: RO)

  # True if an import operation is underway for this list
  importing: Boolean!

  # The access that applies to this user for this list
  access: ACL! @access(scope: ACLS, kind: RO)

  # The user's subscription for this list, if any
  subscription: Subscription @access(scope: SUBSCRIPTIONS, kind: RO)

  # URLs to application/mbox archives for this mailing list
  archive: URL!
  last30days: URL!

  #
  # The following resolvers are only available to the list owner:

  # Access control list entries for this mailing list
  acl(cursor: Cursor): MailingListACLCursor! @access(scope: ACLS, kind: RO)
  # Permissions which apply to any non-subscriber
  nonsubscriber: GeneralACL!
  # Permissions which apply to any subscriber
  subscriber: GeneralACL!
  # Permissions which apply to any authenticated account holder
  identified: GeneralACL!
}

interface ACL {
  # Permission to browse or subscribe to emails
  browse: Boolean!
  # Permission to reply to existing threads
  reply: Boolean!
  # Permission to start new threads
  post: Boolean!
  # Permission to moderate the list
  moderate: Boolean!
}

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

  browse: Boolean!
  reply: Boolean!
  post: Boolean!
  moderate: Boolean!
}

# An ACL entry that applies "generally", for example the rights which apply to
# all subscribers to a list.
type GeneralACL implements ACL {
  browse: Boolean!
  reply: Boolean!
  post: Boolean!
  moderate: Boolean!
}

type Thread {
  created: Time!
  updated: Time!
  subject: String!
  replies: Int!
  participants: Int!
  sender: Entity!

  root: Email!

  list: MailingList! @access(scope: LISTS, kind: RO)

  # Replies to this thread, in chronological order
  descendants(cursor: Cursor): EmailCursor!

  # A mailto: URI for replying to the latest message in this thread
  mailto: String!

  # URL to an application/mbox archive of this thread
  mbox: URL!
}

type Email {
  id: Int!

  # The entity which sent this email. Will be a User if it can be associated
  # with an account, or a Mailbox otherwise.
  sender: Entity!
  # Time we received this email (non-forgable).
  received: Time!
  # Time given by Date header (forgable).
  date: Time
  # The Subject header.
  subject: String!
  # The Message-ID header, without angle brackets.
  messageID: String!
  # The In-Reply-To header, if present, without angle brackets.
  inReplyTo: String

  # Provides the value (or values) of a specific header from this email. Note
  # that the returned value is coerced to UTF-8 and may be lossy under certain
  # circumstances.
  header(want: String!): [String!]!
  # Retrieves the value of an address list header, such as To or Cc.
  addressList(want: String!): [Mailbox!]!
  # The decoded text/plain message part of the email, i.e. email body.
  body: String!
  # A URL from which the full raw message envelope may be downloaded.
  envelope: URL!

  thread: Thread!
  parent: Email
  patch: Patch

  patchset: Patchset @access(scope: PATCHES, kind: RO)
  list: MailingList! @access(scope: LISTS, kind: RO)
}

# Information parsed from the subject line of a patch, such that the following:
#
#   [PATCH myproject v2 3/4] Add foo to bar
#
# Will produce:
#
# index: 3
# count: 4
# version: 2
# prefix: "myproject"
# subject: "Add foo to bar"
type Patch {
  index: Int
  count: Int
  version: Int
  prefix: String
  subject: String
}

enum PatchsetStatus {
  UNKNOWN
  PROPOSED
  NEEDS_REVISION
  SUPERSEDED
  APPROVED
  REJECTED
  APPLIED
}

type Patchset {
  id: Int!
  created: Time!
  updated: Time!
  subject: String!
  version: Int!
  prefix: String
  status: PatchsetStatus!
  submitter: Entity!

  coverLetter: Email @access(scope: EMAILS, kind: RO)
  thread: Thread! @access(scope: EMAILS, kind: RO)
  supersededBy: Patchset
  list: MailingList! @access(scope: LISTS, kind: RO)
  patches(cursor: Cursor): EmailCursor! @access(scope: EMAILS, kind: RO)
  tools: [PatchsetTool!]!

  # URL to an application/mbox archive of only the patches in this thread
  mbox: URL!
}

enum ToolIcon {
  PENDING
  WAITING
  SUCCESS
  FAILED
  CANCELLED
}

# Used to add some kind of indicator for a third-party process associated with
# a patchset, such as a CI service validating the change.
type PatchsetTool {
  id: Int!
  created: Time!
  updated: Time!
  icon: ToolIcon!
  details: String!
  patchset: Patchset!
}

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

type MailingListSubscription implements Subscription {
  id: Int!
  created: Time!
  list: MailingList! @access(scope: LISTS, kind: RO)
}

# A cursor for enumerating ACL 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 MailingListACLCursor {
  results: [MailingListACL!]!
  cursor: Cursor
}

# A cursor for enumerating mailing lists
#
# 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 MailingListCursor {
  results: [MailingList!]!
  cursor: Cursor
}

# A cursor for enumerating threads
#
# 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 ThreadCursor {
  results: [Thread!]!
  cursor: Cursor
}

# A cursor for enumerating emails
#
# 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 EmailCursor {
  results: [Email!]!
  cursor: Cursor
}

# A cursor for enumerating patchsets
#
# 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 PatchsetCursor {
  results: [Patchset!]!
  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)

  # Looks up a specific user
  user(id: Int!): User @access(scope: PROFILE, kind: RO)
  userByName(username: String!): User @access(scope: PROFILE, kind: RO)

  # Looks up a specific mailing list
  mailingList(id: Int!): MailingList @access(scope: LISTS, kind: RO)
  mailingListByName(name: String!): MailingList @access(scope: LISTS, kind: RO)
  mailingListByOwner(ownerName: String!, listName: String!): MailingList @access(scope: LISTS, kind: RO)

  # Looks up a specific email by its ID
  email(id: Int!): Email @access(scope: EMAILS, kind: RO)
  # Looks up a specific email by its Message-ID header, including the angle
  # brackets ('<' and '>').
  message(messageID: String!): Email @access(scope: EMAILS, kind: RO)
  # Looks up a patchset by ID
  patchset(id: Int!): Patchset @access(scope: EMAILS, kind: RO)

  # List of mailing lists that the authenticated user has ownership of
  mailingLists(cursor: Cursor): MailingListCursor! @access(scope: LISTS, kind: RO)

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

# You may omit any fields to leave them unchanged.
# TODO: Allow users to change the name of a mailing list
input MailingListInput {
  description: String

  # List of globs for permitted or rejected mimetypes on this list
  # e.g. text/*
  permitMime: [String!]
  rejectMime: [String!]
}

# All fields are required
input ACLInput {
  browse: Boolean!
  reply: Boolean!
  post: Boolean!
  moderate: Boolean!
}

type Mutation {
  # Creates a new mailing list
  createMailingList(
    name: String!,
    description: String): MailingList! @access(scope: LISTS, kind: RW)

  # Updates a mailing list.
  updateMailingList(
    id: Int!,
    input: MailingListInput!): MailingList @access(scope: LISTS, kind: RW)

  # Deletes a mailing list
  deleteMailingList(id: Int!): MailingList @access(scope: LISTS, kind: RW)

  # Adds or updates the ACL for a user on a mailing list
  updateUserACL(
    listID: Int!,
    userID: Int!,
    input: ACLInput!): MailingListACL @access(scope: ACLS, kind: RW)

  # Adds or updates the ACL for an email address on a mailing list
  updateSenderACL(
    listID: Int!,
    address: String!,
    input: ACLInput!): MailingListACL @access(scope: ACLS, kind: RW)

  # Updates the default ACL for a mailing list, which applies to users and
  # senders for whom a more specific ACL does not exist.
  updateMailingListACL(
    listID: Int!,
    input: ACLInput!): MailingList @access(scope: ACLS, kind: RW)

  # Removes a mailing list ACL. Following this, the default mailing list ACL will apply to this user.
  deleteACL(id: Int!): MailingListACL @access(scope: ACLS, kind: RW)

  # Updates the status of a patchset
  updatePatchset(id: Int!, status: PatchsetStatus!): Patchset @access(scope: PATCHES, kind: RW)

  # Create a new patchset tool
  createTool(patchsetID: Int!, details: String!, icon: ToolIcon!): PatchsetTool @access(scope: PATCHES, kind: RW)

  # Updates the status of a patchset tool by its ID
  updateTool(id: Int!, details: String, icon: ToolIcon): PatchsetTool @access(scope: PATCHES, kind: RW)

  # Creates a mailing list subscription
  mailingListSubscribe(listID: Int!): MailingListSubscription @access(scope: SUBSCRIPTIONS, kind: RW)

  # Deletes a mailing list subscription
  mailingListUnsubscribe(listID: Int!): MailingListSubscription @access(scope: SUBSCRIPTIONS, kind: RW)
}