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

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 (31) hide show
  1. package/dist/api/transaction/{get-voice-api-v3-status-transcription.d.ts → get-voice-api-v3-status-transcript.d.ts} +1 -1
  2. package/dist/api/transaction/{get-voice-api-v3-status-transcription.js → get-voice-api-v3-status-transcript.js} +2 -2
  3. package/dist/audio-chunker/audio-file-manager.js +5 -5
  4. package/dist/index.js +2 -2
  5. package/dist/shared-worker/s3-file-upload.js +60 -110
  6. package/package.json +3 -2
  7. package/dist/api/get-transaction-history.d.ts +0 -5
  8. package/dist/api/get-transaction-history.js +0 -28
  9. package/dist/api/get-voice-api-v2-config.d.ts +0 -2
  10. package/dist/api/get-voice-api-v2-config.js +0 -26
  11. package/dist/api/get-voice-api-v2-status.d.ts +0 -51
  12. package/dist/api/get-voice-api-v2-status.js +0 -25
  13. package/dist/api/get-voice-api-v3-status.d.ts +0 -51
  14. package/dist/api/get-voice-api-v3-status.js +0 -26
  15. package/dist/api/patch-transaction-status.d.ts +0 -4
  16. package/dist/api/patch-transaction-status.js +0 -43
  17. package/dist/api/post-transaction-commit.d.ts +0 -3
  18. package/dist/api/post-transaction-commit.js +0 -32
  19. package/dist/api/post-transaction-init.d.ts +0 -3
  20. package/dist/api/post-transaction-init.js +0 -40
  21. package/dist/api/post-transaction-stop.d.ts +0 -3
  22. package/dist/api/post-transaction-stop.js +0 -32
  23. package/dist/api/templates/post-convert-transaction-to-template.d.ts +0 -3
  24. package/dist/api/templates/post-convert-transaction-to-template.js +0 -32
  25. package/dist/api/transaction/get-voice-api-v2-config.d.ts +0 -2
  26. package/dist/api/transaction/get-voice-api-v2-config.js +0 -26
  27. package/dist/audio-chunker/__tests__/audio-file-manager.test.d.ts +0 -1
  28. package/dist/audio-chunker/__tests__/audio-file-manager.test.js +0 -5
  29. package/dist/shared-worker/s3-file-upload.ts +0 -128
  30. package/dist/utils/search-sessions-by-patient-name.d.ts +0 -7
  31. package/dist/utils/search-sessions-by-patient-name.js +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "1.5.78",
3
+ "version": "1.5.80",
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 && cp -R eka-sdk/ekascribe-v2rx/shared-worker dist",
18
+ "build": "tsc && node esbuild.worker.mjs",
19
19
  "lint": "eslint . --ext .ts",
20
20
  "start": "ts-node ./eka-sdk/ekascribe-v2rx/index.ts",
21
21
  "prepare": "yarn build"
@@ -30,6 +30,7 @@
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",
33
34
  "eslint": "^9.25.0",
34
35
  "ts-node": "^10.9.2",
35
36
  "typescript": "^5.8.3"
@@ -1,5 +0,0 @@
1
- import { TGetTransactionHistoryResponse } from '../constants/types';
2
- declare const getTransactionHistory: ({ txn_count, }: {
3
- txn_count: number;
4
- }) => Promise<TGetTransactionHistoryResponse>;
5
- export default getTransactionHistory;
@@ -1,28 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- // TODO: pagination changes
5
- const getTransactionHistory = async ({ txn_count, }) => {
6
- try {
7
- const headers = new Headers();
8
- headers.append('Content-Type', 'application/json');
9
- const options = {
10
- method: 'GET',
11
- headers,
12
- };
13
- const responseJson = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/history?count=${txn_count}`, options);
14
- const response = await responseJson.json();
15
- return {
16
- data: response.data,
17
- status_code: responseJson.status,
18
- message: `Past ${txn_count} transactions fetched successfully.`,
19
- };
20
- }
21
- catch (error) {
22
- return {
23
- status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
24
- message: `Something went wrong in fetching transactions. ${error}`,
25
- };
26
- }
27
- };
28
- export default getTransactionHistory;
@@ -1,2 +0,0 @@
1
- import { TGetConfigV2Response } from '../constants/types';
2
- export declare const getConfigV2: () => Promise<TGetConfigV2Response>;
@@ -1,26 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- export const getConfigV2 = async () => {
5
- try {
6
- const options = {
7
- method: 'GET',
8
- headers: {
9
- 'Content-Type': 'application/json',
10
- },
11
- };
12
- const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/config/`, options);
13
- const res = await response.json();
14
- return {
15
- ...res,
16
- code: response.status,
17
- };
18
- }
19
- catch (error) {
20
- console.log('Error in getConfigV2 api: ', error);
21
- return {
22
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
23
- message: `Failed to fetch initial configurations, ${error}`,
24
- };
25
- }
26
- };
@@ -1,51 +0,0 @@
1
- export type TTemplateMessage = {
2
- type: 'warning' | 'error';
3
- code?: string;
4
- msg: string;
5
- };
6
- export type TOutputSummary = {
7
- template_id: string;
8
- value?: string | null;
9
- type: string;
10
- name: string;
11
- status: TTemplateStatus;
12
- errors?: TTemplateMessage[];
13
- warnings?: TTemplateMessage[];
14
- };
15
- export type TTemplateStatus = 'success' | 'partial_success' | 'failure';
16
- type TAdditionalData = {
17
- doctor: {
18
- _id: string;
19
- profile: {
20
- personal: {
21
- name: {
22
- l: string;
23
- f: string;
24
- };
25
- };
26
- };
27
- };
28
- };
29
- type TApiResponse = {
30
- data: {
31
- output?: TOutputSummary[];
32
- additional_data?: TAdditionalData;
33
- meta_data?: {
34
- total_resources?: number;
35
- total_parsed_resources?: number;
36
- };
37
- };
38
- error?: {
39
- code: string;
40
- msg: string;
41
- };
42
- };
43
- export type TGetStatusResponse = {
44
- response?: TApiResponse | null;
45
- code: number;
46
- message?: string;
47
- };
48
- export declare const getVoiceApiV2Status: ({ txnId, }: {
49
- txnId: string;
50
- }) => Promise<TGetStatusResponse>;
51
- export {};
@@ -1,25 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V3 } from '../fetch-client/helper';
4
- export const getVoiceApiV2Status = async ({ txnId, }) => {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const options = {
9
- method: 'GET',
10
- headers,
11
- };
12
- const getResponse = await fetchWrapper(`${GET_EKA_V2RX_HOST_V3()}/status/${txnId}`, options);
13
- const response = await getResponse.json();
14
- return {
15
- response,
16
- code: getResponse.status,
17
- };
18
- }
19
- catch (error) {
20
- return {
21
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
22
- message: `Something went wrong! ${error}`,
23
- };
24
- }
25
- };
@@ -1,51 +0,0 @@
1
- export type TTemplateMessage = {
2
- type: 'warning' | 'error';
3
- code?: string;
4
- msg: string;
5
- };
6
- export type TOutputSummary = {
7
- template_id: string;
8
- value?: string | null;
9
- type: string;
10
- name: string;
11
- status: TTemplateStatus;
12
- errors?: TTemplateMessage[];
13
- warnings?: TTemplateMessage[];
14
- };
15
- export type TTemplateStatus = 'success' | 'partial_success' | 'failure';
16
- type TAdditionalData = {
17
- doctor: {
18
- _id: string;
19
- profile: {
20
- personal: {
21
- name: {
22
- l: string;
23
- f: string;
24
- };
25
- };
26
- };
27
- };
28
- };
29
- type TApiResponse = {
30
- data: {
31
- output?: TOutputSummary[];
32
- additional_data?: TAdditionalData;
33
- meta_data?: {
34
- total_resources?: number;
35
- total_parsed_resources?: number;
36
- };
37
- };
38
- error?: {
39
- code: string;
40
- msg: string;
41
- };
42
- };
43
- export type TGetStatusResponse = {
44
- response?: TApiResponse | null;
45
- status_code: number;
46
- message?: string;
47
- };
48
- export declare const getVoiceApiV3Status: ({ txnId, }: {
49
- txnId: string;
50
- }) => Promise<TGetStatusResponse>;
51
- export {};
@@ -1,26 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V3 } from '../fetch-client/helper';
4
- export const getVoiceApiV3Status = async ({ txnId, }) => {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const options = {
9
- method: 'GET',
10
- headers,
11
- };
12
- // Use custom timeout for this API (16 seconds instead of default 5 seconds)
13
- const getResponse = await fetchWrapper(`${GET_EKA_V2RX_HOST_V3()}/status/${txnId}`, options, 16000);
14
- const response = await getResponse.json();
15
- return {
16
- response,
17
- status_code: getResponse.status,
18
- };
19
- }
20
- catch (error) {
21
- return {
22
- status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
23
- message: `Something went wrong! ${error}`,
24
- };
25
- }
26
- };
@@ -1,4 +0,0 @@
1
- import { TPatchTransactionError, TPatchTransactionRequest, TPostTransactionResponse } from '../constants/types';
2
- export declare const processingError: TPatchTransactionError;
3
- declare const patchTransactionStatus: ({ sessionId, processing_status, processing_error, }: TPatchTransactionRequest) => Promise<TPostTransactionResponse>;
4
- export default patchTransactionStatus;
@@ -1,43 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- export const processingError = {
5
- error: {
6
- type: '',
7
- code: 'cancelled_by_user',
8
- msg: 'Cancelled_by_user',
9
- },
10
- };
11
- const patchTransactionStatus = async ({ sessionId, processing_status, processing_error, }) => {
12
- try {
13
- const headers = new Headers();
14
- headers.append('Content-Type', 'application/json');
15
- const raw = {
16
- processing_status,
17
- processing_error,
18
- };
19
- const options = {
20
- method: 'PATCH',
21
- headers,
22
- body: JSON.stringify(raw),
23
- };
24
- const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/${sessionId}`, options);
25
- if (!response.ok) {
26
- throw new Error(`Error: ${response.statusText}`);
27
- }
28
- let res = await response.json();
29
- res = {
30
- ...res,
31
- code: response.status,
32
- };
33
- return res;
34
- }
35
- catch (error) {
36
- console.error('Patch transaction status api failed', error);
37
- return {
38
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
39
- message: `Something went wrong! ${error}`,
40
- };
41
- }
42
- };
43
- export default patchTransactionStatus;
@@ -1,3 +0,0 @@
1
- import { TPostTransactionCommitRequest, TPostTransactionResponse } from '../constants/types';
2
- declare function postTransactionCommit({ audioFiles, txnId, }: TPostTransactionCommitRequest): Promise<TPostTransactionResponse>;
3
- export default postTransactionCommit;
@@ -1,32 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- async function postTransactionCommit({ audioFiles, txnId, }) {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const raw = {
9
- audio_files: audioFiles,
10
- };
11
- const options = {
12
- method: 'POST',
13
- headers,
14
- body: JSON.stringify(raw),
15
- };
16
- const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/commit/${txnId}`, options);
17
- let res = await response.json();
18
- res = {
19
- ...res,
20
- code: response.status,
21
- };
22
- return res;
23
- }
24
- catch (error) {
25
- console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
26
- return {
27
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
28
- message: `Something went wrong! ${error}`,
29
- };
30
- }
31
- }
32
- export default postTransactionCommit;
@@ -1,3 +0,0 @@
1
- import { TPostTransactionInitRequest, TPostTransactionResponse } from '../constants/types';
2
- declare function postTransactionInit({ mode, txnId, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, model_type, }: TPostTransactionInitRequest): Promise<TPostTransactionResponse>;
3
- export default postTransactionInit;
@@ -1,40 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- async function postTransactionInit({ mode, txnId, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, model_type, }) {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const raw = {
9
- mode,
10
- s3_url: s3Url,
11
- input_language,
12
- output_format_template,
13
- model_training_consent,
14
- auto_download,
15
- transfer,
16
- system_info,
17
- model_type,
18
- };
19
- const options = {
20
- method: 'POST',
21
- headers,
22
- body: JSON.stringify(raw),
23
- };
24
- const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/init/${txnId}`, options);
25
- let res = await response.json();
26
- res = {
27
- ...res,
28
- code: response.status,
29
- };
30
- return res;
31
- }
32
- catch (error) {
33
- console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
34
- return {
35
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
36
- message: `Something went wrong! ${error}`,
37
- };
38
- }
39
- }
40
- export default postTransactionInit;
@@ -1,3 +0,0 @@
1
- import { TPostTransactionCommitRequest, TPostTransactionResponse } from '../constants/types';
2
- declare function postTransactionStop({ txnId, audioFiles, }: TPostTransactionCommitRequest): Promise<TPostTransactionResponse>;
3
- export default postTransactionStop;
@@ -1,32 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- import fetchWrapper from '../fetch-client';
3
- import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
4
- async function postTransactionStop({ txnId, audioFiles, }) {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const raw = {
9
- audio_files: audioFiles,
10
- };
11
- const options = {
12
- method: 'POST',
13
- headers,
14
- body: JSON.stringify(raw),
15
- };
16
- const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/stop/${txnId}`, options);
17
- let res = await response.json();
18
- res = {
19
- ...res,
20
- code: response.status,
21
- };
22
- return res;
23
- }
24
- catch (error) {
25
- console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
26
- return {
27
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
28
- message: `Something went wrong! ${error}`,
29
- };
30
- }
31
- }
32
- export default postTransactionStop;
@@ -1,3 +0,0 @@
1
- import { TPostV1ConvertToTemplateRequest, TPostV1ConvertToTemplateResponse } from '../../constants/types';
2
- declare function postConvertTransactionToTemplate({ txn_id, template_id, transcript, }: TPostV1ConvertToTemplateRequest): Promise<TPostV1ConvertToTemplateResponse>;
3
- export default postConvertTransactionToTemplate;
@@ -1,32 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../../constants/constant';
2
- import fetchWrapper from '../../fetch-client';
3
- import { GET_EKA_VOICE_HOST_V1 } from '../../fetch-client/helper';
4
- async function postConvertTransactionToTemplate({ txn_id, template_id, transcript, }) {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- const options = {
9
- method: 'POST',
10
- headers,
11
- body: JSON.stringify({
12
- transcript,
13
- template_id,
14
- }),
15
- };
16
- const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/transaction/${txn_id}/convert-to-template`, options, 60000);
17
- let res = await response.json();
18
- res = {
19
- ...res,
20
- code: response.status,
21
- };
22
- return res;
23
- }
24
- catch (error) {
25
- console.log('%c postV1ConvertToTemplate -> error', 'color:#f5ce50', error);
26
- return {
27
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
28
- message: `Something went wrong! ${error}`,
29
- };
30
- }
31
- }
32
- export default postConvertTransactionToTemplate;
@@ -1,2 +0,0 @@
1
- import { TGetConfigV2Response } from '../../constants/types';
2
- export declare const getConfigV2: () => Promise<TGetConfigV2Response>;
@@ -1,26 +0,0 @@
1
- import { SDK_STATUS_CODE } from '../../constants/constant';
2
- import fetchWrapper from '../../fetch-client';
3
- import { GET_EKA_VOICE_HOST_V2 } from '../../fetch-client/helper';
4
- export const getConfigV2 = async () => {
5
- try {
6
- const options = {
7
- method: 'GET',
8
- headers: {
9
- 'Content-Type': 'application/json',
10
- },
11
- };
12
- const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V2()}/config/`, options);
13
- const res = await response.json();
14
- return {
15
- ...res,
16
- code: response.status,
17
- };
18
- }
19
- catch (error) {
20
- console.log('Error in getConfigV2 api: ', error);
21
- return {
22
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
23
- message: `Failed to fetch initial configurations, ${error}`,
24
- };
25
- }
26
- };
@@ -1,5 +0,0 @@
1
- describe('AudioFileManager', () => {
2
- let audioFileManager;
3
- test('', () => { });
4
- });
5
- export {};
@@ -1,128 +0,0 @@
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');
@@ -1,7 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;