@eka-care/ekascribe-ts-sdk 2.0.46 → 2.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -21,18 +21,17 @@ declare class EkaScribe {
21
21
  private audioBufferInstance;
22
22
  private compatibilityManager;
23
23
  private constructor();
24
- static getInstance({ access_token, env, clientId, clientEndpoint, }: {
24
+ static getInstance({ access_token, env, clientId, }: {
25
25
  access_token?: string;
26
26
  env?: 'PROD' | 'DEV';
27
27
  clientId?: string;
28
- clientEndpoint?: string;
29
28
  }): EkaScribe;
30
29
  resetInstance(): void;
31
30
  getEkascribeConfig(): Promise<TGetConfigV2Response>;
32
31
  updateAuthTokens({ access_token }: {
33
32
  access_token: string;
34
33
  }): void;
35
- initTransaction(request: TPostTransactionInitRequest): Promise<TStartRecordingResponse>;
34
+ initTransaction(request: TPostTransactionInitRequest, sharedWorkerUrl?: string): Promise<TStartRecordingResponse>;
36
35
  startRecording(): Promise<TStartRecordingResponse>;
37
36
  reinitializeVad(): void;
38
37
  destroyVad(): void;
@@ -122,11 +121,10 @@ declare enum ERROR_CODE {
122
121
 
123
122
  declare type Gender = 'M' | 'F' | 'O';
124
123
 
125
- export declare const getEkaScribeInstance: ({ access_token, env, clientId, clientEndpoint, }: {
124
+ export declare const getEkaScribeInstance: ({ access_token, env, clientId, }: {
126
125
  access_token?: string;
127
126
  env?: "PROD" | "DEV";
128
127
  clientId?: string;
129
- clientEndpoint?: string;
130
128
  }) => EkaScribe;
131
129
 
132
130
  declare type TAudioChunksInfo = {
package/dist/index.mjs CHANGED
@@ -38528,40 +38528,40 @@ class AudioFileManager {
38528
38528
  updateAudioInfo(a) {
38529
38529
  return this.audioChunks.push(a), this.audioChunks.length;
38530
38530
  }
38531
- createSharedWorkerInstance() {
38531
+ createSharedWorkerInstance(a) {
38532
38532
  try {
38533
- const a = new SharedWorker(new URL("../shared-worker/s3-file-upload.js"));
38534
- this.sharedWorkerInstance = a;
38535
- const s = EkaScribeStore$1.eventCallback;
38536
- return this.sharedWorkerInstance.port.onmessage = async (n) => {
38537
- const r = n.data;
38538
- switch (r.action) {
38533
+ const s = new SharedWorker(a);
38534
+ this.sharedWorkerInstance = s;
38535
+ const n = EkaScribeStore$1.eventCallback;
38536
+ return this.sharedWorkerInstance.port.onmessage = async (r) => {
38537
+ const c = r.data;
38538
+ switch (c.action) {
38539
38539
  case SHARED_WORKER_ACTION.CONFIGURE_AWS_SUCCESS: {
38540
- s && s({
38540
+ n && n({
38541
38541
  callback_type: CALLBACK_TYPE.AWS_CONFIGURE_STATUS,
38542
38542
  status: "success",
38543
- message: r.message,
38543
+ message: c.message,
38544
38544
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
38545
38545
  });
38546
38546
  return;
38547
38547
  }
38548
38548
  case SHARED_WORKER_ACTION.CONFIGURE_AWS_ERROR: {
38549
- s && s({
38549
+ n && n({
38550
38550
  callback_type: CALLBACK_TYPE.AWS_CONFIGURE_STATUS,
38551
38551
  status: "error",
38552
- message: r.message,
38552
+ message: c.message,
38553
38553
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
38554
38554
  });
38555
38555
  return;
38556
38556
  }
38557
38557
  case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER_SUCCESS: {
38558
38558
  const {
38559
- fileCount: c,
38560
- chunkIndex: u,
38561
- fileBlob: m,
38562
- compressedAudioBuffer: y
38563
- } = r.requestBody;
38564
- s && y && s({
38559
+ fileCount: u,
38560
+ chunkIndex: m,
38561
+ fileBlob: y,
38562
+ compressedAudioBuffer: l
38563
+ } = c.requestBody;
38564
+ n && l && n({
38565
38565
  callback_type: CALLBACK_TYPE.FILE_UPLOAD_STATUS,
38566
38566
  status: "info",
38567
38567
  message: "Audioframes of chunk to store in IDB",
@@ -38569,57 +38569,57 @@ class AudioFileManager {
38569
38569
  data: {
38570
38570
  success: this.successfulUploads.length,
38571
38571
  total: this.audioChunks.length,
38572
- fileName: c,
38573
- chunkData: y
38572
+ fileName: u,
38573
+ chunkData: l
38574
38574
  }
38575
- }), r.response.success ? (this.successfulUploads.push(c), u !== -1 && (this.audioChunks[u] = {
38576
- ...this.audioChunks[u],
38575
+ }), c.response.success ? (this.successfulUploads.push(u), m !== -1 && (this.audioChunks[m] = {
38576
+ ...this.audioChunks[m],
38577
38577
  audioFrames: void 0,
38578
38578
  fileBlob: void 0,
38579
38579
  status: "success",
38580
- response: r.response.success
38581
- }), s && s({
38580
+ response: c.response.success
38581
+ }), n && n({
38582
38582
  callback_type: CALLBACK_TYPE.FILE_UPLOAD_STATUS,
38583
38583
  status: "success",
38584
- message: r.response.success,
38584
+ message: c.response.success,
38585
38585
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
38586
38586
  data: {
38587
38587
  success: this.successfulUploads.length,
38588
38588
  total: this.audioChunks.length,
38589
38589
  is_uploaded: !0
38590
38590
  }
38591
- })) : (s && s({
38591
+ })) : (n && n({
38592
38592
  callback_type: CALLBACK_TYPE.FILE_UPLOAD_STATUS,
38593
38593
  status: "error",
38594
- message: r.response.error || "Upload failed",
38594
+ message: c.response.error || "Upload failed",
38595
38595
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
38596
38596
  error: {
38597
- code: r.response.code,
38598
- msg: r.response.error,
38599
- details: r.response.errorCode
38597
+ code: c.response.code,
38598
+ msg: c.response.error,
38599
+ details: c.response.errorCode
38600
38600
  },
38601
38601
  data: {
38602
- fileName: c,
38602
+ fileName: u,
38603
38603
  is_uploaded: !1
38604
38604
  }
38605
- }), u !== -1 && (this.audioChunks[u] = {
38606
- ...this.audioChunks[u],
38607
- fileBlob: m,
38605
+ }), m !== -1 && (this.audioChunks[m] = {
38606
+ ...this.audioChunks[m],
38607
+ fileBlob: y,
38608
38608
  audioFrames: void 0,
38609
38609
  status: "failure",
38610
- response: r.response.error || "Upload failed"
38611
- }), r.response.errorCode === "ExpiredToken" && this.setupAWSConfiguration({
38610
+ response: c.response.error || "Upload failed"
38611
+ }), c.response.errorCode === "ExpiredToken" && this.setupAWSConfiguration({
38612
38612
  is_shared_worker: !0
38613
38613
  }));
38614
38614
  }
38615
38615
  }
38616
- }, a.port.start(), !0;
38617
- } catch (a) {
38618
- const s = a instanceof Error ? a.message : String(a);
38619
- return s.includes("SecurityError") || s.includes("Failed to construct") ? console.error(
38616
+ }, s.port.start(), !0;
38617
+ } catch (s) {
38618
+ const n = s instanceof Error ? s.message : String(s);
38619
+ return n.includes("SecurityError") || n.includes("Failed to construct") ? console.error(
38620
38620
  "Error creating shared worker instance: CORS/Same-origin policy violation. The SharedWorker script must be served from the same origin as your application, or the server must allow cross-origin access with proper CORS headers. Falling back to non-worker upload method.",
38621
- a
38622
- ) : console.error("Error creating shared worker instance:", a), !1;
38621
+ s
38622
+ ) : console.error("Error creating shared worker instance:", s), !1;
38623
38623
  }
38624
38624
  }
38625
38625
  async setupAWSConfiguration({ is_shared_worker: a }) {
@@ -38753,20 +38753,7 @@ class AudioFileManager {
38753
38753
  };
38754
38754
  }
38755
38755
  async uploadAudioToS3({ audioFrames: a, fileName: s, chunkIndex: n }) {
38756
- if (typeof SharedWorker > "u" || !SharedWorker)
38757
- console.log("Shared Workers are NOT supported in this browser."), await this.uploadAudioToS3WithoutWorker({ audioFrames: a, fileName: s, chunkIndex: n });
38758
- else {
38759
- if (console.log("Shared Workers are supported in this browser."), !this.sharedWorkerInstance) {
38760
- const r = this.createSharedWorkerInstance();
38761
- if (console.log(r, "worker created"), !r) {
38762
- console.warn(
38763
- "Failed to create SharedWorker instance. Falling back to non-worker upload method."
38764
- ), await this.uploadAudioToS3WithoutWorker({ audioFrames: a, fileName: s, chunkIndex: n });
38765
- return;
38766
- }
38767
- }
38768
- await this.uploadAudioToS3WithWorker({ audioFrames: a, fileName: s, chunkIndex: n });
38769
- }
38756
+ typeof SharedWorker > "u" || !SharedWorker || !this.sharedWorkerInstance ? (console.log("Shared Workers are NOT supported in this browser."), await this.uploadAudioToS3WithoutWorker({ audioFrames: a, fileName: s, chunkIndex: n })) : (console.log("Shared Workers are supported in this browser."), await this.uploadAudioToS3WithWorker({ audioFrames: a, fileName: s, chunkIndex: n }));
38770
38757
  }
38771
38758
  async uploadAudioToS3WithWorker({
38772
38759
  audioFrames: a,
@@ -54827,14 +54814,13 @@ const Ur = class Ur {
54827
54814
  static getInstance({
54828
54815
  access_token: a,
54829
54816
  env: s,
54830
- clientId: n,
54831
- clientEndpoint: r
54817
+ clientId: n
54832
54818
  }) {
54833
54819
  return setEnv({
54834
54820
  ...a ? { auth_token: a } : {},
54835
54821
  ...s ? { env: s } : {},
54836
54822
  ...n ? { clientId: n } : {}
54837
- }), console.log(r, "clientEndpoint"), Ur.instance || (Ur.instance = new Ur()), Ur.instance;
54823
+ }), Ur.instance || (Ur.instance = new Ur()), Ur.instance;
54838
54824
  }
54839
54825
  // Method to reset the singleton instance (useful for testing)
54840
54826
  resetInstance() {
@@ -54848,15 +54834,15 @@ const Ur = class Ur {
54848
54834
  auth_token: a
54849
54835
  });
54850
54836
  }
54851
- async initTransaction(a) {
54852
- EkaScribeStore$1.resetStore(), this.audioFileManagerInstance = new AudioFileManager(), EkaScribeStore$1.audioFileManagerInstance = this.audioFileManagerInstance, this.audioBufferInstance = new AudioBufferManager(SAMPLING_RATE, AUDIO_BUFFER_SIZE_IN_S), EkaScribeStore$1.audioBufferInstance = this.audioBufferInstance, this.vadInstance = new VadWebClient(
54837
+ async initTransaction(a, s) {
54838
+ EkaScribeStore$1.resetStore(), this.audioFileManagerInstance = new AudioFileManager(), EkaScribeStore$1.audioFileManagerInstance = this.audioFileManagerInstance, s && this.audioFileManagerInstance.createSharedWorkerInstance(s), this.audioBufferInstance = new AudioBufferManager(SAMPLING_RATE, AUDIO_BUFFER_SIZE_IN_S), EkaScribeStore$1.audioBufferInstance = this.audioBufferInstance, this.vadInstance = new VadWebClient(
54853
54839
  PREF_CHUNK_LENGTH,
54854
54840
  DESP_CHUNK_LENGTH,
54855
54841
  MAX_CHUNK_LENGTH,
54856
54842
  FRAME_RATE
54857
54843
  ), EkaScribeStore$1.vadInstance = this.vadInstance, console.log("Initialising SDK Instances ", EkaScribeStore$1);
54858
- const s = await initialiseTransaction(a);
54859
- return console.log(s, "initTransactionResponse"), s;
54844
+ const n = await initialiseTransaction(a);
54845
+ return console.log(n, "initTransactionResponse"), n;
54860
54846
  }
54861
54847
  async startRecording() {
54862
54848
  const a = await startVoiceRecording();
@@ -55123,9 +55109,8 @@ let EkaScribe = Ur;
55123
55109
  const getEkaScribeInstance = ({
55124
55110
  access_token: i,
55125
55111
  env: a,
55126
- clientId: s,
55127
- clientEndpoint: n
55128
- }) => EkaScribe.getInstance({ access_token: i, env: a, clientId: s, clientEndpoint: n });
55112
+ clientId: s
55113
+ }) => EkaScribe.getInstance({ access_token: i, env: a, clientId: s });
55129
55114
  export {
55130
55115
  getEkaScribeInstance
55131
55116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "2.0.46",
3
+ "version": "2.0.47",
4
4
  "description": "EkaScribe TypeScript SDK - Modern ES2020 build",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",