{"version":3,"sources":["webpack:///../WCC.UI/App/components/controls/uploaders/models/errorTypes.ts","webpack:///../WCC.UI/App/components/controls/uploaders/operations/uploadToS3MultiPart.ts","webpack:///../WCC.UI/App/components/controls/uploaders/operations/uploadToS3SinglePart.ts","webpack:///../WCC.UI/App/components/controls/uploaders/qualzyS3FileUploader/component.html?79fc","webpack:///../WCC.UI/App/components/controls/uploaders/qualzyS3FileUploader/component.ts","webpack:///../WCC.UI/App/components/controls/uploaders/qualzyS3FileUploader/component.html"],"names":["UploadPausedError","Error","UploadCancelledError","UploadTimeoutError","UploadToS3MultiPart","UploadToS3","constructor","file","config","logs","userLogsService","super","_xhrTimeout","_partsUploadAttemptsCount","Map","_currentPartBeingUploaded","_userLogId","_eTags","_logsCountBeforeUpload","_pausedCount","_timedOutCount","supportsPauseAndResume","_this$_config$Events","this","_config","Events","OnFileUploadStarting","abortController","AbortController","changeCanBeDeleted","_logs","logsCount","system","isNullOrEmpty","logCreationRequest","_userLogsService","createLogs","settings","discussionId","UserLogId","error","_this$_config$Events2","_this$_config$Events3","showErrorMessage","messages","ThereWasASystemError","OnFileUploadComplete","_initFileData","initUploadResponse","changeTextStatus","StaticStrings","StartingUpload","changeStatus","FileUploadStatus","Initialized","addEntry","fetch","MultiPartFileStartUploadUrl","method","headers","AuthToken","body","JSON","stringify","EndPoint","Region","Bucket","Folder","Name","File","name","FileType","fileType","FileSize","totalSize","signal","ok","responseText","text","startsWith","WCCResourcedError","parse","_this$_config$Events4","json","OnFileUploadStarted","FileId","e","_this$_config$Events5","_this$_config$Events6","toString","message","substring","_this$_config$Events7","Failed","OnFileUploadFailed","RequestStatus","status","ResponseText","StatusText","statusText","isNotNullOrEmpty","updateLogs","GetAllCombinedLogs","result","enums","UserLogOperationResultTypes","value","Uploading","changeTotalSize","finishUploadResponse","partFraction","Parts","length","totalLoaded","i","_this$_partsUploadAtt","part","fileBlob","fileContents","slice","StartPosition","EndPosition","attemptCount","get","PartNumber","partSucceeded","MaxRetryCount","set","xhr","XMLHttpRequest","open","SignedUploadUrl","timeout","setRequestHeader","upload","addEventListener","event","lengthComputable","currentFileProgress","loaded","size","toFixed","changeUploadedSize","Promise","resolve","reject","onload","_this$_config$Events8","eTag","getResponseHeader","_this$_config$Events9","push","OnFileCunkUploaded","delete","TheRemoteEndpointReturnedAnError","onerror","ontimeout","abort","UploadCancelled","UploadPaused","send","pausedError","cancelledError","Cancelled","retryIntervalInSecs","RetryIntervalInSecs","retryIntervalInMs","retryMsg","UploadError","isWaitingToRetry","_","setTimeout","_this$_config$Events10","_this$_config$Events11","NetworkError","getErrorMessageFromResponse","isPaused","_this$_config$Events12","_this$_config$Events13","MultiPartFileFinishUploadUrl","ChunkIds","UploadId","_this$_config$Events14","_this$_config$Events16","multiPartFileData","_this$_config$Events15","_this$_config$Events17","Success","Uploaded","UploadedSuccessfully","OnFileUploaded","FileUrl","SignedS3Link","_this$_config$Events18","_this$_config$Events19","_this$_config$Events20","pauseUpload","_this$abortController","dispatchEvent","Event","resumeUpload","cancelUpload","undefined","clear","clearLogsFrom","restartUpload","messageRegexResult","exec","replace","UploadToS3SinglePart","initFileData","initUploadRequest","userLogId","CreatingFileMetaData","SingleFileStartUploadUrl","UploadStatus","SignedUrl","then","timeoutError","content","expose","__esModule","default","QualzyS3FileUploader","QualzyUploaderBase","info","ko","applyBindingsToNode","element","createUpload","WCC","Settings","MultiPartChunkSizeBytesForClientUploader","FileToUpload","type","__decorate","injectable","__param","inject","wccModules","componentConfig","componentInfo","effects","module","exports"],"mappings":"+TAAM,MAAOA,UAA0BC,OACjC,MAAOC,UAA6BD,OACpC,MAAOE,UAA2BF,S,mfCiBlC,MAAOG,UAA4BC,IAkFrCC,YAAYC,EAAoBC,EAA0BC,EAAsBC,GAC5EC,MAAMJ,EAAMC,EAAQC,EAAMC,GAjEtB,KAAAE,YAAc,KAMd,KAAAC,0BAAiD,IAAIC,IAMrD,KAAAC,0BAA4B,EAa5B,KAAAC,WAAqB,GAKrB,KAAAC,OAAmB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IAAWG,UAClBL,EAAA,EAAAC,YAAOC,IAAWrO,mBAdNqN,gB,4MCxBrBoB,EAAOC,QAFI","file":"285.829a4eefe7aa6a9fdfac.js","sourcesContent":["export class UploadPausedError extends Error { }\r\nexport class UploadCancelledError extends Error { }\r\nexport class UploadTimeoutError extends Error { }","import {FileToUpload, FileUploadStatus} from \"../models/fileToUpload\";\r\nimport {UploadToS3, UploadToS3Config, UploadToS3Result} from \"./uploadToS3\";\r\nimport WCCResourcedError from \"../../../../models/wccResourcedError\";\r\nimport {\r\n apiMultiPartFileCompleteRequestData,\r\n apiMultiPartFileCompleteResponseData,\r\n apiMultiPartFileInitRequestData,\r\n apiMultiPartFileInitResponseData\r\n} from \"../../../../models/apiS3MultiPartFileData\";\r\nimport {ILogsContainer} from \"../../../../logsContainer\";\r\nimport {UserLogsService} from \"../../../../services/userLogs\";\r\nimport {UploadCancelledError, UploadPausedError, UploadTimeoutError} from \"../models/errorTypes\";\r\n\r\n/**\r\n * The S3 multipart uploader - It uploads a file to AWS S3 by dividing it into smaller chunks. It does this in 3 steps:\r\n * 1. Creates the associated user file in the db and marks the start of the upload operation. THIS HAPPENS ON THE SERVER.\r\n * 2. Uploads all the chunks to AWS S3. THIS HAPPENS ON THE CLIENT SIDE.\r\n * 3. Marks the completion of the file upload after all the chunks are uploaded. THIS HAPPENS ON THE SERVER.\r\n */\r\nexport class UploadToS3MultiPart extends UploadToS3 {\r\n\r\n /**\r\n * The number of times the uploader should re-attempt a failed file\r\n * @private\r\n */\r\n private static MaxRetryCount = 3;\r\n\r\n /**\r\n * The time to wait before we retry the upload\r\n * @private\r\n */\r\n private static RetryIntervalInSecs = 10;\r\n \r\n /**\r\n * The timeout for xhr request for each chunk upload\r\n * @private\r\n */\r\n private _xhrTimeout = 35000; //in milliseconds (or 35 seconds)\r\n\r\n /**\r\n * Tracks the retry attempt counts of each failed part\r\n * @private\r\n */\r\n private _partsUploadAttemptsCount: Map = new Map();\r\n\r\n /**\r\n * The current part being uploaded. Init to 1\r\n * @private\r\n */\r\n private _currentPartBeingUploaded = 1;\r\n \r\n /**\r\n * The file data after the user file is created in the db, and the upload is marked as 'Started' on Aws\r\n * We save it at the class level so that it is not obtained again in case of pause/resume\r\n * @private\r\n */\r\n private _initFileData?: apiMultiPartFileInitResponseData;\r\n\r\n /**\r\n * Logs for this upload\r\n * @private\r\n */\r\n private _userLogId: string = '';\r\n\r\n /**\r\n * Track the eTags returned by AWS after the uploading of each chunk\r\n */\r\n private _eTags: string[] = [];\r\n\r\n /**\r\n * Keeps track of how many log entries are there before upload starts\r\n * This is helpful because if the upload is cancelled and tried again, previous logs are cleared BUT not those logs which existed before the upload process\r\n * @private\r\n */\r\n private _logsCountBeforeUpload: number = 0;\r\n\r\n /**\r\n * Number of times the upload was paused/resumed\r\n * @private\r\n */\r\n private _pausedCount: number = 0;\r\n\r\n /**\r\n * Number of times the upload timed out\r\n * @private\r\n */\r\n private _timedOutCount: number = 0;\r\n \r\n /**\r\n * True if pausing and resuming the upload operation is supported; False otherwise\r\n * We must implement pauseUpload() and resumeUpload() functions if this is set to true\r\n */\r\n public override readonly supportsPauseAndResume: boolean = true;\r\n \r\n /**\r\n * Initialises the S3 multipart upload operation\r\n * @param file The file to upload\r\n * @param config The S3 multipart upload operation config\r\n * @param logs The logs container\r\n * @param userLogsService The user logs service to send logs to the server\r\n */\r\n constructor(file: FileToUpload, config: UploadToS3Config, logs: ILogsContainer, userLogsService: UserLogsService) {\r\n super(file, config, logs, userLogsService);\r\n }\r\n\r\n /**\r\n * Triggers the S3 multipart upload operation\r\n */\r\n override async upload(): Promise {\r\n if (this._config.Events?.OnFileUploadStarting) {\r\n this._config.Events.OnFileUploadStarting();\r\n }\r\n \r\n if (this.abortController == null) {\r\n this.abortController = new AbortController(); //initialize cancellation token controller\r\n }\r\n \r\n this.changeCanBeDeleted(false);\r\n \r\n this._logsCountBeforeUpload = this._logs.logsCount();\r\n \r\n //If the user log doesn't exist, create it first\r\n if (system.isNullOrEmpty(this._userLogId)) {\r\n try {\r\n const logCreationRequest = await this._userLogsService.createLogs(settings.discussionId);\r\n this._userLogId = logCreationRequest.UserLogId;\r\n } catch (error: any) {\r\n this.changeCanBeDeleted(true);\r\n system.showErrorMessage(messages.ThereWasASystemError);\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n return;\r\n }\r\n }\r\n \r\n /* ##################\r\n STEP 1\r\n #################\r\n\r\n Create the user file in the db and initiate the multipart file upload on Aws\r\n */\r\n if (this._initFileData == null) {\r\n //if we have paused it, don't re-fetch the init file data\r\n this.changeTextStatus(this._config.StaticStrings.StartingUpload);\r\n this.changeStatus(FileUploadStatus.Initialized);\r\n\r\n let initUploadResponse;\r\n \r\n try {\r\n this._logs.addEntry(\"Starting the multi-part file upload and creating the user file record\");\r\n \r\n initUploadResponse = await fetch(this._config.MultiPartFileStartUploadUrl,\r\n {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-type\": \"application/json\",\r\n \"x-auth\": this._config.AuthToken\r\n },\r\n body: JSON.stringify({\r\n EndPoint: `https://s3-${this._config.Region}.amazonaws.com/${this._config.Bucket}`,\r\n Folder: this._config.Folder,\r\n Name: this.File.name(),\r\n FileType: this.File.fileType,\r\n FileSize: this.File.totalSize,\r\n UserLogId: this._userLogId\r\n }),\r\n signal: this.abortController!.signal\r\n });\r\n\r\n if (initUploadResponse.ok) {\r\n this._logs.addEntry(\"User file created\");\r\n \r\n //Get the user file data\r\n //Keep in mind that it is not yet uploaded, but here we get upload id, file parts to upload etc.\r\n this._initFileData = await initUploadResponse.json() as apiMultiPartFileInitResponseData;\r\n\r\n if (this._config.Events?.OnFileUploadStarted) {\r\n this._config.Events.OnFileUploadStarted(this._initFileData.FileId);\r\n }\r\n } else {\r\n const responseText = await initUploadResponse.text();\r\n \r\n if (responseText.startsWith(\"{\")) {\r\n throw new WCCResourcedError(JSON.parse(responseText));\r\n }\r\n else {\r\n this._logs.addEntry(responseText);\r\n throw new Error(responseText);\r\n }\r\n }\r\n } catch (e: any) {\r\n let responseText;\r\n if (e instanceof WCCResourcedError) {\r\n const resourcedError = e as WCCResourcedError;\r\n responseText = resourcedError.toString();\r\n this.changeTextStatus(responseText);\r\n }\r\n else {\r\n responseText = (e as Error).message;\r\n this.changeTextStatus(responseText.substring(0, 50) + \"....\");\r\n }\r\n \r\n this.changeStatus(FileUploadStatus.Failed);\r\n \r\n if (this._config.Events?.OnFileUploadFailed && initUploadResponse != null) {\r\n this._config.Events.OnFileUploadFailed({ RequestStatus: initUploadResponse.status, ResponseText: responseText, StatusText: initUploadResponse.statusText });\r\n }\r\n\r\n if (system.isNotNullOrEmpty(this._userLogId)) {\r\n await this._userLogsService.updateLogs(this._userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: enums.UserLogOperationResultTypes.Failed.value\r\n });\r\n }\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n this.changeCanBeDeleted(true);\r\n return;\r\n }\r\n\r\n this._logs.addEntry('Going to upload all file chunk(s) now');\r\n }\r\n\r\n /* ##################\r\n STEP 2\r\n #################\r\n\r\n Upload all the chunks of the file to S3\r\n */\r\n this.changeTextStatus(this._config.StaticStrings.Uploading);\r\n this.changeStatus(FileUploadStatus.Uploading);\r\n\r\n // Progress is now a sum of all parts\r\n this.changeTotalSize(100);\r\n \r\n // the fraction/percentage that each part represents\r\n let partFraction = 100 / this._initFileData.Parts.length;\r\n let totalLoaded = 0;\r\n \r\n for (let i = this._currentPartBeingUploaded; i <= this._initFileData.Parts.length; i++) {\r\n const part = this._initFileData.Parts[i - 1];\r\n const fileBlob = this.File.fileContents.slice(part.StartPosition, part.EndPosition);\r\n \r\n let attemptCount = this._partsUploadAttemptsCount.get(part.PartNumber) ?? 0;\r\n let partSucceeded = false;\r\n \r\n while (attemptCount < UploadToS3MultiPart.MaxRetryCount) {\r\n //Let's first update the attempt count to rule out any infinite loop\r\n ++attemptCount;\r\n this._partsUploadAttemptsCount.set(part.PartNumber, attemptCount);\r\n\r\n const xhr = new XMLHttpRequest();\r\n xhr.open('PUT', part.SignedUploadUrl, true);\r\n xhr.timeout = this._xhrTimeout; // Timeout in milliseconds (30 secs)\r\n xhr.setRequestHeader('Content-Type', this.File.fileType);\r\n\r\n //Hook-in the progress listener so that we can dispatch progress notifications\r\n xhr.upload.addEventListener('progress', (event) => {\r\n if (event.lengthComputable) {\r\n // get the current file progress based on loaded/file size * part fraction e.g. 50/100 * 25 = 12.5%\r\n let currentFileProgress = (event.loaded / fileBlob.size) * partFraction;\r\n // total loaded is number of parts completed * part fraction + current file progress\r\n totalLoaded = partFraction * (i - 1) + currentFileProgress;\r\n\r\n this.changeTextStatus(`${this._config.StaticStrings.Uploading} ${totalLoaded.toFixed(0)}%`);\r\n this.changeUploadedSize(totalLoaded);\r\n }\r\n });\r\n \r\n try {\r\n //Wrap each xhr in a promise so that we can leverage async/await nicely\r\n await new Promise((resolve, reject) => {\r\n xhr.onload = () => {\r\n if (xhr.status >= 200 && xhr.status < 300) {\r\n const eTag = xhr.getResponseHeader('ETag');\r\n this._eTags.push(`${part.PartNumber}:${(eTag ?? \"\")}`);\r\n\r\n if (this._config.Events?.OnFileCunkUploaded) {\r\n this._config.Events?.OnFileCunkUploaded(part);\r\n }\r\n\r\n partSucceeded = true;\r\n this._partsUploadAttemptsCount.delete(part.PartNumber); //if this is successful on 2nd or 3rd attempt, remove it from the attempts set\r\n resolve();\r\n } else {\r\n reject(new Error(`File Chunk #${part.PartNumber} failed to upload. ${this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr)}`));\r\n }\r\n };\r\n\r\n xhr.onerror = () => reject(new Error(`OnError: File Chunk #${part.PartNumber} failed to upload. ${this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr)}`));\r\n xhr.ontimeout = () => reject(new UploadTimeoutError(this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr)));\r\n\r\n //Handle cancellation\r\n this.abortController!.signal.addEventListener('abort', () => {\r\n xhr.abort();\r\n this.abortController = null;\r\n reject(new UploadCancelledError(this._config.StaticStrings.UploadCancelled));\r\n });\r\n\r\n this.abortController!.signal.addEventListener('pause', () => {\r\n xhr.abort();\r\n this.abortController = null;\r\n reject(new UploadPausedError(this._config.StaticStrings.UploadPaused));\r\n });\r\n\r\n // Send the request with the file blob\r\n xhr.send(fileBlob);\r\n });\r\n break;\r\n } catch (e: any) {\r\n if (e instanceof UploadPausedError) {\r\n const pausedError = e as UploadPausedError;\r\n\r\n //now reset everything\r\n this.changeTextStatus(pausedError.message);\r\n this.changeTotalSize(0);\r\n this.changeUploadedSize(0);\r\n\r\n //Since we update the attempt count in the beginning just to be super safe, we want to preserve the current count\r\n //if the upload is paused, hence decrement by 1 to keep it at current count \r\n this._partsUploadAttemptsCount.set(part.PartNumber, attemptCount - 1);\r\n \r\n break; //break the retry loop\r\n }\r\n else if (e instanceof UploadCancelledError) {\r\n const cancelledError = e as UploadCancelledError;\r\n \r\n //now reset everything\r\n this.changeStatus(FileUploadStatus.Cancelled);\r\n this.changeTextStatus(cancelledError.message);\r\n\r\n this.changeTotalSize(0);\r\n this.changeUploadedSize(0);\r\n break; //break the retry loop\r\n }\r\n else {\r\n if (e instanceof UploadTimeoutError) {\r\n this._timedOutCount++;\r\n\r\n if (attemptCount == UploadToS3MultiPart.MaxRetryCount) {\r\n this._logs.addEntry(e.message);\r\n }\r\n }\r\n else {\r\n this._logs.addEntry(e.message);\r\n }\r\n\r\n if (attemptCount < UploadToS3MultiPart.MaxRetryCount) {\r\n const retryIntervalInSecs = attemptCount * UploadToS3MultiPart.RetryIntervalInSecs; //1st time - 10 secs, 2nd time - 20 secs\r\n const retryIntervalInMs = retryIntervalInSecs * 1000;\r\n this._logs.addEntry(`File part: ${part.PartNumber}, Current retry count: ${attemptCount + 1}. Going to retry in ${retryIntervalInSecs} secs..`);\r\n \r\n const retryMsg = this._config.StaticStrings.UploadError(retryIntervalInSecs)\r\n this.changeTextStatus(retryMsg);\r\n this.isWaitingToRetry(true);\r\n \r\n await new Promise((resolve, _) => {\r\n setTimeout(() => {\r\n this.isWaitingToRetry(false);\r\n resolve();\r\n }, retryIntervalInMs);\r\n });\r\n }\r\n \r\n if (attemptCount == UploadToS3MultiPart.MaxRetryCount) {\r\n this.changeStatus(FileUploadStatus.Failed);\r\n this.changeTextStatus(xhr.status == 0 ? this._config.StaticStrings.NetworkError : this.getErrorMessageFromResponse(xhr));\r\n \r\n if (this._config.Events?.OnFileUploadFailed) {\r\n this._config.Events?.OnFileUploadFailed({\r\n RequestStatus: xhr.status,\r\n StatusText: xhr.statusText,\r\n ResponseText: xhr.responseText\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n \r\n this._currentPartBeingUploaded = i;\r\n\r\n if (this.isPaused() || this.status() == FileUploadStatus.Cancelled) {\r\n break; //if paused or cancelled, break the outer loop\r\n }\r\n \r\n if (!partSucceeded) { //tried max number of times, mark this part as failed and bail out\r\n this._logs.addEntry(\"Re-tried uploading file max number of times..\");\r\n this.changeTextStatus(this._config.StaticStrings.NetworkError);\r\n this._partsUploadAttemptsCount.delete(part.PartNumber);\r\n\r\n break; //if tried max number of times, break the outer loop and exit\r\n }\r\n }\r\n \r\n if (this.isPaused() || this.status() == FileUploadStatus.Cancelled || this.status() == FileUploadStatus.Failed) {\r\n if (!this.isPaused()) {\r\n if (this.status() == FileUploadStatus.Cancelled || this.status() == FileUploadStatus.Failed) {\r\n if (this._timedOutCount > 0) {\r\n this._logs.addEntry(`Total timeouts: ${this._timedOutCount}`);\r\n }\r\n\r\n if (this._pausedCount > 0) {\r\n this._logs.addEntry(`Upload paused/resumed: ${this._pausedCount} time(s)`);\r\n }\r\n }\r\n \r\n if (this.status() == FileUploadStatus.Failed) {\r\n this._logs.addEntry('File failed to upload');\r\n }\r\n\r\n if (this.status() == FileUploadStatus.Cancelled) {\r\n this._logs.addEntry('File upload cancelled');\r\n }\r\n\r\n if (system.isNotNullOrEmpty(this._userLogId)) { //don't submit logs on pause\r\n await this._userLogsService.updateLogs(this._userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: this.status() == FileUploadStatus.Cancelled ? enums.UserLogOperationResultTypes.Cancelled.value : enums.UserLogOperationResultTypes.Failed.value\r\n });\r\n }\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n }\r\n \r\n if (this.status() == FileUploadStatus.Cancelled || this.status() == FileUploadStatus.Failed) {\r\n this.changeCanBeDeleted(true);\r\n }\r\n return;\r\n }\r\n \r\n\r\n /* ##################\r\n STEP 3\r\n #################\r\n\r\n Marks the upload as finished/complete\r\n */\r\n\r\n if (this._timedOutCount > 0) {\r\n this._logs.addEntry(`Total timeouts: ${this._timedOutCount}`);\r\n }\r\n\r\n if (this._pausedCount > 0) {\r\n this._logs.addEntry(`Upload paused/resumed: ${this._pausedCount} time(s)`);\r\n }\r\n \r\n this._logs.addEntry(\"All file chunks uploaded, now marking the upload as complete\");\r\n \r\n let finishUploadResponse;\r\n \r\n try {\r\n //Let's now mark the file upload as completed\r\n finishUploadResponse = await fetch(this._config.MultiPartFileFinishUploadUrl,\r\n {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-type\": \"application/json\",\r\n \"x-auth\": this._config.AuthToken\r\n },\r\n body: JSON.stringify({\r\n FileId: this._initFileData.FileId,\r\n ChunkIds: this._eTags,\r\n UploadId: this._initFileData.UploadId,\r\n UserLogId: this._userLogId\r\n }),\r\n signal: this.abortController!.signal\r\n });\r\n\r\n if (finishUploadResponse.ok) {\r\n //Get final data\r\n let multiPartFileData = await finishUploadResponse.json() as apiMultiPartFileCompleteResponseData;\r\n\r\n this._logs.addEntry(\"File Uploaded Successfully\");\r\n \r\n if (system.isNotNullOrEmpty(this._userLogId)) {\r\n await this._userLogsService.updateLogs(this._userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: enums.UserLogOperationResultTypes.Success.value\r\n });\r\n }\r\n\r\n //Inform the user that we're done\r\n this.changeStatus(FileUploadStatus.Uploaded);\r\n this.changeTextStatus(this._config.StaticStrings.UploadedSuccessfully);\r\n\r\n this.changeCanBeDeleted(true);\r\n \r\n //Trigger external events\r\n if (this._config.Events?.OnFileUploaded) {\r\n this._config.Events?.OnFileUploaded({\r\n FileId: multiPartFileData.FileId,\r\n FileUrl: multiPartFileData.SignedS3Link\r\n })\r\n }\r\n \r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n }\r\n else {\r\n const responseText = await finishUploadResponse.text();\r\n\r\n if (responseText.startsWith(\"{\")) {\r\n throw new WCCResourcedError(JSON.parse(responseText));\r\n }\r\n else {\r\n this._logs.addEntry(responseText);\r\n throw new Error(responseText);\r\n }\r\n }\r\n } catch (e: any) {\r\n let responseText;\r\n \r\n if (e instanceof WCCResourcedError) {\r\n const resourcedError = e as WCCResourcedError;\r\n responseText = resourcedError.toString();\r\n this.changeTextStatus(responseText);\r\n }\r\n else {\r\n responseText = (e as Error).message;\r\n this.changeTextStatus(responseText.substring(0, 50) + \"....\");\r\n }\r\n\r\n this._logs.addEntry(`There was an issue completing the upload. Issue Details: ${responseText}`);\r\n\r\n this.changeStatus(FileUploadStatus.Failed);\r\n this.changeCanBeDeleted(true);\r\n\r\n if (this._config.Events?.OnFileUploadFailed && finishUploadResponse != null) {\r\n this._config.Events.OnFileUploadFailed({ RequestStatus: finishUploadResponse.status, ResponseText: responseText, StatusText: finishUploadResponse.statusText });\r\n }\r\n\r\n if (system.isNotNullOrEmpty(this._userLogId)) {\r\n await this._userLogsService.updateLogs(this._userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: enums.UserLogOperationResultTypes.Failed.value\r\n });\r\n }\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n return;\r\n }\r\n }\r\n \r\n /**\r\n * Pauses the upload operation if pause/resume is supported\r\n */\r\n override pauseUpload() {\r\n if (this.isWaitingToRetry()) return;\r\n \r\n this._pausedCount++;\r\n super.pauseUpload();\r\n this.abortController?.signal.dispatchEvent(new Event(\"pause\"));\r\n }\r\n\r\n /**\r\n * Resumes a paused upload operation if pause/resume is supported\r\n */\r\n override async resumeUpload() {\r\n if (this.isWaitingToRetry()) return;\r\n \r\n super.resumeUpload();\r\n await this.upload();\r\n }\r\n\r\n override cancelUpload() {\r\n this.changeStatus(FileUploadStatus.Cancelled);\r\n super.cancelUpload();\r\n }\r\n\r\n /**\r\n * Restarts the upload\r\n */\r\n override async restartUpload(): Promise {\r\n if (this.isWaitingToRetry()) return;\r\n \r\n this._currentPartBeingUploaded = 1;\r\n this._initFileData = undefined;\r\n this._eTags = [];\r\n this._partsUploadAttemptsCount.clear();\r\n this._userLogId = \"\";\r\n \r\n if (this._logsCountBeforeUpload > 0) {\r\n this._logs.clearLogsFrom(this._logsCountBeforeUpload);\r\n }\r\n \r\n this._logs.addEntry(\"Resuming cancelled file..\")\r\n await super.restartUpload();\r\n }\r\n\r\n /**\r\n * Parses the response from XHR, looks for if it's an XML response and extracts the message\r\n * Otherwise it returns the statusText on XHR \r\n * @param xhr Http Request\r\n * @private\r\n */\r\n private getErrorMessageFromResponse(xhr: XMLHttpRequest) {\r\n let message = xhr.statusText;\r\n\r\n let messageRegexResult = /(.*?)<\\/message>/i.exec(xhr.responseText);\r\n if (messageRegexResult != null && messageRegexResult.length > 0) {\r\n message = messageRegexResult[0].replace(//i, \"\").replace(/<\\/message>/i, \"\");\r\n }\r\n \r\n return message;\r\n }\r\n}","import {FileToUpload, FileUploadStatus} from \"../models/fileToUpload\";\r\nimport {apiSinglePartFileInitResponseData} from \"../../../../models/apiS3FileData\";\r\nimport WCCResourcedError from \"../../../../models/wccResourcedError\";\r\nimport {UploadToS3, UploadToS3Config, UploadToS3Result} from \"./uploadToS3\";\r\nimport {ILogsContainer} from \"../../../../logsContainer\";\r\nimport {UserLogsService} from \"../../../../services/userLogs\";\r\nimport {UploadCancelledError, UploadTimeoutError} from \"../models/errorTypes\";\r\n\r\n/**\r\n * The S3 uploader - It uploads a file to AWS S3 in a single go (without multipart/chunking). It does 2 things:\r\n * 1. Creates the associated user file in the db and creates a pre-signed link to upload to.\r\n * 2. Uploads the contents of the file at the generated pre-signed link.\r\n */\r\nexport class UploadToS3SinglePart extends UploadToS3 {\r\n /**\r\n * True if pausing and resuming the upload operation is supported; False otherwise\r\n * We must implement pauseUpload() and resumeUpload() functions if this is set to true\r\n */\r\n public override readonly supportsPauseAndResume: boolean = false;\r\n\r\n /**\r\n * The timeout for xhr request for each chunk upload\r\n * @private\r\n */\r\n private _xhrTimeout = 35000; //in milliseconds (or 35 seconds)\r\n \r\n /**\r\n * Initialises the S3 upload operation\r\n * @param file The file to upload\r\n * @param config The S3 upload operation config\r\n * @param logs The logs container\r\n * @param userLogsService The user logs service to send logs to the server\r\n */\r\n constructor(file: FileToUpload, config: UploadToS3Config, logs: ILogsContainer, userLogsService: UserLogsService) {\r\n super(file, config, logs, userLogsService);\r\n }\r\n\r\n /**\r\n * Triggers the S3 upload operation\r\n */\r\n override async upload(): Promise {\r\n let userLogId = '';\r\n\r\n if (this._config.Events?.OnFileUploadStarting) {\r\n this._config.Events.OnFileUploadStarting();\r\n }\r\n\r\n this.changeCanBeDeleted(false);\r\n \r\n if (this.abortController == null) {\r\n this.abortController = new AbortController(); //initialize cancellation token controller\r\n }\r\n\r\n this._logs.addEntry(\"Starting the upload\");\r\n \r\n //Create a log first\r\n try {\r\n const logCreationRequest = await this._userLogsService.createLogs(settings.discussionId);\r\n userLogId = logCreationRequest.UserLogId;\r\n }\r\n catch (error: any) {\r\n this.changeCanBeDeleted(true);\r\n system.showErrorMessage(messages.ThereWasASystemError);\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n return;\r\n }\r\n \r\n /* ##################\r\n STEP 1\r\n #################\r\n \r\n Create the user file in the db\r\n */\r\n this.changeTextStatus(this._config.StaticStrings.CreatingFileMetaData);\r\n\r\n let initFileData: apiSinglePartFileInitResponseData;\r\n let initUploadRequest;\r\n \r\n try {\r\n this._logs.addEntry(\"Creating the user file record\");\r\n \r\n initUploadRequest = await fetch(this._config.SingleFileStartUploadUrl,\r\n {\r\n //Adding method type \r\n method: \"POST\",\r\n\r\n //Adding body or contents to send \r\n body: JSON.stringify({\r\n EndPoint: `https://s3-${this._config.Region}.amazonaws.com/${this._config.Bucket}`,\r\n Folder: this._config.Folder,\r\n Name: this.File.name(),\r\n FileType: this.File.fileType,\r\n FileSize: this.File.totalSize,\r\n userLogId: userLogId\r\n }),\r\n\r\n //Adding headers to the request \r\n headers: {\r\n \"Content-type\": \"application/json\",\r\n \"x-auth\": this._config.AuthToken\r\n },\r\n\r\n signal: this.abortController.signal\r\n });\r\n\r\n if (initUploadRequest.ok) {\r\n this._logs.addEntry(\"User file created\");\r\n \r\n //Get the user file data\r\n //Keep in mind that it is not yet uploaded, but here we get file id, signed url to upload to etc.\r\n initFileData = await initUploadRequest.json() as apiSinglePartFileInitResponseData;\r\n \r\n if (this._config.Events?.OnFileUploadStarted) {\r\n this._config.Events.OnFileUploadStarted(initFileData.FileId);\r\n }\r\n } else {\r\n const responseText = await initUploadRequest.text();\r\n\r\n if (responseText.startsWith(\"{\")) {\r\n throw new WCCResourcedError(JSON.parse(responseText));\r\n }\r\n else {\r\n this._logs.addEntry(responseText);\r\n throw new Error(responseText);\r\n }\r\n }\r\n } catch (e: any) {\r\n let responseText;\r\n\r\n if (e instanceof WCCResourcedError) {\r\n const resourcedError = e as WCCResourcedError;\r\n responseText = resourcedError.toString();\r\n this.changeTextStatus(responseText);\r\n }\r\n else {\r\n responseText = (e as Error).message;\r\n this.changeTextStatus(responseText.substring(0, 50) + \"....\");\r\n }\r\n \r\n this.changeStatus(FileUploadStatus.Failed);\r\n \r\n if (this._config.Events?.OnFileUploadFailed && initUploadRequest != null) {\r\n this._config.Events.OnFileUploadFailed({ RequestStatus: initUploadRequest.status, ResponseText: responseText, StatusText: initUploadRequest.statusText });\r\n }\r\n \r\n if (system.isNotNullOrEmpty(userLogId)) {\r\n await this._userLogsService.updateLogs(userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: enums.UserLogOperationResultTypes.Failed.value\r\n });\r\n }\r\n\r\n this.changeCanBeDeleted(true);\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n return;\r\n }\r\n \r\n /* ##################\r\n STEP 2\r\n #################\r\n \r\n Upload the file to S3 now\r\n */\r\n\r\n this._logs.addEntry(\"Preparing the file to send to S3\");\r\n \r\n this.changeTextStatus(this._config.StaticStrings.StartingUpload)\r\n\r\n //Prepare the request now\r\n const xhr = new XMLHttpRequest();\r\n xhr.open('PUT', initFileData.SignedUploadUrl);\r\n xhr.timeout = this._xhrTimeout; // Timeout in milliseconds (30 secs)\r\n \r\n //Hook-in the progress listener so that we can dispatch progress notifications\r\n xhr.upload.addEventListener('progress', (event) => {\r\n if (event.lengthComputable) {\r\n //Update progress\r\n this.changeUploadedSize(event.loaded);\r\n }\r\n });\r\n\r\n this.changeTextStatus(this._config.StaticStrings.Uploading)\r\n this.changeStatus(FileUploadStatus.Uploading);\r\n\r\n this._logs.addEntry(\"Ready to send the file to S3\");\r\n \r\n //Start the uploading\r\n xhr.send(this.File.fileContents);\r\n\r\n this._logs.addEntry(\"Upload started\");\r\n \r\n try {\r\n return await new Promise((resolve, reject) => {\r\n xhr.onload = () => {\r\n if (xhr.status >= 200 && xhr.status < 300) {\r\n //The request succeeded, change status and return result appropriately\r\n this.changeStatus(FileUploadStatus.Uploaded);\r\n this.changeTextStatus(this._config.StaticStrings.UploadedSuccessfully);\r\n const result = {\r\n FileId: initFileData.FileId,\r\n UploadStatus: FileUploadStatus.Uploaded,\r\n FileUrl: initFileData.SignedUrl\r\n };\r\n \r\n this._logs.addEntry(\"File Uploaded Successfully\");\r\n\r\n if (system.isNotNullOrEmpty(userLogId)) {\r\n this._userLogsService.updateLogs(userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: enums.UserLogOperationResultTypes.Success.value\r\n }).then(() => {\r\n this.changeCanBeDeleted(true);\r\n\r\n if (this._config.Events?.OnFileUploaded) {\r\n this._config.Events.OnFileUploaded(result);\r\n }\r\n \r\n resolve();\r\n });\r\n }\r\n else {\r\n this.changeCanBeDeleted(true);\r\n\r\n if (this._config.Events?.OnFileUploaded) {\r\n this._config.Events.OnFileUploaded(result);\r\n }\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n \r\n resolve();\r\n }\r\n } else {\r\n const error = this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr);\r\n this._logs.addEntry(\"File failed to upload. \" + error);\r\n reject(new Error(error));\r\n }\r\n };\r\n\r\n xhr.onerror = () => {\r\n const error = this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr);\r\n this._logs.addEntry(\"File failed to upload. \" + error);\r\n reject(new Error(error));\r\n };\r\n\r\n xhr.ontimeout = () => {\r\n this._logs.addEntry(\"File timed out..\");\r\n reject(new UploadTimeoutError(xhr.status == 0 ? this._config.StaticStrings.NetworkError : this._config.StaticStrings.TheRemoteEndpointReturnedAnError(xhr)));\r\n }\r\n\r\n //Handle cancellation\r\n this.abortController!.signal.addEventListener('abort', () => {\r\n xhr.abort();\r\n this.abortController = null;\r\n reject(new UploadCancelledError(this._config.StaticStrings.UploadCancelled));\r\n });\r\n });\r\n }\r\n catch(e: any) {\r\n if (e instanceof UploadCancelledError) {\r\n const cancelledError = e as UploadCancelledError;\r\n\r\n //now reset everything\r\n this.changeStatus(FileUploadStatus.Cancelled);\r\n this.changeTextStatus(cancelledError.message);\r\n }\r\n else if (e instanceof UploadTimeoutError) {\r\n const timeoutError = e as UploadTimeoutError;\r\n\r\n //now reset everything\r\n this.changeStatus(FileUploadStatus.Failed);\r\n this.changeTextStatus(timeoutError.message);\r\n }\r\n else {\r\n this.changeStatus(FileUploadStatus.Failed);\r\n this.changeTextStatus(xhr.status == 0 ? this._config.StaticStrings.NetworkError : xhr.statusText);\r\n\r\n if (this._config.Events?.OnFileUploadFailed) {\r\n this._config.Events.OnFileUploadFailed({\r\n RequestStatus: xhr.status,\r\n ResponseText: xhr.responseText,\r\n StatusText: xhr.statusText\r\n });\r\n }\r\n }\r\n\r\n this.changeTotalSize(0);\r\n this.changeUploadedSize(0);\r\n\r\n this.changeCanBeDeleted(true);\r\n \r\n if (system.isNotNullOrEmpty(userLogId)) {\r\n await this._userLogsService.updateLogs(userLogId, this._logs.GetAllCombinedLogs('\\n'), {\r\n result: this.status() == FileUploadStatus.Cancelled ? enums.UserLogOperationResultTypes.Cancelled.value : enums.UserLogOperationResultTypes.Failed.value\r\n });\r\n }\r\n\r\n if (this._config.Events?.OnFileUploadComplete) {\r\n this._config.Events?.OnFileUploadComplete();\r\n }\r\n }\r\n }\r\n}","define([\n \"!!../../../../../node_modules/html-loader/dist/cjs.js??ref--26-1!./component.html\", \n \"!../../../../webpack/runtime/htmlExposer.js\"], function (content, expose) {\n content = content.__esModule ? content.default : content;\n expose(content);\n return content;\n });","import { wccModules } from 'enums/wccModules';\r\nimport { inject, injectable } from 'inversify';\r\nimport { EffectsContainer } from 'mixins/withEffects';\r\nimport ko from \"knockout\";\r\nimport QualzyUploaderBase from \"../qualzyUploaderBase\";\r\nimport {FileToUpload} from \"../models/fileToUpload\";\r\nimport {\r\n UploadToS3,\r\n UploadToS3Config,\r\n UploadToS3Events,\r\n UploadToS3Result,\r\n UploadToS3Strings\r\n} from \"../operations/uploadToS3\";\r\n\r\nimport '../qualzyUploaderBase.html';\r\nimport '../qualzyUploaderBase.scss';\r\n\r\nimport './component.html';\r\nimport {UploadToS3SinglePart} from \"../operations/uploadToS3SinglePart\";\r\nimport {UploadToS3MultiPart} from \"../operations/uploadToS3MultiPart\";\r\nimport {ILogsContainer} from \"../../../../logsContainer\";\r\nimport {UserLogsService} from \"../../../../services/userLogs\";\r\n\r\n/**\r\n * Uploader that upload file(s) to AWS S3 as a single file\r\n */\r\n@injectable()\r\nexport default class QualzyS3FileUploader extends \r\n QualzyUploaderBase{\r\n\r\n /**\r\n * Initialise the S3 uploader control\r\n * @param config The configuration for the uploader\r\n * @param info Any component info\r\n * @param _ The effects container\r\n * @param userLogsService The user logs service to send logs to the server\r\n */\r\n constructor(\r\n @inject(wccModules.componentConfig) config: UploadToS3Config,\r\n @inject(wccModules.componentInfo) info: ko.components.ComponentInfo,\r\n @inject(wccModules.effects) _: EffectsContainer,\r\n @inject(wccModules.userLogsService) userLogsService: UserLogsService\r\n ) {\r\n super(config, userLogsService);\r\n \r\n ko.applyBindingsToNode(info.element, {\r\n 'css': {\r\n 'qualzy-file-uploader': true\r\n }\r\n }, this);\r\n }\r\n\r\n /**\r\n * Creates the s3 upload operation from a file instance\r\n * It creates a single part file upload if the size of the file is smaller; Otherwise it creates a multipart file upload\r\n * @param file The file to upload\r\n * @param logs The logs container\r\n * @protected\r\n */\r\n protected createUpload(file: File, logs: ILogsContainer): UploadToS3 {\r\n if (file.size > WCC.Settings.MultiPartChunkSizeBytesForClientUploader) {\r\n logs.addEntry(\"Using multi-part S3 file uploading\")\r\n return new UploadToS3MultiPart(new FileToUpload(file.name, file.size, file.type, file), this._config, logs, this._userLogsService);\r\n }\r\n logs.addEntry(\"Using single-part S3 file uploading\");\r\n return new UploadToS3SinglePart(new FileToUpload(file.name, file.size, file.type, file), this._config, logs, this._userLogsService);\r\n }\r\n}","// Module\nvar code = \"\";\n// Exports\nmodule.exports = code;"],"sourceRoot":""}