scalar Cursor
scalar Time
scalar Upload
"Used to provide a human-friendly description of an access scope"
directive @scopehelp(details: String!) on ENUM_VALUE
"""
This is used to decorate fields which are only accessible with a personal
access token, and are not available to clients using OAuth 2.0 access tokens.
"""
directive @private on FIELD_DEFINITION
"""
This used to decorate fields which are for internal use, and are not
available to normal API users.
"""
directive @internal on FIELD_DEFINITION
enum AccessScope {
PROFILE @scopehelp(details: "profile information")
REPOSITORIES @scopehelp(details: "repository metadata")
REVISIONS @scopehelp(details: "hg revisions & data")
ACLS @scopehelp(details: "access control lists")
}
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. For the meta.sr.ht API, you have access to all public
information without any special permissions - user profile information,
public keys, and so on.
"""
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
"Optional features"
features: Features!
"Config settings"
settings: Settings!
}
"Describes the status of optional features"
type Features {
artifacts: Boolean!
}
"Instance specific settings"
type Settings {
sshUser: String!
}
enum AccessMode {
"Read-only"
RO
"Read/write"
RW
}
enum Visibility {
"Visible to everyone, listed on your profile"
PUBLIC
"Visible to everyone (if they know the URL), not listed on your profile"
UNLISTED
"Not visible to anyone except those explicitly added to the access list"
PRIVATE
}
interface Entity {
id: Int!
created: Time!
updated: Time!
"""
The canonical name of this entity. For users, this is their username
prefixed with '~'. Additional entity types will be supported in the future.
"""
canonicalName: String!
"Returns a specific repository owned by the entity."
repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
"Returns a list of repositories owned by the entity."
repositories(cursor: Cursor): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
}
type User implements Entity {
id: Int!
created: Time!
updated: Time!
canonicalName: String!
username: String!
email: String!
url: String
location: String
bio: String
repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
repositories(cursor: Cursor): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
}
type Repository {
id: Int!
created: Time!
updated: Time!
owner: Entity! @access(scope: PROFILE, kind: RO)
name: String!
description: String
visibility: Visibility!
"""
The repository's custom README, if set.
NOTICE: This returns unsanitized HTML. It is the client's responsibility to
sanitize this for display on the web, if so desired.
"""
readme: String
"Whether or not this repository is a non-publishing repository."
nonPublishing: Boolean!
accessControlList(cursor: Cursor): ACLCursor! @access(scope: ACLS, kind: RO)
# Mercurial API
"The tip reference for this repository (latest commit)"
tip: Revision @access(scope: REVISIONS, kind: RO)
"""
Returns the list of open heads in the repository (like `hg heads`)
If `rev` is specified, return only open heads on the branch associated with
the given revision (like `hg heads REV`)
"""
heads(cursor: Cursor, rev: String): RevisionCursor! @access(scope: REVISIONS, kind: RO)
"""
Returns a list of commits (like `hg log`)
If `rev` is specified, only show the given commit (like `hg log --rev REV`)
"""
log(cursor: Cursor, rev: String): RevisionCursor! @access(scope: REVISIONS, kind: RO)
"Returns a list of bookmarks"
bookmarks(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
"Returns a list of branches"
branches(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
"Returns a list of tags"
tags(cursor: Cursor): NamedRevisionCursor! @access(scope: REVISIONS, kind: RO)
"Returns a list of files matching the given path"
files(path: String!, revspec: String, cursor: Cursor) : FileCursor! @access(scope: REVISIONS, kind: RO)
"Returns the contents of a file given a relative path and an optional revset"
cat(path: String!, revspec: String) : String @access(scope: REVISIONS, kind: RO)
}
type OAuthClient {
uuid: String!
}
enum WebhookEvent {
REPO_CREATED
REPO_UPDATE
REPO_DELETED
}
interface WebhookSubscription {
id: Int!
events: [WebhookEvent!]!
query: String!
url: String!
"""
If this webhook was registered by an authorized OAuth 2.0 client, this
field is non-null.
"""
client: OAuthClient @private
"All deliveries which have been sent to this webhook."
deliveries(cursor: Cursor): WebhookDeliveryCursor!
"Returns a sample payload for this subscription, for testing purposes"
sample(event: WebhookEvent!): String!
}
type UserWebhookSubscription implements WebhookSubscription {
id: Int!
events: [WebhookEvent!]!
query: String!
url: String!
client: OAuthClient @private
deliveries(cursor: Cursor): WebhookDeliveryCursor!
sample(event: WebhookEvent!): String!
}
type WebhookDelivery {
uuid: String!
date: Time!
event: WebhookEvent!
subscription: WebhookSubscription!
requestBody: String!
"""
These details are provided only after a response is received from the
remote server. If a response is sent whose Content-Type is not text/*, or
cannot be decoded as UTF-8, the response body will be null. It will be
truncated after 64 KiB.
"""
responseBody: String
responseHeaders: String
responseStatus: Int
}
interface WebhookPayload {
uuid: String!
event: WebhookEvent!
date: Time!
}
type RepositoryEvent implements WebhookPayload {
uuid: String!
event: WebhookEvent!
date: Time!
repository: Repository!
}
"""
A cursor for enumerating a list of repositories
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 RepositoryCursor {
results: [Repository]!
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: [ACL]!
cursor: Cursor
}
"""
A cursor for enumerating revisions
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 RevisionCursor {
results: [Revision]!
cursor: Cursor
}
"""
A cursor for enumerating bookmarks, tags, and branches
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 NamedRevisionCursor {
results: [NamedRevision]!
cursor: Cursor
}
"""
A cursor for enumerating files in a repository
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 FileCursor {
results: [File!]!
cursor: Cursor
}
"""
A cursor for enumerating a list of webhook deliveries
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 WebhookDeliveryCursor {
results: [WebhookDelivery!]!
cursor: Cursor
}
"""
A cursor for enumerating a list of webhook 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 WebhookSubscriptionCursor {
results: [WebhookSubscription!]!
cursor: Cursor
}
type ACL {
id: Int!
created: Time!
repository: Repository!
entity: Entity! @access(scope: PROFILE, kind: RO)
mode: AccessMode
}
type Revision {
id: String!
branch: String!
tags: [String]!
author: String!
description: String!
}
type NamedRevision {
name: String!
id: String!
}
type File {
name: String!
}
type Tag {
name: String!
id: String!
}
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 repositories that the authenticated user has access to.
NOTE: in this version of the API, only repositories owned by the
authenticated user are returned, but in the future the default behavior
will be to return all repositories 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.
"""
repositories(cursor: Cursor): RepositoryCursor @access(scope: REPOSITORIES, kind: RO)
"""
Returns a list of user webhook subscriptions. For clients
authenticated with a personal access token, this returns all webhooks
configured by all GraphQL clients for your account. For clients
authenticated with an OAuth 2.0 access token, this returns only webhooks
registered for your client.
"""
userWebhooks(cursor: Cursor): WebhookSubscriptionCursor!
"Returns details of a user webhook subscription by its ID."
userWebhook(id: Int!): WebhookSubscription
"""
Returns information about the webhook currently being processed. This is
not valid during normal queries over HTTP, and will return an error if used
outside of a webhook context.
"""
webhook: WebhookPayload!
}
input RepoInput {
"""
Omit these fields to leave them unchanged, or set them to null to clear
their value.
"""
name: String
description: String
visibility: Visibility
"""
Updates the custom README associated with this repository. Note that the
provided HTML will be sanitized when displayed on the web; see
https://man.sr.ht/markdown/#post-processing
"""
readme: String
"Controls whether this repository is a non-publishing repository."
nonPublishing: Boolean
}
input UserWebhookInput {
url: String!
events: [WebhookEvent!]!
query: String!
}
type Mutation {
"Creates a new mercurial repository"
createRepository(name: String!, visibility: Visibility!, description: String): Repository! @access(scope: REPOSITORIES, kind: RW)
"Updates the metadata for a mercurial repository"
updateRepository(id: Int!, input: RepoInput!): Repository! @access(scope: REPOSITORIES, kind: RW)
"Deletes a mercurial repository"
deleteRepository(id: Int!): Repository! @access(scope: REPOSITORIES, kind: RW)
"Adds or updates a user in the access control list"
updateACL(repoId: Int!, mode: AccessMode!, entity: ID!): ACL! @access(scope: ACLS, kind: RW)
"Deletes an entry from the access control list"
deleteACL(id: Int!): ACL! @access(scope: ACLS, kind: RW)
"""
Creates a new user webhook subscription. When an event from the
provided list of events occurs, the 'query' parameter (a GraphQL query)
will be evaluated and the results will be sent to the provided URL as the
body of an HTTP POST request. The list of events must include at least one
event, and no duplicates.
This query is evaluated in the webhook context, such that query { webhook }
may be used to access details of the event which trigged the webhook. The
query may not make any mutations.
"""
createUserWebhook(config: UserWebhookInput!): WebhookSubscription!
"""
Deletes a user webhook. Any events already queued may still be
delivered after this request completes. Clients authenticated with a
personal access token may delete any webhook registered for their account,
but authorized OAuth 2.0 clients may only delete their own webhooks.
Manually deleting a webhook configured by a third-party client may cause
unexpected behavior with the third-party integration.
"""
deleteUserWebhook(id: Int!): WebhookSubscription!
"""
Deletes the authenticated user's account. Internal use only.
"""
deleteUser: Int! @internal
}