Referencia de la API

Aplicación

Consultar app.capabilities para comprobar la compatibilidad de funciones y app.access junto con los permisos del anfitrión para la autorización. Los ejemplos usan valores sintéticos; sustituir las rutas, ID, entradas y filtros antes de llamar.

Definiciones de tipos

graphql
type Mutation {
  clearAppCache: Boolean!
  restartHttpServer(httpPort: Int, httpsPort: Int): HttpServerState!
  relaunchApp: Boolean!
  requestAccess(feature: AccessFeature!): Boolean!
  setTempValue(key: String!, value: String!): KeyValuePair!
  updateDeviceName(name: String!): Boolean!
}

type Query {
  appCacheSize: Long!
  appUpdate: AppUpdate!
  httpServer: HttpServer!
  app: App!
}

type Subscription {
  httpServerChanged: HttpServer!
  deviceNameUpdated: String!
  accessUpdated: Boolean!
  contentChanged: Boolean!
}

enum AccessFeature {
	IMAGES
	VIDEOS
	AUDIO
	DOCS
	FILES
	CONTACTS
	SMS
	CALLS
	CALL_PHONE
	PHONE_NUMBER
	APPS
	NOTIFICATIONS
	CLIPBOARD
	ADB
}

type App {
	clientId: ID!
	httpPort: Int!
	httpsPort: Int!
	deviceName: String!
	developerMode: Boolean!
	urlToken: String!
	tlsCertificateSha256: String
	appDir: String!
	deviceType: DeviceType!
	capabilities: [Capability!]!
	buildChannel: AppChannelType!
	access: [AccessFeature!]!
	downloadsDir: String!
	debug: Boolean!
}

enum AppChannelType {
	GITHUB
	GOOGLE
	FDROID
}

type AppUpdate {
	currentVersion: String!
	latestVersion: String
	releaseName: String!
	publishedAt: Instant
	hasUpdate: Boolean!
	url: String
}

enum Capability {
	ADB
	BLE
	WIFI_AWARE
	APP_RELAUNCH
	MEDIA_TRASH
	MEDIA_DELETE
	MEDIA_MOVE
	MEDIA_FAVORITE
	APP_UPDATES
	MIRROR_AUDIO
	MEDIA_SCAN
	TELEPHONY
	PACKAGES
	SCREEN_MIRROR
	NOTIFICATIONS
	CLIPBOARD
	DISK_MANAGER
	HTTP_SERVER
}

enum DeviceType {
	COMPUTER
	PHONE
	TABLET
	TV
	NAS
	OTHER
}

type HttpServer {
	state: HttpServerState!
	addresses: [String!]!
	onlineClients: [ID!]!
	remoteAccess: Boolean!
	mdnsHostname: String!
}

type HttpServerState {
	revision: Long!
	restarting: Boolean!
	httpPort: Int!
	httpsPort: Int!
	error: String!
}

scalar Instant

type KeyValuePair {
	key: String!
	value: String!
}

scalar Long

Operaciones

mutation

clearAppCache

Eliminar los archivos desechables de la caché de la aplicación.

graphql
mutation clearAppCache {
  clearAppCache
}
mutation

restartHttpServer

Cambiar los puertos HTTP/HTTPS y esperar a que los nuevos escuchadores estén listos. Requiere HTTP_SERVER. Devuelve los puertos reales; vuelva a conectarse si cambia la dirección actual.

graphql
mutation restartHttpServer($httpPort: Int, $httpsPort: Int) {
  restartHttpServer(httpPort: $httpPort, httpsPort: $httpsPort) { revision restarting httpPort httpsPort error }
}
query

appCacheSize

Devolver el uso de la caché de la aplicación en bytes.

graphql
query appCacheSize {
  appCacheSize
}
query

appUpdate

Consultar la información disponible sobre actualizaciones de la aplicación.

graphql
query appUpdate {
  appUpdate { currentVersion latestVersion releaseName publishedAt hasUpdate url }
}
query

httpServer

Consultar el estado HTTP/HTTPS, las direcciones de la red local, los clientes conectados y el acceso remoto. Requiere autenticación y HTTP_SERVER.

graphql
query httpServer {
  httpServer { addresses onlineClients remoteAccess mdnsHostname }
}
subscription

httpServerChanged

Recibe el estado actual del servidor HTTP al suscribirse y cuando cambien los puertos de escucha, la red, los clientes conectados o las preferencias. Requiere un cliente autenticado y compatibilidad con HTTP_SERVER. Cancela la suscripción al salir de la página y vuelve a suscribirte al regresar.

graphql
subscription httpServerChanged {
  httpServerChanged { addresses onlineClients remoteAccess mdnsHostname }
}
subscription

deviceNameUpdated

Recibir el nombre visible actualizado del dispositivo.

graphql
subscription deviceNameUpdated {
  deviceNameUpdated
}
subscription

accessUpdated

Recibir una señal cuando cambie la autorización de funciones del dispositivo.

graphql
subscription accessUpdated {
  accessUpdated
}
subscription

contentChanged

Recibir una señal cuando cambie el contenido almacenado.

graphql
subscription contentChanged {
  contentChanged
}
mutation

relaunchApp

Reiniciar el proceso de PlainApp en el dispositivo.

graphql
# The app restarts itself; the response only acknowledges that the
# request was accepted, since the connection dies with the process.
mutation relaunchApp {
  relaunchApp
}
mutation

requestAccess

Solicitar autorización del dispositivo para una función compatible; puede requerir la intervención del usuario en el dispositivo.

graphql
mutation requestAccess($feature: AccessFeature!) {
  requestAccess(feature: $feature)
}
mutation

setTempValue

Establecer y devolver un par clave/valor transitorio en memoria; no son datos persistentes de Key Value.

graphql
mutation setTempValue($key: String!, $value: String!) {
  setTempValue(key: $key, value: $value) { key value }
}
mutation

updateDeviceName

Cambiar el nombre visible del dispositivo mostrado en la interfaz web y anunciado a los pares vinculados.

graphql
# Renaming the device also re-publishes the mDNS advertisement, so a
# client that waits for the new name to appear does see it.
mutation updateDeviceName($name: String!) {
  updateDeviceName(name: $name)
}
query

app

Consultar la identidad, configuración, capacidades y autorización de la aplicación. app.urlToken pertenece a la sesión que llama y cifra enlaces de recursos; no es el token de autenticación de GraphQL.

graphql
# Everything a client needs to reach this device: its identity, the
# port it listens on and the token that authorises it.
query app {
  app { clientId httpPort httpsPort deviceName developerMode urlToken tlsCertificateSha256 appDir }
}