Skip to content

Commit

Permalink
Update rsp-client to use 0.11.0.Final protocol (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
robstryker authored and dgolovin committed Jan 24, 2019
1 parent f4f2469 commit 4f3709b
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 3,481 deletions.
3,432 changes: 0 additions & 3,432 deletions package-lock.json

This file was deleted.

59 changes: 55 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export class RSPClient {
return this.serverUtil.getServerHandles(timeout);
}

getServerState(handle: Protocol.ServerHandle, timeout: number = 2000): Promise<Protocol.ServerState> {
return this.serverUtil.getServerState(handle, timeout);
}

/**
* Retreives all supported server types
*
Expand Down Expand Up @@ -343,7 +347,7 @@ export class RSPClient {
* @param launchParameters parameters to start the server with, see {@link Protocol.LaunchParameters}
* @param timeout timeout in milliseconds
*/
startServerSync(launchParameters: Protocol.LaunchParameters, timeout: number = 60000): Promise<Protocol.ServerStateChange> {
startServerSync(launchParameters: Protocol.LaunchParameters, timeout: number = 60000): Promise<Protocol.ServerState> {
return this.launcherUtil.startServerSync(launchParameters, timeout);
}

Expand All @@ -354,10 +358,57 @@ export class RSPClient {
* @param stopAttributes server stopping parameters, set force to 'true' to force shutdown, see {@link Protocol.StopServerAttributes}
* @param timeout timeout in milliseconds
*/
stopServerSync(stopAttributes: Protocol.StopServerAttributes, timeout: number = 60000): Promise<Protocol.ServerStateChange> {
stopServerSync(stopAttributes: Protocol.StopServerAttributes, timeout: number = 60000): Promise<Protocol.ServerState> {
return this.launcherUtil.stopServerSync(stopAttributes, timeout);
}



/**
* Get a list of deployments for the given server
*
* @param server A server handle see {@link Protocol.ServerHandle}
* @param timeout timeout in milliseconds
*/
getDeployables(server: Protocol.ServerHandle, timeout: number = 60000): Promise<Protocol.DeployableState[]> {
return this.serverUtil.getDeployables(server, timeout);
}


/**
* Add a deployable to a given server
*
* @param server A server handle see {@link Protocol.ServerHandle}
* @param timeout timeout in milliseconds
*/
addDeployable(req: Protocol.ModifyDeployableRequest, timeout: number = 60000): Promise<Protocol.Status> {
return this.serverUtil.addDeployable(req, timeout);
}


/**
* Remove a deployable from a given server
*
* @param server A server handle see {@link Protocol.ServerHandle}
* @param timeout timeout in milliseconds
*/
removeDeployable(req: Protocol.ModifyDeployableRequest, timeout: number = 60000): Promise<Protocol.Status> {
return this.serverUtil.removeDeployable(req, timeout);
}


/**
* Publish a given server
*
* @param server A server handle see {@link Protocol.ServerHandle}
* @param timeout timeout in milliseconds
*/
publish(req: Protocol.PublishServerRequest, timeout: number = 60000): Promise<Protocol.Status> {
return this.serverUtil.publish(req, timeout);
}



/**
* Attaches a listener to discovery path added event
*
Expand Down Expand Up @@ -399,7 +450,7 @@ export class RSPClient {
*
* @param listener callback to handle the event
*/
onServerStateChange(listener: (arg: Protocol.ServerStateChange) => void): void {
onServerStateChange(listener: (arg: Protocol.ServerState) => void): void {
this.emitter.on('serverStateChanged', listener);
}

Expand Down Expand Up @@ -482,7 +533,7 @@ export class RSPClient {
* @param capabilities client capabilities to register
* @param timeout timeout in milliseconds
*/
registerClientCapabilities(capabilities: Protocol.ClientCapabilitiesRequest, timeout: number = 2000): Promise<Protocol.ServerCapabilitesResponse> {
registerClientCapabilities(capabilities: Protocol.ClientCapabilitiesRequest, timeout: number = 2000): Promise<Protocol.ServerCapabilitiesResponse> {
return this.capabilitiesUtil.registerClientCapabilities(capabilities, timeout);
}

Expand Down
27 changes: 25 additions & 2 deletions src/protocol/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export namespace Messages {
export const type = new RequestType<void, Array<Protocol.ServerHandle>, void, void>('server/getServerHandles');
}

/**
* The `server/getServerState` request is sent by the client
*/
export namespace GetServerStateRequest {
export const type = new RequestType<Protocol.ServerHandle, Protocol.ServerState, void, void>('server/getServerState');
}

/**
* The `server/getServerTypes` request is sent by the client to list the server
* types currently supported. The details of how many server types are supported
Expand Down Expand Up @@ -221,8 +228,24 @@ export namespace Messages {
}

export namespace RegisterClientCapabilitiesRequest {
export const type = new RequestType<Protocol.ClientCapabilitiesRequest, Protocol.ServerCapabilitesResponse, void, void>('server/registerClientCapabilities');
export const type = new RequestType<Protocol.ClientCapabilitiesRequest, Protocol.ServerCapabilitiesResponse, void, void>('server/registerClientCapabilities');
}
export namespace GetDeployablesRequest {
export const type = new RequestType<Protocol.ServerHandle, Protocol.DeployableState[], void, void>('server/getDeployables');
}

export namespace AddDeployableRequest {
export const type = new RequestType<Protocol.ModifyDeployableRequest, Protocol.Status, void, void>('server/addDeployable');
}

export namespace RemoveDeployableRequest {
export const type = new RequestType<Protocol.ModifyDeployableRequest, Protocol.Status, void, void>('server/removeDeployable');
}

export namespace PublishRequest {
export const type = new RequestType<Protocol.PublishServerRequest, Protocol.Status, void, void>('server/publish');
}

}

/**
Expand Down Expand Up @@ -300,7 +323,7 @@ export namespace Messages {
* `4` representing stopped
*/
export namespace ServerStateChangedNotification {
export const type = new NotificationType<Protocol.ServerStateChange, void>('client/serverStateChanged');
export const type = new NotificationType<Protocol.ServerState, void>('client/serverStateChanged');
}

/**
Expand Down
92 changes: 80 additions & 12 deletions src/protocol/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Json objects sent between the server and the client
*/
export namespace Protocol {

export interface Attribute {
type: string;
description: string;
Expand All @@ -12,17 +13,57 @@ export namespace Protocol {
attributes: { [index: string]: Attribute };
}

export interface ClientCapabilitiesRequest {
map: { [index: string]: string };
}

export interface CommandLineDetails {
cmdLine: string[];
workingDir: string;
envp: string[];
properties: { [index: string]: string };
}

export interface CreateServerResponse {
status: Status;
invalidKeys: string[];
}

export interface DeployableReference {
label: string;
path: string;
}

export interface DeployableState {
server: ServerHandle;
reference: DeployableReference;
state: number;
publishState: number;
}

export interface DiscoveryPath {
filepath: string;
}

export interface DownloadRuntimeDescription {
name: string;
id: string;
version: string;
url: string;
licenseURL: string;
humanUrl: string;
disclaimer: boolean;
properties: { [index: string]: string };
size: string;
installationMethod: string;
}

export interface DownloadSingleRuntimeRequest {
requestId: number;
downloadRuntimeId: string;
data: { [index: string]: any };
}

export interface LaunchAttributesRequest {
serverTypeId: string;
mode: string;
Expand All @@ -33,6 +74,20 @@ export namespace Protocol {
params: ServerAttributes;
}

export interface ListDownloadRuntimeResponse {
runtimes: DownloadRuntimeDescription[];
}

export interface ModifyDeployableRequest {
server: ServerHandle;
deployable: DeployableReference;
}

export interface PublishServerRequest {
server: ServerHandle;
kind: number;
}

export interface ServerAttributes {
serverType: string;
id: string;
Expand All @@ -49,6 +104,11 @@ export namespace Protocol {
serverAdapterTypeId: string;
}

export interface ServerCapabilitiesResponse {
serverCapabilities: { [index: string]: string };
clientRegistrationStatus: Status;
}

export interface ServerHandle {
id: string;
type: ServerType;
Expand Down Expand Up @@ -76,9 +136,11 @@ export namespace Protocol {
request: LaunchParameters;
}

export interface ServerStateChange {
export interface ServerState {
server: ServerHandle;
state: number;
publishState: number;
deployableStates: DeployableState[];
}

export interface ServerType {
Expand Down Expand Up @@ -106,6 +168,11 @@ export namespace Protocol {
force: boolean;
}

export interface StringPrompt {
code: number;
prompt: string;
}

export interface VMDescription {
id: string;
installLocation: string;
Expand All @@ -116,17 +183,18 @@ export namespace Protocol {
id: string;
}

export interface ClientCapabilitiesRequest {
map: { [index: string]: string };
}

export interface ServerCapabilitesResponse {
clientRegistrationStatus: Status;
map: { [index: string]: string };
export interface WorkflowResponse {
status: Status;
requestId: number;
items: WorkflowResponseItem[];
}

export interface StringPrompt {
code: number;
prompt: string;
export interface WorkflowResponseItem {
id: string;
itemType: string;
label: string;
content: string;
responseType: string;
validResponses: string[];
}
}
}
32 changes: 22 additions & 10 deletions src/protocol/serverState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export namespace ServerState {
*/
export const STOPPED = 4;

/**
* Publish state constant (value 0) indicating that it's
* in an unknown state.
*/
export const PUBLISH_STATE_UNKNOWN = 0;

/**
* Publish state constant (value 1) indicating that there
* is no publish required.
Expand All @@ -57,6 +51,24 @@ export namespace ServerState {
*/
export const PUBLISH_STATE_FULL = 3;

/**
* Publish state constant (value 4) indicating that the
* deployable has yet to be added / deployed, and should be.
*/
export const PUBLISH_STATE_ADD = 4;

/**
* Publish state constant (value 5) indicating that a
* removal of the deployable is required
*/
export const PUBLISH_STATE_REMOVE = 5;

/**
* Publish state constant (value 6) indicating that it's
* in an unknown state.
*/
export const PUBLISH_STATE_UNKNOWN = 6;

/**
* Publish kind constant (value 1) indicating an incremental publish request.
*/
Expand All @@ -68,12 +80,12 @@ export namespace ServerState {
export const PUBLISH_FULL = 2;

/**
* Publish kind constant (value 3) indicating an automatic publish request.
* Publish kind constant (value 3) indicating a publish clean request
*/
export const PUBLISH_AUTO = 3;
export const PUBLISH_CLEAN = 3;

/**
* Publish kind constant (value 4) indicating a publish clean request
* Publish kind constant (value 4) indicating an automatic publish request.
*/
export const PUBLISH_CLEAN = 4;
export const PUBLISH_AUTO = 4;
}
2 changes: 1 addition & 1 deletion src/util/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Capabilities {
* @param capabilities the client capabilities
* @param timeout timeout in milliseconds
*/
registerClientCapabilities(capabilities: Protocol.ClientCapabilitiesRequest, timeout: number = 2000): Promise<Protocol.ServerCapabilitesResponse> {
registerClientCapabilities(capabilities: Protocol.ClientCapabilitiesRequest, timeout: number = 2000): Promise<Protocol.ServerCapabilitiesResponse> {
return Common.sendSimpleRequest(this.connection, Messages.Server.RegisterClientCapabilitiesRequest.type,
capabilities, timeout, ErrorMessages.REGISTERCLIENT_CAPABILITIES_TIMEOUT);
}
Expand Down
Loading

0 comments on commit 4f3709b

Please sign in to comment.