diff --git a/.babelrc b/.babelrc index 89c9693a6..3f72b2dec 100644 --- a/.babelrc +++ b/.babelrc @@ -17,13 +17,9 @@ "transform-class-properties", "transform-es2015-destructuring", "transform-es2015-for-of", + "transform-es2015-modules-commonjs", "transform-object-rest-spread", "transform-regenerator", "syntax-async-functions", - ], - env: { - test: { - plugins: ["transform-es2015-modules-commonjs"] - } - } + ] } diff --git a/HOWTO.md b/HOWTO.md index c5f672af0..a8def1332 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -26,7 +26,8 @@ new Client().connect('Demo', 'https://demo.opennms.org/opennms', 'demo', 'demo') const idRestriction = new Restriction('id', Comparators.GE, 1); const filter = new Filter(idRestriction); // query all alarms with an ID greater than or equal to 1 - client.alarms().find(filter).then((alarms) => { + return client.alarms().find(filter).then((alarms) => { + console.log('got ' + alarms.length + ' alarms.'); // return all the node IDs associated with the matching alarms return alarms.map((alarm) => { return alarm.nodeId; @@ -45,6 +46,11 @@ new Client().connect('Demo', 'https://demo.opennms.org/opennms', 'demo', 'demo') console.log('node ' + node.id + ' (' + node.label + ') has ' + node.ipInterfaces.length + ' IP interfaces'); }); + return true; }); +}).catch((err) => { + console.log('error:',err); + console.log(err.stack); + throw err; }); ``` diff --git a/src/CLI.ts b/src/CLI.ts index 17bc5b95c..d0a44b726 100644 --- a/src/CLI.ts +++ b/src/CLI.ts @@ -96,15 +96,15 @@ function CLI() { const http = new Rest.AxiosHTTP(server); return Client.getMetadata(server, http).then((res) => { let c = colors.green; - if (res.data.type === API.ServerTypes.MERIDIAN) { - console.log(colors.blue('OpenNMS Meridian ' + res.data.version.displayVersion + ' Capabilities:')); + if (res.type === API.ServerTypes.MERIDIAN) { + console.log(colors.blue('OpenNMS Meridian ' + res.version.displayVersion + ' Capabilities:')); c = colors.blue; } else { - console.log(colors.green('OpenNMS Horizon ' + res.data.version.displayVersion + ' Capabilities:')); + console.log(colors.green('OpenNMS Horizon ' + res.version.displayVersion + ' Capabilities:')); } console.log(''); - const caps = res.data.capabilities(); + const caps = res.capabilities(); const rows = []; for (const cap in caps) { if (cap === 'type') { diff --git a/src/Client.ts b/src/Client.ts index d470ea246..cfd4c9deb 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -3,6 +3,7 @@ import * as axios from 'axios'; import {log, catRoot} from './api/Log'; import {Category} from 'typescript-logging'; +import {IHasHTTP} from './api/IHasHTTP'; import {IOnmsHTTP} from './api/IOnmsHTTP'; import {OnmsAuthConfig} from './api/OnmsAuthConfig'; @@ -28,7 +29,7 @@ const catClient = new Category('client', catRoot); * The OpenNMS client. This is the primary interface to OpenNMS servers. * @module Client */ /** */ -export class Client { +export class Client implements IHasHTTP { /** * Given an OnmsServer object, check that it can be connected to. * @@ -37,20 +38,19 @@ export class Client { * @param timeout - how long to wait before giving up when making ReST calls */ public static async checkServer(server: OnmsServer, httpImpl?: IOnmsHTTP, timeout?: number): Promise { - const opts = new OnmsHTTPOptions(timeout, server.auth); + const opts = new OnmsHTTPOptions(timeout, server.auth, server); if (!httpImpl) { - if (!Client.http) { + if (!Client.defaultHttp) { throw new OnmsError('No HTTP implementation is configured!'); } - httpImpl = Client.http; + httpImpl = Client.defaultHttp; } opts.accept = 'text/plain'; const infoUrl = server.resolveURL('rest/alarms/count'); - log.debug('checking URL: ' + infoUrl, catClient); - return httpImpl.get(infoUrl, opts).then((ret) => { - return true; - }); + log.debug('checkServer: checking URL: ' + infoUrl, catClient); + await httpImpl.get(infoUrl, opts); + return true; } /** @@ -62,33 +62,35 @@ export class Client { * @param timeout - how long to wait before giving up when making ReST calls */ public static async getMetadata(server: OnmsServer, httpImpl?: IOnmsHTTP, timeout?: number): - Promise> { - const opts = new OnmsHTTPOptions(timeout, server.auth); + Promise { + const opts = new OnmsHTTPOptions(timeout, server.auth, server); opts.accept = 'application/json'; if (!httpImpl) { - if (!Client.http) { - throw new OnmsError('No HTTP implementation is configured!'); + if (!Client.defaultHttp) { + throw new OnmsError('No default HTTP implementation is configured!'); } - httpImpl = Client.http; + httpImpl = Client.defaultHttp; } const infoUrl = server.resolveURL('rest/info'); - log.debug('checking URL: ' + infoUrl, catClient); - return httpImpl.get(infoUrl, opts).then((ret) => { - const version = new OnmsVersion(ret.data.version, ret.data.displayVersion); - const metadata = new ServerMetadata(version); - - if (ret.data.packageName) { - if (ret.data.packageName.toLowerCase() === 'meridian') { - metadata.type = ServerTypes.MERIDIAN; - } + log.debug('getMetadata: checking URL: ' + infoUrl, catClient); + + const response = await httpImpl.get(infoUrl, opts); + const version = new OnmsVersion(response.data.version, response.data.displayVersion); + const metadata = new ServerMetadata(version); + if (response.data.packageName) { + if (response.data.packageName.toLowerCase() === 'meridian') { + metadata.type = ServerTypes.MERIDIAN; } - return OnmsResult.ok(metadata, ret.message, ret.code); - }); + } + return metadata; } - /** The OnmsHTTP implementation to be used when making requests */ - private static http: IOnmsHTTP; + /** The default OnmsHTTP implementation to be used when making requests */ + private static defaultHttp: IOnmsHTTP; + + /** the OnmsHTTP implementation that will be used when making requests */ + public http: IOnmsHTTP; /** The remote server to connect to */ public server: OnmsServer; @@ -102,10 +104,11 @@ export class Client { */ constructor(httpImpl?: IOnmsHTTP) { if (httpImpl) { - Client.http = httpImpl; + Client.defaultHttp = httpImpl; } else { - Client.http = new AxiosHTTP(); + Client.defaultHttp = new AxiosHTTP(); } + this.http = Client.defaultHttp; } /** @@ -115,12 +118,20 @@ export class Client { public async connect(name: string, url: string, username: string, password: string, timeout?: number) { const self = this; const server = new OnmsServer(name, url, username, password); + await Client.checkServer(server, undefined, timeout); - return Client.getMetadata(server, undefined, timeout).then((result) => { - self.server = server; - server.metadata = result.data; - return self; - }); + const metadata = await Client.getMetadata(server, undefined, timeout); + + if (!self.http) { + self.http = Client.defaultHttp; + } + if (!self.http.server) { + self.http.server = server; + } + self.server = server; + server.metadata = metadata; + + return self; } /** Get an alarm DAO for querying alarms. */ diff --git a/src/api/IHasHTTP.ts b/src/api/IHasHTTP.ts new file mode 100644 index 000000000..e2806a01d --- /dev/null +++ b/src/api/IHasHTTP.ts @@ -0,0 +1,16 @@ +import {IOnmsHTTP} from './IOnmsHTTP'; + +/** + * Interface for a class that has an HTTP object. + * + * This exists to avoid import loops between the DAOs (that need to easily access {@link IOnmsHTTP}) + * and the {@link Client} which needs to contain an {@link IOnmsHTTP}. + * + * @interface + * @module IHasHTTP + */ /** */ + +export interface IHasHTTP { + /** the HTTP implementation this object should contain */ + http: IOnmsHTTP; +} diff --git a/src/api/IOnmsHTTP.ts b/src/api/IOnmsHTTP.ts index 86f70606b..ff2227f35 100644 --- a/src/api/IOnmsHTTP.ts +++ b/src/api/IOnmsHTTP.ts @@ -10,7 +10,7 @@ import {OnmsServer} from './OnmsServer'; /** * Interface for making ReST calls to an HTTP server. * @interface - * @module OnmsHTTP + * @module IOnmsHTTP * * Notes to implementors: * - Implementations of this interface MUST have a constructor that allows an empty diff --git a/src/api/OnmsHTTPOptions.ts b/src/api/OnmsHTTPOptions.ts index 86e2567c5..4b3affff5 100644 --- a/src/api/OnmsHTTPOptions.ts +++ b/src/api/OnmsHTTPOptions.ts @@ -1,4 +1,5 @@ import {OnmsAuthConfig} from './OnmsAuthConfig'; +import {OnmsServer} from './OnmsServer'; import {IHash} from '../internal/IHash'; /** @@ -9,6 +10,9 @@ export class OnmsHTTPOptions { /** the authentication config that should be used when no server auth is configured */ public auth: OnmsAuthConfig; + /** the server to use if no server is set on the HTTP implementation */ + public server: OnmsServer; + /** how long to wait for ReST calls to time out */ public timeout = 10000; @@ -22,12 +26,15 @@ export class OnmsHTTPOptions { * Construct a new OnmsHTTPOptions object. * @constructor */ - constructor(timeout?: number, auth?: OnmsAuthConfig) { + constructor(timeout?: number, auth?: OnmsAuthConfig, server?: OnmsServer) { if (timeout !== undefined) { this.timeout = timeout; } if (auth !== undefined) { this.auth = auth; } + if (server !== undefined) { + this.server = server; + } } } diff --git a/src/dao/AbstractDAO.ts b/src/dao/AbstractDAO.ts index a3c02b8c0..3032c3400 100644 --- a/src/dao/AbstractDAO.ts +++ b/src/dao/AbstractDAO.ts @@ -1,7 +1,6 @@ +import {IHasHTTP} from '../api/IHasHTTP'; import {IOnmsHTTP} from '../api/IOnmsHTTP'; -import {Client} from '../Client'; - import {Filter} from '../api/Filter'; import {OnmsHTTPOptions} from '../api/OnmsHTTPOptions'; @@ -23,12 +22,11 @@ export abstract class AbstractDAO { protected http: IOnmsHTTP; /** construct a DAO instance */ - constructor(impl: Client | IOnmsHTTP) { - if (impl instanceof Client) { - this.http = (impl as any).http; - } else { - this.http = impl; + constructor(impl: IHasHTTP | IOnmsHTTP) { + if ((impl as IHasHTTP).http) { + impl = (impl as IHasHTTP).http; } + this.http = impl as IOnmsHTTP; } /** create a model object given a JSON data structure */ diff --git a/src/dao/AlarmDAO.ts b/src/dao/AlarmDAO.ts index 2ace58e1c..eaa7993c4 100644 --- a/src/dao/AlarmDAO.ts +++ b/src/dao/AlarmDAO.ts @@ -1,20 +1,18 @@ import {AbstractDAO} from './AbstractDAO'; import {EventDAO} from './EventDAO'; -import {Client} from '../Client'; +import {Filter} from '../api/Filter'; +import {IHasHTTP} from '../api/IHasHTTP'; +import {IOnmsHTTP} from '../api/IOnmsHTTP'; +import {OnmsError} from '../api/OnmsError'; import {OnmsAlarm} from '../model/OnmsAlarm'; +import {AlarmTypes} from '../model/OnmsAlarmType'; import {OnmsParm} from '../model/OnmsParm'; import {OnmsServiceType} from '../model/OnmsServiceType'; - -import {AlarmTypes} from '../model/OnmsAlarmType'; import {Severities} from '../model/OnmsSeverity'; import {TroubleTicketStates} from '../model/OnmsTroubleTicketState'; -import {Filter} from '../api/Filter'; -import {IOnmsHTTP} from '../api/IOnmsHTTP'; -import {OnmsError} from '../api/OnmsError'; - import {log, catDao} from '../api/Log'; import {Category} from 'typescript-logging'; @@ -29,7 +27,7 @@ export class AlarmDAO extends AbstractDAO { /** an event DAO to be used for creating events attached to alarms from API/JSON data */ private eventDao: EventDAO; - constructor(impl: Client | IOnmsHTTP) { + constructor(impl: IHasHTTP | IOnmsHTTP) { super(impl); this.eventDao = new EventDAO(impl); } diff --git a/src/dao/EventDAO.ts b/src/dao/EventDAO.ts index a0dcca4c8..13fa2b24a 100644 --- a/src/dao/EventDAO.ts +++ b/src/dao/EventDAO.ts @@ -1,6 +1,8 @@ import {AbstractDAO} from './AbstractDAO'; import {Filter} from '../api/Filter'; +import {IHasHTTP} from '../api/IHasHTTP'; +import {IOnmsHTTP} from '../api/IOnmsHTTP'; import {OnmsError} from '../api/OnmsError'; import {Util} from '../internal/Util'; @@ -21,6 +23,10 @@ const cat = new Category('events', catDao); * @module EventDAO */ /** */ export class EventDAO extends AbstractDAO { + constructor(impl: IHasHTTP | IOnmsHTTP) { + super(impl); + } + /** * create an event object from a JSON object * @hidden diff --git a/src/dao/NodeDAO.ts b/src/dao/NodeDAO.ts index 0c19764aa..f2a7b37fa 100644 --- a/src/dao/NodeDAO.ts +++ b/src/dao/NodeDAO.ts @@ -1,6 +1,8 @@ import {AbstractDAO} from './AbstractDAO'; import {Filter} from '../api/Filter'; +import {IHasHTTP} from '../api/IHasHTTP'; +import {IOnmsHTTP} from '../api/IOnmsHTTP'; import {OnmsError} from '../api/OnmsError'; import {Util} from '../internal/Util'; @@ -31,6 +33,10 @@ const cat = new Category('nodes', catDao); * @module NodeDAO */ /** */ export class NodeDAO extends AbstractDAO { + constructor(impl: IHasHTTP | IOnmsHTTP) { + super(impl); + } + /** * create a node object from a JSON object * @hidden diff --git a/src/model/OnmsIpInterface.ts b/src/model/OnmsIpInterface.ts index c0a81142c..c1e808f57 100644 --- a/src/model/OnmsIpInterface.ts +++ b/src/model/OnmsIpInterface.ts @@ -3,7 +3,6 @@ import {Moment} from 'moment'; import {OnmsManagedType} from './OnmsManagedType'; import {OnmsMonitoredService} from './OnmsMonitoredService'; -import {OnmsNode} from './OnmsNode'; import {OnmsPrimaryType} from './OnmsPrimaryType'; /** @@ -44,7 +43,7 @@ export class OnmsIpInterface { } /** the node this interface is associated with */ - public node: OnmsNode; + public node: any; /** the services on this interface */ public services = [] as OnmsMonitoredService[]; diff --git a/src/model/OnmsMonitoredService.ts b/src/model/OnmsMonitoredService.ts index ae522aa52..2ebf1950f 100644 --- a/src/model/OnmsMonitoredService.ts +++ b/src/model/OnmsMonitoredService.ts @@ -1,8 +1,6 @@ import {Address4, Address6} from 'ip-address'; import {Moment} from 'moment'; -import {OnmsIpInterface} from './OnmsIpInterface'; -import {OnmsNode} from './OnmsNode'; import {OnmsServiceType} from './OnmsServiceType'; import {OnmsServiceStatusType} from './OnmsServiceStatusType'; @@ -21,10 +19,10 @@ export class OnmsMonitoredService { public lastGood: Moment; /** the node associated with this service */ - public node: OnmsNode; + public node: any; /** the ipInterface associated with this service */ - public ipInterface: OnmsIpInterface; + public ipInterface: any; /** the service type associated with this service */ public type: OnmsServiceType; diff --git a/src/model/OnmsSnmpInterface.ts b/src/model/OnmsSnmpInterface.ts index f0f2c9fba..03b7a74a2 100644 --- a/src/model/OnmsSnmpInterface.ts +++ b/src/model/OnmsSnmpInterface.ts @@ -1,7 +1,6 @@ import {Moment} from 'moment'; import {OnmsCollectType} from './OnmsCollectType'; -import {OnmsNode} from './OnmsNode'; import {OnmsSnmpStatusType} from './OnmsSnmpStatusType'; import {PhysAddr} from './PhysAddr'; @@ -17,7 +16,7 @@ export class OnmsSnmpInterface { public physAddr: PhysAddr; /** the node associated with this interface */ - public node: OnmsNode; + public node: any; /** the SNMP interface index */ public ifIndex: number; diff --git a/src/rest/AbstractHTTP.ts b/src/rest/AbstractHTTP.ts index 086d3229b..d86f87185 100644 --- a/src/rest/AbstractHTTP.ts +++ b/src/rest/AbstractHTTP.ts @@ -37,20 +37,14 @@ export abstract class AbstractHTTP implements IOnmsHTTP { /** the server associated with this HTTP implementation */ public get server() { + this.assertFilterProcessorExists(); return this.serverObj; } public set server(server: OnmsServer) { this.serverObj = server; + this.assertFilterProcessorExists(); this.onSetServer(); - if (!this.filterProcessor) { - if (this.serverObj && this.serverObj.metadata) { - switch (this.serverObj.metadata.apiVersion()) { - default: - this.filterProcessor = new V1FilterProcessor(); - } - } - } } /** @@ -62,6 +56,7 @@ export abstract class AbstractHTTP implements IOnmsHTTP { constructor(server?: OnmsServer, timeout = 10000) { this.serverObj = server; this.timeout = timeout; + this.assertFilterProcessorExists(); } /** make an HTTP get call -- this should be overridden by the implementation */ @@ -87,14 +82,20 @@ export abstract class AbstractHTTP implements IOnmsHTTP { } } + /** get the server in the options object, or fall back to the one assigned to the HTTP impl */ + protected getServer(options?: OnmsHTTPOptions) { + return options.server || this.serverObj; + } + /** combine all options from the given options, the current server, and the default options */ protected getOptions(options?: OnmsHTTPOptions) { let ret = Object.assign({auth: {}}, this.options); if (this.timeout) { ret.timeout = this.timeout; } - if (this.serverObj && this.serverObj.auth) { - ret.auth = Object.assign(ret.auth, this.serverObj.auth); + const server = this.getServer(options); + if (server && server.auth) { + ret.auth = Object.assign(ret.auth, server.auth); } ret = Object.assign(ret, options); return ret; @@ -104,4 +105,16 @@ export abstract class AbstractHTTP implements IOnmsHTTP { protected onSetServer() { // do nothing by default } + + /** make sure the filter processor is initialized */ + private assertFilterProcessorExists() { + if (!this.filterProcessor) { + if (this.serverObj && this.serverObj.metadata) { + switch (this.serverObj.metadata.apiVersion()) { + default: + this.filterProcessor = new V1FilterProcessor(); + } + } + } + } } diff --git a/src/rest/AxiosHTTP.ts b/src/rest/AxiosHTTP.ts index f85e1a3c5..2d30f9d9e 100644 --- a/src/rest/AxiosHTTP.ts +++ b/src/rest/AxiosHTTP.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import {AxiosInstance, AxiosRequestConfig} from 'axios'; +import {AxiosStatic, AxiosInstance, AxiosRequestConfig} from 'axios'; /** @hidden */ // tslint:disable-next-line @@ -23,16 +23,20 @@ const catAxios = new Category('axios', catRest); * @implements IOnmsHTTP */ /** */ export class AxiosHTTP extends AbstractHTTP { + /** the Axios implementation we'll use for making ReST calls */ + private axiosImpl: AxiosStatic; + /** the Axios instance we'll use for making ReST calls */ private axiosObj: AxiosInstance; - constructor(server?: OnmsServer, timeout = 10000) { + constructor(server?: OnmsServer, axiosImpl?: AxiosStatic, timeout = 10000) { super(server, timeout); + this.axiosImpl = axiosImpl || axios; } /** make an HTTP get call -- this should be overridden by the implementation */ public get(url: string, options?: OnmsHTTPOptions) { - const realUrl = this.server.resolveURL(url); + const realUrl = this.getServer(options).resolveURL(url); const opts = this.getConfig(options); const urlObj = new URI(realUrl); @@ -101,16 +105,17 @@ export class AxiosHTTP extends AbstractHTTP { /** internal method for getting/constructing an Axios object on-demand, based on the current server config */ private getImpl(options?: OnmsHTTPOptions) { if (!this.axiosObj) { - if (!this.server) { + const server = this.getServer(options); + if (!server) { throw new OnmsError('You must set a server before attempting to make queries using Axios!'); } const allOptions = this.getOptions(options); - this.axiosObj = axios.create({ + this.axiosObj = this.axiosImpl.create({ auth: { password: allOptions.auth.password, username: allOptions.auth.username, }, - baseURL: this.server.url, + baseURL: server.url, timeout: allOptions.timeout, withCredentials: true, }); diff --git a/src/rest/GrafanaHTTP.ts b/src/rest/GrafanaHTTP.ts index 38ba2c234..1a7e0574b 100644 --- a/src/rest/GrafanaHTTP.ts +++ b/src/rest/GrafanaHTTP.ts @@ -33,7 +33,7 @@ export class GrafanaHTTP extends AbstractHTTP { /** make an HTTP get call -- this should be overridden by the implementation */ public get(url: string, options?: OnmsHTTPOptions) { - const realUrl = this.server.resolveURL(url); + const realUrl = this.getServer(options).resolveURL(url); log.debug('getting ' + realUrl); const query = this.getConfig(options); query.method = 'GET'; diff --git a/src/rest/SuperAgentHTTP.ts b/src/rest/SuperAgentHTTP.ts index c34f405dc..ae3abea2b 100644 --- a/src/rest/SuperAgentHTTP.ts +++ b/src/rest/SuperAgentHTTP.ts @@ -12,18 +12,26 @@ import {Category} from 'typescript-logging'; /** @hidden */ const catAgent = new Category('super-agent', catRest); +/** @hidden */ +// tslint:disable-next-line +const URI = require('urijs'); + /** * Implementation of the OnmsHTTP interface using SuperAgent: https://github.com/visionmedia/superagent * @module SuperAgentHTTP * @implements IOnmsHTTP */ /** */ export class SuperAgentHTTP extends AbstractHTTP { - constructor(server?: OnmsServer, timeout = 10000) { + /** the SuperAgent implementation, override if using nodejs instead of the browser */ + private saImpl: any; + + constructor(server?: OnmsServer, saImpl?: any, timeout = 10000) { super(server, timeout); + this.saImpl = saImpl; } /** make an HTTP get call -- this should be overridden by the implementation */ - public get(url: string, options?: OnmsHTTPOptions) { + public async get(url: string, options?: OnmsHTTPOptions) { return this.getImpl('get', url, options).then((response) => { if (response.body) { return OnmsResult.ok(response.body, undefined, response.status, response.type); @@ -35,23 +43,34 @@ export class SuperAgentHTTP extends AbstractHTTP { /** internal method for getting/constructing a superAgent object on-demand, based on the current server config */ private getImpl(method: string, url: string, options?: OnmsHTTPOptions) { - if (!this.server) { + const server = this.getServer(options); + if (!server) { throw new OnmsError('You must set a server before attempting to make queries using SuperAgent!'); } - const realUrl = this.server.resolveURL(url); + const realUrl = server.resolveURL(url); const allOptions = this.getOptions(options); const urlObj = new URI(realUrl); urlObj.search(options.parameters); log.debug('getting ' + urlObj.toString(), catAgent); - return request[method](realUrl) + const r = this.saImpl ? this.saImpl : request; + + let impl = r[method](realUrl) .withCredentials() .timeout(allOptions.timeout) .set('Accept', allOptions.accept) .auth(allOptions.auth.username, allOptions.auth.password) - .query(allOptions.parameters); + .buffer(true); + + if (allOptions.accept === 'application/xml') { + impl = impl.parse(this.transformXML); + } else if (allOptions.accept === 'application/json') { + impl = impl.parse(this.transformJSON); + } + + return impl.query(allOptions.parameters); } } diff --git a/test/Client.spec.ts b/test/Client.spec.ts index 5c109163e..60dec1aa5 100644 --- a/test/Client.spec.ts +++ b/test/Client.spec.ts @@ -46,10 +46,9 @@ describe('Given an instance of OpenNMS...', () => { expect(ret).toBeDefined(); return ret.then((result) => { expect(result).toBeDefined(); - expect(result).toBeInstanceOf(OnmsResult); - expect(result.data).toBeInstanceOf(ServerMetadata); - expect(result.data.version.version).toEqual('19.1.0'); - expect(result.data.type).toEqual(ServerTypes.HORIZON); + expect(result).toBeInstanceOf(ServerMetadata); + expect(result.version.version).toEqual('19.1.0'); + expect(result.type).toEqual(ServerTypes.HORIZON); }); }); it('it should return a server object with metadata when connect is called', () => { diff --git a/webpack.config.js b/webpack.config.js index 27ce7f82b..31a9bf05e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -53,9 +53,14 @@ var config = { ], extensions: ['.webpack.js', '.web.js', '.ts', '.js'] }, - plugins: [], + plugins: [ + new webpack.DefinePlugin({ + "global.GENTLY": false + }), + ], node: { fs: 'empty', + __dirname: true, child_process: false, global: false, process: false