| 1 |
# This schema definition is available in the public domain, or under the terms |
| 2 |
# of CC-0, at your choice. |
| 3 |
scalar Cursor |
| 4 |
scalar Time |
| 5 |
scalar Upload |
| 6 |
""" |
| 7 |
URL from which some secondary data may be retrieved. You must provide the |
| 8 |
same Authentication header to this address as you did to the GraphQL resolver |
| 9 |
which provided it. The URL is not guaranteed to be consistent for an extended |
| 10 |
length of time; applications should submit a new GraphQL query each time they |
| 11 |
wish to access the data at the provided URL. |
| 12 |
""" |
| 13 |
scalar URL |
| 14 |
|
| 15 |
""" |
| 16 |
This is used to decorate fields which are only accessible with a personal |
| 17 |
access token, and are not available to clients using OAuth 2.0 access tokens. |
| 18 |
""" |
| 19 |
directive @private on FIELD_DEFINITION |
| 20 |
|
| 21 |
"Used to provide a human-friendly description of an access scope." |
| 22 |
directive @scopehelp(details: String!) on ENUM_VALUE |
| 23 |
|
| 24 |
""" |
| 25 |
This used to decorate fields which are for internal use, and are not |
| 26 |
available to normal API users. |
| 27 |
""" |
| 28 |
directive @internal on FIELD_DEFINITION |
| 29 |
|
| 30 |
enum AccessScope { |
| 31 |
PROFILE @scopehelp(details: "profile information") |
| 32 |
PASTES @scopehelp(details: "pastes") |
| 33 |
} |
| 34 |
|
| 35 |
enum AccessKind { |
| 36 |
RO @scopehelp(details: "read") |
| 37 |
RW @scopehelp(details: "read and write") |
| 38 |
} |
| 39 |
|
| 40 |
""" |
| 41 |
Decorates fields for which access requires a particular OAuth 2.0 scope with |
| 42 |
read or write access. For the meta.sr.ht API, you have access to all public |
| 43 |
information without any special permissions - user profile information, |
| 44 |
public keys, and so on. |
| 45 |
""" |
| 46 |
directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION |
| 47 |
|
| 48 |
enum Visibility { |
| 49 |
"Visible to everyone, listed on your profile" |
| 50 |
PUBLIC |
| 51 |
"Visible to everyone (if they know the URL), not listed on your profile" |
| 52 |
UNLISTED |
| 53 |
"Not visible to anyone except those explicitly added to the access list" |
| 54 |
PRIVATE |
| 55 |
} |
| 56 |
|
| 57 |
# https://semver.org |
| 58 |
type Version { |
| 59 |
major: Int! |
| 60 |
minor: Int! |
| 61 |
patch: Int! |
| 62 |
buildVersion: String! |
| 63 |
buildDate: String! |
| 64 |
""" |
| 65 |
If this API version is scheduled for deprecation, this is the date on which |
| 66 |
it will stop working; or null if this API version is not scheduled for |
| 67 |
deprecation. |
| 68 |
""" |
| 69 |
deprecationDate: Time |
| 70 |
} |
| 71 |
|
| 72 |
interface Entity { |
| 73 |
id: Int! |
| 74 |
created: Time! |
| 75 |
""" |
| 76 |
The canonical name of this entity. For users, this is their username |
| 77 |
prefixed with '~'. Additional entity types will be supported in the future. |
| 78 |
""" |
| 79 |
canonicalName: String! |
| 80 |
|
| 81 |
pastes(cursor: Cursor): PasteCursor! @access(scope: PASTES, kind: RO) |
| 82 |
} |
| 83 |
|
| 84 |
type User implements Entity { |
| 85 |
id: Int! |
| 86 |
created: Time! |
| 87 |
canonicalName: String! |
| 88 |
|
| 89 |
pastes(cursor: Cursor): PasteCursor! @access(scope: PASTES, kind: RO) |
| 90 |
|
| 91 |
username: String! |
| 92 |
} |
| 93 |
|
| 94 |
type Paste { |
| 95 |
id: String! |
| 96 |
created: Time! |
| 97 |
visibility: Visibility! |
| 98 |
files: [File!]! |
| 99 |
|
| 100 |
user: Entity! @access(scope: PROFILE, kind: RO) |
| 101 |
} |
| 102 |
|
| 103 |
type File { |
| 104 |
filename: String |
| 105 |
hash: String! |
| 106 |
contents: URL! |
| 107 |
} |
| 108 |
|
| 109 |
""" |
| 110 |
A cursor for enumerating pastes |
| 111 |
|
| 112 |
If there are additional results available, the cursor object may be passed |
| 113 |
back into the same endpoint to retrieve another page. If the cursor is null, |
| 114 |
there are no remaining results to return. |
| 115 |
""" |
| 116 |
type PasteCursor { |
| 117 |
results: [Paste!]! |
| 118 |
cursor: Cursor |
| 119 |
} |
| 120 |
|
| 121 |
type OAuthClient { |
| 122 |
uuid: String! |
| 123 |
} |
| 124 |
|
| 125 |
enum WebhookEvent { |
| 126 |
PASTE_CREATED |
| 127 |
PASTE_UPDATED |
| 128 |
PASTE_DELETED |
| 129 |
} |
| 130 |
|
| 131 |
interface WebhookSubscription { |
| 132 |
id: Int! |
| 133 |
events: [WebhookEvent!]! |
| 134 |
query: String! |
| 135 |
url: String! |
| 136 |
|
| 137 |
""" |
| 138 |
If this webhook was registered by an authorized OAuth 2.0 client, this |
| 139 |
field is non-null. |
| 140 |
""" |
| 141 |
client: OAuthClient @private |
| 142 |
|
| 143 |
"All deliveries which have been sent to this webhook." |
| 144 |
deliveries(cursor: Cursor): WebhookDeliveryCursor! |
| 145 |
|
| 146 |
"Returns a sample payload for this subscription, for testing purposes" |
| 147 |
sample(event: WebhookEvent!): String! |
| 148 |
} |
| 149 |
|
| 150 |
type UserWebhookSubscription implements WebhookSubscription { |
| 151 |
id: Int! |
| 152 |
events: [WebhookEvent!]! |
| 153 |
query: String! |
| 154 |
url: String! |
| 155 |
client: OAuthClient @private |
| 156 |
deliveries(cursor: Cursor): WebhookDeliveryCursor! |
| 157 |
sample(event: WebhookEvent!): String! |
| 158 |
} |
| 159 |
|
| 160 |
type WebhookDelivery { |
| 161 |
uuid: String! |
| 162 |
date: Time! |
| 163 |
event: WebhookEvent! |
| 164 |
subscription: WebhookSubscription! |
| 165 |
requestBody: String! |
| 166 |
|
| 167 |
""" |
| 168 |
These details are provided only after a response is received from the |
| 169 |
remote server. If a response is sent whose Content-Type is not text/*, or |
| 170 |
cannot be decoded as UTF-8, the response body will be null. It will be |
| 171 |
truncated after 64 KiB. |
| 172 |
""" |
| 173 |
responseBody: String |
| 174 |
responseHeaders: String |
| 175 |
responseStatus: Int |
| 176 |
} |
| 177 |
|
| 178 |
interface WebhookPayload { |
| 179 |
uuid: String! |
| 180 |
event: WebhookEvent! |
| 181 |
date: Time! |
| 182 |
} |
| 183 |
|
| 184 |
type PasteEvent implements WebhookPayload { |
| 185 |
uuid: String! |
| 186 |
event: WebhookEvent! |
| 187 |
date: Time! |
| 188 |
|
| 189 |
paste: Paste! |
| 190 |
} |
| 191 |
|
| 192 |
""" |
| 193 |
A cursor for enumerating a list of webhook deliveries |
| 194 |
|
| 195 |
If there are additional results available, the cursor object may be passed |
| 196 |
back into the same endpoint to retrieve another page. If the cursor is null, |
| 197 |
there are no remaining results to return. |
| 198 |
""" |
| 199 |
type WebhookDeliveryCursor { |
| 200 |
results: [WebhookDelivery!]! |
| 201 |
cursor: Cursor |
| 202 |
} |
| 203 |
|
| 204 |
""" |
| 205 |
A cursor for enumerating a list of webhook subscriptions |
| 206 |
|
| 207 |
If there are additional results available, the cursor object may be passed |
| 208 |
back into the same endpoint to retrieve another page. If the cursor is null, |
| 209 |
there are no remaining results to return. |
| 210 |
""" |
| 211 |
type WebhookSubscriptionCursor { |
| 212 |
results: [WebhookSubscription!]! |
| 213 |
cursor: Cursor |
| 214 |
} |
| 215 |
|
| 216 |
type Query { |
| 217 |
"Returns API version information." |
| 218 |
version: Version! |
| 219 |
|
| 220 |
"Returns the authenticated user." |
| 221 |
me: User! @access(scope: PROFILE, kind: RO) |
| 222 |
|
| 223 |
"Returns a specific user." |
| 224 |
user(username: String!): User @access(scope: PROFILE, kind: RO) |
| 225 |
|
| 226 |
"Returns a list of pastes created by the authenticated user." |
| 227 |
pastes(cursor: Cursor): PasteCursor @access(scope: PASTES, kind: RO) |
| 228 |
|
| 229 |
"Returns a paste by its ID." |
| 230 |
paste(id: String!): Paste @access(scope: PASTES, kind: RO) |
| 231 |
|
| 232 |
""" |
| 233 |
Returns a list of user webhook subscriptions. For clients |
| 234 |
authenticated with a personal access token, this returns all webhooks |
| 235 |
configured by all GraphQL clients for your account. For clients |
| 236 |
authenticated with an OAuth 2.0 access token, this returns only webhooks |
| 237 |
registered for your client. |
| 238 |
""" |
| 239 |
userWebhooks(cursor: Cursor): WebhookSubscriptionCursor! |
| 240 |
|
| 241 |
"Returns details of a user webhook subscription by its ID." |
| 242 |
userWebhook(id: Int!): WebhookSubscription |
| 243 |
|
| 244 |
""" |
| 245 |
Returns information about the webhook currently being processed. This is |
| 246 |
not valid during normal queries over HTTP, and will return an error if used |
| 247 |
outside of a webhook context. |
| 248 |
""" |
| 249 |
webhook: WebhookPayload! |
| 250 |
} |
| 251 |
|
| 252 |
input UserWebhookInput { |
| 253 |
url: String! |
| 254 |
events: [WebhookEvent!]! |
| 255 |
query: String! |
| 256 |
} |
| 257 |
|
| 258 |
type Mutation { |
| 259 |
""" |
| 260 |
Creates a new paste from a list of files. The files uploaded must have a |
| 261 |
content type of text/* and must be decodable as UTF-8. |
| 262 |
|
| 263 |
Note that the web UI will replace CRLF with LF in uploads; the GraphQL API |
| 264 |
does not. |
| 265 |
""" |
| 266 |
create( |
| 267 |
files: [Upload!]!, |
| 268 |
visibility: Visibility!, |
| 269 |
): Paste! @access(scope: PASTES, kind: RW) |
| 270 |
|
| 271 |
"Updates the visibility of a paste." |
| 272 |
update(id: String!, visibility: Visibility!): Paste @access(scope: PASTES, kind: RW) |
| 273 |
|
| 274 |
"Deletes a paste by its ID." |
| 275 |
delete(id: String!): Paste @access(scope: PASTES, kind: RW) |
| 276 |
|
| 277 |
""" |
| 278 |
Creates a new user webhook subscription. When an event from the |
| 279 |
provided list of events occurs, the 'query' parameter (a GraphQL query) |
| 280 |
will be evaluated and the results will be sent to the provided URL as the |
| 281 |
body of an HTTP POST request. The list of events must include at least one |
| 282 |
event, and no duplicates. |
| 283 |
|
| 284 |
This query is evaluated in the webhook context, such that query { webhook } |
| 285 |
may be used to access details of the event which trigged the webhook. The |
| 286 |
query may not make any mutations. |
| 287 |
""" |
| 288 |
createUserWebhook(config: UserWebhookInput!): WebhookSubscription! |
| 289 |
|
| 290 |
""" |
| 291 |
Deletes a user webhook. Any events already queued may still be |
| 292 |
delivered after this request completes. Clients authenticated with a |
| 293 |
personal access token may delete any webhook registered for their account, |
| 294 |
but authorized OAuth 2.0 clients may only delete their own webhooks. |
| 295 |
Manually deleting a webhook configured by a third-party client may cause |
| 296 |
unexpected behavior with the third-party integration. |
| 297 |
""" |
| 298 |
deleteUserWebhook(id: Int!): WebhookSubscription! |
| 299 |
|
| 300 |
""" |
| 301 |
Deletes the authenticated user's account. Internal use only. |
| 302 |
""" |
| 303 |
deleteUser: Int! @internal |
| 304 |
} |