filemail-sdk 9.4.10 → 10.2.0

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 (240) hide show
  1. package/dist/src/autoDownloader/autoDownloader.d.ts.map +1 -1
  2. package/dist/src/autoDownloader/autoDownloader.js +0 -1
  3. package/dist/src/autoDownloader/autoDownloader.js.map +1 -1
  4. package/dist/src/client/downloader/downloaderCore.js +1 -1
  5. package/dist/src/client/downloader/downloaderCore.js.map +1 -1
  6. package/dist/src/client/downloader/node/nodeTransferDownloader.d.ts.map +1 -1
  7. package/dist/src/client/downloader/node/nodeTransferDownloader.js +0 -2
  8. package/dist/src/client/downloader/node/nodeTransferDownloader.js.map +1 -1
  9. package/dist/src/client/uploader/node/nodeTransferUploader.d.ts.map +1 -1
  10. package/dist/src/client/uploader/node/nodeTransferUploader.js +6 -5
  11. package/dist/src/client/uploader/node/nodeTransferUploader.js.map +1 -1
  12. package/dist/src/client/uploader/transferUploaderBase.d.ts +2 -0
  13. package/dist/src/client/uploader/transferUploaderBase.d.ts.map +1 -1
  14. package/dist/src/client/uploader/transferUploaderBase.js +45 -31
  15. package/dist/src/client/uploader/transferUploaderBase.js.map +1 -1
  16. package/dist/src/client/uploader/transferUploaderConfig.d.ts +3 -4
  17. package/dist/src/client/uploader/transferUploaderConfig.d.ts.map +1 -1
  18. package/dist/src/client/uploader/transferUploaderConfig.js.map +1 -1
  19. package/dist/src/client/uploader/utils/uploaderUtils.d.ts.map +1 -1
  20. package/dist/src/client/uploader/utils/uploaderUtils.js +1 -2
  21. package/dist/src/client/uploader/utils/uploaderUtils.js.map +1 -1
  22. package/dist/src/client/uploader/web/webTransferUploader.d.ts.map +1 -1
  23. package/dist/src/client/uploader/web/webTransferUploader.js +5 -4
  24. package/dist/src/client/uploader/web/webTransferUploader.js.map +1 -1
  25. package/dist/src/downloader/api/node/nodeFileServerDownloadClient.d.ts.map +1 -1
  26. package/dist/src/downloader/api/node/nodeFileServerDownloadClient.js +6 -2
  27. package/dist/src/downloader/api/node/nodeFileServerDownloadClient.js.map +1 -1
  28. package/dist/src/downloader/chunkDownloader.d.ts.map +1 -1
  29. package/dist/src/downloader/chunkDownloader.js +2 -3
  30. package/dist/src/downloader/chunkDownloader.js.map +1 -1
  31. package/dist/src/downloader/downloadTracker.d.ts.map +1 -1
  32. package/dist/src/downloader/downloadTracker.js +0 -1
  33. package/dist/src/downloader/downloadTracker.js.map +1 -1
  34. package/dist/src/downloader/filesDownloader.d.ts.map +1 -1
  35. package/dist/src/downloader/filesDownloader.js +0 -1
  36. package/dist/src/downloader/filesDownloader.js.map +1 -1
  37. package/dist/src/index.d.ts +5 -2
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/index.js.map +1 -1
  40. package/dist/src/uploader/api/node/nodeFileServerUploadClient.d.ts +1 -1
  41. package/dist/src/uploader/api/node/nodeFileServerUploadClient.d.ts.map +1 -1
  42. package/dist/src/uploader/api/node/nodeFileServerUploadClient.js +5 -4
  43. package/dist/src/uploader/api/node/nodeFileServerUploadClient.js.map +1 -1
  44. package/dist/src/uploader/api/web/webFileServerUploadClient.d.ts +1 -1
  45. package/dist/src/uploader/api/web/webFileServerUploadClient.d.ts.map +1 -1
  46. package/dist/src/uploader/api/web/webFileServerUploadClient.js +5 -4
  47. package/dist/src/uploader/api/web/webFileServerUploadClient.js.map +1 -1
  48. package/dist/src/uploader/chunksIterator/chunksIterator.d.ts +1 -3
  49. package/dist/src/uploader/chunksIterator/chunksIterator.d.ts.map +1 -1
  50. package/dist/src/uploader/chunksIterator/chunksIterator.js +4 -4
  51. package/dist/src/uploader/chunksIterator/chunksIterator.js.map +1 -1
  52. package/dist/src/uploader/eventArgs/fileAckFailedEventArgs.d.ts +8 -0
  53. package/dist/src/uploader/eventArgs/fileAckFailedEventArgs.d.ts.map +1 -0
  54. package/dist/src/uploader/eventArgs/fileAckFailedEventArgs.js +2 -0
  55. package/dist/src/uploader/eventArgs/fileAckFailedEventArgs.js.map +1 -0
  56. package/dist/src/uploader/eventArgs/fileChunkUploadCompletedEventArgs.d.ts +1 -1
  57. package/dist/src/uploader/eventArgs/fileChunkUploadCompletedEventArgs.d.ts.map +1 -1
  58. package/dist/src/uploader/eventArgs/fileChunkUploadCompletedEventArgs.js.map +1 -1
  59. package/dist/src/uploader/eventArgs/fileChunkUploadEventArgs.d.ts +1 -0
  60. package/dist/src/uploader/eventArgs/fileChunkUploadEventArgs.d.ts.map +1 -1
  61. package/dist/src/uploader/eventArgs/fileChunkUploadEventArgs.js.map +1 -1
  62. package/dist/src/uploader/eventArgs/fileChunkUploadProgressedEventArgs.d.ts +1 -0
  63. package/dist/src/uploader/eventArgs/fileChunkUploadProgressedEventArgs.d.ts.map +1 -1
  64. package/dist/src/uploader/eventArgs/fileChunkUploadProgressedEventArgs.js.map +1 -1
  65. package/dist/src/uploader/eventArgs/fileUploadEventArgs.d.ts +1 -0
  66. package/dist/src/uploader/eventArgs/fileUploadEventArgs.d.ts.map +1 -1
  67. package/dist/src/uploader/eventArgs/fileUploadEventArgs.js.map +1 -1
  68. package/dist/src/uploader/eventArgs/filesBatchAckFailedEventArgs.d.ts +6 -0
  69. package/dist/src/uploader/eventArgs/filesBatchAckFailedEventArgs.d.ts.map +1 -0
  70. package/dist/src/uploader/eventArgs/filesBatchAckFailedEventArgs.js +2 -0
  71. package/dist/src/uploader/eventArgs/filesBatchAckFailedEventArgs.js.map +1 -0
  72. package/dist/src/uploader/eventArgs/filesRegistrationBatchFailedEventArgs.d.ts +6 -0
  73. package/dist/src/uploader/eventArgs/filesRegistrationBatchFailedEventArgs.d.ts.map +1 -0
  74. package/dist/src/uploader/eventArgs/filesRegistrationBatchFailedEventArgs.js +2 -0
  75. package/dist/src/uploader/eventArgs/filesRegistrationBatchFailedEventArgs.js.map +1 -0
  76. package/dist/src/uploader/export/transferUploadExportData.d.ts +4 -1
  77. package/dist/src/uploader/export/transferUploadExportData.d.ts.map +1 -1
  78. package/dist/src/uploader/export/transferUploadExportData.js.map +1 -1
  79. package/dist/src/uploader/export/transferUploadExportState.d.ts +4 -1
  80. package/dist/src/uploader/export/transferUploadExportState.d.ts.map +1 -1
  81. package/dist/src/uploader/export/transferUploadExportState.js.map +1 -1
  82. package/dist/src/uploader/export/transferUploadMetadata.d.ts +0 -9
  83. package/dist/src/uploader/export/transferUploadMetadata.d.ts.map +1 -1
  84. package/dist/src/uploader/export/transferUploadMetadata.js.map +1 -1
  85. package/dist/src/uploader/options/transferUploadAppendInfo.d.ts +1 -0
  86. package/dist/src/uploader/options/transferUploadAppendInfo.d.ts.map +1 -1
  87. package/dist/src/uploader/options/transferUploadAppendInfo.js.map +1 -1
  88. package/dist/src/uploader/options/transferUploadConfig.d.ts +1 -2
  89. package/dist/src/uploader/options/transferUploadConfig.d.ts.map +1 -1
  90. package/dist/src/uploader/options/transferUploadConfig.js.map +1 -1
  91. package/dist/src/uploader/pendingFileAck.d.ts +7 -0
  92. package/dist/src/uploader/pendingFileAck.d.ts.map +1 -0
  93. package/dist/src/uploader/pendingFileAck.js +2 -0
  94. package/dist/src/uploader/pendingFileAck.js.map +1 -0
  95. package/dist/src/uploader/registeredTransferFile.d.ts +6 -0
  96. package/dist/src/uploader/registeredTransferFile.d.ts.map +1 -0
  97. package/dist/src/uploader/registeredTransferFile.js +2 -0
  98. package/dist/src/uploader/registeredTransferFile.js.map +1 -0
  99. package/dist/src/uploader/state/continuousChunksCalculator.d.ts +1 -0
  100. package/dist/src/uploader/state/continuousChunksCalculator.d.ts.map +1 -1
  101. package/dist/src/uploader/state/continuousChunksCalculator.js +8 -2
  102. package/dist/src/uploader/state/continuousChunksCalculator.js.map +1 -1
  103. package/dist/src/uploader/state/transferUploadState.d.ts +11 -8
  104. package/dist/src/uploader/state/transferUploadState.d.ts.map +1 -1
  105. package/dist/src/uploader/state/transferUploadState.js +57 -28
  106. package/dist/src/uploader/state/transferUploadState.js.map +1 -1
  107. package/dist/src/uploader/state/transferUploadStateFile.d.ts +1 -0
  108. package/dist/src/uploader/state/transferUploadStateFile.d.ts.map +1 -1
  109. package/dist/src/uploader/state/transferUploadStateFile.js +1 -0
  110. package/dist/src/uploader/state/transferUploadStateFile.js.map +1 -1
  111. package/dist/src/uploader/transferFilesRegistrar.d.ts +30 -0
  112. package/dist/src/uploader/transferFilesRegistrar.d.ts.map +1 -0
  113. package/dist/src/uploader/transferFilesRegistrar.js +158 -0
  114. package/dist/src/uploader/transferFilesRegistrar.js.map +1 -0
  115. package/dist/src/uploader/transferUpload.d.ts +21 -14
  116. package/dist/src/uploader/transferUpload.d.ts.map +1 -1
  117. package/dist/src/uploader/transferUpload.js +122 -142
  118. package/dist/src/uploader/transferUpload.js.map +1 -1
  119. package/dist/src/uploader/transferUploadAcker.d.ts +18 -0
  120. package/dist/src/uploader/transferUploadAcker.d.ts.map +1 -0
  121. package/dist/src/uploader/transferUploadAcker.js +123 -0
  122. package/dist/src/uploader/transferUploadAcker.js.map +1 -0
  123. package/dist/src/uploader/transferUploadEvent.d.ts +4 -1
  124. package/dist/src/uploader/transferUploadEvent.d.ts.map +1 -1
  125. package/dist/src/uploader/transferUploadEvent.js +4 -1
  126. package/dist/src/uploader/transferUploadEvent.js.map +1 -1
  127. package/dist/src/utils/api/apiClient.d.ts +6 -0
  128. package/dist/src/utils/api/apiClient.d.ts.map +1 -1
  129. package/dist/src/utils/api/apiClient.js.map +1 -1
  130. package/dist/src/utils/api/apiClientBase.d.ts +0 -2
  131. package/dist/src/utils/api/apiClientBase.d.ts.map +1 -1
  132. package/dist/src/utils/api/apiClientBase.js +6 -13
  133. package/dist/src/utils/api/apiClientBase.js.map +1 -1
  134. package/dist/src/utils/api/dtos/ackTransferFilesRequest.d.ts +9 -0
  135. package/dist/src/utils/api/dtos/ackTransferFilesRequest.d.ts.map +1 -0
  136. package/dist/src/utils/api/dtos/ackTransferFilesRequest.js +2 -0
  137. package/dist/src/utils/api/dtos/ackTransferFilesRequest.js.map +1 -0
  138. package/dist/src/utils/api/dtos/ackTransferFilesResponse.d.ts +7 -0
  139. package/dist/src/utils/api/dtos/ackTransferFilesResponse.d.ts.map +1 -0
  140. package/dist/src/utils/api/dtos/ackTransferFilesResponse.js +2 -0
  141. package/dist/src/utils/api/dtos/ackTransferFilesResponse.js.map +1 -0
  142. package/dist/src/utils/api/dtos/finalizeTransferRequest.d.ts +1 -1
  143. package/dist/src/utils/api/dtos/finalizeTransferRequest.d.ts.map +1 -1
  144. package/dist/src/utils/api/dtos/finalizeTransferRequest.js.map +1 -1
  145. package/dist/src/utils/api/dtos/initializeTransferRequest.d.ts +1 -0
  146. package/dist/src/utils/api/dtos/initializeTransferRequest.d.ts.map +1 -1
  147. package/dist/src/utils/api/dtos/initializeTransferRequest.js.map +1 -1
  148. package/dist/src/utils/api/dtos/initializeTransferResponse.d.ts +0 -9
  149. package/dist/src/utils/api/dtos/initializeTransferResponse.d.ts.map +1 -1
  150. package/dist/src/utils/api/dtos/initializeTransferResponse.js.map +1 -1
  151. package/dist/src/utils/api/dtos/registerTransferFilesRequest.d.ts +18 -0
  152. package/dist/src/utils/api/dtos/registerTransferFilesRequest.d.ts.map +1 -0
  153. package/dist/src/utils/api/dtos/registerTransferFilesRequest.js +2 -0
  154. package/dist/src/utils/api/dtos/registerTransferFilesRequest.js.map +1 -0
  155. package/dist/src/utils/api/dtos/registerTransferFilesResponse.d.ts +9 -0
  156. package/dist/src/utils/api/dtos/registerTransferFilesResponse.d.ts.map +1 -0
  157. package/dist/src/utils/api/dtos/registerTransferFilesResponse.js +2 -0
  158. package/dist/src/utils/api/dtos/registerTransferFilesResponse.js.map +1 -0
  159. package/dist/src/utils/api/fileServerClientFactory.d.ts +2 -4
  160. package/dist/src/utils/api/fileServerClientFactory.d.ts.map +1 -1
  161. package/dist/src/utils/api/fileServerClientFactory.js.map +1 -1
  162. package/dist/src/utils/api/node/nodeApiClient.d.ts +6 -0
  163. package/dist/src/utils/api/node/nodeApiClient.d.ts.map +1 -1
  164. package/dist/src/utils/api/node/nodeApiClient.js +26 -2
  165. package/dist/src/utils/api/node/nodeApiClient.js.map +1 -1
  166. package/dist/src/utils/api/node/nodeFileServerClientFactory.d.ts +2 -4
  167. package/dist/src/utils/api/node/nodeFileServerClientFactory.d.ts.map +1 -1
  168. package/dist/src/utils/api/node/nodeFileServerClientFactory.js +3 -7
  169. package/dist/src/utils/api/node/nodeFileServerClientFactory.js.map +1 -1
  170. package/dist/src/utils/api/web/webApiClient.d.ts +6 -0
  171. package/dist/src/utils/api/web/webApiClient.d.ts.map +1 -1
  172. package/dist/src/utils/api/web/webApiClient.js +24 -2
  173. package/dist/src/utils/api/web/webApiClient.js.map +1 -1
  174. package/dist/src/utils/api/web/webFileServerClientFactory.d.ts +2 -4
  175. package/dist/src/utils/api/web/webFileServerClientFactory.d.ts.map +1 -1
  176. package/dist/src/utils/api/web/webFileServerClientFactory.js +3 -6
  177. package/dist/src/utils/api/web/webFileServerClientFactory.js.map +1 -1
  178. package/dist/src/utils/fileSystem/node/nodeFileSystemService.d.ts.map +1 -1
  179. package/dist/src/utils/fileSystem/node/nodeFileSystemService.js +0 -3
  180. package/dist/src/utils/fileSystem/node/nodeFileSystemService.js.map +1 -1
  181. package/dist/src/utils/mergeAbortAndPauseSignals.d.ts +6 -1
  182. package/dist/src/utils/mergeAbortAndPauseSignals.d.ts.map +1 -1
  183. package/dist/src/utils/mergeAbortAndPauseSignals.js +14 -7
  184. package/dist/src/utils/mergeAbortAndPauseSignals.js.map +1 -1
  185. package/dist/src/utils/promiseAll.d.ts.map +1 -1
  186. package/dist/src/utils/promiseAll.js +0 -1
  187. package/dist/src/utils/promiseAll.js.map +1 -1
  188. package/package.json +1 -2
  189. package/dist/src/uploader/api/dtos/handshakeRequest.d.ts +0 -6
  190. package/dist/src/uploader/api/dtos/handshakeRequest.d.ts.map +0 -1
  191. package/dist/src/uploader/api/dtos/handshakeRequest.js +0 -2
  192. package/dist/src/uploader/api/dtos/handshakeRequest.js.map +0 -1
  193. package/dist/src/uploader/api/dtos/handshakeResponse.d.ts +0 -6
  194. package/dist/src/uploader/api/dtos/handshakeResponse.d.ts.map +0 -1
  195. package/dist/src/uploader/api/dtos/handshakeResponse.js +0 -2
  196. package/dist/src/uploader/api/dtos/handshakeResponse.js.map +0 -1
  197. package/dist/src/uploader/api/dtos/pingResponse.d.ts +0 -5
  198. package/dist/src/uploader/api/dtos/pingResponse.d.ts.map +0 -1
  199. package/dist/src/uploader/api/dtos/pingResponse.js +0 -2
  200. package/dist/src/uploader/api/dtos/pingResponse.js.map +0 -1
  201. package/dist/src/uploader/api/dtos/sendChunkRequest.d.ts +0 -10
  202. package/dist/src/uploader/api/dtos/sendChunkRequest.d.ts.map +0 -1
  203. package/dist/src/uploader/api/dtos/sendChunkRequest.js +0 -2
  204. package/dist/src/uploader/api/dtos/sendChunkRequest.js.map +0 -1
  205. package/dist/src/uploader/api/fileServerUdpClient.d.ts +0 -19
  206. package/dist/src/uploader/api/fileServerUdpClient.d.ts.map +0 -1
  207. package/dist/src/uploader/api/fileServerUdpClient.js +0 -2
  208. package/dist/src/uploader/api/fileServerUdpClient.js.map +0 -1
  209. package/dist/src/uploader/api/node/nodeFileServerUdpClient.d.ts +0 -39
  210. package/dist/src/uploader/api/node/nodeFileServerUdpClient.d.ts.map +0 -1
  211. package/dist/src/uploader/api/node/nodeFileServerUdpClient.js +0 -264
  212. package/dist/src/uploader/api/node/nodeFileServerUdpClient.js.map +0 -1
  213. package/dist/src/uploader/eventArgs/transferUploadModeChosenEventArgs.d.ts +0 -7
  214. package/dist/src/uploader/eventArgs/transferUploadModeChosenEventArgs.d.ts.map +0 -1
  215. package/dist/src/uploader/eventArgs/transferUploadModeChosenEventArgs.js +0 -2
  216. package/dist/src/uploader/eventArgs/transferUploadModeChosenEventArgs.js.map +0 -1
  217. package/dist/src/uploader/optimizer/optimizationValues.d.ts +0 -9
  218. package/dist/src/uploader/optimizer/optimizationValues.d.ts.map +0 -1
  219. package/dist/src/uploader/optimizer/optimizationValues.js +0 -2
  220. package/dist/src/uploader/optimizer/optimizationValues.js.map +0 -1
  221. package/dist/src/uploader/optimizer/strategies/udpConcurrencyBasedOptimizationStrategy.d.ts +0 -33
  222. package/dist/src/uploader/optimizer/strategies/udpConcurrencyBasedOptimizationStrategy.d.ts.map +0 -1
  223. package/dist/src/uploader/optimizer/strategies/udpConcurrencyBasedOptimizationStrategy.js +0 -135
  224. package/dist/src/uploader/optimizer/strategies/udpConcurrencyBasedOptimizationStrategy.js.map +0 -1
  225. package/dist/src/uploader/optimizer/strategies/udpSleepBasedOptimizationStrategy.d.ts +0 -30
  226. package/dist/src/uploader/optimizer/strategies/udpSleepBasedOptimizationStrategy.d.ts.map +0 -1
  227. package/dist/src/uploader/optimizer/strategies/udpSleepBasedOptimizationStrategy.js +0 -106
  228. package/dist/src/uploader/optimizer/strategies/udpSleepBasedOptimizationStrategy.js.map +0 -1
  229. package/dist/src/uploader/optimizer/transferUploadOptimizationStrategy.d.ts +0 -20
  230. package/dist/src/uploader/optimizer/transferUploadOptimizationStrategy.d.ts.map +0 -1
  231. package/dist/src/uploader/optimizer/transferUploadOptimizationStrategy.js +0 -2
  232. package/dist/src/uploader/optimizer/transferUploadOptimizationStrategy.js.map +0 -1
  233. package/dist/src/uploader/optimizer/transferUploadOptimizer.d.ts +0 -27
  234. package/dist/src/uploader/optimizer/transferUploadOptimizer.d.ts.map +0 -1
  235. package/dist/src/uploader/optimizer/transferUploadOptimizer.js +0 -169
  236. package/dist/src/uploader/optimizer/transferUploadOptimizer.js.map +0 -1
  237. package/dist/src/uploader/optimizer/uploadOptimizer.d.ts +0 -11
  238. package/dist/src/uploader/optimizer/uploadOptimizer.d.ts.map +0 -1
  239. package/dist/src/uploader/optimizer/uploadOptimizer.js +0 -2
  240. package/dist/src/uploader/optimizer/uploadOptimizer.js.map +0 -1
@@ -7,15 +7,6 @@ interface TransferUploadMetadata {
7
7
  iv: Uint8Array;
8
8
  key: Uint8Array;
9
9
  };
10
- udpData?: {
11
- ip: string;
12
- port: number;
13
- threshold: number;
14
- handshakeData?: {
15
- sessionGuid: string;
16
- aesKey: Uint8Array;
17
- };
18
- };
19
10
  }
20
11
  export default TransferUploadMetadata;
21
12
  //# sourceMappingURL=transferUploadMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadMetadata.d.ts","sourceRoot":"","sources":["../../../../src/uploader/export/transferUploadMetadata.ts"],"names":[],"mappings":"AAAA,UAAU,sBAAsB;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE;QACb,EAAE,EAAE,UAAU,CAAC;QACf,GAAG,EAAE,UAAU,CAAC;KACnB,CAAC;IACF,OAAO,CAAC,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE;YACZ,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE,UAAU,CAAC;SACtB,CAAA;KACJ,CAAA;CACJ;AAED,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"transferUploadMetadata.d.ts","sourceRoot":"","sources":["../../../../src/uploader/export/transferUploadMetadata.ts"],"names":[],"mappings":"AAAA,UAAU,sBAAsB;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE;QACb,EAAE,EAAE,UAAU,CAAC;QACf,GAAG,EAAE,UAAU,CAAC;KACnB,CAAC;CACL;AAED,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadMetadata.js","sourceRoot":"","sources":["../../../../src/uploader/export/transferUploadMetadata.ts"],"names":[],"mappings":"","sourcesContent":["interface TransferUploadMetadata {\n transferId: string,\n transferKey: string,\n transferFileServerUrl: string,\n transferRegion?: string,\n encryptionData?: {\n iv: Uint8Array,\n key: Uint8Array,\n },\n udpData?: {\n ip: string,\n port: number,\n threshold: number,\n handshakeData?: {\n sessionGuid: string,\n aesKey: Uint8Array,\n }\n }\n}\n\nexport default TransferUploadMetadata;"]}
1
+ {"version":3,"file":"transferUploadMetadata.js","sourceRoot":"","sources":["../../../../src/uploader/export/transferUploadMetadata.ts"],"names":[],"mappings":"","sourcesContent":["interface TransferUploadMetadata {\n transferId: string,\n transferKey: string,\n transferFileServerUrl: string,\n transferRegion?: string,\n encryptionData?: {\n iv: Uint8Array,\n key: Uint8Array,\n },\n}\n\nexport default TransferUploadMetadata;"]}
@@ -4,6 +4,7 @@ interface TransferUploadAppendInfo<T> extends TransferUploadInfoBase<T> {
4
4
  transferKey: string;
5
5
  transferFileServerUrl: string;
6
6
  transferDownloadUrl: string;
7
+ isLegacyTransfer: boolean;
7
8
  transferRegion?: string;
8
9
  e2eeData?: TransferUploadAppendInfoE2eeData;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadAppendInfo.d.ts","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadAppendInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,UAAU,wBAAwB,CAAC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC,CAAC;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,gCAAgC,CAAC;CAC/C;AAED,UAAU,gCAAgC;IACtC,EAAE,EAAE,UAAU,CAAC;IACf,GAAG,EAAE,UAAU,CAAC;CACnB;AAED,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,CAAC"}
1
+ {"version":3,"file":"transferUploadAppendInfo.d.ts","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadAppendInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,UAAU,wBAAwB,CAAC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC,CAAC;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,gCAAgC,CAAC;CAC/C;AAED,UAAU,gCAAgC;IACtC,EAAE,EAAE,UAAU,CAAC;IACf,GAAG,EAAE,UAAU,CAAC;CACnB;AAED,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadAppendInfo.js","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadAppendInfo.ts"],"names":[],"mappings":"","sourcesContent":["import type TransferUploadInfoBase from \"./transferUploadInfoBase.js\";\n\ninterface TransferUploadAppendInfo<T> extends TransferUploadInfoBase<T> {\n transferId: string,\n transferKey: string,\n transferFileServerUrl: string,\n transferDownloadUrl: string,\n transferRegion?: string,\n e2eeData?: TransferUploadAppendInfoE2eeData,\n}\n\ninterface TransferUploadAppendInfoE2eeData {\n iv: Uint8Array,\n key: Uint8Array,\n}\n\nexport { TransferUploadAppendInfoE2eeData, TransferUploadAppendInfo };\n"]}
1
+ {"version":3,"file":"transferUploadAppendInfo.js","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadAppendInfo.ts"],"names":[],"mappings":"","sourcesContent":["import type TransferUploadInfoBase from \"./transferUploadInfoBase.js\";\n\ninterface TransferUploadAppendInfo<T> extends TransferUploadInfoBase<T> {\n transferId: string,\n transferKey: string,\n transferFileServerUrl: string,\n transferDownloadUrl: string,\n isLegacyTransfer: boolean,\n transferRegion?: string,\n e2eeData?: TransferUploadAppendInfoE2eeData,\n}\n\ninterface TransferUploadAppendInfoE2eeData {\n iv: Uint8Array,\n key: Uint8Array,\n}\n\nexport { TransferUploadAppendInfoE2eeData, TransferUploadAppendInfo };\n"]}
@@ -1,8 +1,7 @@
1
1
  interface TransferUploadConfig {
2
2
  progressEventThrottlingInMs: number;
3
3
  currentRatesTimespanInMs: number;
4
- forceUdp?: boolean;
5
- turnOffUdp?: boolean;
4
+ chunkSizeInBytes: number;
6
5
  }
7
6
  export default TransferUploadConfig;
8
7
  //# sourceMappingURL=transferUploadConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadConfig.d.ts","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadConfig.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC1B,2BAA2B,EAAE,MAAM,CAAC;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"transferUploadConfig.d.ts","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadConfig.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC1B,2BAA2B,EAAE,MAAM,CAAC;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadConfig.js","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadConfig.ts"],"names":[],"mappings":"","sourcesContent":["interface TransferUploadConfig {\n progressEventThrottlingInMs: number,\n currentRatesTimespanInMs: number,\n forceUdp?: boolean,\n turnOffUdp?: boolean,\n}\n\nexport default TransferUploadConfig;"]}
1
+ {"version":3,"file":"transferUploadConfig.js","sourceRoot":"","sources":["../../../../src/uploader/options/transferUploadConfig.ts"],"names":[],"mappings":"","sourcesContent":["interface TransferUploadConfig {\n progressEventThrottlingInMs: number,\n currentRatesTimespanInMs: number,\n chunkSizeInBytes: number,\n}\n\nexport default TransferUploadConfig;\n"]}
@@ -0,0 +1,7 @@
1
+ interface PendingFileAck {
2
+ externalFileId: string | number;
3
+ uploadItemId: string;
4
+ sizeInBytes: number;
5
+ }
6
+ export default PendingFileAck;
7
+ //# sourceMappingURL=pendingFileAck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pendingFileAck.d.ts","sourceRoot":"","sources":["../../../src/uploader/pendingFileAck.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACpB,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pendingFileAck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pendingFileAck.js","sourceRoot":"","sources":["../../../src/uploader/pendingFileAck.ts"],"names":[],"mappings":"","sourcesContent":["interface PendingFileAck {\n externalFileId: string | number,\n uploadItemId: string,\n sizeInBytes: number,\n}\n\nexport default PendingFileAck;\n"]}
@@ -0,0 +1,6 @@
1
+ interface RegisteredTransferFile {
2
+ uploadItemId: string;
3
+ fileId: string;
4
+ }
5
+ export default RegisteredTransferFile;
6
+ //# sourceMappingURL=registeredTransferFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registeredTransferFile.d.ts","sourceRoot":"","sources":["../../../src/uploader/registeredTransferFile.ts"],"names":[],"mappings":"AAAA,UAAU,sBAAsB;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=registeredTransferFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registeredTransferFile.js","sourceRoot":"","sources":["../../../src/uploader/registeredTransferFile.ts"],"names":[],"mappings":"","sourcesContent":["interface RegisteredTransferFile {\n uploadItemId: string,\n fileId: string,\n}\n\nexport default RegisteredTransferFile;\n"]}
@@ -2,6 +2,7 @@ export default class ContinuousChunksCalculator {
2
2
  #private;
3
3
  export(): ContinuousChunksCalculatorState;
4
4
  recover(exportedState: ContinuousChunksCalculatorState): void;
5
+ private copyFileChunksEntry;
5
6
  getChunks(fileId: string | number): readonly Readonly<ContinuousChunk>[];
6
7
  getChunksUploadedBytesCount(fileId: string | number): number;
7
8
  addNewChunk(fileId: string | number, newChunk: ContinuousChunk): void;
@@ -1 +1 @@
1
- {"version":3,"file":"continuousChunksCalculator.d.ts","sourceRoot":"","sources":["../../../../src/uploader/state/continuousChunksCalculator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,0BAA0B;;IAG3C,MAAM,IAAI,+BAA+B;IAIzC,OAAO,CAAC,aAAa,EAAE,+BAA+B;IAItD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,QAAQ,CAAC,eAAe,CAAC,EAAE;IAIxE,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAI5D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,eAAe;IAY9D,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,eAAe;IA0CvB,OAAO,CAAC,iCAAiC;IAWzC,OAAO,CAAC,+BAA+B;IAKvC,OAAO,CAAC,6BAA6B;IAMrC,OAAO,CAAC,0BAA0B;CAIrC;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7E,MAAM,MAAM,+BAA+B,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"continuousChunksCalculator.d.ts","sourceRoot":"","sources":["../../../../src/uploader/state/continuousChunksCalculator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,0BAA0B;;IAG3C,MAAM,IAAI,+BAA+B;IAKzC,OAAO,CAAC,aAAa,EAAE,+BAA+B;IAKtD,OAAO,CAAC,mBAAmB;IAK3B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,QAAQ,CAAC,eAAe,CAAC,EAAE;IAIxE,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAI5D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,eAAe;IAY9D,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,eAAe;IA0CvB,OAAO,CAAC,iCAAiC;IAWzC,OAAO,CAAC,+BAA+B;IAKvC,OAAO,CAAC,6BAA6B;IAMrC,OAAO,CAAC,0BAA0B;CAIrC;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7E,MAAM,MAAM,+BAA+B,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC"}
@@ -1,10 +1,16 @@
1
1
  export default class ContinuousChunksCalculator {
2
2
  #filesChunks = new Map();
3
3
  export() {
4
- return Array.from(this.#filesChunks.entries());
4
+ const fileChunksEntries = Array.from(this.#filesChunks.entries());
5
+ return fileChunksEntries.map(entry => this.copyFileChunksEntry(entry));
5
6
  }
6
7
  recover(exportedState) {
7
- this.#filesChunks = new Map(exportedState);
8
+ const copiedEntries = exportedState.map(entry => this.copyFileChunksEntry(entry));
9
+ this.#filesChunks = new Map(copiedEntries);
10
+ }
11
+ copyFileChunksEntry([fileId, chunks]) {
12
+ const copiedChunks = chunks.map(chunk => ({ ...chunk }));
13
+ return [fileId, copiedChunks];
8
14
  }
9
15
  getChunks(fileId) {
10
16
  return this.#filesChunks.get(fileId) ?? [];
@@ -1 +1 @@
1
- {"version":3,"file":"continuousChunksCalculator.js","sourceRoot":"","sources":["../../../../src/uploader/state/continuousChunksCalculator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC3C,YAAY,GAA4C,IAAI,GAAG,EAAE,CAAC;IAElE,MAAM;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,aAA8C;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,MAAuB;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,2BAA2B,CAAC,MAAuB;QAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IAED,WAAW,CAAC,MAAuB,EAAE,QAAyB;QAC1D,IAAI,QAAQ,CAAC,WAAW,KAAK,CAAC;YAC1B,OAAO;QAEX,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,6BAA6B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAEO,6BAA6B,CA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,CAAC;QAClD,UAAU,CAAC,kBAAkB,CAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;QACvE,UAAU,CAAC,kBAAkB,CAAE,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAEO,0BAA0B,CAAC,MAAuB,EAAE,eAAuB,EAAE,QAAyB;QAC1G,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAClD,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;CACJ","sourcesContent":["export default class ContinuousChunksCalculator {\n #filesChunks: Map<string | number, ContinuousChunk[]> = new Map();\n\n export(): ContinuousChunksCalculatorState {\n return Array.from(this.#filesChunks.entries());\n }\n\n recover(exportedState: ContinuousChunksCalculatorState) {\n this.#filesChunks = new Map(exportedState);\n }\n\n getChunks(fileId: string | number): readonly Readonly<ContinuousChunk>[] {\n return this.#filesChunks.get(fileId) ?? [];\n }\n\n getChunksUploadedBytesCount(fileId: string | number): number {\n return this.getChunks(fileId).reduce((partialSum, chunk) => partialSum + chunk.sizeInBytes, 0);\n }\n\n addNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n if (newChunk.sizeInBytes === 0)\n return;\n\n if (!this.#filesChunks.has(fileId)) {\n this.initializeNewFileWithNewChunk(fileId, newChunk);\n return;\n }\n\n this.processNewChunk(fileId, newChunk);\n }\n\n private initializeNewFileWithNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n const initValue = [newChunk];\n\n this.#filesChunks.set(fileId, initValue);\n\n return initValue;\n }\n\n private processNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n\n for (let i = 0; i < fileChunks.length; i++) {\n const nextChunkIndex = i + 1;\n\n const thisChunk = fileChunks[i]!;\n const nextChunk = fileChunks.length > nextChunkIndex ? fileChunks[nextChunkIndex] : undefined;\n\n const thisChunksNextContinuousChunkStartPosition = thisChunk.startPosition + thisChunk.sizeInBytes;\n const newChunksNextContinuousChunkStartPosition = newChunk.startPosition + newChunk.sizeInBytes;\n\n const isThisChunkStartingAfterNewChunk = thisChunk.startPosition > newChunk.startPosition;\n\n const canExtendThisChunk = thisChunksNextContinuousChunkStartPosition === newChunk.startPosition;\n const canJoinWithThisChunk = thisChunk.startPosition === newChunksNextContinuousChunkStartPosition;\n const canJoinWithNextChunk = nextChunk && nextChunk.startPosition === newChunksNextContinuousChunkStartPosition;\n\n if (canExtendThisChunk && canJoinWithNextChunk) {\n this.joinTwoExistingChunksWithNewChunk(fileId, i, newChunk, nextChunkIndex);\n return;\n }\n\n if (canExtendThisChunk) {\n this.extendExistingChunkWithNewChunk(fileId, i, newChunk);\n return;\n }\n\n if (canJoinWithThisChunk) {\n this.joinNewChunkWithExistingChunk(fileId, newChunk, i);\n return;\n }\n\n if (isThisChunkStartingAfterNewChunk) {\n this.insertNewChunkIntoSequence(fileId, i, newChunk);\n return;\n }\n }\n\n fileChunks.push(newChunk);\n }\n\n private joinTwoExistingChunksWithNewChunk(fileId: string | number, leftChunkIndex: number, newChunk: ContinuousChunk, rightChunkIndex: number) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n\n const leftChunk = fileChunks[leftChunkIndex]!;\n const rightChunk = fileChunks[rightChunkIndex]!;\n\n leftChunk.sizeInBytes += newChunk.sizeInBytes + rightChunk.sizeInBytes;\n\n fileChunks.splice(rightChunkIndex, 1);\n }\n\n private extendExistingChunkWithNewChunk(fileId: string | number, existingChunkIndex: number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks[existingChunkIndex]!.sizeInBytes += newChunk.sizeInBytes;\n }\n\n private joinNewChunkWithExistingChunk(fileId: string | number, newChunk: ContinuousChunk, existingChunkIndex: number) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks[existingChunkIndex]!.startPosition = newChunk.startPosition;\n fileChunks[existingChunkIndex]!.sizeInBytes += newChunk.sizeInBytes;\n }\n\n private insertNewChunkIntoSequence(fileId: string | number, indexToInsertAt: number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks.splice(indexToInsertAt, 0, newChunk);\n }\n}\n\nexport type ContinuousChunk = { startPosition: number, sizeInBytes: number };\nexport type ContinuousChunksCalculatorState = [string | number, ContinuousChunk[]][];"]}
1
+ {"version":3,"file":"continuousChunksCalculator.js","sourceRoot":"","sources":["../../../../src/uploader/state/continuousChunksCalculator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC3C,YAAY,GAA4C,IAAI,GAAG,EAAE,CAAC;IAElE,MAAM;QACF,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;QAClE,OAAO,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,aAA8C;QAClD,MAAM,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAEO,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAgD;QACvF,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,SAAS,CAAC,MAAuB;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IA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AAC,cAAc,CAAE,CAAC;QAC9C,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,CAAE,CAAC;QAEhD,SAAS,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAEvE,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,+BAA+B,CAAC,MAAuB,EAAE,kBAA0B,EAAE,QAAyB;QAClH,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAClD,UAAU,CAAC,kBAAkB,CAAE,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAEO,6BAA6B,CAAC,MAAuB,EAAE,QAAyB,EAAE,kBAA0B;QAChH,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAClD,UAAU,CAAC,kBAAkB,CAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;QACvE,UAAU,CAAC,kBAAkB,CAAE,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAEO,0BAA0B,CAAC,MAAuB,EAAE,eAAuB,EAAE,QAAyB;QAC1G,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAClD,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;CACJ","sourcesContent":["export default class ContinuousChunksCalculator {\n #filesChunks: Map<string | number, ContinuousChunk[]> = new Map();\n\n export(): ContinuousChunksCalculatorState {\n const fileChunksEntries = Array.from(this.#filesChunks.entries());\n return fileChunksEntries.map(entry => this.copyFileChunksEntry(entry));\n }\n\n recover(exportedState: ContinuousChunksCalculatorState) {\n const copiedEntries = exportedState.map(entry => this.copyFileChunksEntry(entry));\n this.#filesChunks = new Map(copiedEntries);\n }\n\n private copyFileChunksEntry([fileId, chunks]: readonly [string | number, ContinuousChunk[]]): [string | number, ContinuousChunk[]] {\n const copiedChunks = chunks.map(chunk => ({ ...chunk }));\n return [fileId, copiedChunks];\n }\n\n getChunks(fileId: string | number): readonly Readonly<ContinuousChunk>[] {\n return this.#filesChunks.get(fileId) ?? [];\n }\n\n getChunksUploadedBytesCount(fileId: string | number): number {\n return this.getChunks(fileId).reduce((partialSum, chunk) => partialSum + chunk.sizeInBytes, 0);\n }\n\n addNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n if (newChunk.sizeInBytes === 0)\n return;\n\n if (!this.#filesChunks.has(fileId)) {\n this.initializeNewFileWithNewChunk(fileId, newChunk);\n return;\n }\n\n this.processNewChunk(fileId, newChunk);\n }\n\n private initializeNewFileWithNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n const initValue = [newChunk];\n\n this.#filesChunks.set(fileId, initValue);\n\n return initValue;\n }\n\n private processNewChunk(fileId: string | number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n\n for (let i = 0; i < fileChunks.length; i++) {\n const nextChunkIndex = i + 1;\n\n const thisChunk = fileChunks[i]!;\n const nextChunk = fileChunks.length > nextChunkIndex ? fileChunks[nextChunkIndex] : undefined;\n\n const thisChunksNextContinuousChunkStartPosition = thisChunk.startPosition + thisChunk.sizeInBytes;\n const newChunksNextContinuousChunkStartPosition = newChunk.startPosition + newChunk.sizeInBytes;\n\n const isThisChunkStartingAfterNewChunk = thisChunk.startPosition > newChunk.startPosition;\n\n const canExtendThisChunk = thisChunksNextContinuousChunkStartPosition === newChunk.startPosition;\n const canJoinWithThisChunk = thisChunk.startPosition === newChunksNextContinuousChunkStartPosition;\n const canJoinWithNextChunk = nextChunk && nextChunk.startPosition === newChunksNextContinuousChunkStartPosition;\n\n if (canExtendThisChunk && canJoinWithNextChunk) {\n this.joinTwoExistingChunksWithNewChunk(fileId, i, newChunk, nextChunkIndex);\n return;\n }\n\n if (canExtendThisChunk) {\n this.extendExistingChunkWithNewChunk(fileId, i, newChunk);\n return;\n }\n\n if (canJoinWithThisChunk) {\n this.joinNewChunkWithExistingChunk(fileId, newChunk, i);\n return;\n }\n\n if (isThisChunkStartingAfterNewChunk) {\n this.insertNewChunkIntoSequence(fileId, i, newChunk);\n return;\n }\n }\n\n fileChunks.push(newChunk);\n }\n\n private joinTwoExistingChunksWithNewChunk(fileId: string | number, leftChunkIndex: number, newChunk: ContinuousChunk, rightChunkIndex: number) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n\n const leftChunk = fileChunks[leftChunkIndex]!;\n const rightChunk = fileChunks[rightChunkIndex]!;\n\n leftChunk.sizeInBytes += newChunk.sizeInBytes + rightChunk.sizeInBytes;\n\n fileChunks.splice(rightChunkIndex, 1);\n }\n\n private extendExistingChunkWithNewChunk(fileId: string | number, existingChunkIndex: number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks[existingChunkIndex]!.sizeInBytes += newChunk.sizeInBytes;\n }\n\n private joinNewChunkWithExistingChunk(fileId: string | number, newChunk: ContinuousChunk, existingChunkIndex: number) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks[existingChunkIndex]!.startPosition = newChunk.startPosition;\n fileChunks[existingChunkIndex]!.sizeInBytes += newChunk.sizeInBytes;\n }\n\n private insertNewChunkIntoSequence(fileId: string | number, indexToInsertAt: number, newChunk: ContinuousChunk) {\n const fileChunks = this.#filesChunks.get(fileId)!;\n fileChunks.splice(indexToInsertAt, 0, newChunk);\n }\n}\n\nexport type ContinuousChunk = { startPosition: number, sizeInBytes: number };\nexport type ContinuousChunksCalculatorState = [string | number, ContinuousChunk[]][];"]}
@@ -23,6 +23,7 @@ export default class TransferUploadState {
23
23
  getChunksForFile(externalId: string | number): readonly Readonly<ContinuousChunk>[];
24
24
  export(): TransferUploadExportState;
25
25
  recover(): void;
26
+ private hasAllChunksUploaded;
26
27
  private recoverFromExportedState;
27
28
  getFile(externalFileId: string | number): ReadonlyTransferUploadStateFile;
28
29
  private getFileInternal;
@@ -35,14 +36,16 @@ export default class TransferUploadState {
35
36
  transferCanceled(): void;
36
37
  transferCompleted(transferMetadata: TransferUploadMetadata, transferDownloadUrl: string, confirmationUrl: string | undefined, recipientTrackingLinks?: TransferUploadCompletedEventArgs[`recipientTrackingLinks`]): void;
37
38
  transferFailed(): void;
38
- fileUploadStarted(file: TransferUploadStateFile): void;
39
- fileUploadCompleted(file: TransferUploadStateFile): void;
40
- fileUploadFailed(file: TransferUploadStateFile): void;
41
- chunkUploadStarted(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number): void;
42
- chunkUploadProgressed(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number, apiEventArgs: ChunkProgressEvent): void;
39
+ fileUploadStarted(file: TransferUploadStateFile, uploadItemId: string | undefined): void;
40
+ fileUploadCompleted(file: TransferUploadStateFile, uploadItemId: string | undefined): void;
41
+ fileCompleted(externalFileId: string | number, uploadItemId: string | undefined): void;
42
+ fileAckFailed(externalFileId: string | number, uploadItemId: string, reason: string, error: Error): void;
43
+ fileUploadFailed(file: TransferUploadStateFile, uploadItemId: string | undefined): void;
44
+ chunkUploadStarted(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number): void;
45
+ chunkUploadProgressed(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number, apiEventArgs: ChunkProgressEvent): void;
43
46
  private getRatesAndNotifyUploadProgressed;
44
- chunkUploadCompleted(externalFileId: string | number, startPosition: number, sizeInBytes: number, latencyInMsIfUdp: number | undefined): void;
45
- chunkUploadCompletedPartially(externalFileId: string | number, startPosition: number, sizeInBytes: number, uploadedBytesCount: number, isPauseRequested: boolean, latencyInMsIfUdp?: number): void;
46
- chunkUploadFailed(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number, uploadedBytesCount: number, failedReason: string, error: Error): void;
47
+ chunkUploadCompleted(externalFileId: string | number, uploadItemId: string | undefined, startPosition: number, sizeInBytes: number): void;
48
+ chunkUploadCompletedPartially(externalFileId: string | number, uploadItemId: string | undefined, startPosition: number, sizeInBytes: number, uploadedBytesCount: number, isPauseRequested: boolean): void;
49
+ chunkUploadFailed(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number, uploadedBytesCount: number, failedReason: string, error: Error): void;
47
50
  }
48
51
  //# sourceMappingURL=transferUploadState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadState.d.ts","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadState.ts"],"names":[],"mappings":"AAGA,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAEnE,OAAO,cAAc,MAAM,qCAAqC,CAAC;AAKjE,OAAO,KAAK,kBAAkB,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,WAAW,MAAM,uCAAuC,CAAC;AAKrE,OAAO,KAAK,gCAAgC,MAAM,kDAAkD,CAAC;AACrG,OAAO,KAAK,+BAA+B,MAAM,sCAAsC,CAAC;AACxF,OAAO,KAAK,gCAAgC,MAAM,uCAAuC,CAAC;AAE1F,OAAO,KAAK,yBAAyB,MAAM,wCAAwC,CAAC;AAEpF,OAAO,KAAK,sBAAsB,MAAM,qCAAqC,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIvE,MAAM,CAAC,OAAO,OAAO,mBAAmB;;IAmBpC,IAAI,MAAM,IAAI,cAAc,CAE3B;IAED,IAAI,mBAAmB,IAAI,MAAM,CAEhC;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,IAAI,KAAK,IAAI,gCAAgC,CAE5C;gBAEW,KAAK,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AAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAOjG,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS;IAUhF,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAe1I,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,GAAG,IAAI;IActL,OAAO,CAAC,iCAAiC;IAczC,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAqBlI,6BAA6B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO;IAyBlM,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAsB5M"}
@@ -42,7 +42,6 @@ export default class TransferUploadState {
42
42
  this.#currentRatesTimespanInMs = currentRatesTimespanInMs;
43
43
  this.#getRatesAndNotifyUploadProgressedThrottled = throttle(this.getRatesAndNotifyUploadProgressed, progressEventThrottlingInMs);
44
44
  this.initializeTransferStatus(files);
45
- this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);
46
45
  this.#continuousChunkCalculator = new ContinuousChunksCalculator();
47
46
  if (exportedState)
48
47
  this.recoverFromExportedState(exportedState);
@@ -57,7 +56,10 @@ export default class TransferUploadState {
57
56
  return this.#continuousChunkCalculator.getChunks(externalId);
58
57
  }
59
58
  export() {
60
- return this.#continuousChunkCalculator.export();
59
+ return {
60
+ continuousChunksCalculatorState: this.#continuousChunkCalculator.export(),
61
+ completedFiles: Object.values(this.#files).filter(file => file.isCompleted).map(file => file.externalId),
62
+ };
61
63
  }
62
64
  recover() {
63
65
  this.#status = TransferStatus.Initialized;
@@ -73,15 +75,28 @@ export default class TransferUploadState {
73
75
  file.failedBytesCount = 0;
74
76
  if (file.isCompleted)
75
77
  this.#completedFilesCount += 1;
78
+ // A file can have all its chunks recorded and still miss the live isUploadCompleted transition (e.g. a
79
+ // full chunk recorded through the partially-completed path on pause), so the flag is recomputed from
80
+ // the chunks the same way recoverFromExportedState does - such a file has to be acked on the next run.
81
+ file.isUploadCompleted = this.hasAllChunksUploaded(file);
76
82
  file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);
77
83
  this.#uploadedBytesCount += file.uploadedBytesCount;
78
84
  }
79
85
  }
86
+ hasAllChunksUploaded(file) {
87
+ const fileChunks = this.#continuousChunkCalculator.getChunks(file.externalId);
88
+ return fileChunks.length === 1 && fileChunks[0].startPosition === 0 && fileChunks[0].sizeInBytes === file.fileSizeInBytes;
89
+ }
80
90
  recoverFromExportedState(exportedState) {
81
- this.#continuousChunkCalculator.recover(exportedState);
91
+ // Remove this variable and the legacy recovery logic after all our clients are on desktop version >= 4.22
92
+ const isLegacyModeTransfer = Array.isArray(exportedState);
93
+ const continuousChunksState = isLegacyModeTransfer ? exportedState : exportedState.continuousChunksCalculatorState;
94
+ const completedFiles = isLegacyModeTransfer ? undefined : new Set(exportedState.completedFiles);
95
+ this.#continuousChunkCalculator.recover(continuousChunksState);
82
96
  for (const [, file] of Object.entries(this.#files)) {
83
- const fileChunks = this.#continuousChunkCalculator.getChunks(file.externalId);
84
- file.isCompleted = fileChunks.length === 1 && fileChunks[0].startPosition === 0 && fileChunks[0].sizeInBytes === file.fileSizeInBytes;
97
+ const isUploadCompleted = this.hasAllChunksUploaded(file);
98
+ file.isUploadCompleted = isUploadCompleted;
99
+ file.isCompleted = isLegacyModeTransfer ? isUploadCompleted : completedFiles.has(file.externalId);
85
100
  file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);
86
101
  if (file.isCompleted)
87
102
  this.#completedFilesCount += 1;
@@ -99,7 +114,7 @@ export default class TransferUploadState {
99
114
  }
100
115
  transferRun() {
101
116
  this.#status = TransferStatus.Running;
102
- this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);
117
+ this.#ratesCalculator = undefined;
103
118
  this.#eventsEngine.emit(TransferUploadEvent.TransferRun);
104
119
  }
105
120
  transferPauseRequested() {
@@ -156,39 +171,53 @@ export default class TransferUploadState {
156
171
  this.#getRatesAndNotifyUploadProgressedThrottled.cancel();
157
172
  this.#eventsEngine.emit(TransferUploadEvent.TransferFailed);
158
173
  }
159
- fileUploadStarted(file) {
174
+ fileUploadStarted(file, uploadItemId) {
160
175
  file.isBeingUploaded = true;
161
- const eventArgs = { fileStatus: file };
176
+ const eventArgs = { fileStatus: file, uploadItemId };
162
177
  this.#eventsEngine.emit(TransferUploadEvent.FileUploadStarted, eventArgs);
163
178
  }
164
- fileUploadCompleted(file) {
179
+ fileUploadCompleted(file, uploadItemId) {
165
180
  file.isBeingUploaded = false;
181
+ file.isUploadCompleted = true;
182
+ const eventArgs = { fileStatus: file, uploadItemId };
183
+ this.#eventsEngine.emit(TransferUploadEvent.FileUploadCompleted, eventArgs);
184
+ }
185
+ fileCompleted(externalFileId, uploadItemId) {
186
+ const file = this.getFileInternal(externalFileId);
166
187
  file.isCompleted = true;
167
188
  this.#completedFilesCount += 1;
168
- const eventArgs = { fileStatus: file };
169
- this.#eventsEngine.emit(TransferUploadEvent.FileUploadCompleted, eventArgs);
189
+ this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);
190
+ const eventArgs = { fileStatus: file, uploadItemId };
191
+ this.#eventsEngine.emit(TransferUploadEvent.FileCompleted, eventArgs);
192
+ }
193
+ fileAckFailed(externalFileId, uploadItemId, reason, error) {
194
+ const file = this.getFileInternal(externalFileId);
195
+ const eventArgs = { fileStatus: file, uploadItemId, reason, error };
196
+ this.#eventsEngine.emit(TransferUploadEvent.FileAckFailed, eventArgs);
170
197
  }
171
- fileUploadFailed(file) {
198
+ fileUploadFailed(file, uploadItemId) {
172
199
  file.isBeingUploaded = false;
173
200
  file.isFailed = true;
174
201
  this.#failedFilesCount += 1;
175
- const eventArgs = { fileStatus: file, reason: file.failedReason };
202
+ const eventArgs = { fileStatus: file, uploadItemId, reason: file.failedReason };
176
203
  this.#eventsEngine.emit(TransferUploadEvent.FileUploadFailed, eventArgs);
177
204
  }
178
- chunkUploadStarted(externalFileId, chunkStartPosition, chunkSizeInBytes) {
205
+ chunkUploadStarted(externalFileId, uploadItemId, chunkStartPosition, chunkSizeInBytes) {
179
206
  const file = this.getFileInternal(externalFileId);
207
+ if (!this.#ratesCalculator)
208
+ this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);
180
209
  if (!file.isBeingUploaded)
181
- this.fileUploadStarted(file);
210
+ this.fileUploadStarted(file, uploadItemId);
182
211
  file.runningChunksCount += 1;
183
- const eventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes };
212
+ const eventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes };
184
213
  this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadStarted, eventArgs);
185
214
  }
186
- chunkUploadProgressed(externalFileId, chunkStartPosition, chunkSizeInBytes, apiEventArgs) {
215
+ chunkUploadProgressed(externalFileId, uploadItemId, chunkStartPosition, chunkSizeInBytes, apiEventArgs) {
187
216
  const file = this.getFileInternal(externalFileId);
188
217
  file.uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;
189
218
  this.#uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;
190
219
  this.#ratesCalculator.addNewProgressEvent(apiEventArgs.transferredBytesSinceLastEvent);
191
- const eventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes, transferredBytesSinceLastEvent: apiEventArgs.transferredBytesSinceLastEvent };
220
+ const eventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes, transferredBytesSinceLastEvent: apiEventArgs.transferredBytesSinceLastEvent };
192
221
  this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadProgressed, eventArgs);
193
222
  this.#getRatesAndNotifyUploadProgressedThrottled();
194
223
  }
@@ -203,21 +232,21 @@ export default class TransferUploadState {
203
232
  };
204
233
  this.#eventsEngine.emit(TransferUploadEvent.TransferProgressed, tranferEventArgs);
205
234
  }
206
- chunkUploadCompleted(externalFileId, startPosition, sizeInBytes, latencyInMsIfUdp) {
235
+ chunkUploadCompleted(externalFileId, uploadItemId, startPosition, sizeInBytes) {
207
236
  const file = this.getFileInternal(externalFileId);
208
237
  file.runningChunksCount -= 1;
209
238
  this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes });
210
239
  this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);
211
- const eventArgs = { fileStatus: file, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, latencyInMsIfUdp };
240
+ const eventArgs = { fileStatus: file, uploadItemId, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes };
212
241
  this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompleted, eventArgs);
213
242
  if (file.runningChunksCount > 0)
214
243
  return;
215
244
  if (file.uploadedBytesCount === file.fileSizeInBytes)
216
- this.fileUploadCompleted(file);
245
+ this.fileUploadCompleted(file, uploadItemId);
217
246
  else if (file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)
218
- this.fileUploadFailed(file);
247
+ this.fileUploadFailed(file, uploadItemId);
219
248
  }
220
- chunkUploadCompletedPartially(externalFileId, startPosition, sizeInBytes, uploadedBytesCount, isPauseRequested, latencyInMsIfUdp) {
249
+ chunkUploadCompletedPartially(externalFileId, uploadItemId, startPosition, sizeInBytes, uploadedBytesCount, isPauseRequested) {
221
250
  const file = this.getFileInternal(externalFileId);
222
251
  file.runningChunksCount -= 1;
223
252
  const failedBytes = sizeInBytes - uploadedBytesCount;
@@ -228,12 +257,12 @@ export default class TransferUploadState {
228
257
  if (uploadedBytesCount > 0)
229
258
  this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes: uploadedBytesCount });
230
259
  this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);
231
- const eventArgs = { fileStatus: file, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, uploadedBytesCount, isPauseRequested, latencyInMsIfUdp };
260
+ const eventArgs = { fileStatus: file, uploadItemId, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, uploadedBytesCount, isPauseRequested };
232
261
  this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompletedPartially, eventArgs);
233
262
  if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)
234
- this.fileUploadFailed(file);
263
+ this.fileUploadFailed(file, uploadItemId);
235
264
  }
236
- chunkUploadFailed(externalFileId, chunkStartPosition, chunkSizeInBytes, uploadedBytesCount, failedReason, error) {
265
+ chunkUploadFailed(externalFileId, uploadItemId, chunkStartPosition, chunkSizeInBytes, uploadedBytesCount, failedReason, error) {
237
266
  const file = this.getFileInternal(externalFileId);
238
267
  file.runningChunksCount -= 1;
239
268
  const failedBytes = chunkSizeInBytes;
@@ -243,10 +272,10 @@ export default class TransferUploadState {
243
272
  this.#failedBytesCount += failedBytes;
244
273
  if (!file.failedReason)
245
274
  file.failedReason = failedReason;
246
- const eventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes, reason: failedReason, error };
275
+ const eventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes, reason: failedReason, error };
247
276
  this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadFailed, eventArgs);
248
277
  if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)
249
- this.fileUploadFailed(file);
278
+ this.fileUploadFailed(file, uploadItemId);
250
279
  }
251
280
  }
252
281
  //# sourceMappingURL=transferUploadState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadState.js","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadState.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAC5D,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAC5D,OAAO,6BAA6B,MAAM,uCAAuC,CAAC;AAClF,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AAqBzE,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,GAAmB,cAAc,CAAC,WAAW,CAAC;IAErD,oBAAoB,GAAG,CAAC,CAAC;IACzB,iBAAiB,GAAG,CAAC,CAAC;IACtB,MAAM,GAA6B,EAAE,CAAC;IACtC,aAAa,CAAe;IAE5B,gBAAgB,CAAgC;IAChD,0BAA0B,CAA6B;IACvD,yBAAyB,CAAS;IAElC,mBAAmB,GAAG,CAAC,CAAC;IACxB,iBAAiB,GAAG,CAAC,CAAC;IAEtB,gBAAgB,GAAG,CAAC,CAAC;IAErB,2CAA2C,CAAwF;IAEnI,IAAI,MAAM;QACN,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B,KAAK,IAAI,CAAC,eAAe;YACzG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["/* eslint-disable no-param-reassign */\nimport throttle from 'lodash.throttle';\n\nimport TransferUploadStateFile from \"./transferUploadStateFile.js\";\nimport TransferUploadEvent from \"../transferUploadEvent.js\";\nimport TransferStatus from \"../../utils/types/transferStatus.js\";\nimport TransferUploadError from \"../transferUploadError.js\";\nimport TransferUploadRatesCalculator from \"./transferUploadProgressCalculator.js\";\nimport ContinuousChunksCalculator from './continuousChunksCalculator.js';\n\nimport type ChunkProgressEvent from \"../../utils/events/chunkProgressEvent.js\";\nimport type EventsEngine from \"../../utils/events/eventsEngine.js\";\nimport type FileDetails from \"../../utils/fileSystem/fileDetails.js\";\nimport type TransferUploadStateFiles from \"./transferUploadStateFiles.js\";\nimport type FileChunkUploadFailedEventArgs from \"../eventArgs/fileChunkUploadFailedEventArgs.js\";\nimport type FileChunkUploadEventArgs from \"../eventArgs/fileChunkUploadEventArgs.js\";\nimport type FileUploadEventArgs from \"../eventArgs/fileUploadEventArgs.js\";\nimport type TransferUploadCompletedEventArgs from \"../eventArgs/transferUploadCompletedEventArgs.js\";\nimport type ReadonlyTransferUploadStateFile from \"./readonlyTransferUploadStateFile.js\";\nimport type ReadonlyTransferUploadStateFiles from \"./readonlyTransferUploadStateFiles.js\";\nimport type FileUploadFailedEventArgs from \"../eventArgs/fileUploadFailedEventArgs.js\";\nimport type TransferUploadExportState from \"../export/transferUploadExportState.js\";\nimport type TransferUploadProgressedEventArgs from \"../eventArgs/transferUploadProgressedEventArgs.js\";\nimport type TransferUploadMetadata from '../export/transferUploadMetadata.js';\nimport type FileChunkUploadProgressedEventArgs from '../eventArgs/fileChunkUploadProgressedEventArgs.js';\nimport type { ContinuousChunk } from './continuousChunksCalculator.js';\nimport type FileChunkUploadCompletedPartiallyEventArgs from '../eventArgs/fileChunkUploadCompletedPartiallyEventArgs.js';\nimport type FileChunkUploadCompletedEventArgs from '../eventArgs/fileChunkUploadCompletedEventArgs.js';\n\nexport default class TransferUploadState {\n #status: TransferStatus = TransferStatus.Initialized;\n\n #completedFilesCount = 0;\n #failedFilesCount = 0;\n #files: TransferUploadStateFiles = {};\n #eventsEngine: EventsEngine;\n\n #ratesCalculator: TransferUploadRatesCalculator;\n #continuousChunkCalculator: ContinuousChunksCalculator;\n #currentRatesTimespanInMs: number;\n\n #uploadedBytesCount = 0;\n #failedBytesCount = 0;\n\n #totalBytesCount = 0;\n\n #getRatesAndNotifyUploadProgressedThrottled: ReturnType<typeof throttle<TransferUploadState[`getRatesAndNotifyUploadProgressed`]>>;\n\n get status(): TransferStatus {\n return this.#status;\n }\n\n get completedFilesCount(): number {\n return this.#completedFilesCount;\n }\n\n get failedFilesCount(): number {\n return this.#failedFilesCount;\n }\n\n get uploadedBytesCount(): number {\n return this.#uploadedBytesCount;\n }\n\n get failedBytesCount(): number {\n return this.#failedBytesCount;\n }\n\n get files(): ReadonlyTransferUploadStateFiles {\n return this.#files;\n }\n\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number)\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number, exportedState: TransferUploadExportState)\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number, exportedState?: TransferUploadExportState) {\n this.#eventsEngine = eventsEngine;\n this.#currentRatesTimespanInMs = currentRatesTimespanInMs;\n\n this.#getRatesAndNotifyUploadProgressedThrottled = throttle(this.getRatesAndNotifyUploadProgressed, progressEventThrottlingInMs);\n\n this.initializeTransferStatus(files);\n\n this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);\n this.#continuousChunkCalculator = new ContinuousChunksCalculator();\n\n if (exportedState)\n this.recoverFromExportedState(exportedState);\n }\n\n private initializeTransferStatus(filesDetails: readonly FileDetails[]) {\n for (const file of filesDetails) {\n this.#files[file.externalId] = new TransferUploadStateFile(file.externalId, file.fileSizeInBytes, file.fileName);\n\n this.#totalBytesCount += file.fileSizeInBytes;\n }\n }\n\n getChunksForFile(externalId: string | number): readonly Readonly<ContinuousChunk>[] {\n return this.#continuousChunkCalculator.getChunks(externalId);\n }\n\n export(): TransferUploadExportState {\n return this.#continuousChunkCalculator.export();\n }\n\n recover() {\n this.#status = TransferStatus.Initialized;\n this.#completedFilesCount = 0;\n this.#uploadedBytesCount = 0;\n this.#failedFilesCount = 0;\n this.#failedBytesCount = 0;\n\n for (const [, file] of Object.entries(this.#files)) {\n file.isBeingUploaded = false;\n file.runningChunksCount = 0;\n file.isFailed = false;\n file.failedReason = null;\n file.failedBytesCount = 0;\n\n if (file.isCompleted)\n this.#completedFilesCount += 1;\n\n file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);\n\n this.#uploadedBytesCount += file.uploadedBytesCount;\n }\n }\n\n private recoverFromExportedState(exportedState: TransferUploadExportState) {\n this.#continuousChunkCalculator.recover(exportedState);\n\n for (const [, file] of Object.entries(this.#files)) {\n const fileChunks = this.#continuousChunkCalculator.getChunks(file.externalId);\n\n file.isCompleted = fileChunks.length === 1 && fileChunks[0]!.startPosition === 0 && fileChunks[0]!.sizeInBytes === file.fileSizeInBytes;\n file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);\n\n if (file.isCompleted)\n this.#completedFilesCount += 1;\n\n this.#uploadedBytesCount += file.uploadedBytesCount;\n }\n }\n\n getFile(externalFileId: string | number): ReadonlyTransferUploadStateFile {\n return this.getFileInternal(externalFileId);\n }\n\n private getFileInternal(externalFileId: string | number): TransferUploadStateFile {\n const file = this.#files[externalFileId];\n\n if (!file)\n throw new TransferUploadError(`File with id = ${externalFileId} doesn't exist`);\n\n return file;\n }\n\n transferRun() {\n this.#status = TransferStatus.Running;\n\n this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferRun);\n }\n\n transferPauseRequested() {\n this.#status = TransferStatus.Pausing;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferPauseRequested);\n }\n\n transferPaused() {\n this.#status = TransferStatus.Paused;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.flush();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferPaused);\n }\n\n transferAbortRequested() {\n this.#status = TransferStatus.Aborting;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferAbortRequested);\n }\n\n transferAborted() {\n this.#status = TransferStatus.Aborted;\n\n for (const [, file] of Object.entries(this.#files)) {\n if (file.isBeingUploaded) {\n file.isBeingUploaded = false;\n file.isFailed = true;\n\n if (!file.failedReason)\n file.failedReason = `Aborted`;\n }\n }\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferAborted);\n }\n\n transferCancelRequested() {\n this.#status = TransferStatus.Canceling;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCancelRequested);\n }\n\n transferCanceled() {\n this.#status = TransferStatus.Canceled;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCanceled);\n }\n\n transferCompleted(transferMetadata: TransferUploadMetadata, transferDownloadUrl: string, confirmationUrl: string | undefined, recipientTrackingLinks?: TransferUploadCompletedEventArgs[`recipientTrackingLinks`]) {\n this.#status = TransferStatus.Completed;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.flush();\n\n const eventArgs: TransferUploadCompletedEventArgs = {\n transferId: transferMetadata.transferId,\n transferKey: transferMetadata.transferKey,\n transferDownloadUrl,\n confirmationUrl,\n fileServerUrl: transferMetadata.transferFileServerUrl,\n region: transferMetadata.transferRegion,\n recipientTrackingLinks,\n };\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCompleted, eventArgs);\n }\n\n transferFailed() {\n this.#status = TransferStatus.Failed;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferFailed);\n }\n\n fileUploadStarted(file: TransferUploadStateFile) {\n file.isBeingUploaded = true;\n\n const eventArgs: FileUploadEventArgs = { fileStatus: file };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadStarted, eventArgs);\n }\n\n fileUploadCompleted(file: TransferUploadStateFile) {\n file.isBeingUploaded = false;\n file.isCompleted = true;\n\n this.#completedFilesCount += 1;\n\n const eventArgs: FileUploadEventArgs = { fileStatus: file };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadCompleted, eventArgs);\n }\n\n fileUploadFailed(file: TransferUploadStateFile) {\n file.isBeingUploaded = false;\n file.isFailed = true;\n\n this.#failedFilesCount += 1;\n\n const eventArgs: FileUploadFailedEventArgs = { fileStatus: file, reason: file.failedReason };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadFailed, eventArgs);\n }\n\n chunkUploadStarted(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number) {\n const file = this.getFileInternal(externalFileId);\n\n if (!file.isBeingUploaded)\n this.fileUploadStarted(file);\n\n file.runningChunksCount += 1;\n\n const eventArgs: FileChunkUploadEventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadStarted, eventArgs);\n }\n\n chunkUploadProgressed(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number, apiEventArgs: ChunkProgressEvent): void {\n const file = this.getFileInternal(externalFileId);\n\n file.uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;\n this.#uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;\n\n this.#ratesCalculator.addNewProgressEvent(apiEventArgs.transferredBytesSinceLastEvent);\n\n const eventArgs: FileChunkUploadProgressedEventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes, transferredBytesSinceLastEvent: apiEventArgs.transferredBytesSinceLastEvent };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadProgressed, eventArgs);\n\n this.#getRatesAndNotifyUploadProgressedThrottled();\n }\n\n private getRatesAndNotifyUploadProgressed() {\n const progressStats = this.#ratesCalculator.getRates(this.#uploadedBytesCount);\n\n const tranferEventArgs: TransferUploadProgressedEventArgs = {\n uploadedBytesTotalCount: this.#uploadedBytesCount,\n progressInPercentage: (this.#uploadedBytesCount * 100) / this.#totalBytesCount,\n remainingSeconds: progressStats.remainingSeconds,\n averageSpeedInBytesPerSecond: progressStats.averageSpeedInBytesPerSec,\n currentSpeedInBytesPerSecond: progressStats.currentSpeedInBytesPerSec,\n };\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferProgressed, tranferEventArgs);\n }\n\n chunkUploadCompleted(externalFileId: string | number, startPosition: number, sizeInBytes: number, latencyInMsIfUdp: number | undefined) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes });\n\n this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);\n\n const eventArgs: FileChunkUploadCompletedEventArgs = { fileStatus: file, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, latencyInMsIfUdp };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompleted, eventArgs);\n\n if (file.runningChunksCount > 0)\n return;\n\n if (file.uploadedBytesCount === file.fileSizeInBytes)\n this.fileUploadCompleted(file);\n else if (file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file);\n }\n\n chunkUploadCompletedPartially(externalFileId: string | number, startPosition: number, sizeInBytes: number, uploadedBytesCount: number, isPauseRequested: boolean, latencyInMsIfUdp?: number) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n const failedBytes = sizeInBytes - uploadedBytesCount;\n\n file.failedBytesCount += failedBytes;\n this.#failedBytesCount += failedBytes;\n\n if (!file.failedReason)\n file.failedReason = isPauseRequested ? `Pause requested` : `Chunk upload completed partially`;\n\n if (uploadedBytesCount > 0)\n this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes: uploadedBytesCount });\n\n this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);\n\n const eventArgs: FileChunkUploadCompletedPartiallyEventArgs = { fileStatus: file, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, uploadedBytesCount, isPauseRequested, latencyInMsIfUdp };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompletedPartially, eventArgs);\n\n if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file);\n }\n\n chunkUploadFailed(externalFileId: string | number, chunkStartPosition: number, chunkSizeInBytes: number, uploadedBytesCount: number, failedReason: string, error: Error) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n const failedBytes = chunkSizeInBytes;\n\n file.uploadedBytesCount -= uploadedBytesCount;\n file.failedBytesCount += failedBytes;\n\n this.#uploadedBytesCount -= uploadedBytesCount;\n this.#failedBytesCount += failedBytes;\n\n if (!file.failedReason)\n file.failedReason = failedReason;\n\n const eventArgs: FileChunkUploadFailedEventArgs = { fileStatus: file, chunkStartPosition, chunkSizeInBytes, reason: failedReason, error };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadFailed, eventArgs);\n\n if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file);\n }\n}"]}
1
+ {"version":3,"file":"transferUploadState.js","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadState.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,mBAAmB,M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CAAC,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["/* eslint-disable no-param-reassign */\nimport throttle from 'lodash.throttle';\n\nimport TransferUploadStateFile from \"./transferUploadStateFile.js\";\nimport TransferUploadEvent from \"../transferUploadEvent.js\";\nimport TransferStatus from \"../../utils/types/transferStatus.js\";\nimport TransferUploadError from \"../transferUploadError.js\";\nimport TransferUploadRatesCalculator from \"./transferUploadProgressCalculator.js\";\nimport ContinuousChunksCalculator from './continuousChunksCalculator.js';\n\nimport type ChunkProgressEvent from \"../../utils/events/chunkProgressEvent.js\";\nimport type EventsEngine from \"../../utils/events/eventsEngine.js\";\nimport type FileDetails from \"../../utils/fileSystem/fileDetails.js\";\nimport type TransferUploadStateFiles from \"./transferUploadStateFiles.js\";\nimport type FileChunkUploadFailedEventArgs from \"../eventArgs/fileChunkUploadFailedEventArgs.js\";\nimport type FileAckFailedEventArgs from \"../eventArgs/fileAckFailedEventArgs.js\";\nimport type FileChunkUploadEventArgs from \"../eventArgs/fileChunkUploadEventArgs.js\";\nimport type FileUploadEventArgs from \"../eventArgs/fileUploadEventArgs.js\";\nimport type TransferUploadCompletedEventArgs from \"../eventArgs/transferUploadCompletedEventArgs.js\";\nimport type ReadonlyTransferUploadStateFile from \"./readonlyTransferUploadStateFile.js\";\nimport type ReadonlyTransferUploadStateFiles from \"./readonlyTransferUploadStateFiles.js\";\nimport type FileUploadFailedEventArgs from \"../eventArgs/fileUploadFailedEventArgs.js\";\nimport type TransferUploadExportState from \"../export/transferUploadExportState.js\";\nimport type TransferUploadProgressedEventArgs from \"../eventArgs/transferUploadProgressedEventArgs.js\";\nimport type TransferUploadMetadata from '../export/transferUploadMetadata.js';\nimport type FileChunkUploadProgressedEventArgs from '../eventArgs/fileChunkUploadProgressedEventArgs.js';\nimport type { ContinuousChunk, ContinuousChunksCalculatorState } from './continuousChunksCalculator.js';\nimport type FileChunkUploadCompletedPartiallyEventArgs from '../eventArgs/fileChunkUploadCompletedPartiallyEventArgs.js';\nimport type FileChunkUploadCompletedEventArgs from '../eventArgs/fileChunkUploadCompletedEventArgs.js';\n\nexport default class TransferUploadState {\n #status: TransferStatus = TransferStatus.Initialized;\n\n #completedFilesCount = 0;\n #failedFilesCount = 0;\n #files: TransferUploadStateFiles = {};\n #eventsEngine: EventsEngine;\n\n #ratesCalculator?: TransferUploadRatesCalculator;\n #continuousChunkCalculator: ContinuousChunksCalculator;\n\n readonly #currentRatesTimespanInMs: number;\n\n #uploadedBytesCount = 0;\n #failedBytesCount = 0;\n\n #totalBytesCount = 0;\n\n #getRatesAndNotifyUploadProgressedThrottled: ReturnType<typeof throttle<TransferUploadState[`getRatesAndNotifyUploadProgressed`]>>;\n\n get status(): TransferStatus {\n return this.#status;\n }\n\n get completedFilesCount(): number {\n return this.#completedFilesCount;\n }\n\n get failedFilesCount(): number {\n return this.#failedFilesCount;\n }\n\n get uploadedBytesCount(): number {\n return this.#uploadedBytesCount;\n }\n\n get failedBytesCount(): number {\n return this.#failedBytesCount;\n }\n\n get files(): ReadonlyTransferUploadStateFiles {\n return this.#files;\n }\n\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number)\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number, exportedState: TransferUploadExportState)\n constructor(files: readonly FileDetails[], eventsEngine: EventsEngine, currentRatesTimespanInMs: number, progressEventThrottlingInMs: number, exportedState?: TransferUploadExportState) {\n this.#eventsEngine = eventsEngine;\n this.#currentRatesTimespanInMs = currentRatesTimespanInMs;\n\n this.#getRatesAndNotifyUploadProgressedThrottled = throttle(this.getRatesAndNotifyUploadProgressed, progressEventThrottlingInMs);\n\n this.initializeTransferStatus(files);\n\n this.#continuousChunkCalculator = new ContinuousChunksCalculator();\n\n if (exportedState)\n this.recoverFromExportedState(exportedState);\n }\n\n private initializeTransferStatus(filesDetails: readonly FileDetails[]) {\n for (const file of filesDetails) {\n this.#files[file.externalId] = new TransferUploadStateFile(file.externalId, file.fileSizeInBytes, file.fileName);\n\n this.#totalBytesCount += file.fileSizeInBytes;\n }\n }\n\n getChunksForFile(externalId: string | number): readonly Readonly<ContinuousChunk>[] {\n return this.#continuousChunkCalculator.getChunks(externalId);\n }\n\n export(): TransferUploadExportState {\n return {\n continuousChunksCalculatorState: this.#continuousChunkCalculator.export(),\n completedFiles: Object.values(this.#files).filter(file => file.isCompleted).map(file => file.externalId),\n };\n }\n\n recover() {\n this.#status = TransferStatus.Initialized;\n this.#completedFilesCount = 0;\n this.#uploadedBytesCount = 0;\n this.#failedFilesCount = 0;\n this.#failedBytesCount = 0;\n\n for (const [, file] of Object.entries(this.#files)) {\n file.isBeingUploaded = false;\n file.runningChunksCount = 0;\n file.isFailed = false;\n file.failedReason = null;\n file.failedBytesCount = 0;\n\n if (file.isCompleted)\n this.#completedFilesCount += 1;\n\n // A file can have all its chunks recorded and still miss the live isUploadCompleted transition (e.g. a\n // full chunk recorded through the partially-completed path on pause), so the flag is recomputed from\n // the chunks the same way recoverFromExportedState does - such a file has to be acked on the next run.\n file.isUploadCompleted = this.hasAllChunksUploaded(file);\n file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);\n\n this.#uploadedBytesCount += file.uploadedBytesCount;\n }\n }\n\n private hasAllChunksUploaded(file: TransferUploadStateFile): boolean {\n const fileChunks = this.#continuousChunkCalculator.getChunks(file.externalId);\n\n return fileChunks.length === 1 && fileChunks[0]!.startPosition === 0 && fileChunks[0]!.sizeInBytes === file.fileSizeInBytes;\n }\n\n private recoverFromExportedState(exportedState: TransferUploadExportState | ContinuousChunksCalculatorState) {\n // Remove this variable and the legacy recovery logic after all our clients are on desktop version >= 4.22\n const isLegacyModeTransfer = Array.isArray(exportedState);\n\n const continuousChunksState = isLegacyModeTransfer ? exportedState : exportedState.continuousChunksCalculatorState;\n const completedFiles = isLegacyModeTransfer ? undefined : new Set(exportedState.completedFiles);\n\n this.#continuousChunkCalculator.recover(continuousChunksState);\n\n for (const [, file] of Object.entries(this.#files)) {\n const isUploadCompleted = this.hasAllChunksUploaded(file);\n\n file.isUploadCompleted = isUploadCompleted;\n file.isCompleted = isLegacyModeTransfer ? isUploadCompleted : completedFiles!.has(file.externalId);\n file.uploadedBytesCount = this.#continuousChunkCalculator.getChunksUploadedBytesCount(file.externalId);\n\n if (file.isCompleted)\n this.#completedFilesCount += 1;\n\n this.#uploadedBytesCount += file.uploadedBytesCount;\n }\n }\n\n getFile(externalFileId: string | number): ReadonlyTransferUploadStateFile {\n return this.getFileInternal(externalFileId);\n }\n\n private getFileInternal(externalFileId: string | number): TransferUploadStateFile {\n const file = this.#files[externalFileId];\n\n if (!file)\n throw new TransferUploadError(`File with id = ${externalFileId} doesn't exist`);\n\n return file;\n }\n\n transferRun() {\n this.#status = TransferStatus.Running;\n\n this.#ratesCalculator = undefined;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferRun);\n }\n\n transferPauseRequested() {\n this.#status = TransferStatus.Pausing;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferPauseRequested);\n }\n\n transferPaused() {\n this.#status = TransferStatus.Paused;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.flush();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferPaused);\n }\n\n transferAbortRequested() {\n this.#status = TransferStatus.Aborting;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferAbortRequested);\n }\n\n transferAborted() {\n this.#status = TransferStatus.Aborted;\n\n for (const [, file] of Object.entries(this.#files)) {\n if (file.isBeingUploaded) {\n file.isBeingUploaded = false;\n file.isFailed = true;\n\n if (!file.failedReason)\n file.failedReason = `Aborted`;\n }\n }\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferAborted);\n }\n\n transferCancelRequested() {\n this.#status = TransferStatus.Canceling;\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCancelRequested);\n }\n\n transferCanceled() {\n this.#status = TransferStatus.Canceled;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCanceled);\n }\n\n transferCompleted(transferMetadata: TransferUploadMetadata, transferDownloadUrl: string, confirmationUrl: string | undefined, recipientTrackingLinks?: TransferUploadCompletedEventArgs[`recipientTrackingLinks`]) {\n this.#status = TransferStatus.Completed;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.flush();\n\n const eventArgs: TransferUploadCompletedEventArgs = {\n transferId: transferMetadata.transferId,\n transferKey: transferMetadata.transferKey,\n transferDownloadUrl,\n confirmationUrl,\n fileServerUrl: transferMetadata.transferFileServerUrl,\n region: transferMetadata.transferRegion,\n recipientTrackingLinks,\n };\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferCompleted, eventArgs);\n }\n\n transferFailed() {\n this.#status = TransferStatus.Failed;\n\n this.#getRatesAndNotifyUploadProgressedThrottled.cancel();\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferFailed);\n }\n\n fileUploadStarted(file: TransferUploadStateFile, uploadItemId: string | undefined) {\n file.isBeingUploaded = true;\n\n const eventArgs: FileUploadEventArgs = { fileStatus: file, uploadItemId };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadStarted, eventArgs);\n }\n\n fileUploadCompleted(file: TransferUploadStateFile, uploadItemId: string | undefined) {\n file.isBeingUploaded = false;\n file.isUploadCompleted = true;\n\n const eventArgs: FileUploadEventArgs = { fileStatus: file, uploadItemId };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadCompleted, eventArgs);\n }\n\n fileCompleted(externalFileId: string | number, uploadItemId: string | undefined) {\n const file = this.getFileInternal(externalFileId);\n\n file.isCompleted = true;\n\n this.#completedFilesCount += 1;\n\n this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);\n\n const eventArgs: FileUploadEventArgs = { fileStatus: file, uploadItemId };\n this.#eventsEngine.emit(TransferUploadEvent.FileCompleted, eventArgs);\n }\n\n fileAckFailed(externalFileId: string | number, uploadItemId: string, reason: string, error: Error) {\n const file = this.getFileInternal(externalFileId);\n\n const eventArgs: FileAckFailedEventArgs = { fileStatus: file, uploadItemId, reason, error };\n this.#eventsEngine.emit(TransferUploadEvent.FileAckFailed, eventArgs);\n }\n\n fileUploadFailed(file: TransferUploadStateFile, uploadItemId: string | undefined) {\n file.isBeingUploaded = false;\n file.isFailed = true;\n\n this.#failedFilesCount += 1;\n\n const eventArgs: FileUploadFailedEventArgs = { fileStatus: file, uploadItemId, reason: file.failedReason };\n this.#eventsEngine.emit(TransferUploadEvent.FileUploadFailed, eventArgs);\n }\n\n chunkUploadStarted(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number) {\n const file = this.getFileInternal(externalFileId);\n\n if (!this.#ratesCalculator)\n this.#ratesCalculator = new TransferUploadRatesCalculator(this.#totalBytesCount, this.#currentRatesTimespanInMs);\n\n if (!file.isBeingUploaded)\n this.fileUploadStarted(file, uploadItemId);\n\n file.runningChunksCount += 1;\n\n const eventArgs: FileChunkUploadEventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadStarted, eventArgs);\n }\n\n chunkUploadProgressed(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number, apiEventArgs: ChunkProgressEvent): void {\n const file = this.getFileInternal(externalFileId);\n\n file.uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;\n this.#uploadedBytesCount += apiEventArgs.transferredBytesSinceLastEvent;\n\n this.#ratesCalculator!.addNewProgressEvent(apiEventArgs.transferredBytesSinceLastEvent);\n\n const eventArgs: FileChunkUploadProgressedEventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes, transferredBytesSinceLastEvent: apiEventArgs.transferredBytesSinceLastEvent };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadProgressed, eventArgs);\n\n this.#getRatesAndNotifyUploadProgressedThrottled();\n }\n\n private getRatesAndNotifyUploadProgressed() {\n const progressStats = this.#ratesCalculator!.getRates(this.#uploadedBytesCount);\n\n const tranferEventArgs: TransferUploadProgressedEventArgs = {\n uploadedBytesTotalCount: this.#uploadedBytesCount,\n progressInPercentage: (this.#uploadedBytesCount * 100) / this.#totalBytesCount,\n remainingSeconds: progressStats.remainingSeconds,\n averageSpeedInBytesPerSecond: progressStats.averageSpeedInBytesPerSec,\n currentSpeedInBytesPerSecond: progressStats.currentSpeedInBytesPerSec,\n };\n\n this.#eventsEngine.emit(TransferUploadEvent.TransferProgressed, tranferEventArgs);\n }\n\n chunkUploadCompleted(externalFileId: string | number, uploadItemId: string | undefined, startPosition: number, sizeInBytes: number) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes });\n\n this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);\n\n const eventArgs: FileChunkUploadCompletedEventArgs = { fileStatus: file, uploadItemId, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompleted, eventArgs);\n\n if (file.runningChunksCount > 0)\n return;\n\n if (file.uploadedBytesCount === file.fileSizeInBytes)\n this.fileUploadCompleted(file, uploadItemId);\n else if (file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file, uploadItemId);\n }\n\n chunkUploadCompletedPartially(externalFileId: string | number, uploadItemId: string | undefined, startPosition: number, sizeInBytes: number, uploadedBytesCount: number, isPauseRequested: boolean) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n const failedBytes = sizeInBytes - uploadedBytesCount;\n\n file.failedBytesCount += failedBytes;\n this.#failedBytesCount += failedBytes;\n\n if (!file.failedReason)\n file.failedReason = isPauseRequested ? `Pause requested` : `Chunk upload completed partially`;\n\n if (uploadedBytesCount > 0)\n this.#continuousChunkCalculator.addNewChunk(externalFileId, { startPosition, sizeInBytes: uploadedBytesCount });\n\n this.#eventsEngine.emit(TransferUploadEvent.RecreateDataUpdated);\n\n const eventArgs: FileChunkUploadCompletedPartiallyEventArgs = { fileStatus: file, uploadItemId, chunkStartPosition: startPosition, chunkSizeInBytes: sizeInBytes, uploadedBytesCount, isPauseRequested };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadCompletedPartially, eventArgs);\n\n if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file, uploadItemId);\n }\n\n chunkUploadFailed(externalFileId: string | number, uploadItemId: string | undefined, chunkStartPosition: number, chunkSizeInBytes: number, uploadedBytesCount: number, failedReason: string, error: Error) {\n const file = this.getFileInternal(externalFileId);\n\n file.runningChunksCount -= 1;\n\n const failedBytes = chunkSizeInBytes;\n\n file.uploadedBytesCount -= uploadedBytesCount;\n file.failedBytesCount += failedBytes;\n\n this.#uploadedBytesCount -= uploadedBytesCount;\n this.#failedBytesCount += failedBytes;\n\n if (!file.failedReason)\n file.failedReason = failedReason;\n\n const eventArgs: FileChunkUploadFailedEventArgs = { fileStatus: file, uploadItemId, chunkStartPosition, chunkSizeInBytes, reason: failedReason, error };\n this.#eventsEngine.emit(TransferUploadEvent.FileChunkUploadFailed, eventArgs);\n\n if (file.runningChunksCount === 0 && file.uploadedBytesCount + file.failedBytesCount === file.fileSizeInBytes)\n this.fileUploadFailed(file, uploadItemId);\n }\n}"]}
@@ -4,6 +4,7 @@ export default class TransferUploadStateFile {
4
4
  readonly fileName: string;
5
5
  isBeingUploaded: boolean;
6
6
  runningChunksCount: number;
7
+ isUploadCompleted: boolean;
7
8
  isCompleted: boolean;
8
9
  isFailed: boolean;
9
10
  failedReason: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadStateFile.d.ts","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadStateFile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,uBAAuB;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,eAAe,UAAS;IACxB,kBAAkB,SAAK;IACvB,WAAW,UAAS;IACpB,QAAQ,UAAS;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,gBAAgB,SAAK;IACrB,kBAAkB,SAAK;gBAEX,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAKrF"}
1
+ {"version":3,"file":"transferUploadStateFile.d.ts","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadStateFile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,uBAAuB;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,eAAe,UAAS;IACxB,kBAAkB,SAAK;IACvB,iBAAiB,UAAS;IAC1B,WAAW,UAAS;IACpB,QAAQ,UAAS;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,gBAAgB,SAAK;IACrB,kBAAkB,SAAK;gBAEX,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAKrF"}
@@ -4,6 +4,7 @@ export default class TransferUploadStateFile {
4
4
  fileName;
5
5
  isBeingUploaded = false;
6
6
  runningChunksCount = 0;
7
+ isUploadCompleted = false;
7
8
  isCompleted = false;
8
9
  isFailed = false;
9
10
  failedReason = null;
@@ -1 +1 @@
1
- {"version":3,"file":"transferUploadStateFile.js","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadStateFile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC/B,UAAU,CAAkB;IAC5B,eAAe,CAAS;IACxB,QAAQ,CAAS;IAC1B,eAAe,GAAG,KAAK,CAAC;IACxB,kBAAkB,GAAG,CAAC,CAAC;IACvB,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,GAAG,KAAK,CAAC;IACjB,YAAY,GAAkB,IAAI,CAAC;IACnC,gBAAgB,GAAG,CAAC,CAAC;IACrB,kBAAkB,GAAG,CAAC,CAAC;IAEvB,YAAY,UAA2B,EAAE,eAAuB,EAAE,QAAgB;QAC9E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["export default class TransferUploadStateFile {\n readonly externalId: string | number;\n readonly fileSizeInBytes: number;\n readonly fileName: string;\n isBeingUploaded = false;\n runningChunksCount = 0;\n isCompleted = false;\n isFailed = false;\n failedReason: string | null = null;\n failedBytesCount = 0;\n uploadedBytesCount = 0;\n\n constructor(externalId: string | number, fileSizeInBytes: number, fileName: string) {\n this.externalId = externalId;\n this.fileSizeInBytes = fileSizeInBytes;\n this.fileName = fileName;\n }\n}\n"]}
1
+ {"version":3,"file":"transferUploadStateFile.js","sourceRoot":"","sources":["../../../../src/uploader/state/transferUploadStateFile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC/B,UAAU,CAAkB;IAC5B,eAAe,CAAS;IACxB,QAAQ,CAAS;IAC1B,eAAe,GAAG,KAAK,CAAC;IACxB,kBAAkB,GAAG,CAAC,CAAC;IACvB,iBAAiB,GAAG,KAAK,CAAC;IAC1B,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,GAAG,KAAK,CAAC;IACjB,YAAY,GAAkB,IAAI,CAAC;IACnC,gBAAgB,GAAG,CAAC,CAAC;IACrB,kBAAkB,GAAG,CAAC,CAAC;IAEvB,YAAY,UAA2B,EAAE,eAAuB,EAAE,QAAgB;QAC9E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["export default class TransferUploadStateFile {\n readonly externalId: string | number;\n readonly fileSizeInBytes: number;\n readonly fileName: string;\n isBeingUploaded = false;\n runningChunksCount = 0;\n isUploadCompleted = false;\n isCompleted = false;\n isFailed = false;\n failedReason: string | null = null;\n failedBytesCount = 0;\n uploadedBytesCount = 0;\n\n constructor(externalId: string | number, fileSizeInBytes: number, fileName: string) {\n this.externalId = externalId;\n this.fileSizeInBytes = fileSizeInBytes;\n this.fileName = fileName;\n }\n}\n"]}