@webex/internal-plugin-llm
Advanced tools
Comparing version 2.31.1 to 2.31.2
@@ -85,7 +85,7 @@ "use strict"; | ||
/** | ||
* If the LLM plugin has been registered and listening | ||
* @instance | ||
* @type {Boolean} | ||
* @public | ||
*/ | ||
* If the LLM plugin has been registered and listening | ||
* @instance | ||
* @type {Boolean} | ||
* @public | ||
*/ | ||
@@ -146,3 +146,8 @@ /** | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "disconnectLLM", function () { | ||
return _this.disconnect(); | ||
return _this.disconnect().then(function () { | ||
_this.registered = false; | ||
_this.locusUrl = undefined; | ||
_this.binding = undefined; | ||
_this.webSocketUrl = undefined; | ||
}); | ||
}); | ||
@@ -149,0 +154,0 @@ _this.registered = false; |
{ | ||
"name": "@webex/internal-plugin-llm", | ||
"version": "2.31.1", | ||
"version": "2.31.2", | ||
"description": "", | ||
@@ -13,4 +13,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@webex/internal-plugin-llm": "2.31.1", | ||
"@webex/internal-plugin-mercury": "2.31.1" | ||
"@webex/internal-plugin-llm": "2.31.2", | ||
"@webex/internal-plugin-mercury": "2.31.2" | ||
}, | ||
@@ -24,6 +24,6 @@ "browserify": { | ||
"devDependencies": { | ||
"@webex/test-helper-chai": "2.31.1", | ||
"@webex/test-helper-mock-webex": "2.31.1", | ||
"@webex/test-helper-chai": "2.31.2", | ||
"@webex/test-helper-mock-webex": "2.31.2", | ||
"sinon": "^9.2.4" | ||
} | ||
} |
@@ -46,16 +46,15 @@ import Mercury from '@webex/internal-plugin-mercury'; | ||
/** | ||
* If the LLM plugin has been registered and listening | ||
* @instance | ||
* @type {Boolean} | ||
* @public | ||
*/ | ||
private registered:boolean = false; | ||
* If the LLM plugin has been registered and listening | ||
* @instance | ||
* @type {Boolean} | ||
* @public | ||
*/ | ||
private registered: boolean = false; | ||
private webSocketUrl: string; | ||
private webSocketUrl?: string; | ||
private binding: string; | ||
private binding?: string; | ||
private locusUrl: string; | ||
private locusUrl?: string; | ||
/** | ||
@@ -70,3 +69,2 @@ * Initializes the LLM Plugin | ||
this.registered = false; | ||
@@ -80,12 +78,15 @@ } | ||
*/ | ||
private register = (llmSocketUrl:string):Promise<void> => this.request({ | ||
method: 'POST', | ||
url: llmSocketUrl, | ||
}).then((res: { body: { webSocketUrl: string; binding: string; }; }) => { | ||
this.webSocketUrl = res.body.webSocketUrl; | ||
this.binding = res.body.binding; | ||
}).catch((error:any) => { | ||
LoggerProxy.logger.error(`Error connecting to websocket: ${error}`); | ||
throw error; | ||
}); | ||
private register = (llmSocketUrl: string): Promise<void> => | ||
this.request({ | ||
method: 'POST', | ||
url: llmSocketUrl, | ||
}) | ||
.then((res: {body: {webSocketUrl: string; binding: string}}) => { | ||
this.webSocketUrl = res.body.webSocketUrl; | ||
this.binding = res.body.binding; | ||
}) | ||
.catch((error: any) => { | ||
LoggerProxy.logger.error(`Error connecting to websocket: ${error}`); | ||
throw error; | ||
}); | ||
@@ -98,9 +99,10 @@ /** | ||
*/ | ||
public registerAndConnect = (locusUrl:string, datachannelUrl:string):Promise<void> => this.register(datachannelUrl).then(() => { | ||
if (!locusUrl || !datachannelUrl) return undefined; | ||
this.locusUrl = locusUrl; | ||
this.connect(this.webSocketUrl).then(() => { | ||
this.registered = true; | ||
public registerAndConnect = (locusUrl: string, datachannelUrl: string): Promise<void> => | ||
this.register(datachannelUrl).then(() => { | ||
if (!locusUrl || !datachannelUrl) return undefined; | ||
this.locusUrl = locusUrl; | ||
this.connect(this.webSocketUrl).then(() => { | ||
this.registered = true; | ||
}); | ||
}); | ||
}); | ||
@@ -111,3 +113,3 @@ /** | ||
*/ | ||
public isConnected = ():boolean => this.registered; | ||
public isConnected = (): boolean => this.registered; | ||
@@ -118,3 +120,3 @@ /** | ||
*/ | ||
public getBinding = ():string => this.binding; | ||
public getBinding = (): string => this.binding; | ||
@@ -125,3 +127,3 @@ /** | ||
*/ | ||
public getLocusUrl = ():string => this.locusUrl; | ||
public getLocusUrl = (): string => this.locusUrl; | ||
@@ -132,4 +134,9 @@ /** | ||
*/ | ||
public disconnectLLM = (): Promise<void> => this.disconnect(); | ||
public disconnectLLM = (): Promise<void> => | ||
this.disconnect().then(() => { | ||
this.registered = false; | ||
this.locusUrl = undefined; | ||
this.binding = undefined; | ||
this.webSocketUrl = undefined; | ||
}); | ||
} | ||
@@ -5,6 +5,4 @@ import MockWebex from '@webex/test-helper-mock-webex'; | ||
import Mercury from '@webex/internal-plugin-mercury'; | ||
import LLMService from '@webex/internal-plugin-llm'; | ||
describe('plugin-llm', () => { | ||
@@ -32,8 +30,7 @@ const locusUrl = 'locusUrl'; | ||
binding: 'binding', | ||
webSocketUrl: 'url' | ||
} | ||
webSocketUrl: 'url', | ||
}, | ||
}); | ||
}); | ||
describe('#registerAndConnect', () => { | ||
@@ -44,4 +41,4 @@ it('registers connection', async () => { | ||
binding: 'binding', | ||
webSocketUrl: 'url' | ||
} | ||
webSocketUrl: 'url', | ||
}, | ||
}); | ||
@@ -53,8 +50,8 @@ assert.equal(llmService.isConnected(), false); | ||
it('doesn\'t registers connection for invalid input', async () => { | ||
it("doesn't registers connection for invalid input", async () => { | ||
llmService.register = sinon.stub().resolves({ | ||
body: { | ||
binding: 'binding', | ||
webSocketUrl: 'url' | ||
} | ||
webSocketUrl: 'url', | ||
}, | ||
}); | ||
@@ -70,8 +67,10 @@ await llmService.registerAndConnect(); | ||
sinon.assert.calledOnceWithExactly( | ||
llmService.request, | ||
sinon.match({ | ||
method: 'POST', | ||
url: `${datachannelUrl}`, | ||
}) | ||
); | ||
sinon.assert.calledOnceWithExactly(llmService.request, sinon.match({ | ||
method: 'POST', | ||
url: `${datachannelUrl}`, | ||
})); | ||
assert.equal(llmService.getBinding(), 'binding'); | ||
@@ -86,4 +85,4 @@ }); | ||
binding: 'binding', | ||
webSocketUrl: 'url' | ||
} | ||
webSocketUrl: 'url', | ||
}, | ||
}); | ||
@@ -99,2 +98,5 @@ await llmService.registerAndConnect(locusUrl, datachannelUrl); | ||
sinon.assert.calledOnce(llmService.disconnect); | ||
assert.equal(llmService.isConnected(), false); | ||
assert.equal(llmService.getLocusUrl(), undefined); | ||
assert.equal(llmService.getBinding(), undefined); | ||
}); | ||
@@ -101,0 +103,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25078
397
+ Added@webex/common@2.31.2(transitive)
+ Added@webex/common-timers@2.31.2(transitive)
+ Added@webex/http-core@2.31.2(transitive)
+ Added@webex/internal-plugin-device@2.31.2(transitive)
+ Added@webex/internal-plugin-feature@2.31.2(transitive)
+ Added@webex/internal-plugin-mercury@2.31.2(transitive)
+ Added@webex/internal-plugin-metrics@2.31.2(transitive)
+ Added@webex/plugin-logger@2.31.2(transitive)
+ Added@webex/storage-adapter-spec@2.31.2(transitive)
+ Added@webex/test-helper-chai@2.31.2(transitive)
+ Added@webex/test-helper-file@2.31.2(transitive)
+ Added@webex/test-helper-make-local-url@2.31.2(transitive)
+ Added@webex/test-helper-mocha@2.31.2(transitive)
+ Added@webex/test-helper-mock-web-socket@2.31.2(transitive)
+ Added@webex/test-helper-mock-webex@2.31.2(transitive)
+ Added@webex/test-helper-refresh-callback@2.31.2(transitive)
+ Added@webex/test-helper-retry@2.31.2(transitive)
+ Added@webex/test-helper-test-users@2.31.2(transitive)
+ Added@webex/test-users@2.31.2(transitive)
+ Added@webex/webex-core@2.31.2(transitive)
- Removed@webex/common@2.31.1(transitive)
- Removed@webex/common-timers@2.31.1(transitive)
- Removed@webex/http-core@2.31.1(transitive)
- Removed@webex/internal-plugin-device@2.31.1(transitive)
- Removed@webex/internal-plugin-feature@2.31.1(transitive)
- Removed@webex/internal-plugin-mercury@2.31.1(transitive)
- Removed@webex/internal-plugin-metrics@2.31.1(transitive)
- Removed@webex/plugin-logger@2.31.1(transitive)
- Removed@webex/storage-adapter-spec@2.31.1(transitive)
- Removed@webex/test-helper-chai@2.31.1(transitive)
- Removed@webex/test-helper-file@2.31.1(transitive)
- Removed@webex/test-helper-make-local-url@2.31.1(transitive)
- Removed@webex/test-helper-mocha@2.31.1(transitive)
- Removed@webex/test-helper-mock-web-socket@2.31.1(transitive)
- Removed@webex/test-helper-mock-webex@2.31.1(transitive)
- Removed@webex/test-helper-refresh-callback@2.31.1(transitive)
- Removed@webex/test-helper-retry@2.31.1(transitive)
- Removed@webex/test-helper-test-users@2.31.1(transitive)
- Removed@webex/test-users@2.31.1(transitive)
- Removed@webex/webex-core@2.31.1(transitive)