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.18

dist/augnitoambientsdk.js

20

package.json
{
"name": "augnitoambientsdk",
"version": "1.0.1",
"version": "1.0.18",
"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,38 @@ /**

*/
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.config = this.createSocketConfig(this.validateConfig(config));
this.recorderIns = new AugnitoRecorder({
serverURL: this.config?.prepareWSSURL("wav", "") || "",
enableLogs: true,
isDebug: false,
bufferInterval: 30,
EOS_Message: "{\\\"JobAction\\\":\\\"EOS\\\",\\\"Status\\\":0,\\\"Type\\\":\\\"meta\\\"}",
socketTimeoutInterval: 10000,
});
console.log(this.recorderIns);
this.recorderIns.onError = this.onErrorCallback.bind(this);
this.recorderIns.onStateChanged = this.onStateChangeCallback.bind(this);
this.recorderIns.onSessionEvent =
this.onSessionEventCallback.bind(this);
this.recorderIns.onPartialResult =
this.onPartialResultsCallback.bind(this);
this.recorderIns.onFinalResult = this.onSocketFinalResult.bind(this);
}
/**
* @description Callback to receive the JOb Id
*/
* @description Callback to receive the JOb Id
*/
public onJobCreated?: (text: string) => void;

@@ -34,3 +58,3 @@

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

@@ -40,4 +64,7 @@ */

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

@@ -47,12 +74,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 +91,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 +122,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 +145,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 +158,87 @@ // #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 {
if (!data) {
return;
}
let json: any;
try {
json = typeof data === "string" ? JSON.parse(data) : data;
} catch (error) {
Logger.error(`Error parsing session event data: ${error}`, this._logTag);
return;
}
if (!json || !("Type" in json)) {
return;
}
if (json.Type.toLowerCase() === "meta" && this.config?.onMetaEvent) {
if (!json.JobID) {
Logger.error(`JobID is missing in meta event`, this._logTag);
return;
}
this.config.onMetaEvent(json.JobID);
} else if (json.Type.toLowerCase() === "error" && json.Data) {
this.onErrorCallback(json.Data);
}
if (typeof json.Event !== "object" || json.Event === null) {
return;
}
const { Type: eventType, Value: eventValue } = json.Event;
if (!eventType) {
return;
}
if (eventType === "SESSION_CREATED" && eventValue) {
Logger.log(`session Token ${eventValue}`, this._logTag);
} else if (eventType === "SERVICE_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") {
Logger.error("INVALID_AUTH_CREDENTIALS", this._logTag);
} else if (eventType === "LOW_BANDWIDTH") {
Logger.log("LOW_BANDWIDTH: Check internet connection", this._logTag);
}
}
// #endregion

@@ -163,13 +251,14 @@

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.onStopOfRecording = this.onStateChangeCallback.bind(this);
// _socketConfig.onStartOfRecording =
// this.onStateChangeCallback.bind(this);
// _socketConfig.onStopOfRecording = this.onStateChangeCallback.bind(this);
_socketConfig.onError = this.onErrorCallback.bind(this);

@@ -179,2 +268,2 @@ _socketConfig.onMetaEvent = this.onEventCallback.bind(this);

}
}
}

@@ -5,4 +5,4 @@ import AmbientConfig from "./AmbientConfig";

onStartOfRecording?: (isRecording: boolean) => void;
onStopOfRecording?: (isRecording: boolean) => void;
// onStartOfRecording?: (isRecording: boolean) => void;
// onStopOfRecording?: (isRecording: boolean) => void;
onError?: (errorMessage: string) => void;

@@ -12,3 +12,3 @@ onMetaEvent?:(jobId: string) => void;

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

@@ -15,0 +15,0 @@

@@ -37,3 +37,3 @@ import { socketConfig } from '../config/socketConfig.js';

await this.StartAudioStream();
this.onStartOfRecording();
// this.onStartOfRecording();
}

@@ -93,3 +93,3 @@ catch (e) {

this.recordingInpogress = false;
this.onStopOfRecording();
// this.onStopOfRecording();
this.getAndProcessBlob();

@@ -227,13 +227,13 @@ }

private onStartOfRecording():void{
if (this._config.onStartOfRecording) {
this._config.onStartOfRecording(true);
}
}
// private onStartOfRecording():void{
// if (this._config.onStartOfRecording) {
// this._config.onStartOfRecording(true);
// }
// }
private onStopOfRecording():void{
if (this._config.onStopOfRecording) {
this._config.onStopOfRecording(false);
}
}
// private onStopOfRecording():void{
// if (this._config.onStopOfRecording) {
// this._config.onStopOfRecording(false);
// }
// }

@@ -240,0 +240,0 @@ private onMetaEvent(data:string):void{

@@ -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