Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

augnitoambientsdk

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

augnitoambientsdk - npm Package Compare versions

Comparing version 1.0.1 to 1.0.5

dist/augnitoambientsdk.js

20

package.json
{
"name": "augnitoambientsdk",
"version": "1.0.1",
"version": "1.0.5",
"description": "Use this typescript SDK to integrate Augnito’s Ambient Tech within your EMR. To get access credentials or know more about how Augnito Ambient can benefit you, please visit our website and connect with our sales team: https://augnito.ai/",
"main": "dist/index.js",
"main": "dist/augnitoambientsdk.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
"build": "rollup -c"
},

@@ -13,3 +13,3 @@ "keywords": [

"Clinical Documentation",
"Augnito",
"Augnito",
"Voice AI",

@@ -22,4 +22,14 @@ "Ambient Intelligence"

"devDependencies": {
"typescript": "^5.3.3"
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"typescript": "^5.3.3",
"rollup": "^2.79.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0"
},
"dependencies": {
"augnitorecorder": "^1.0.5",
"rollup-plugin-typescript2": "^0.36.0"
}
}

@@ -1,7 +0,9 @@

import AmbientConfig from "./config/AmbientConfig";
import AmbientConfig from "./config/AmbientConfig";
import { socketConfig } from "./config/socketConfig";
import { AmbientRestAPI } from "./api/AmbientRestAPI";
import { websocketHandler } from "./handlers/websocketHandler";
// import { websocketHandler } from "./handlers/websocketHandler";
import { Logger } from "./utils/Logger";
import { Guard } from "./utils/Guard";
import { AugnitoRecorder } from "augnitorecorder";
import { AugnitoSocketResponse } from "./support/AugnitoSocketResponse";

@@ -12,16 +14,40 @@ /**

*/
export class AugnitoAmbient{
private _logTag = 'Augnito-Ambient';
export class AugnitoAmbient {
private _logTag = "Augnito-Ambient";
private _ambientRestAPI: AmbientRestAPI;
private _wsHandler: websocketHandler;
constructor(config: AmbientConfig){
// private _wsHandler: websocketHandler;
private config: socketConfig | null | undefined;
private recorderIns: AugnitoRecorder;
constructor(config: AmbientConfig) {
this._ambientRestAPI = new AmbientRestAPI(this.validateConfig(config));
this._wsHandler = new websocketHandler(
this.createSocketConfig(this.validateConfig(config))
);
// this._wsHandler = new websocketHandler(
// this.createSocketConfig(this.validateConfig(config))
// );
this.recorderIns = new AugnitoRecorder({
serverURL: this.config?.prepareWSSURL("wav", "") || "",
enableLogs: true,
isDebug: false,
bufferInterval: 1,
EOS_Message: '{"JobAction":"EOS","Status":0,"Type":"meta"}',
socketTimeoutInterval: 10000,
});
this.recorderIns.onError = this.onErrorCallback.bind(this);
this.recorderIns.onPartialResult =
this.onPartialResultsCallback.bind(this);
this.recorderIns.onFinalResult = this.onSocketFinalResult.bind(this);
this.recorderIns.onStateChanged = this.onStateChangeCallback.bind(this);
this.recorderIns.onSessionEvent =
this.onSessionEventCallback.bind(this);
const _socketConfig = new socketConfig(config);
_socketConfig.onStartOfRecording =
this.recorderIns.onStateChanged.bind(this);
_socketConfig.onStopOfRecording = this.recorderIns.onStateChanged.bind(this);;
_socketConfig.onError = this.recorderIns.onError.bind(this);
_socketConfig.onMetaEvent = this.recorderIns.onSessionEvent.bind(this);
}
/**
* @description Callback to receive the JOb Id
*/
* @description Callback to receive the JOb Id
*/
public onJobCreated?: (text: string) => void;

@@ -34,3 +60,3 @@

/**
/**
* Callback triggered when an error occurs within the SDK

@@ -40,4 +66,11 @@ */

public onPartialResult?: (text: string) => void;
public onFinalResult?: (text: string) => void;
public onSessionEvent?: (text: string) => void;
public onIdleMic?: () => void;
// #region Public Methods
/**

@@ -47,12 +80,11 @@ * Returns the Note parameters which need be use while doing toggle listeing

*/
public async getNoteParams():Promise<any>{
try{
public async getNoteParams(): Promise<any> {
try {
if (!this._ambientRestAPI) {
Logger.error('SDK not initialized', this._logTag);
Logger.error("SDK not initialized", this._logTag);
return;
}
return await this._ambientRestAPI.GetNoteParams();
}
catch(e:any){
if(e instanceof Error){
}
return await this._ambientRestAPI.GetNoteParams();
} catch (e: any) {
if (e instanceof Error) {
this.onErrorCallback(e.message);

@@ -65,27 +97,22 @@ }

* @param JobId to retrieve output for a specific audio file
* @returns JSON object contains both Transcript and Note on sucess else fail resonse
* @returns JSON object contains both Transcript and Note on sucess else fail resonse
*/
public async getSummarizedNote(JobId:string):Promise<any>{
try{
public async getSummarizedNote(JobId: string): Promise<any> {
try {
if (!this._ambientRestAPI) {
Logger.error('SDK not initialized', this._logTag);
Logger.error("SDK not initialized", this._logTag);
return;
}
var responseJson = await this._ambientRestAPI.FetchJob(JobId);
if(responseJson)
{
if(responseJson.Status === 200){
if (responseJson) {
if (responseJson.Status === 200) {
return responseJson;
}
else{
} else {
this.onErrorCallback(responseJson.ErrorMessage);
}
}
else
{
} else {
this.onErrorCallback("Unknown Error!");
}
}
catch(e:any){
if(e instanceof Error){
} catch (e: any) {
if (e instanceof Error) {
this.onErrorCallback(e.message);

@@ -101,12 +128,14 @@ }

*/
public async sendSummarizedNote(JobId:string, NoteDate:string):Promise<any>{
try{
public async sendSummarizedNote(
JobId: string,
NoteDate: string
): Promise<any> {
try {
if (!this._ambientRestAPI) {
Logger.error('SDK not initialized', this._logTag);
Logger.error("SDK not initialized", this._logTag);
return;
}
return await this._ambientRestAPI.SendFinalNote(JobId,NoteDate);
}
catch(e:any){
if(e instanceof Error){
return await this._ambientRestAPI.SendFinalNote(JobId, NoteDate);
} catch (e: any) {
if (e instanceof Error) {
this.onErrorCallback(e.message);

@@ -122,11 +151,9 @@ }

*/
public toggleListening(filetype:string, noteparams:any): void {
if (!this._wsHandler) {
Logger.error('SDK not initialized', this._logTag);
return;
public toggleListening(): void {
if (!this.recorderIns) {
Logger.error("SDK not initialized", this._logTag);
return;
}
Guard.Against.NullOrEmpty(filetype, 'FileType');
Guard.Against.NullOrEmpty(noteparams, 'Note Params');
this._wsHandler.toggleListening(filetype,noteparams);
}
this.recorderIns.toggleStartStopAudioStream();
}

@@ -137,20 +164,80 @@ // #endregion

private onEventCallback(data:string):void{
private onEventCallback(data: string): void {
if (this.onJobCreated) {
this.onJobCreated(data);
}
}
}
private onStateChangeCallback(isRecording:boolean):void{
private onStateChangeCallback(isRecording: boolean): void {
if (this.onStateChanged) {
this.onStateChanged(isRecording);
}
}
}
private onErrorCallback(errorMessage:string):void{
private onErrorCallback(errorMessage: string): void {
if (this.onError) {
this.onError(errorMessage);
}
}
}
private onPartialResultsCallback(data: string): void {
if (this.onPartialResult) {
this.onPartialResult(data);
}
}
private onSocketFinalResult(data: string): void {
if (this.onFinalResult) {
this.onFinalResult(data);
}
}
private onIdleMicCallback(): void {
if (this.onIdleMic) {
this.onIdleMic();
}
}
private onSessionEventCallback(data: string | AugnitoSocketResponse): void {
var json = undefined;
if (typeof data === "string") {
json = JSON.parse(data);
} else {
json = data;
}
Logger.log({ type: "onSessionEvent", data: data }, this._logTag);
if (this.onSessionEvent) {
this.onSessionEvent(json);
}
if (typeof json.Event == "string" && json.Event === "None") {
return;
}
const eventType = json.Event.Type;
const eventValue = json.Event.Value;
if (eventType === "SESSION_CREATED") {
const sessionToken = eventValue;
Logger.log("session Token " + sessionToken, this._logTag);
} else if (eventType === "SERVICE_DOWN") {
// Very rare, But This event will come when Speech server's any internal component down.
Logger.error(eventType, this._logTag);
} else if (eventType === "NO_DICTATION_STOP_MIC") {
Logger.log("NO_DICTATION_STOP_MIC", this._logTag);
this.onIdleMicCallback();
} else if (eventType === "INVALID_AUTH_CREDENTIALS") {
// This event happens when one of following is invalid.
// AccountCode, AccessKey, Active subscription for trial or paid. lmid.
Logger.error("INVALID_AUTH_CREDENTIALS", this._logTag);
Logger.log(
"Invalid authentication, Please check your Account Status, Lm Id and Access Key."
);
} else if (eventType === "LOW_BANDWIDTH") {
// Speech API need continues upload speed of 32KBps if it raw audio data with 16k sampling rate.
// If fluctuation in internet than speech output may be delayed. It's good to notify that speech may delayed due to poor network connection.
// Client app can use this event to show un attendant popup to indicate network status.
Logger.log(
"LOW_BANDWIDTH: Check internet connection",
this._logTag
);
}
}
// #endregion

@@ -163,12 +250,13 @@

validateConfig(config: AmbientConfig): AmbientConfig {
Guard.Against.NullOrEmpty(config.server, 'Server');
Guard.Against.NullOrEmpty(config.subscriptionCode, 'SubscriptionCode');
Guard.Against.NullOrEmpty(config.accessKey, 'AccessKey');
Guard.Against.NullOrEmpty(config.userTag, 'UserTag');
Guard.Against.NullOrEmpty(config.server, "Server");
Guard.Against.NullOrEmpty(config.subscriptionCode, "SubscriptionCode");
Guard.Against.NullOrEmpty(config.accessKey, "AccessKey");
Guard.Against.NullOrEmpty(config.userTag, "UserTag");
return config;
};
}
private createSocketConfig(config: AmbientConfig): socketConfig {
const _socketConfig = new socketConfig(config);
_socketConfig.onStartOfRecording = this.onStateChangeCallback.bind(this);
_socketConfig.onStartOfRecording =
this.onStateChangeCallback.bind(this);
_socketConfig.onStopOfRecording = this.onStateChangeCallback.bind(this);

@@ -179,2 +267,2 @@ _socketConfig.onError = this.onErrorCallback.bind(this);

}
}
}

@@ -11,3 +11,3 @@ import AmbientConfig from "./AmbientConfig";

constructor(private _config:AmbientConfig){
this.wssBaseURL = `wss://${_config.server}/ambient/process-job`;
this.wssBaseURL = `wss://${_config.server}/ambient/stream-job`;
}

@@ -14,0 +14,0 @@

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -28,5 +28,5 @@ {

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "ESNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */

@@ -33,0 +33,0 @@ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc