An object containing the constant values of the various states of kited
State | Value | Alias |
---|---|---|
UNSUPPORTED | 0 |
|
UNINSTALLED | 1 |
|
NOT_RUNNING | 2 |
INSTALLED |
NOT_REACHABLE | 3 |
RUNNING |
UNLOGGED | 4 |
REACHABLE |
NOT_WHITELISTED | 5 |
AUTHENTICATED |
WHITELISTED | 6 |
 |
The editorConfig
object is provided as a way for an editor to store information across instances and session. It can be setup with different concrete stores that implements the various solutions to store the data.
By default it is setup with a MemoryStore
that just stores everything in memory (it thus won't persist across session nor instances).
The available stores are:
MemoryStore
: Used as a placeholder, it is also useful in tests.FileStore
: Stores everything on a file at the path specified during creationLocalStore
: When running in a browser environment this store allows you to use thelocalStorage
as a way to store the config data. The store takes akey
which will be used to access the data in the local storage object.
The object exposes two main functions, get
and set
that both returns a promise when invoked.
Storage is done using JSON format, and the path
argument in both methods resolves to a real object in that JSON structure. However, stores implementation only have to deal with strings, the whole serialization/parsing is handled by the editor config object.
KiteAPI.editorConfig.set('path.to.some.data', 'data')
.then(() => KiteAPI.editorConfig.get('path.to.some.data'))
.then(data => {
console.log(data)
// output: data
// store data: { path: { to: { some: 'data' }} }
})
This function is both a proxy to the KiteConnector
method of the same name as well as calling the corresponding function on the Account
object.
Registers a listener to the did-detect-whitelisted-path
event and will be notified when a request for an editor API responds with a 200
. The listener will be invoked with the path that have been detected as whitelisted.
The function returns a disposable object to unregister the listener from this event.
const disposable = KiteAPI.onDidDetectWhitelistedPath(path => {
// path is whitelisted
})
disposable.dispose(); // the listener will no longer receive events
Registers a listener to the did-detect-non-whitelisted-path
event and will be notified when a request for an editor API responds with a 403
. The listener will be invoked with the path that have been detected as not whitelisted.
The function returns a disposable object to unregister the listener from this event.
const disposable = KiteAPI.onDidDetectNonWhitelistedPath(path => {
// path is not whitelisted
})
disposable.dispose(); // the listener will no longer receive events
Makes a request to Kite using KiteConnector.request
and automatically parses the JSON response when the status code was 200
.
KiteAPI.requestJSON({path}).then(data => {
// data is the result of JSON.parse on the response text
})
Makes a GET
request to Kite at the endpoint /clientapi/iskitelocal
. Responds with a boolean resolving Promise to true
in the case of a 200
status code, false
otherwise
KiteAPI.isKiteLocal().then(isLocal => {
// do stuff related to kite-locality
})
Makes a POST
request to Kite at the endpoint /clientapi/settings/${key}
, where the body is set to value
. It automatically parses the JSON response when the status code is 200
KiteAPI.setKiteSetting('some_setting_name', 'a_value')
Makes a GET
request to Kite at the endpoint /clientapi/settings/${key}
. It automatically parses the JSON response when the status code is 200
KiteAPI.getKiteSetting('some_setting').then(settingValue => {
// do something with settingValue
})
Returns a promise that resolves if a user can be authenticated. A user can be authenticated if Kite is reachable and if the user is not already logged into Kite.
KiteAPI.canAuthenticateUser().then(() => {
// user can be authenticated
})
Makes a request to authenticate the user through Kite and returns a promise that will resolve if the authentication succeeds.
KiteAPI.authenticateUser('[email protected]', 'password')
.then(() => {
// User is logged in
})
.catch(err => {
// authentication failed
})
Makes a request to authenticate a user using a session id and returns a promise that will resolve if the authentication succeeds. This function can be used to authenticate a user in Kite whose account have been created using kite.com
API.
KiteAPI.authenticateSessionID('session-id')
.then(() => {
// User is logged in
})
.catch(err => {
// authentication failed
})
Returns a promise that resolves if the path
is part of the whitelist, otherwise the promise will be rejected.
When calling that function, depending on the outcome, a did-detect-whitelisted-path
or did-detect-non-whitelisted-path
event will be dispatched.
KiteAPI.isPathWhitelisted(path)
.then(() => {
// path is whitelisted
})
.catch(err => {
// path is not whitelisted or an error occurred
// err contains the details of the failure
})
Returns a promise that resolves if the path
can be whitelisted.
A path can be whitelisted if it's not already part of the whitelist and if the projectdir
endpoint responds with a 200
.
In case of success, the promise resolves with the path returned by the projectdir
endpoint.
KiteAPI.canWhitelistPath(path).then(projectDir => {
// projectDir can be sent to the whitelist endpoint
})
Makes a request to the whitelist endpoint and returns a promise that resolves if the path have been successfully whitelisted.
KiteAPI.whitelistPath(path).then(() => {
// path is now whitelisted
})
Makes a request to the blacklist endpoint and returns a promise that resolves if the path have been successfully blacklisted. The noAction
parameters will allow to set the closed_whitelist_notification_without_action
value in the request, it defaults to false
.
KiteAPI.blacklistPath(path).then(() => {
// path is now blacklisted
})
Makes a request to the languages endpoint and returns a promise that resolves with an array of the supported languages.
KiteAPI.getSupportedLanguages().then(languages => {
// do something with languages
})
Makes a request to the onboarding_file endpoint and returns a promise that resolves with a filepath string.
KiteAPI.getOnboardingFilePath().then(path => {
// do something with path
})
A proxy to the KiteConnector.arch
method.
A proxy to the KiteConnector.canInstallKite
method.
A proxy to the KiteConnector.canRunKite
method.
A proxy to the KiteConnector.canRunKiteEnterprise
. method
A proxy to the KiteConnector.checkHealth
method.
A proxy to the KiteConnector.downloadKite
method.
A proxy to the KiteConnector.downloadKiteRelease
. method
A proxy to the KiteConnector.hasBothKiteInstalled
. method
A proxy to the KiteConnector.hasManyKiteEnterpriseInstallation
method.
A proxy to the KiteConnector.hasManyKiteInstallation
method.
A proxy to the KiteConnector.installKite
method.
A proxy to the KiteConnector.isAdmin
method.
A proxy to the KiteConnector.isKiteEnterpriseInstalled
method.
A proxy to the KiteConnector.isKiteEnterpriseRunning
method.
A proxy to the KiteConnector.isKiteInstalled
method.
A proxy to the KiteConnector.isKiteReachable
method.
A proxy to the KiteConnector.isKiteRunning
method.
A proxy to the KiteConnector.isKiteSupported
method.
A proxy to the KiteConnector.isOSSupported
method.
A proxy to the KiteConnector.isOSVersionSupported
. method
A proxy to the KiteConnector.isUserAuthenticated
. method
A proxy to the KiteConnector.onDidFailRequest
method.
A proxy to the KiteConnector.request
method.
A proxy to the KiteConnector.runKiteWithCopilot
method.
A proxy to the KiteConnector.runKite
method.
A proxy to the KiteConnector.runKiteAndWait
method.
A proxy to the KiteConnector.runKiteEnterprise
method.
A proxy to the KiteConnector.runKiteEnterpriseAndWait
method.
A proxy to the KiteConnector.toggleRequestDebug
method.
A proxy to the KiteConnector.waitForKite
method.