@eka-care/ekascribe-ts-sdk 1.5.80 → 1.5.81

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.
Files changed (30) hide show
  1. package/dist/api/get-transaction-history.d.ts +5 -0
  2. package/dist/api/get-transaction-history.js +28 -0
  3. package/dist/api/get-voice-api-v2-config.d.ts +2 -0
  4. package/dist/api/get-voice-api-v2-config.js +26 -0
  5. package/dist/api/get-voice-api-v2-status.d.ts +51 -0
  6. package/dist/api/get-voice-api-v2-status.js +25 -0
  7. package/dist/api/get-voice-api-v3-status.d.ts +51 -0
  8. package/dist/api/get-voice-api-v3-status.js +26 -0
  9. package/dist/api/patch-transaction-status.d.ts +4 -0
  10. package/dist/api/patch-transaction-status.js +43 -0
  11. package/dist/api/post-transaction-commit.d.ts +3 -0
  12. package/dist/api/post-transaction-commit.js +32 -0
  13. package/dist/api/post-transaction-init.d.ts +3 -0
  14. package/dist/api/post-transaction-init.js +40 -0
  15. package/dist/api/post-transaction-stop.d.ts +3 -0
  16. package/dist/api/post-transaction-stop.js +32 -0
  17. package/dist/api/templates/post-convert-transaction-to-template.d.ts +3 -0
  18. package/dist/api/templates/post-convert-transaction-to-template.js +32 -0
  19. package/dist/api/transaction/get-voice-api-v2-config.d.ts +2 -0
  20. package/dist/api/transaction/get-voice-api-v2-config.js +26 -0
  21. package/dist/api/transaction/get-voice-api-v3-status-transcription.d.ts +61 -0
  22. package/dist/api/transaction/get-voice-api-v3-status-transcription.js +26 -0
  23. package/dist/audio-chunker/__tests__/audio-file-manager.test.d.ts +1 -0
  24. package/dist/audio-chunker/__tests__/audio-file-manager.test.js +5 -0
  25. package/dist/audio-chunker/audio-file-manager.js +24 -6
  26. package/dist/shared-worker/s3-file-upload.js +110 -60
  27. package/dist/shared-worker/s3-file-upload.ts +128 -0
  28. package/dist/utils/search-sessions-by-patient-name.d.ts +7 -0
  29. package/dist/utils/search-sessions-by-patient-name.js +27 -0
  30. package/package.json +2 -3
@@ -0,0 +1,128 @@
1
+ // window is undefined in sharedWorker so it is needed to decode the XML AWS error
2
+ if (typeof window === 'undefined') {
3
+ self.window = self;
4
+ }
5
+
6
+ import { configureAWS } from '../aws-services/configure-aws';
7
+ import pushFileToS3 from '../aws-services/upload-file-to-s3';
8
+ import { AUDIO_EXTENSION_TYPE_MAP, OUTPUT_FORMAT } from '../constants/constant';
9
+ import { SHARED_WORKER_ACTION } from '../constants/enums';
10
+ import compressAudioToMp3 from '../utils/compress-mp3-audio';
11
+
12
+ // onconnect - to establish communication channel with the main thread
13
+ // eslint-disable-next-line
14
+ // @ts-ignore
15
+ onconnect = function (event: MessageEvent) {
16
+ // after connection messages are being channelled through the port
17
+ const workerPort = event.ports[0];
18
+
19
+ let uploadRequestReceived: number = 0;
20
+ let uploadRequestCompleted: number = 0;
21
+
22
+ // onmessage - to handle messages from the main thread
23
+ workerPort.onmessage = async function (event) {
24
+ const workerData = event.data;
25
+
26
+ switch (workerData.action) {
27
+ case SHARED_WORKER_ACTION.CONFIGURE_AWS: {
28
+ try {
29
+ const { accessKeyId, secretKey, sessionToken } = workerData.payload;
30
+
31
+ configureAWS({
32
+ accessKeyId,
33
+ secretKey,
34
+ sessionToken,
35
+ });
36
+
37
+ workerPort.postMessage({
38
+ action: SHARED_WORKER_ACTION.CONFIGURE_AWS_SUCCESS,
39
+ message: 'AWS configured successfully',
40
+ });
41
+ } catch (error: unknown) {
42
+ workerPort.postMessage({
43
+ action: SHARED_WORKER_ACTION.CONFIGURE_AWS_ERROR,
44
+ error: error || 'Failed to configure AWS',
45
+ });
46
+ }
47
+
48
+ return;
49
+ }
50
+
51
+ case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER: {
52
+ const { fileName, audioFrames, txnID, businessID, fileBlob, s3BucketName } =
53
+ workerData.payload;
54
+ uploadRequestReceived++;
55
+
56
+ let audioBlob: Blob;
57
+ let compressedAudioBuffer: Uint8Array<ArrayBufferLike>[];
58
+
59
+ if (fileBlob) {
60
+ audioBlob = fileBlob;
61
+ } else {
62
+ compressedAudioBuffer = compressAudioToMp3(audioFrames);
63
+
64
+ audioBlob = new Blob(compressedAudioBuffer, {
65
+ type: AUDIO_EXTENSION_TYPE_MAP[OUTPUT_FORMAT],
66
+ });
67
+ }
68
+
69
+ await pushFileToS3({
70
+ s3BucketName,
71
+ fileBlob: audioBlob,
72
+ fileName,
73
+ txnID,
74
+ businessID,
75
+ is_shared_worker: true,
76
+ })
77
+ .then((response) => {
78
+ uploadRequestCompleted++;
79
+ // postMessage - to send messages back to the main thread
80
+ workerPort.postMessage({
81
+ action: SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER_SUCCESS,
82
+ response,
83
+ requestBody: {
84
+ ...workerData.payload,
85
+ fileBlob: audioBlob,
86
+ compressedAudioBuffer,
87
+ },
88
+ });
89
+ })
90
+ .catch((error) => {
91
+ console.log(error, 'shared worker - file upload');
92
+ uploadRequestCompleted++;
93
+ });
94
+
95
+ return;
96
+ }
97
+
98
+ case SHARED_WORKER_ACTION.WAIT_FOR_ALL_UPLOADS: {
99
+ if (uploadRequestReceived === uploadRequestCompleted) {
100
+ workerPort.postMessage({
101
+ action: SHARED_WORKER_ACTION.WAIT_FOR_ALL_UPLOADS_SUCCESS,
102
+ response: {
103
+ uploadRequestReceived,
104
+ uploadRequestCompleted,
105
+ },
106
+ });
107
+ return;
108
+ }
109
+
110
+ workerPort.postMessage({
111
+ action: SHARED_WORKER_ACTION.WAIT_FOR_ALL_UPLOADS_ERROR,
112
+ response: {
113
+ uploadRequestReceived,
114
+ uploadRequestCompleted,
115
+ },
116
+ });
117
+ return;
118
+ }
119
+ }
120
+ };
121
+
122
+ workerPort.postMessage(`[WORKER] Web worker onmessage established ${JSON.stringify(workerPort)}`);
123
+
124
+ // start the worker port to listen for messages
125
+ workerPort.start();
126
+ };
127
+
128
+ console.log('File upload web worker created');
@@ -0,0 +1,7 @@
1
+ import { TSessionHistoryData } from '../constants/types';
2
+ export type TSearchSessionsByPatientRequest = {
3
+ sessions: TSessionHistoryData[];
4
+ patientName: string;
5
+ };
6
+ declare const searchSessionsByPatient: ({ sessions, patientName, }: TSearchSessionsByPatientRequest) => Promise<unknown>;
7
+ export default searchSessionsByPatient;
@@ -0,0 +1,27 @@
1
+ function debounce(func, delay) {
2
+ let timeoutId;
3
+ return (...args) => {
4
+ return new Promise((resolve) => {
5
+ clearTimeout(timeoutId);
6
+ timeoutId = setTimeout(() => {
7
+ resolve(func(...args));
8
+ }, delay);
9
+ });
10
+ };
11
+ }
12
+ const searchByName = (sessions, patientName) => {
13
+ if (!patientName.trim()) {
14
+ return sessions;
15
+ }
16
+ const searchTerm = patientName.toLowerCase().trim();
17
+ return sessions.filter((session) => {
18
+ if (!session.patient_details?.username)
19
+ return false;
20
+ return session.patient_details?.username.toLowerCase().includes(searchTerm);
21
+ });
22
+ };
23
+ const debouncedSearch = debounce(searchByName, 300);
24
+ const searchSessionsByPatient = async ({ sessions, patientName, }) => {
25
+ return debouncedSearch(sessions, patientName);
26
+ };
27
+ export default searchSessionsByPatient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "1.5.80",
3
+ "version": "1.5.81",
4
4
  "main": "dist/index.js",
5
5
  "repository": "git@github.com:eka-care/eka-js-sdk.git",
6
6
  "author": "Sanikagoyal28 <sanikagoyal9@gmail.com>",
@@ -15,7 +15,7 @@
15
15
  "license": "MIT",
16
16
  "types": "dist/index.d.ts",
17
17
  "scripts": {
18
- "build": "tsc && node esbuild.worker.mjs",
18
+ "build": "tsc && cp -R eka-sdk/ekascribe-v2rx/shared-worker dist",
19
19
  "lint": "eslint . --ext .ts",
20
20
  "start": "ts-node ./eka-sdk/ekascribe-v2rx/index.ts",
21
21
  "prepare": "yarn build"
@@ -30,7 +30,6 @@
30
30
  "@types/node": "^22.14.1",
31
31
  "@typescript-eslint/eslint-plugin": "^8.30.1",
32
32
  "@typescript-eslint/parser": "^8.30.1",
33
- "esbuild": "^0.27.0",
34
33
  "eslint": "^9.25.0",
35
34
  "ts-node": "^10.9.2",
36
35
  "typescript": "^5.8.3"