@milaboratories/pl-drivers 1.11.59 → 1.11.60

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 (330) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/clients/constructors.cjs +28 -28
  3. package/dist/clients/constructors.cjs.map +1 -1
  4. package/dist/clients/constructors.d.ts +17 -13
  5. package/dist/clients/constructors.js +28 -26
  6. package/dist/clients/constructors.js.map +1 -1
  7. package/dist/clients/crc32c.cjs +8 -13
  8. package/dist/clients/crc32c.cjs.map +1 -1
  9. package/dist/clients/crc32c.js +8 -12
  10. package/dist/clients/crc32c.js.map +1 -1
  11. package/dist/clients/download.cjs +119 -160
  12. package/dist/clients/download.cjs.map +1 -1
  13. package/dist/clients/download.d.ts +45 -41
  14. package/dist/clients/download.js +115 -137
  15. package/dist/clients/download.js.map +1 -1
  16. package/dist/clients/logs.cjs +78 -82
  17. package/dist/clients/logs.cjs.map +1 -1
  18. package/dist/clients/logs.d.ts +34 -24
  19. package/dist/clients/logs.js +77 -80
  20. package/dist/clients/logs.js.map +1 -1
  21. package/dist/clients/ls_api.cjs +62 -68
  22. package/dist/clients/ls_api.cjs.map +1 -1
  23. package/dist/clients/ls_api.d.ts +15 -11
  24. package/dist/clients/ls_api.js +61 -66
  25. package/dist/clients/ls_api.js.map +1 -1
  26. package/dist/clients/progress.cjs +49 -59
  27. package/dist/clients/progress.cjs.map +1 -1
  28. package/dist/clients/progress.d.ts +27 -20
  29. package/dist/clients/progress.js +48 -57
  30. package/dist/clients/progress.js.map +1 -1
  31. package/dist/clients/upload.cjs +189 -250
  32. package/dist/clients/upload.cjs.map +1 -1
  33. package/dist/clients/upload.d.ts +44 -34
  34. package/dist/clients/upload.js +187 -229
  35. package/dist/clients/upload.js.map +1 -1
  36. package/dist/drivers/download_blob/blob_key.cjs +9 -26
  37. package/dist/drivers/download_blob/blob_key.cjs.map +1 -1
  38. package/dist/drivers/download_blob/blob_key.js +7 -5
  39. package/dist/drivers/download_blob/blob_key.js.map +1 -1
  40. package/dist/drivers/download_blob/download_blob.cjs +395 -478
  41. package/dist/drivers/download_blob/download_blob.cjs.map +1 -1
  42. package/dist/drivers/download_blob/download_blob.d.ts +102 -100
  43. package/dist/drivers/download_blob/download_blob.js +388 -453
  44. package/dist/drivers/download_blob/download_blob.js.map +1 -1
  45. package/dist/drivers/download_blob/download_blob_task.cjs +128 -163
  46. package/dist/drivers/download_blob/download_blob_task.cjs.map +1 -1
  47. package/dist/drivers/download_blob/download_blob_task.js +125 -141
  48. package/dist/drivers/download_blob/download_blob_task.js.map +1 -1
  49. package/dist/drivers/download_blob/sparse_cache/cache.cjs +166 -195
  50. package/dist/drivers/download_blob/sparse_cache/cache.cjs.map +1 -1
  51. package/dist/drivers/download_blob/sparse_cache/cache.js +164 -193
  52. package/dist/drivers/download_blob/sparse_cache/cache.js.map +1 -1
  53. package/dist/drivers/download_blob/sparse_cache/file.cjs +29 -50
  54. package/dist/drivers/download_blob/sparse_cache/file.cjs.map +1 -1
  55. package/dist/drivers/download_blob/sparse_cache/file.js +28 -29
  56. package/dist/drivers/download_blob/sparse_cache/file.js.map +1 -1
  57. package/dist/drivers/download_blob/sparse_cache/ranges.cjs +48 -76
  58. package/dist/drivers/download_blob/sparse_cache/ranges.cjs.map +1 -1
  59. package/dist/drivers/download_blob/sparse_cache/ranges.js +47 -54
  60. package/dist/drivers/download_blob/sparse_cache/ranges.js.map +1 -1
  61. package/dist/drivers/download_blob_url/driver.cjs +125 -165
  62. package/dist/drivers/download_blob_url/driver.cjs.map +1 -1
  63. package/dist/drivers/download_blob_url/driver.d.ts +45 -42
  64. package/dist/drivers/download_blob_url/driver.js +123 -144
  65. package/dist/drivers/download_blob_url/driver.js.map +1 -1
  66. package/dist/drivers/download_blob_url/driver_id.cjs +4 -4
  67. package/dist/drivers/download_blob_url/driver_id.cjs.map +1 -1
  68. package/dist/drivers/download_blob_url/driver_id.js +4 -3
  69. package/dist/drivers/download_blob_url/driver_id.js.map +1 -1
  70. package/dist/drivers/download_blob_url/snapshot.cjs +7 -11
  71. package/dist/drivers/download_blob_url/snapshot.cjs.map +1 -1
  72. package/dist/drivers/download_blob_url/snapshot.d.ts +10 -5
  73. package/dist/drivers/download_blob_url/snapshot.js +5 -8
  74. package/dist/drivers/download_blob_url/snapshot.js.map +1 -1
  75. package/dist/drivers/download_blob_url/task.cjs +147 -194
  76. package/dist/drivers/download_blob_url/task.cjs.map +1 -1
  77. package/dist/drivers/download_blob_url/task.d.ts +55 -57
  78. package/dist/drivers/download_blob_url/task.js +140 -170
  79. package/dist/drivers/download_blob_url/task.js.map +1 -1
  80. package/dist/drivers/download_url/driver.cjs +109 -146
  81. package/dist/drivers/download_url/driver.cjs.map +1 -1
  82. package/dist/drivers/download_url/driver.d.ts +59 -57
  83. package/dist/drivers/download_url/driver.js +107 -125
  84. package/dist/drivers/download_url/driver.js.map +1 -1
  85. package/dist/drivers/download_url/task.cjs +104 -137
  86. package/dist/drivers/download_url/task.cjs.map +1 -1
  87. package/dist/drivers/download_url/task.d.ts +33 -37
  88. package/dist/drivers/download_url/task.js +99 -113
  89. package/dist/drivers/download_url/task.js.map +1 -1
  90. package/dist/drivers/helpers/download_local_handle.cjs +13 -14
  91. package/dist/drivers/helpers/download_local_handle.cjs.map +1 -1
  92. package/dist/drivers/helpers/download_local_handle.js +13 -13
  93. package/dist/drivers/helpers/download_local_handle.js.map +1 -1
  94. package/dist/drivers/helpers/download_remote_handle.cjs +23 -24
  95. package/dist/drivers/helpers/download_remote_handle.cjs.map +1 -1
  96. package/dist/drivers/helpers/download_remote_handle.js +22 -22
  97. package/dist/drivers/helpers/download_remote_handle.js.map +1 -1
  98. package/dist/drivers/helpers/files_cache.cjs +53 -64
  99. package/dist/drivers/helpers/files_cache.cjs.map +1 -1
  100. package/dist/drivers/helpers/files_cache.js +52 -62
  101. package/dist/drivers/helpers/files_cache.js.map +1 -1
  102. package/dist/drivers/helpers/helpers.cjs +24 -28
  103. package/dist/drivers/helpers/helpers.cjs.map +1 -1
  104. package/dist/drivers/helpers/helpers.d.ts +10 -7
  105. package/dist/drivers/helpers/helpers.js +24 -27
  106. package/dist/drivers/helpers/helpers.js.map +1 -1
  107. package/dist/drivers/helpers/logs_handle.cjs +24 -33
  108. package/dist/drivers/helpers/logs_handle.cjs.map +1 -1
  109. package/dist/drivers/helpers/logs_handle.js +24 -29
  110. package/dist/drivers/helpers/logs_handle.js.map +1 -1
  111. package/dist/drivers/helpers/ls_remote_import_handle.cjs +20 -20
  112. package/dist/drivers/helpers/ls_remote_import_handle.cjs.map +1 -1
  113. package/dist/drivers/helpers/ls_remote_import_handle.js +20 -18
  114. package/dist/drivers/helpers/ls_remote_import_handle.js.map +1 -1
  115. package/dist/drivers/helpers/ls_storage_entry.cjs +36 -40
  116. package/dist/drivers/helpers/ls_storage_entry.cjs.map +1 -1
  117. package/dist/drivers/helpers/ls_storage_entry.js +36 -37
  118. package/dist/drivers/helpers/ls_storage_entry.js.map +1 -1
  119. package/dist/drivers/helpers/polling_ops.d.ts +6 -5
  120. package/dist/drivers/helpers/read_file.cjs +34 -57
  121. package/dist/drivers/helpers/read_file.cjs.map +1 -1
  122. package/dist/drivers/helpers/read_file.js +30 -34
  123. package/dist/drivers/helpers/read_file.js.map +1 -1
  124. package/dist/drivers/logs.cjs +94 -112
  125. package/dist/drivers/logs.cjs.map +1 -1
  126. package/dist/drivers/logs.d.ts +35 -32
  127. package/dist/drivers/logs.js +93 -110
  128. package/dist/drivers/logs.js.map +1 -1
  129. package/dist/drivers/logs_stream.cjs +210 -242
  130. package/dist/drivers/logs_stream.cjs.map +1 -1
  131. package/dist/drivers/logs_stream.d.ts +55 -53
  132. package/dist/drivers/logs_stream.js +209 -240
  133. package/dist/drivers/logs_stream.js.map +1 -1
  134. package/dist/drivers/ls.cjs +151 -238
  135. package/dist/drivers/ls.cjs.map +1 -1
  136. package/dist/drivers/ls.d.ts +53 -49
  137. package/dist/drivers/ls.js +148 -216
  138. package/dist/drivers/ls.js.map +1 -1
  139. package/dist/drivers/types.cjs +25 -53
  140. package/dist/drivers/types.cjs.map +1 -1
  141. package/dist/drivers/types.d.ts +91 -106
  142. package/dist/drivers/types.js +23 -50
  143. package/dist/drivers/types.js.map +1 -1
  144. package/dist/drivers/upload.cjs +127 -153
  145. package/dist/drivers/upload.cjs.map +1 -1
  146. package/dist/drivers/upload.d.ts +52 -50
  147. package/dist/drivers/upload.js +126 -151
  148. package/dist/drivers/upload.js.map +1 -1
  149. package/dist/drivers/upload_task.cjs +223 -260
  150. package/dist/drivers/upload_task.cjs.map +1 -1
  151. package/dist/drivers/upload_task.d.ts +54 -52
  152. package/dist/drivers/upload_task.js +221 -258
  153. package/dist/drivers/upload_task.js.map +1 -1
  154. package/dist/drivers/urls/url.cjs +30 -35
  155. package/dist/drivers/urls/url.cjs.map +1 -1
  156. package/dist/drivers/urls/url.js +28 -33
  157. package/dist/drivers/urls/url.js.map +1 -1
  158. package/dist/drivers/virtual_storages.cjs +36 -48
  159. package/dist/drivers/virtual_storages.cjs.map +1 -1
  160. package/dist/drivers/virtual_storages.d.ts +6 -2
  161. package/dist/drivers/virtual_storages.js +32 -46
  162. package/dist/drivers/virtual_storages.js.map +1 -1
  163. package/dist/helpers/download.cjs +72 -95
  164. package/dist/helpers/download.cjs.map +1 -1
  165. package/dist/helpers/download.d.ts +13 -9
  166. package/dist/helpers/download.js +71 -93
  167. package/dist/helpers/download.js.map +1 -1
  168. package/dist/helpers/download_errors.cjs +28 -27
  169. package/dist/helpers/download_errors.cjs.map +1 -1
  170. package/dist/helpers/download_errors.d.ts +16 -13
  171. package/dist/helpers/download_errors.js +28 -26
  172. package/dist/helpers/download_errors.js.map +1 -1
  173. package/dist/helpers/validate.cjs +8 -7
  174. package/dist/helpers/validate.cjs.map +1 -1
  175. package/dist/helpers/validate.d.ts +4 -1
  176. package/dist/helpers/validate.js +6 -5
  177. package/dist/helpers/validate.js.map +1 -1
  178. package/dist/index.cjs +75 -79
  179. package/dist/index.d.ts +22 -22
  180. package/dist/index.js +22 -21
  181. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs +238 -249
  182. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs.map +1 -1
  183. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs +27 -27
  184. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs.map +1 -1
  185. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +25 -23
  186. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js +26 -25
  187. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js.map +1 -1
  188. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +51 -87
  189. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js +238 -245
  190. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js.map +1 -1
  191. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs +295 -289
  192. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs.map +1 -1
  193. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs +30 -30
  194. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs.map +1 -1
  195. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js +29 -28
  196. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js.map +1 -1
  197. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +86 -150
  198. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js +295 -285
  199. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js.map +1 -1
  200. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs +385 -393
  201. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs.map +1 -1
  202. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs +34 -34
  203. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs.map +1 -1
  204. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +33 -34
  205. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js +33 -32
  206. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js.map +1 -1
  207. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +78 -129
  208. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js +385 -387
  209. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js.map +1 -1
  210. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs +570 -468
  211. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs.map +1 -1
  212. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs +82 -82
  213. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs.map +1 -1
  214. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +109 -112
  215. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js +81 -80
  216. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js.map +1 -1
  217. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +243 -264
  218. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js +569 -460
  219. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js.map +1 -1
  220. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs +751 -729
  221. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs.map +1 -1
  222. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs +67 -67
  223. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs.map +1 -1
  224. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js +66 -65
  225. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js.map +1 -1
  226. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts +15 -381
  227. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js +749 -718
  228. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js.map +1 -1
  229. package/dist/proto-grpc/google/protobuf/duration.cjs +92 -100
  230. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
  231. package/dist/proto-grpc/google/protobuf/duration.d.ts +38 -43
  232. package/dist/proto-grpc/google/protobuf/duration.js +91 -98
  233. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
  234. package/dist/proto-grpc/google/protobuf/timestamp.cjs +117 -128
  235. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
  236. package/dist/proto-grpc/google/protobuf/timestamp.d.ts +50 -55
  237. package/dist/proto-grpc/google/protobuf/timestamp.js +116 -126
  238. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
  239. package/dist/proto-rest/downloadapi.d.ts +85 -91
  240. package/dist/proto-rest/index.d.ts +11 -16
  241. package/dist/proto-rest/progressapi.d.ts +130 -140
  242. package/dist/proto-rest/streamingapi.d.ts +413 -434
  243. package/package.json +12 -12
  244. package/dist/clients/constructors.d.ts.map +0 -1
  245. package/dist/clients/crc32c.d.ts +0 -2
  246. package/dist/clients/crc32c.d.ts.map +0 -1
  247. package/dist/clients/download.d.ts.map +0 -1
  248. package/dist/clients/logs.d.ts.map +0 -1
  249. package/dist/clients/ls_api.d.ts.map +0 -1
  250. package/dist/clients/progress.d.ts.map +0 -1
  251. package/dist/clients/upload.d.ts.map +0 -1
  252. package/dist/drivers/download_blob/blob_key.d.ts +0 -5
  253. package/dist/drivers/download_blob/blob_key.d.ts.map +0 -1
  254. package/dist/drivers/download_blob/download_blob.d.ts.map +0 -1
  255. package/dist/drivers/download_blob/download_blob_task.d.ts +0 -56
  256. package/dist/drivers/download_blob/download_blob_task.d.ts.map +0 -1
  257. package/dist/drivers/download_blob/sparse_cache/cache.d.ts +0 -82
  258. package/dist/drivers/download_blob/sparse_cache/cache.d.ts.map +0 -1
  259. package/dist/drivers/download_blob/sparse_cache/file.d.ts +0 -8
  260. package/dist/drivers/download_blob/sparse_cache/file.d.ts.map +0 -1
  261. package/dist/drivers/download_blob/sparse_cache/ranges.d.ts +0 -46
  262. package/dist/drivers/download_blob/sparse_cache/ranges.d.ts.map +0 -1
  263. package/dist/drivers/download_blob_url/driver.d.ts.map +0 -1
  264. package/dist/drivers/download_blob_url/driver_id.d.ts +0 -6
  265. package/dist/drivers/download_blob_url/driver_id.d.ts.map +0 -1
  266. package/dist/drivers/download_blob_url/snapshot.d.ts.map +0 -1
  267. package/dist/drivers/download_blob_url/task.d.ts.map +0 -1
  268. package/dist/drivers/download_url/driver.d.ts.map +0 -1
  269. package/dist/drivers/download_url/task.d.ts.map +0 -1
  270. package/dist/drivers/helpers/download_local_handle.d.ts +0 -11
  271. package/dist/drivers/helpers/download_local_handle.d.ts.map +0 -1
  272. package/dist/drivers/helpers/download_remote_handle.d.ts +0 -13
  273. package/dist/drivers/helpers/download_remote_handle.d.ts.map +0 -1
  274. package/dist/drivers/helpers/files_cache.d.ts +0 -29
  275. package/dist/drivers/helpers/files_cache.d.ts.map +0 -1
  276. package/dist/drivers/helpers/helpers.d.ts.map +0 -1
  277. package/dist/drivers/helpers/logs_handle.d.ts +0 -15
  278. package/dist/drivers/helpers/logs_handle.d.ts.map +0 -1
  279. package/dist/drivers/helpers/ls_remote_import_handle.d.ts +0 -8
  280. package/dist/drivers/helpers/ls_remote_import_handle.d.ts.map +0 -1
  281. package/dist/drivers/helpers/ls_storage_entry.d.ts +0 -23
  282. package/dist/drivers/helpers/ls_storage_entry.d.ts.map +0 -1
  283. package/dist/drivers/helpers/polling_ops.d.ts.map +0 -1
  284. package/dist/drivers/helpers/read_file.d.ts +0 -12
  285. package/dist/drivers/helpers/read_file.d.ts.map +0 -1
  286. package/dist/drivers/helpers/test_helpers.d.ts +0 -2
  287. package/dist/drivers/helpers/test_helpers.d.ts.map +0 -1
  288. package/dist/drivers/logs.d.ts.map +0 -1
  289. package/dist/drivers/logs_stream.d.ts.map +0 -1
  290. package/dist/drivers/ls.d.ts.map +0 -1
  291. package/dist/drivers/types.d.ts.map +0 -1
  292. package/dist/drivers/upload.d.ts.map +0 -1
  293. package/dist/drivers/upload_task.d.ts.map +0 -1
  294. package/dist/drivers/urls/url.d.ts +0 -13
  295. package/dist/drivers/urls/url.d.ts.map +0 -1
  296. package/dist/drivers/virtual_storages.d.ts.map +0 -1
  297. package/dist/helpers/download.d.ts.map +0 -1
  298. package/dist/helpers/download_errors.d.ts.map +0 -1
  299. package/dist/helpers/validate.d.ts.map +0 -1
  300. package/dist/index.cjs.map +0 -1
  301. package/dist/index.d.ts.map +0 -1
  302. package/dist/index.js.map +0 -1
  303. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +0 -1
  304. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +0 -1
  305. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +0 -46
  306. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +0 -1
  307. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +0 -1
  308. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +0 -1
  309. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +0 -1
  310. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +0 -1
  311. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +0 -1
  312. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts +0 -108
  313. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +0 -1
  314. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +0 -1
  315. package/dist/proto-grpc/google/api/http.d.ts +0 -460
  316. package/dist/proto-grpc/google/api/http.d.ts.map +0 -1
  317. package/dist/proto-grpc/google/protobuf/descriptor.d.ts +0 -2340
  318. package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +0 -1
  319. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +0 -1
  320. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +0 -1
  321. package/dist/proto-rest/downloadapi.d.ts.map +0 -1
  322. package/dist/proto-rest/index.d.ts.map +0 -1
  323. package/dist/proto-rest/lsapi.d.ts +0 -148
  324. package/dist/proto-rest/lsapi.d.ts.map +0 -1
  325. package/dist/proto-rest/progressapi.d.ts.map +0 -1
  326. package/dist/proto-rest/streamingapi.d.ts.map +0 -1
  327. package/dist/proto-rest/uploadapi.d.ts +0 -355
  328. package/dist/proto-rest/uploadapi.d.ts.map +0 -1
  329. package/dist/test_env.d.ts +0 -6
  330. package/dist/test_env.d.ts.map +0 -1
@@ -1,488 +1,405 @@
1
- 'use strict';
2
-
3
- var computable = require('@milaboratories/computable');
4
- var plClient = require('@milaboratories/pl-client');
5
- var plModelCommon = require('@milaboratories/pl-model-common');
6
- var plTree = require('@milaboratories/pl-tree');
7
- var tsHelpers = require('@milaboratories/ts-helpers');
8
- var Denque = require('denque');
9
- var fs = require('node:fs');
10
- var node_crypto = require('node:crypto');
11
- var fsp = require('node:fs/promises');
12
- var os = require('node:os');
13
- var path = require('node:path');
14
- var readline = require('node:readline/promises');
15
- var consumers = require('node:stream/consumers');
16
- var read_file = require('../helpers/read_file.cjs');
17
- var download_local_handle = require('../helpers/download_local_handle.cjs');
18
- var download_remote_handle = require('../helpers/download_remote_handle.cjs');
19
- var helpers = require('../helpers/helpers.cjs');
20
- var logs_handle = require('../helpers/logs_handle.cjs');
21
- var types = require('../types.cjs');
22
- var blob_key = require('./blob_key.cjs');
23
- var download_blob_task = require('./download_blob_task.cjs');
24
- var files_cache = require('../helpers/files_cache.cjs');
25
- var cache = require('./sparse_cache/cache.cjs');
26
- var download_errors = require('../../helpers/download_errors.cjs');
27
-
28
- function _interopNamespaceDefault(e) {
29
- var n = Object.create(null);
30
- if (e) {
31
- Object.keys(e).forEach(function (k) {
32
- if (k !== 'default') {
33
- var d = Object.getOwnPropertyDescriptor(e, k);
34
- Object.defineProperty(n, k, d.get ? d : {
35
- enumerable: true,
36
- get: function () { return e[k]; }
37
- });
38
- }
39
- });
40
- }
41
- n.default = e;
42
- return Object.freeze(n);
43
- }
44
-
45
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
46
- var fsp__namespace = /*#__PURE__*/_interopNamespaceDefault(fsp);
47
- var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
48
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
49
- var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline);
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_download_errors = require('../../helpers/download_errors.cjs');
3
+ const require_read_file = require('../helpers/read_file.cjs');
4
+ const require_download_local_handle = require('../helpers/download_local_handle.cjs');
5
+ const require_types = require('../types.cjs');
6
+ const require_download_remote_handle = require('../helpers/download_remote_handle.cjs');
7
+ const require_helpers = require('../helpers/helpers.cjs');
8
+ const require_logs_handle = require('../helpers/logs_handle.cjs');
9
+ const require_blob_key = require('./blob_key.cjs');
10
+ const require_download_blob_task = require('./download_blob_task.cjs');
11
+ const require_files_cache = require('../helpers/files_cache.cjs');
12
+ const require_cache = require('./sparse_cache/cache.cjs');
13
+ let _milaboratories_pl_client = require("@milaboratories/pl-client");
14
+ let node_fs_promises = require("node:fs/promises");
15
+ node_fs_promises = require_runtime.__toESM(node_fs_promises);
16
+ let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
17
+ let node_path = require("node:path");
18
+ node_path = require_runtime.__toESM(node_path);
19
+ let node_stream_consumers = require("node:stream/consumers");
20
+ let _milaboratories_computable = require("@milaboratories/computable");
21
+ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
22
+ let _milaboratories_pl_tree = require("@milaboratories/pl-tree");
23
+ let denque = require("denque");
24
+ denque = require_runtime.__toESM(denque);
25
+ let fs = require("fs");
26
+ fs = require_runtime.__toESM(fs);
27
+ let node_crypto = require("node:crypto");
28
+ let node_os = require("node:os");
29
+ node_os = require_runtime.__toESM(node_os);
30
+ let node_readline_promises = require("node:readline/promises");
31
+ node_readline_promises = require_runtime.__toESM(node_readline_promises);
50
32
 
33
+ //#region src/drivers/download_blob/download_blob.ts
51
34
  /** DownloadDriver holds a queue of downloading tasks,
52
- * and notifies every watcher when a file were downloaded. */
53
- class DownloadDriver {
54
- logger;
55
- clientDownload;
56
- clientLogs;
57
- rangesCacheDir;
58
- signer;
59
- ops;
60
- /** Represents a unique key to the path of a blob as a map. */
61
- keyToDownload = new Map();
62
- /** Writes and removes files to a hard drive and holds a counter for every
63
- * file that should be kept. */
64
- cache;
65
- rangesCache;
66
- /** Downloads files and writes them to the local dir. */
67
- downloadQueue;
68
- keyToOnDemand = new Map();
69
- idToLastLines = new Map();
70
- idToProgressLog = new Map();
71
- saveDir;
72
- constructor(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops) {
73
- this.logger = logger;
74
- this.clientDownload = clientDownload;
75
- this.clientLogs = clientLogs;
76
- this.rangesCacheDir = rangesCacheDir;
77
- this.signer = signer;
78
- this.ops = ops;
79
- this.cache = new files_cache.FilesCache(this.ops.cacheSoftSizeBytes);
80
- const fsRanges = new cache.SparseCacheFsRanges(this.logger, this.rangesCacheDir);
81
- const fsStorage = new cache.SparseCacheFsFile(this.logger, this.rangesCacheDir);
82
- this.rangesCache = new cache.SparseCache(this.logger, this.ops.rangesCacheMaxSizeBytes, fsRanges, fsStorage);
83
- this.downloadQueue = new tsHelpers.TaskProcessor(this.logger, ops.nConcurrentDownloads);
84
- this.saveDir = path__namespace.resolve(saveDir);
85
- }
86
- static async init(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops) {
87
- const driver = new DownloadDriver(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops);
88
- await driver.rangesCache.reset();
89
- return driver;
90
- }
91
- getDownloadedBlob(res, ctx) {
92
- if (ctx === undefined) {
93
- return computable.Computable.make((ctx) => this.getDownloadedBlob(res, ctx));
94
- }
95
- const rInfo = plTree.treeEntryToResourceInfo(res, ctx);
96
- const callerId = node_crypto.randomUUID();
97
- ctx.addOnDestroy(() => this.releaseBlob(rInfo, callerId));
98
- const result = this.getDownloadedBlobNoCtx(ctx.watcher, rInfo, callerId);
99
- if (result == undefined) {
100
- ctx.markUnstable("download blob is still undefined");
101
- }
102
- return result;
103
- }
104
- getDownloadedBlobNoCtx(w, rInfo, callerId) {
105
- validateDownloadableResourceType("getDownloadedBlob", rInfo.type);
106
- // We don't need to request files with wider limits,
107
- // PFrame's engine does it disk-optimally by itself.
108
- const task = this.getOrSetNewTask(rInfo, callerId);
109
- task.attach(w, callerId);
110
- const result = task.getBlob();
111
- if (!result.done) {
112
- return undefined;
113
- }
114
- if (result.result.ok) {
115
- return result.result.value;
116
- }
117
- throw result.result.error;
118
- }
119
- getOrSetNewTask(rInfo, callerId) {
120
- const key = blob_key.blobKey(rInfo.id);
121
- const inMemoryTask = this.keyToDownload.get(key);
122
- if (inMemoryTask) {
123
- return inMemoryTask;
124
- }
125
- // schedule the blob downloading, then it'll be added to the cache.
126
- const fPath = path__namespace.resolve(this.saveDir, key);
127
- const newTask = new download_blob_task.DownloadBlobTask(this.logger, this.clientDownload, rInfo, download_local_handle.newLocalHandle(fPath, this.signer), fPath);
128
- this.keyToDownload.set(key, newTask);
129
- this.downloadQueue.push({
130
- fn: () => this.downloadBlob(newTask, callerId),
131
- recoverableErrorPredicate: (e) => !download_blob_task.nonRecoverableError(e),
132
- });
133
- return newTask;
134
- }
135
- async downloadBlob(task, callerId) {
136
- await task.download();
137
- const blob = task.getBlob();
138
- if (blob.done && blob.result.ok) {
139
- this.cache.addCache(task, callerId);
140
- }
141
- }
142
- getOnDemandBlob(res, ctx) {
143
- if (ctx === undefined)
144
- return computable.Computable.make((ctx) => this.getOnDemandBlob(res, ctx));
145
- const rInfo = plTree.isPlTreeEntry(res)
146
- ? plTree.makeResourceSnapshot(res, types.OnDemandBlobResourceSnapshot, ctx)
147
- : res;
148
- const callerId = node_crypto.randomUUID();
149
- ctx.addOnDestroy(() => this.releaseOnDemandBlob(rInfo.id, callerId));
150
- // note that the watcher is not needed,
151
- // the handler never changes.
152
- const result = this.getOnDemandBlobNoCtx(rInfo, callerId);
153
- return result;
154
- }
155
- getOnDemandBlobNoCtx(info, callerId) {
156
- validateDownloadableResourceType("getOnDemandBlob", info.type);
157
- let blob = this.keyToOnDemand.get(blob_key.blobKey(info.id));
158
- if (blob === undefined) {
159
- blob = new OnDemandBlobHolder(types.getSize(info), download_remote_handle.newRemoteHandle(info, this.signer));
160
- this.keyToOnDemand.set(blob_key.blobKey(info.id), blob);
161
- }
162
- blob.attach(callerId);
163
- return blob.getHandle();
164
- }
165
- /** Gets a path from a handle. */
166
- getLocalPath(handle) {
167
- const { path } = download_local_handle.parseLocalHandle(handle, this.signer);
168
- return path;
169
- }
170
- async getContent(handle, optionsOrRange) {
171
- let options = {};
172
- if (typeof optionsOrRange === "object" && optionsOrRange !== null) {
173
- if ("range" in optionsOrRange) {
174
- options = optionsOrRange;
175
- }
176
- else {
177
- const range = optionsOrRange;
178
- plModelCommon.validateRangeBytes(range, `getContent`);
179
- options = { range };
180
- }
181
- }
182
- const request = () => this.withContent(handle, {
183
- ...options,
184
- handler: async (content) => {
185
- const chunks = [];
186
- for await (const chunk of content) {
187
- options.signal?.throwIfAborted();
188
- chunks.push(chunk);
189
- }
190
- return Buffer.concat(chunks);
191
- },
192
- });
193
- try {
194
- return await request();
195
- }
196
- catch (error) {
197
- if (download_errors.isOffByOneError(error)) {
198
- return await request();
199
- }
200
- throw error;
201
- }
202
- }
203
- /** Gets a content stream of a blob by a handle and calls handler with it. */
204
- async withContent(handle, options) {
205
- const { range, signal, handler } = options;
206
- if (download_local_handle.isLocalBlobHandle(handle)) {
207
- return await read_file.withFileContent({ path: this.getLocalPath(handle), range, signal, handler });
208
- }
209
- if (download_remote_handle.isRemoteBlobHandle(handle)) {
210
- const result = download_remote_handle.parseRemoteHandle(handle, this.signer);
211
- const key = blob_key.blobKey(result.info.id);
212
- const filePath = await this.rangesCache.get(key, range ?? { from: 0, to: result.size });
213
- signal?.throwIfAborted();
214
- if (filePath)
215
- return await read_file.withFileContent({ path: filePath, range, signal, handler });
216
- return await this.clientDownload.withBlobContent(result.info, { signal }, options, async (content, size) => {
217
- const [handlerStream, cacheStream] = content.tee();
218
- const handlerPromise = handler(handlerStream, size);
219
- consumers.buffer(cacheStream)
220
- .then((data) => this.rangesCache.set(key, range ?? { from: 0, to: result.size }, data))
221
- .catch(() => {
222
- // Ignore cache errors - they shouldn't affect the main handler result
223
- // This prevents unhandled promise rejections when the stream fails
224
- });
225
- return await handlerPromise;
226
- });
227
- }
228
- throw new Error("Malformed remote handle");
229
- }
230
- /**
231
- * Creates computable that will return blob content once it is downloaded.
232
- * Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
233
- */
234
- getComputableContent(res, range) {
235
- if (range) {
236
- plModelCommon.validateRangeBytes(range, `getComputableContent`);
237
- }
238
- return computable.Computable.make((ctx) => this.getDownloadedBlob(res, ctx), {
239
- postprocessValue: (v) => (v ? this.getContent(v.handle, { range }) : undefined),
240
- }).withStableType();
241
- }
242
- getLastLogs(res, lines, ctx) {
243
- if (ctx == undefined)
244
- return computable.Computable.make((ctx) => this.getLastLogs(res, lines, ctx));
245
- const r = plTree.treeEntryToResourceInfo(res, ctx);
246
- const callerId = node_crypto.randomUUID();
247
- ctx.addOnDestroy(() => this.releaseBlob(r, callerId));
248
- const result = this.getLastLogsNoCtx(ctx.watcher, r, lines, callerId);
249
- if (result == undefined)
250
- ctx.markUnstable("either a file was not downloaded or logs was not read");
251
- return result;
252
- }
253
- getLastLogsNoCtx(w, rInfo, lines, callerId) {
254
- validateDownloadableResourceType("getLastLogs", rInfo.type);
255
- const blob = this.getDownloadedBlobNoCtx(w, rInfo, callerId);
256
- if (blob == undefined)
257
- return undefined;
258
- const { path } = download_local_handle.parseLocalHandle(blob.handle, this.signer);
259
- let logGetter = this.idToLastLines.get(blob_key.blobKey(rInfo.id));
260
- if (logGetter == undefined) {
261
- const newLogGetter = new LastLinesGetter(path, lines);
262
- this.idToLastLines.set(blob_key.blobKey(rInfo.id), newLogGetter);
263
- logGetter = newLogGetter;
264
- }
265
- const result = logGetter.getOrSchedule(w);
266
- if (result.error)
267
- throw result.error;
268
- return result.log;
269
- }
270
- getProgressLog(res, patternToSearch, ctx) {
271
- if (ctx == undefined)
272
- return computable.Computable.make((ctx) => this.getProgressLog(res, patternToSearch, ctx));
273
- const r = plTree.treeEntryToResourceInfo(res, ctx);
274
- const callerId = node_crypto.randomUUID();
275
- ctx.addOnDestroy(() => this.releaseBlob(r, callerId));
276
- const result = this.getProgressLogNoCtx(ctx.watcher, r, patternToSearch, callerId);
277
- if (result === undefined)
278
- ctx.markUnstable("either a file was not downloaded or a progress log was not read");
279
- return result;
280
- }
281
- getProgressLogNoCtx(w, rInfo, patternToSearch, callerId) {
282
- validateDownloadableResourceType("getProgressLog", rInfo.type);
283
- const blob = this.getDownloadedBlobNoCtx(w, rInfo, callerId);
284
- if (blob == undefined)
285
- return undefined;
286
- const { path } = download_local_handle.parseLocalHandle(blob.handle, this.signer);
287
- let logGetter = this.idToProgressLog.get(blob_key.blobKey(rInfo.id));
288
- if (logGetter == undefined) {
289
- const newLogGetter = new LastLinesGetter(path, 1, patternToSearch);
290
- this.idToProgressLog.set(blob_key.blobKey(rInfo.id), newLogGetter);
291
- logGetter = newLogGetter;
292
- }
293
- const result = logGetter.getOrSchedule(w);
294
- if (result.error)
295
- throw result.error;
296
- return result.log;
297
- }
298
- getLogHandle(res, ctx) {
299
- if (ctx == undefined)
300
- return computable.Computable.make((ctx) => this.getLogHandle(res, ctx));
301
- const r = plTree.treeEntryToResourceInfo(res, ctx);
302
- return this.getLogHandleNoCtx(r);
303
- }
304
- getLogHandleNoCtx(rInfo) {
305
- validateDownloadableResourceType("getLogHandle", rInfo.type);
306
- return logs_handle.newLogHandle(false, rInfo);
307
- }
308
- async lastLines(handle, lineCount, offsetBytes, // if 0n, then start from the end.
309
- searchStr) {
310
- const resp = await this.clientLogs.lastLines(logs_handle.getResourceInfoFromLogHandle(handle), lineCount, BigInt(offsetBytes ?? 0), searchStr);
311
- return {
312
- live: false,
313
- shouldUpdateHandle: false,
314
- data: resp.data,
315
- size: Number(resp.size),
316
- newOffset: Number(resp.newOffset),
317
- };
318
- }
319
- async readText(handle, lineCount, offsetBytes, searchStr) {
320
- const resp = await this.clientLogs.readText(logs_handle.getResourceInfoFromLogHandle(handle), lineCount, BigInt(offsetBytes ?? 0), searchStr);
321
- return {
322
- live: false,
323
- shouldUpdateHandle: false,
324
- data: resp.data,
325
- size: Number(resp.size),
326
- newOffset: Number(resp.newOffset),
327
- };
328
- }
329
- async releaseBlob(rInfo, callerId) {
330
- const task = this.keyToDownload.get(blob_key.blobKey(rInfo.id));
331
- if (task == undefined) {
332
- return;
333
- }
334
- if (this.cache.existsFile(blob_key.blobKey(rInfo.id))) {
335
- const toDelete = this.cache.removeFile(blob_key.blobKey(rInfo.id), callerId);
336
- await Promise.all(toDelete.map(async (cachedFile) => {
337
- await fsp__namespace.rm(cachedFile.path);
338
- this.cache.removeCache(cachedFile);
339
- this.removeTask(tsHelpers.mapGet(this.keyToDownload, blob_key.pathToKey(cachedFile.path)), `the task ${plClient.stringifyWithResourceId(cachedFile)} was removed` +
340
- `from cache along with ${plClient.stringifyWithResourceId(toDelete.map((d) => d.path))}`);
341
- }));
342
- }
343
- else {
344
- // The task is still in a downloading queue.
345
- const deleted = task.counter.dec(callerId);
346
- if (deleted) {
347
- this.removeTask(task, `the task ${plClient.stringifyWithResourceId(task.info())} was removed from cache`);
348
- }
349
- }
350
- }
351
- removeTask(task, reason) {
352
- task.abort(reason);
353
- task.change.markChanged(`download task for ${task.path} removed: ${reason}`);
354
- this.keyToDownload.delete(blob_key.pathToKey(task.path));
355
- this.idToLastLines.delete(blob_key.blobKey(task.rInfo.id));
356
- this.idToProgressLog.delete(blob_key.blobKey(task.rInfo.id));
357
- }
358
- async releaseOnDemandBlob(blobId, callerId) {
359
- const deleted = this.keyToOnDemand.get(blob_key.blobKey(blobId))?.release(callerId) ?? false;
360
- if (deleted)
361
- this.keyToOnDemand.delete(blob_key.blobKey(blobId));
362
- }
363
- /** Removes all files from a hard drive. */
364
- async releaseAll() {
365
- this.downloadQueue.stop();
366
- this.keyToDownload.forEach((task, key) => {
367
- this.keyToDownload.delete(key);
368
- task.change.markChanged(`task ${plClient.resourceIdToString(task.rInfo.id)} released`);
369
- });
370
- }
371
- async dispose() {
372
- await this.rangesCache.dispose();
373
- }
374
- async [Symbol.asyncDispose]() {
375
- await this.dispose();
376
- }
377
- }
35
+ * and notifies every watcher when a file were downloaded. */
36
+ var DownloadDriver = class DownloadDriver {
37
+ /** Represents a unique key to the path of a blob as a map. */
38
+ keyToDownload = /* @__PURE__ */ new Map();
39
+ /** Writes and removes files to a hard drive and holds a counter for every
40
+ * file that should be kept. */
41
+ cache;
42
+ rangesCache;
43
+ /** Downloads files and writes them to the local dir. */
44
+ downloadQueue;
45
+ keyToOnDemand = /* @__PURE__ */ new Map();
46
+ idToLastLines = /* @__PURE__ */ new Map();
47
+ idToProgressLog = /* @__PURE__ */ new Map();
48
+ saveDir;
49
+ constructor(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops) {
50
+ this.logger = logger;
51
+ this.clientDownload = clientDownload;
52
+ this.clientLogs = clientLogs;
53
+ this.rangesCacheDir = rangesCacheDir;
54
+ this.signer = signer;
55
+ this.ops = ops;
56
+ this.cache = new require_files_cache.FilesCache(this.ops.cacheSoftSizeBytes);
57
+ const fsRanges = new require_cache.SparseCacheFsRanges(this.logger, this.rangesCacheDir);
58
+ const fsStorage = new require_cache.SparseCacheFsFile(this.logger, this.rangesCacheDir);
59
+ this.rangesCache = new require_cache.SparseCache(this.logger, this.ops.rangesCacheMaxSizeBytes, fsRanges, fsStorage);
60
+ this.downloadQueue = new _milaboratories_ts_helpers.TaskProcessor(this.logger, ops.nConcurrentDownloads);
61
+ this.saveDir = node_path.resolve(saveDir);
62
+ }
63
+ static async init(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops) {
64
+ const driver = new DownloadDriver(logger, clientDownload, clientLogs, saveDir, rangesCacheDir, signer, ops);
65
+ await driver.rangesCache.reset();
66
+ return driver;
67
+ }
68
+ getDownloadedBlob(res, ctx) {
69
+ if (ctx === void 0) return _milaboratories_computable.Computable.make((ctx) => this.getDownloadedBlob(res, ctx));
70
+ const rInfo = (0, _milaboratories_pl_tree.treeEntryToResourceInfo)(res, ctx);
71
+ const callerId = (0, node_crypto.randomUUID)();
72
+ ctx.addOnDestroy(() => this.releaseBlob(rInfo, callerId));
73
+ const result = this.getDownloadedBlobNoCtx(ctx.watcher, rInfo, callerId);
74
+ if (result == void 0) ctx.markUnstable("download blob is still undefined");
75
+ return result;
76
+ }
77
+ getDownloadedBlobNoCtx(w, rInfo, callerId) {
78
+ validateDownloadableResourceType("getDownloadedBlob", rInfo.type);
79
+ const task = this.getOrSetNewTask(rInfo, callerId);
80
+ task.attach(w, callerId);
81
+ const result = task.getBlob();
82
+ if (!result.done) return;
83
+ if (result.result.ok) return result.result.value;
84
+ throw result.result.error;
85
+ }
86
+ getOrSetNewTask(rInfo, callerId) {
87
+ const key = require_blob_key.blobKey(rInfo.id);
88
+ const inMemoryTask = this.keyToDownload.get(key);
89
+ if (inMemoryTask) return inMemoryTask;
90
+ const fPath = node_path.resolve(this.saveDir, key);
91
+ const newTask = new require_download_blob_task.DownloadBlobTask(this.logger, this.clientDownload, rInfo, require_download_local_handle.newLocalHandle(fPath, this.signer), fPath);
92
+ this.keyToDownload.set(key, newTask);
93
+ this.downloadQueue.push({
94
+ fn: () => this.downloadBlob(newTask, callerId),
95
+ recoverableErrorPredicate: (e) => !require_download_blob_task.nonRecoverableError(e)
96
+ });
97
+ return newTask;
98
+ }
99
+ async downloadBlob(task, callerId) {
100
+ await task.download();
101
+ const blob = task.getBlob();
102
+ if (blob.done && blob.result.ok) this.cache.addCache(task, callerId);
103
+ }
104
+ getOnDemandBlob(res, ctx) {
105
+ if (ctx === void 0) return _milaboratories_computable.Computable.make((ctx) => this.getOnDemandBlob(res, ctx));
106
+ const rInfo = (0, _milaboratories_pl_tree.isPlTreeEntry)(res) ? (0, _milaboratories_pl_tree.makeResourceSnapshot)(res, require_types.OnDemandBlobResourceSnapshot, ctx) : res;
107
+ const callerId = (0, node_crypto.randomUUID)();
108
+ ctx.addOnDestroy(() => this.releaseOnDemandBlob(rInfo.id, callerId));
109
+ return this.getOnDemandBlobNoCtx(rInfo, callerId);
110
+ }
111
+ getOnDemandBlobNoCtx(info, callerId) {
112
+ validateDownloadableResourceType("getOnDemandBlob", info.type);
113
+ let blob = this.keyToOnDemand.get(require_blob_key.blobKey(info.id));
114
+ if (blob === void 0) {
115
+ blob = new OnDemandBlobHolder(require_types.getSize(info), require_download_remote_handle.newRemoteHandle(info, this.signer));
116
+ this.keyToOnDemand.set(require_blob_key.blobKey(info.id), blob);
117
+ }
118
+ blob.attach(callerId);
119
+ return blob.getHandle();
120
+ }
121
+ /** Gets a path from a handle. */
122
+ getLocalPath(handle) {
123
+ const { path } = require_download_local_handle.parseLocalHandle(handle, this.signer);
124
+ return path;
125
+ }
126
+ async getContent(handle, optionsOrRange) {
127
+ let options = {};
128
+ if (typeof optionsOrRange === "object" && optionsOrRange !== null) if ("range" in optionsOrRange) options = optionsOrRange;
129
+ else {
130
+ const range = optionsOrRange;
131
+ (0, _milaboratories_pl_model_common.validateRangeBytes)(range, `getContent`);
132
+ options = { range };
133
+ }
134
+ const request = () => this.withContent(handle, {
135
+ ...options,
136
+ handler: async (content) => {
137
+ const chunks = [];
138
+ for await (const chunk of content) {
139
+ options.signal?.throwIfAborted();
140
+ chunks.push(chunk);
141
+ }
142
+ return Buffer.concat(chunks);
143
+ }
144
+ });
145
+ try {
146
+ return await request();
147
+ } catch (error) {
148
+ if (require_download_errors.isOffByOneError(error)) return await request();
149
+ throw error;
150
+ }
151
+ }
152
+ /** Gets a content stream of a blob by a handle and calls handler with it. */
153
+ async withContent(handle, options) {
154
+ const { range, signal, handler } = options;
155
+ if (require_download_local_handle.isLocalBlobHandle(handle)) return await require_read_file.withFileContent({
156
+ path: this.getLocalPath(handle),
157
+ range,
158
+ signal,
159
+ handler
160
+ });
161
+ if (require_download_remote_handle.isRemoteBlobHandle(handle)) {
162
+ const result = require_download_remote_handle.parseRemoteHandle(handle, this.signer);
163
+ const key = require_blob_key.blobKey(result.info.id);
164
+ const filePath = await this.rangesCache.get(key, range ?? {
165
+ from: 0,
166
+ to: result.size
167
+ });
168
+ signal?.throwIfAborted();
169
+ if (filePath) return await require_read_file.withFileContent({
170
+ path: filePath,
171
+ range,
172
+ signal,
173
+ handler
174
+ });
175
+ return await this.clientDownload.withBlobContent(result.info, { signal }, options, async (content, size) => {
176
+ const [handlerStream, cacheStream] = content.tee();
177
+ const handlerPromise = handler(handlerStream, size);
178
+ (0, node_stream_consumers.buffer)(cacheStream).then((data) => this.rangesCache.set(key, range ?? {
179
+ from: 0,
180
+ to: result.size
181
+ }, data)).catch(() => {});
182
+ return await handlerPromise;
183
+ });
184
+ }
185
+ throw new Error("Malformed remote handle");
186
+ }
187
+ /**
188
+ * Creates computable that will return blob content once it is downloaded.
189
+ * Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
190
+ */
191
+ getComputableContent(res, range) {
192
+ if (range) (0, _milaboratories_pl_model_common.validateRangeBytes)(range, `getComputableContent`);
193
+ return _milaboratories_computable.Computable.make((ctx) => this.getDownloadedBlob(res, ctx), { postprocessValue: (v) => v ? this.getContent(v.handle, { range }) : void 0 }).withStableType();
194
+ }
195
+ getLastLogs(res, lines, ctx) {
196
+ if (ctx == void 0) return _milaboratories_computable.Computable.make((ctx) => this.getLastLogs(res, lines, ctx));
197
+ const r = (0, _milaboratories_pl_tree.treeEntryToResourceInfo)(res, ctx);
198
+ const callerId = (0, node_crypto.randomUUID)();
199
+ ctx.addOnDestroy(() => this.releaseBlob(r, callerId));
200
+ const result = this.getLastLogsNoCtx(ctx.watcher, r, lines, callerId);
201
+ if (result == void 0) ctx.markUnstable("either a file was not downloaded or logs was not read");
202
+ return result;
203
+ }
204
+ getLastLogsNoCtx(w, rInfo, lines, callerId) {
205
+ validateDownloadableResourceType("getLastLogs", rInfo.type);
206
+ const blob = this.getDownloadedBlobNoCtx(w, rInfo, callerId);
207
+ if (blob == void 0) return void 0;
208
+ const { path } = require_download_local_handle.parseLocalHandle(blob.handle, this.signer);
209
+ let logGetter = this.idToLastLines.get(require_blob_key.blobKey(rInfo.id));
210
+ if (logGetter == void 0) {
211
+ const newLogGetter = new LastLinesGetter(path, lines);
212
+ this.idToLastLines.set(require_blob_key.blobKey(rInfo.id), newLogGetter);
213
+ logGetter = newLogGetter;
214
+ }
215
+ const result = logGetter.getOrSchedule(w);
216
+ if (result.error) throw result.error;
217
+ return result.log;
218
+ }
219
+ getProgressLog(res, patternToSearch, ctx) {
220
+ if (ctx == void 0) return _milaboratories_computable.Computable.make((ctx) => this.getProgressLog(res, patternToSearch, ctx));
221
+ const r = (0, _milaboratories_pl_tree.treeEntryToResourceInfo)(res, ctx);
222
+ const callerId = (0, node_crypto.randomUUID)();
223
+ ctx.addOnDestroy(() => this.releaseBlob(r, callerId));
224
+ const result = this.getProgressLogNoCtx(ctx.watcher, r, patternToSearch, callerId);
225
+ if (result === void 0) ctx.markUnstable("either a file was not downloaded or a progress log was not read");
226
+ return result;
227
+ }
228
+ getProgressLogNoCtx(w, rInfo, patternToSearch, callerId) {
229
+ validateDownloadableResourceType("getProgressLog", rInfo.type);
230
+ const blob = this.getDownloadedBlobNoCtx(w, rInfo, callerId);
231
+ if (blob == void 0) return void 0;
232
+ const { path } = require_download_local_handle.parseLocalHandle(blob.handle, this.signer);
233
+ let logGetter = this.idToProgressLog.get(require_blob_key.blobKey(rInfo.id));
234
+ if (logGetter == void 0) {
235
+ const newLogGetter = new LastLinesGetter(path, 1, patternToSearch);
236
+ this.idToProgressLog.set(require_blob_key.blobKey(rInfo.id), newLogGetter);
237
+ logGetter = newLogGetter;
238
+ }
239
+ const result = logGetter.getOrSchedule(w);
240
+ if (result.error) throw result.error;
241
+ return result.log;
242
+ }
243
+ getLogHandle(res, ctx) {
244
+ if (ctx == void 0) return _milaboratories_computable.Computable.make((ctx) => this.getLogHandle(res, ctx));
245
+ const r = (0, _milaboratories_pl_tree.treeEntryToResourceInfo)(res, ctx);
246
+ return this.getLogHandleNoCtx(r);
247
+ }
248
+ getLogHandleNoCtx(rInfo) {
249
+ validateDownloadableResourceType("getLogHandle", rInfo.type);
250
+ return require_logs_handle.newLogHandle(false, rInfo);
251
+ }
252
+ async lastLines(handle, lineCount, offsetBytes, searchStr) {
253
+ const resp = await this.clientLogs.lastLines(require_logs_handle.getResourceInfoFromLogHandle(handle), lineCount, BigInt(offsetBytes ?? 0), searchStr);
254
+ return {
255
+ live: false,
256
+ shouldUpdateHandle: false,
257
+ data: resp.data,
258
+ size: Number(resp.size),
259
+ newOffset: Number(resp.newOffset)
260
+ };
261
+ }
262
+ async readText(handle, lineCount, offsetBytes, searchStr) {
263
+ const resp = await this.clientLogs.readText(require_logs_handle.getResourceInfoFromLogHandle(handle), lineCount, BigInt(offsetBytes ?? 0), searchStr);
264
+ return {
265
+ live: false,
266
+ shouldUpdateHandle: false,
267
+ data: resp.data,
268
+ size: Number(resp.size),
269
+ newOffset: Number(resp.newOffset)
270
+ };
271
+ }
272
+ async releaseBlob(rInfo, callerId) {
273
+ const task = this.keyToDownload.get(require_blob_key.blobKey(rInfo.id));
274
+ if (task == void 0) return;
275
+ if (this.cache.existsFile(require_blob_key.blobKey(rInfo.id))) {
276
+ const toDelete = this.cache.removeFile(require_blob_key.blobKey(rInfo.id), callerId);
277
+ await Promise.all(toDelete.map(async (cachedFile) => {
278
+ await node_fs_promises.rm(cachedFile.path);
279
+ this.cache.removeCache(cachedFile);
280
+ this.removeTask((0, _milaboratories_ts_helpers.mapGet)(this.keyToDownload, require_blob_key.pathToKey(cachedFile.path)), `the task ${(0, _milaboratories_pl_client.stringifyWithResourceId)(cachedFile)} was removedfrom cache along with ${(0, _milaboratories_pl_client.stringifyWithResourceId)(toDelete.map((d) => d.path))}`);
281
+ }));
282
+ } else if (task.counter.dec(callerId)) this.removeTask(task, `the task ${(0, _milaboratories_pl_client.stringifyWithResourceId)(task.info())} was removed from cache`);
283
+ }
284
+ removeTask(task, reason) {
285
+ task.abort(reason);
286
+ task.change.markChanged(`download task for ${task.path} removed: ${reason}`);
287
+ this.keyToDownload.delete(require_blob_key.pathToKey(task.path));
288
+ this.idToLastLines.delete(require_blob_key.blobKey(task.rInfo.id));
289
+ this.idToProgressLog.delete(require_blob_key.blobKey(task.rInfo.id));
290
+ }
291
+ async releaseOnDemandBlob(blobId, callerId) {
292
+ if (this.keyToOnDemand.get(require_blob_key.blobKey(blobId))?.release(callerId) ?? false) this.keyToOnDemand.delete(require_blob_key.blobKey(blobId));
293
+ }
294
+ /** Removes all files from a hard drive. */
295
+ async releaseAll() {
296
+ this.downloadQueue.stop();
297
+ this.keyToDownload.forEach((task, key) => {
298
+ this.keyToDownload.delete(key);
299
+ task.change.markChanged(`task ${(0, _milaboratories_pl_client.resourceIdToString)(task.rInfo.id)} released`);
300
+ });
301
+ }
302
+ async dispose() {
303
+ await this.rangesCache.dispose();
304
+ }
305
+ async [Symbol.asyncDispose]() {
306
+ await this.dispose();
307
+ }
308
+ };
378
309
  /** Keeps a counter to the on demand handle. */
379
- class OnDemandBlobHolder {
380
- size;
381
- handle;
382
- counter = new tsHelpers.CallersCounter();
383
- constructor(size, handle) {
384
- this.size = size;
385
- this.handle = handle;
386
- }
387
- getHandle() {
388
- return { handle: this.handle, size: this.size };
389
- }
390
- attach(callerId) {
391
- this.counter.inc(callerId);
392
- }
393
- release(callerId) {
394
- return this.counter.dec(callerId);
395
- }
396
- }
397
- class LastLinesGetter {
398
- path;
399
- lines;
400
- patternToSearch;
401
- updater;
402
- log;
403
- change = new computable.ChangeSource();
404
- error = undefined;
405
- constructor(path, lines, patternToSearch) {
406
- this.path = path;
407
- this.lines = lines;
408
- this.patternToSearch = patternToSearch;
409
- this.updater = new helpers.Updater(async () => this.update());
410
- }
411
- getOrSchedule(w) {
412
- this.change.attachWatcher(w);
413
- this.updater.schedule();
414
- return {
415
- log: this.log,
416
- error: this.error,
417
- };
418
- }
419
- async update() {
420
- try {
421
- const newLogs = await getLastLines(this.path, this.lines, this.patternToSearch);
422
- if (this.log != newLogs)
423
- this.change.markChanged(`logs for ${this.path} updated`);
424
- this.log = newLogs;
425
- }
426
- catch (e) {
427
- if (plClient.isNotFoundError(e)) {
428
- // No resource
429
- this.log = "";
430
- this.error = e;
431
- this.change.markChanged(`log update for ${this.path} failed, resource not found`);
432
- return;
433
- }
434
- throw e;
435
- }
436
- }
437
- }
310
+ var OnDemandBlobHolder = class {
311
+ counter = new _milaboratories_ts_helpers.CallersCounter();
312
+ constructor(size, handle) {
313
+ this.size = size;
314
+ this.handle = handle;
315
+ }
316
+ getHandle() {
317
+ return {
318
+ handle: this.handle,
319
+ size: this.size
320
+ };
321
+ }
322
+ attach(callerId) {
323
+ this.counter.inc(callerId);
324
+ }
325
+ release(callerId) {
326
+ return this.counter.dec(callerId);
327
+ }
328
+ };
329
+ var LastLinesGetter = class {
330
+ updater;
331
+ log;
332
+ change = new _milaboratories_computable.ChangeSource();
333
+ error = void 0;
334
+ constructor(path, lines, patternToSearch) {
335
+ this.path = path;
336
+ this.lines = lines;
337
+ this.patternToSearch = patternToSearch;
338
+ this.updater = new require_helpers.Updater(async () => this.update());
339
+ }
340
+ getOrSchedule(w) {
341
+ this.change.attachWatcher(w);
342
+ this.updater.schedule();
343
+ return {
344
+ log: this.log,
345
+ error: this.error
346
+ };
347
+ }
348
+ async update() {
349
+ try {
350
+ const newLogs = await getLastLines(this.path, this.lines, this.patternToSearch);
351
+ if (this.log != newLogs) this.change.markChanged(`logs for ${this.path} updated`);
352
+ this.log = newLogs;
353
+ } catch (e) {
354
+ if ((0, _milaboratories_pl_client.isNotFoundError)(e)) {
355
+ this.log = "";
356
+ this.error = e;
357
+ this.change.markChanged(`log update for ${this.path} failed, resource not found`);
358
+ return;
359
+ }
360
+ throw e;
361
+ }
362
+ }
363
+ };
438
364
  /** Gets last lines from a file by reading the file from the top and keeping
439
- * last N lines in a window queue. */
365
+ * last N lines in a window queue. */
440
366
  async function getLastLines(fPath, nLines, patternToSearch) {
441
- let inStream;
442
- let rl;
443
- try {
444
- inStream = fs__namespace.createReadStream(fPath);
445
- rl = readline__namespace.createInterface({ input: inStream, crlfDelay: Infinity });
446
- const lines = new Denque();
447
- for await (const line of rl) {
448
- if (patternToSearch != undefined && !line.includes(patternToSearch))
449
- continue;
450
- lines.push(line);
451
- if (lines.length > nLines) {
452
- lines.shift();
453
- }
454
- }
455
- // last EOL is for keeping backward compat with platforma implementation.
456
- return lines.toArray().join(os__namespace.EOL) + os__namespace.EOL;
457
- }
458
- finally {
459
- // Cleanup resources in finally block to ensure they're always cleaned up
460
- try {
461
- if (rl) {
462
- rl.close();
463
- }
464
- }
465
- catch (cleanupError) {
466
- console.error("Error closing readline interface:", cleanupError);
467
- }
468
- try {
469
- if (inStream && !inStream.destroyed) {
470
- inStream.destroy();
471
- }
472
- }
473
- catch (cleanupError) {
474
- console.error("Error destroying read stream:", cleanupError);
475
- }
476
- }
367
+ let inStream;
368
+ let rl;
369
+ try {
370
+ inStream = fs.createReadStream(fPath);
371
+ rl = node_readline_promises.createInterface({
372
+ input: inStream,
373
+ crlfDelay: Infinity
374
+ });
375
+ const lines = new denque.default();
376
+ for await (const line of rl) {
377
+ if (patternToSearch != void 0 && !line.includes(patternToSearch)) continue;
378
+ lines.push(line);
379
+ if (lines.length > nLines) lines.shift();
380
+ }
381
+ return lines.toArray().join(node_os.EOL) + node_os.EOL;
382
+ } finally {
383
+ try {
384
+ if (rl) rl.close();
385
+ } catch (cleanupError) {
386
+ console.error("Error closing readline interface:", cleanupError);
387
+ }
388
+ try {
389
+ if (inStream && !inStream.destroyed) inStream.destroy();
390
+ } catch (cleanupError) {
391
+ console.error("Error destroying read stream:", cleanupError);
392
+ }
393
+ }
477
394
  }
478
395
  function validateDownloadableResourceType(methodName, rType) {
479
- if (!rType.name.startsWith("Blob/")) {
480
- let message = `${methodName}: wrong resource type: ${rType.name}, expected: a resource of type that starts with 'Blob/'.`;
481
- if (rType.name == "Blob")
482
- message += ` If it's called from workflow, should a file be exported with 'file.exportFile' function?`;
483
- throw new helpers.WrongResourceTypeError(message);
484
- }
396
+ if (!rType.name.startsWith("Blob/")) {
397
+ let message = `${methodName}: wrong resource type: ${rType.name}, expected: a resource of type that starts with 'Blob/'.`;
398
+ if (rType.name == "Blob") message += ` If it's called from workflow, should a file be exported with 'file.exportFile' function?`;
399
+ throw new require_helpers.WrongResourceTypeError(message);
400
+ }
485
401
  }
486
402
 
403
+ //#endregion
487
404
  exports.DownloadDriver = DownloadDriver;
488
- //# sourceMappingURL=download_blob.cjs.map
405
+ //# sourceMappingURL=download_blob.cjs.map