@eka-care/ekascribe-ts-sdk 1.5.87 → 1.5.89

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 (57) hide show
  1. package/dist/api/config/get-voice-api-v2-config-my-templates.js +22 -12
  2. package/dist/api/config/get-voice-api-v2-config.js +22 -12
  3. package/dist/api/config/patch-voice-api-v2-config.js +21 -13
  4. package/dist/api/post-cog-init.js +28 -15
  5. package/dist/api/post-v1-file-upload.js +38 -28
  6. package/dist/api/template-sections/delete-v1-template-section.js +37 -27
  7. package/dist/api/template-sections/get-v1-template-sections.js +37 -27
  8. package/dist/api/template-sections/patch-v1-template-section.js +46 -36
  9. package/dist/api/template-sections/post-v1-template-section.js +45 -35
  10. package/dist/api/templates/cook-v1-medai-ai-create-template.js +35 -25
  11. package/dist/api/templates/delete-v1-template.js +37 -27
  12. package/dist/api/templates/get-v1-templates.js +37 -27
  13. package/dist/api/templates/patch-v1-template.js +44 -33
  14. package/dist/api/templates/post-convert-transcription-to-template.js +41 -31
  15. package/dist/api/templates/post-transaction-convert-to-template.js +38 -28
  16. package/dist/api/templates/post-v1-template.js +43 -33
  17. package/dist/api/transaction/get-transaction-history.js +20 -9
  18. package/dist/api/transaction/get-voice-api-v3-status-transcript.js +21 -8
  19. package/dist/api/transaction/get-voice-api-v3-status.js +21 -8
  20. package/dist/api/transaction/patch-transaction-status.js +23 -14
  21. package/dist/api/transaction/patch-voice-api-v3-status.js +22 -12
  22. package/dist/api/transaction/post-transaction-commit.js +41 -31
  23. package/dist/api/transaction/post-transaction-init.js +52 -47
  24. package/dist/api/transaction/post-transaction-stop.js +41 -31
  25. package/dist/api/upload-audio-with-presigned-url.js +67 -55
  26. package/dist/audio-chunker/audio-buffer-manager.js +5 -3
  27. package/dist/audio-chunker/audio-file-manager.js +353 -350
  28. package/dist/audio-chunker/vad-web.js +116 -97
  29. package/dist/aws-services/configure-aws.js +5 -2
  30. package/dist/aws-services/get-files-s3.js +20 -7
  31. package/dist/aws-services/s3-retry-wrapper.js +44 -31
  32. package/dist/aws-services/translate-text-to-target-language.js +28 -15
  33. package/dist/aws-services/upload-file-to-s3.js +17 -6
  34. package/dist/constants/constant.js +22 -19
  35. package/dist/constants/enums.js +15 -12
  36. package/dist/constants/setup-config.js +10 -7
  37. package/dist/constants/types.d.ts +1 -1
  38. package/dist/constants/types.js +2 -1
  39. package/dist/fetch-client/helper.js +24 -11
  40. package/dist/fetch-client/index.js +61 -52
  41. package/dist/index.js +321 -254
  42. package/dist/main/end-recording.js +56 -53
  43. package/dist/main/init-transaction.js +36 -27
  44. package/dist/main/pause-recording.js +17 -18
  45. package/dist/main/poll-output-summary.js +21 -7
  46. package/dist/main/resume-recording.js +13 -14
  47. package/dist/main/retry-upload-recording.js +39 -30
  48. package/dist/main/start-recording.js +34 -26
  49. package/dist/main/upload-full-audio-with-presigned-url.js +84 -69
  50. package/dist/shared-worker/s3-file-upload.js +88 -79
  51. package/dist/shared-worker/s3-file-upload.ts +1 -1
  52. package/dist/store/store.js +3 -1
  53. package/dist/utils/compress-mp3-audio.d.ts +1 -1
  54. package/dist/utils/compress-mp3-audio.js +6 -4
  55. package/dist/utils/get-worker-url.js +12 -7
  56. package/dist/utils/search-past-sessions.js +23 -9
  57. package/package.json +1 -1
@@ -1,14 +1,26 @@
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 processingError = {
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.processingError = void 0;
13
+ const constant_1 = require("../../constants/constant");
14
+ const fetch_client_1 = require("../../fetch-client");
15
+ const helper_1 = require("../../fetch-client/helper");
16
+ exports.processingError = {
5
17
  error: {
6
18
  type: '',
7
19
  code: 'cancelled_by_user',
8
20
  msg: 'Cancelled_by_user',
9
21
  },
10
22
  };
11
- const patchTransactionStatus = async ({ sessionId, processing_status, processing_error, }) => {
23
+ const patchTransactionStatus = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId, processing_status, processing_error, }) {
12
24
  try {
13
25
  const headers = new Headers();
14
26
  headers.append('Content-Type', 'application/json');
@@ -21,23 +33,20 @@ const patchTransactionStatus = async ({ sessionId, processing_status, processing
21
33
  headers,
22
34
  body: JSON.stringify(raw),
23
35
  };
24
- const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V2()}/transaction/${sessionId}`, options);
36
+ const response = yield (0, fetch_client_1.default)(`${(0, helper_1.GET_EKA_VOICE_HOST_V2)()}/transaction/${sessionId}`, options);
25
37
  if (!response.ok) {
26
38
  throw new Error(`Error: ${response.statusText}`);
27
39
  }
28
- let res = await response.json();
29
- res = {
30
- ...res,
31
- code: response.status,
32
- };
40
+ let res = yield response.json();
41
+ res = Object.assign(Object.assign({}, res), { code: response.status });
33
42
  return res;
34
43
  }
35
44
  catch (error) {
36
45
  console.error('Patch transaction status api failed', error);
37
46
  return {
38
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
47
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
39
48
  message: `Something went wrong! ${error}`,
40
49
  };
41
50
  }
42
- };
43
- export default patchTransactionStatus;
51
+ });
52
+ exports.default = patchTransactionStatus;
@@ -1,7 +1,19 @@
1
- import { SDK_STATUS_CODE } from '../../constants/constant';
2
- import fetchWrapper from '../../fetch-client';
3
- import { GET_EKA_VOICE_HOST_V3 } from '../../fetch-client/helper';
4
- export const patchVoiceApiV3Status = async ({ txnId, data, }) => {
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.patchVoiceApiV3Status = void 0;
13
+ const constant_1 = require("../../constants/constant");
14
+ const fetch_client_1 = require("../../fetch-client");
15
+ const helper_1 = require("../../fetch-client/helper");
16
+ const patchVoiceApiV3Status = (_a) => __awaiter(void 0, [_a], void 0, function* ({ txnId, data, }) {
5
17
  try {
6
18
  const headers = new Headers();
7
19
  headers.append('Content-Type', 'application/json');
@@ -11,17 +23,15 @@ export const patchVoiceApiV3Status = async ({ txnId, data, }) => {
11
23
  body: JSON.stringify(data),
12
24
  };
13
25
  // Use custom timeout for this API (16 seconds instead of default 5 seconds)
14
- const getResponse = await fetchWrapper(`${GET_EKA_VOICE_HOST_V3()}/status/${txnId}`, options, 30000);
15
- const response = await getResponse.json();
16
- return {
17
- ...response,
18
- code: getResponse.status,
19
- };
26
+ const getResponse = yield (0, fetch_client_1.default)(`${(0, helper_1.GET_EKA_VOICE_HOST_V3)()}/status/${txnId}`, options, 30000);
27
+ const response = yield getResponse.json();
28
+ return Object.assign(Object.assign({}, response), { code: getResponse.status });
20
29
  }
21
30
  catch (error) {
22
31
  return {
23
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
32
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
24
33
  message: `Something went wrong! ${error}`,
25
34
  };
26
35
  }
27
- };
36
+ });
37
+ exports.patchVoiceApiV3Status = patchVoiceApiV3Status;
@@ -1,32 +1,42 @@
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
- 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_VOICE_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
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const constant_1 = require("../../constants/constant");
13
+ const fetch_client_1 = require("../../fetch-client");
14
+ const helper_1 = require("../../fetch-client/helper");
15
+ function postTransactionCommit(_a) {
16
+ return __awaiter(this, arguments, void 0, function* ({ audioFiles, txnId, }) {
17
+ try {
18
+ const headers = new Headers();
19
+ headers.append('Content-Type', 'application/json');
20
+ const raw = {
21
+ audio_files: audioFiles,
22
+ };
23
+ const options = {
24
+ method: 'POST',
25
+ headers,
26
+ body: JSON.stringify(raw),
27
+ };
28
+ const response = yield (0, fetch_client_1.default)(`${(0, helper_1.GET_EKA_VOICE_HOST_V2)()}/transaction/commit/${txnId}`, options);
29
+ let res = yield response.json();
30
+ res = Object.assign(Object.assign({}, res), { code: response.status });
31
+ return res;
32
+ }
33
+ catch (error) {
34
+ console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
35
+ return {
36
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
37
+ message: `Something went wrong! ${error}`,
38
+ };
39
+ }
40
+ });
31
41
  }
32
- export default postTransactionCommit;
42
+ exports.default = postTransactionCommit;
@@ -1,49 +1,54 @@
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
- async function postTransactionInit({ mode, txn_id, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, patient_details, model_type, version, flavour, batch_s3_url, audio_file_names, output_language, additional_data, }) {
5
- try {
6
- const headers = new Headers();
7
- headers.append('Content-Type', 'application/json');
8
- if (flavour) {
9
- headers.set('flavour', flavour);
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const constant_1 = require("../../constants/constant");
13
+ const fetch_client_1 = require("../../fetch-client");
14
+ const helper_1 = require("../../fetch-client/helper");
15
+ function postTransactionInit(_a) {
16
+ return __awaiter(this, arguments, void 0, function* ({ mode, txn_id, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, patient_details, model_type, version, flavour, batch_s3_url, audio_file_names, output_language, additional_data, }) {
17
+ try {
18
+ const headers = new Headers();
19
+ headers.append('Content-Type', 'application/json');
20
+ if (flavour) {
21
+ headers.set('flavour', flavour);
22
+ }
23
+ const raw = Object.assign({ mode, s3_url: s3Url, input_language,
24
+ output_language,
25
+ output_format_template,
26
+ model_training_consent,
27
+ auto_download,
28
+ transfer,
29
+ system_info,
30
+ patient_details,
31
+ model_type,
32
+ version,
33
+ batch_s3_url,
34
+ additional_data }, (audio_file_names ? { client_generated_files: audio_file_names } : {}));
35
+ const options = {
36
+ method: 'POST',
37
+ headers,
38
+ body: JSON.stringify(raw),
39
+ };
40
+ const response = yield (0, fetch_client_1.default)(`${(0, helper_1.GET_EKA_VOICE_HOST_V2)()}/transaction/init/${txn_id}`, options);
41
+ let res = yield response.json();
42
+ res = Object.assign(Object.assign({}, res), { code: response.status });
43
+ return res;
10
44
  }
11
- const raw = {
12
- mode,
13
- s3_url: s3Url,
14
- input_language,
15
- output_language,
16
- output_format_template,
17
- model_training_consent,
18
- auto_download,
19
- transfer,
20
- system_info,
21
- patient_details,
22
- model_type,
23
- version,
24
- batch_s3_url,
25
- additional_data,
26
- ...(audio_file_names ? { client_generated_files: audio_file_names } : {}),
27
- };
28
- const options = {
29
- method: 'POST',
30
- headers,
31
- body: JSON.stringify(raw),
32
- };
33
- const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V2()}/transaction/init/${txn_id}`, options);
34
- let res = await response.json();
35
- res = {
36
- ...res,
37
- code: response.status,
38
- };
39
- return res;
40
- }
41
- catch (error) {
42
- console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
43
- return {
44
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
45
- message: `Something went wrong! ${error}`,
46
- };
47
- }
45
+ catch (error) {
46
+ console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
47
+ return {
48
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
49
+ message: `Something went wrong! ${error}`,
50
+ };
51
+ }
52
+ });
48
53
  }
49
- export default postTransactionInit;
54
+ exports.default = postTransactionInit;
@@ -1,32 +1,42 @@
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
- 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_VOICE_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
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const constant_1 = require("../../constants/constant");
13
+ const fetch_client_1 = require("../../fetch-client");
14
+ const helper_1 = require("../../fetch-client/helper");
15
+ function postTransactionStop(_a) {
16
+ return __awaiter(this, arguments, void 0, function* ({ txnId, audioFiles, }) {
17
+ try {
18
+ const headers = new Headers();
19
+ headers.append('Content-Type', 'application/json');
20
+ const raw = {
21
+ audio_files: audioFiles,
22
+ };
23
+ const options = {
24
+ method: 'POST',
25
+ headers,
26
+ body: JSON.stringify(raw),
27
+ };
28
+ const response = yield (0, fetch_client_1.default)(`${(0, helper_1.GET_EKA_VOICE_HOST_V2)()}/transaction/stop/${txnId}`, options);
29
+ let res = yield response.json();
30
+ res = Object.assign(Object.assign({}, res), { code: response.status });
31
+ return res;
32
+ }
33
+ catch (error) {
34
+ console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
35
+ return {
36
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
37
+ message: `Something went wrong! ${error}`,
38
+ };
39
+ }
40
+ });
31
41
  }
32
- export default postTransactionStop;
42
+ exports.default = postTransactionStop;
@@ -1,60 +1,72 @@
1
- import { SDK_STATUS_CODE } from '../constants/constant';
2
- async function uploadSingleFile(uploadData, folderPath, file, fileName) {
3
- try {
4
- const updatedFields = {
5
- ...uploadData.fields,
6
- key: folderPath + fileName,
7
- };
8
- const formData = new FormData();
9
- Object.entries(updatedFields).forEach(([key, value]) => {
10
- formData.append(key, value);
11
- });
12
- formData.append('file', file);
13
- const response = await fetch(uploadData.url, {
14
- method: 'POST',
15
- body: formData,
16
- });
17
- if (response.status === 204) {
18
- // S3 returns 204 No Content on successful upload
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const constant_1 = require("../constants/constant");
13
+ function uploadSingleFile(uploadData, folderPath, file, fileName) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ const updatedFields = Object.assign(Object.assign({}, uploadData.fields), { key: folderPath + fileName });
17
+ const formData = new FormData();
18
+ Object.entries(updatedFields).forEach(([key, value]) => {
19
+ formData.append(key, value);
20
+ });
21
+ formData.append('file', file);
22
+ const response = yield fetch(uploadData.url, {
23
+ method: 'POST',
24
+ body: formData,
25
+ });
26
+ if (response.status === 204) {
27
+ // S3 returns 204 No Content on successful upload
28
+ return {
29
+ key: folderPath + fileName,
30
+ size: file.size,
31
+ success: true,
32
+ };
33
+ }
34
+ else {
35
+ throw new Error(`Upload failed with status: ${response.status}`);
36
+ }
37
+ }
38
+ catch (error) {
39
+ console.error('uploadSingleFile error:', error);
19
40
  return {
20
- key: folderPath + fileName,
21
- size: file.size,
22
- success: true,
41
+ success: false,
42
+ error: `Upload failed: ${error}`,
23
43
  };
24
44
  }
25
- else {
26
- throw new Error(`Upload failed with status: ${response.status}`);
27
- }
28
- }
29
- catch (error) {
30
- console.error('uploadSingleFile error:', error);
31
- return {
32
- success: false,
33
- error: `Upload failed: ${error}`,
34
- };
35
- }
45
+ });
36
46
  }
37
- async function uploadFilesWithPresignedUrl({ audioFiles, audioFileNames, presignedUrlResponse, }) {
38
- try {
39
- const uploadPromises = audioFiles.map((file, index) => {
40
- const fileName = audioFileNames[index];
41
- return uploadSingleFile({ ...presignedUrlResponse.uploadData }, presignedUrlResponse.folderPath, file, fileName);
42
- });
43
- const results = await Promise.all(uploadPromises);
44
- const failedUploads = results.filter((result) => !result.success);
45
- const successfulUploads = results.filter((result) => result.success);
46
- // TODO: presigned url expiry handling and failed files handling
47
- return {
48
- code: failedUploads.length > 0 ? 207 : 200, // 207 for partial success, 200 for all success
49
- message: `Upload completed. ${successfulUploads.length}/${results.length} files uploaded successfully.`,
50
- };
51
- }
52
- catch (error) {
53
- console.error('uploadAudioFilesWithPresignedUrl error:', error);
54
- return {
55
- code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
56
- message: `Upload failed: ${error}`,
57
- };
58
- }
47
+ function uploadFilesWithPresignedUrl(_a) {
48
+ return __awaiter(this, arguments, void 0, function* ({ audioFiles, audioFileNames, presignedUrlResponse, }) {
49
+ try {
50
+ const uploadPromises = audioFiles.map((file, index) => {
51
+ const fileName = audioFileNames[index];
52
+ return uploadSingleFile(Object.assign({}, presignedUrlResponse.uploadData), presignedUrlResponse.folderPath, file, fileName);
53
+ });
54
+ const results = yield Promise.all(uploadPromises);
55
+ const failedUploads = results.filter((result) => !result.success);
56
+ const successfulUploads = results.filter((result) => result.success);
57
+ // TODO: presigned url expiry handling and failed files handling
58
+ return {
59
+ code: failedUploads.length > 0 ? 207 : 200, // 207 for partial success, 200 for all success
60
+ message: `Upload completed. ${successfulUploads.length}/${results.length} files uploaded successfully.`,
61
+ };
62
+ }
63
+ catch (error) {
64
+ console.error('uploadAudioFilesWithPresignedUrl error:', error);
65
+ return {
66
+ code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
67
+ message: `Upload failed: ${error}`,
68
+ };
69
+ }
70
+ });
59
71
  }
60
- export default uploadFilesWithPresignedUrl;
72
+ exports.default = uploadFilesWithPresignedUrl;
@@ -1,4 +1,6 @@
1
- import { SAMPLING_RATE } from '../constants/constant';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constant_1 = require("../constants/constant");
2
4
  class AudioBufferManager {
3
5
  /**
4
6
  * Class that creates an audio buffer to store frame data
@@ -102,7 +104,7 @@ class AudioBufferManager {
102
104
  * Calculate timestamps for an audio chunk
103
105
  */
104
106
  calculateChunkTimestamps(rawSamplesLength) {
105
- const start = rawSamplesLength / SAMPLING_RATE - this.getDurationInSeconds();
107
+ const start = rawSamplesLength / constant_1.SAMPLING_RATE - this.getDurationInSeconds();
106
108
  const end = start + this.getDurationInSeconds();
107
109
  // Format start time as MM:SS.ffffff
108
110
  const startMinutes = Math.floor(start / 60)
@@ -133,4 +135,4 @@ class AudioBufferManager {
133
135
  this.currentFrameLength = 0;
134
136
  }
135
137
  }
136
- export default AudioBufferManager;
138
+ exports.default = AudioBufferManager;