@milaboratories/pl-drivers 1.11.19 → 1.11.21

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 (265) hide show
  1. package/dist/clients/constructors.cjs +5 -5
  2. package/dist/clients/constructors.cjs.map +1 -1
  3. package/dist/clients/constructors.js +5 -5
  4. package/dist/clients/constructors.js.map +1 -1
  5. package/dist/clients/download.cjs +29 -5
  6. package/dist/clients/download.cjs.map +1 -1
  7. package/dist/clients/download.d.ts +5 -4
  8. package/dist/clients/download.d.ts.map +1 -1
  9. package/dist/clients/download.js +30 -6
  10. package/dist/clients/download.js.map +1 -1
  11. package/dist/clients/logs.cjs +57 -16
  12. package/dist/clients/logs.cjs.map +1 -1
  13. package/dist/clients/logs.d.ts +6 -5
  14. package/dist/clients/logs.d.ts.map +1 -1
  15. package/dist/clients/logs.js +58 -17
  16. package/dist/clients/logs.js.map +1 -1
  17. package/dist/clients/ls_api.cjs +44 -8
  18. package/dist/clients/ls_api.cjs.map +1 -1
  19. package/dist/clients/ls_api.d.ts +4 -4
  20. package/dist/clients/ls_api.d.ts.map +1 -1
  21. package/dist/clients/ls_api.js +45 -9
  22. package/dist/clients/ls_api.js.map +1 -1
  23. package/dist/clients/progress.cjs +32 -29
  24. package/dist/clients/progress.cjs.map +1 -1
  25. package/dist/clients/progress.d.ts +5 -5
  26. package/dist/clients/progress.d.ts.map +1 -1
  27. package/dist/clients/progress.js +33 -30
  28. package/dist/clients/progress.js.map +1 -1
  29. package/dist/clients/upload.cjs +96 -30
  30. package/dist/clients/upload.cjs.map +1 -1
  31. package/dist/clients/upload.d.ts +8 -11
  32. package/dist/clients/upload.d.ts.map +1 -1
  33. package/dist/clients/upload.js +97 -31
  34. package/dist/clients/upload.js.map +1 -1
  35. package/dist/drivers/download_blob/download_blob.cjs +2 -2
  36. package/dist/drivers/download_blob/download_blob.cjs.map +1 -1
  37. package/dist/drivers/download_blob/download_blob.js +1 -1
  38. package/dist/drivers/download_blob/download_blob.js.map +1 -1
  39. package/dist/drivers/download_blob/download_blob_task.cjs +5 -5
  40. package/dist/drivers/download_blob/download_blob_task.cjs.map +1 -1
  41. package/dist/drivers/download_blob/download_blob_task.js +2 -2
  42. package/dist/drivers/download_blob/download_blob_task.js.map +1 -1
  43. package/dist/drivers/download_blob_url/task.cjs +5 -5
  44. package/dist/drivers/download_blob_url/task.cjs.map +1 -1
  45. package/dist/drivers/download_blob_url/task.js +2 -2
  46. package/dist/drivers/download_blob_url/task.js.map +1 -1
  47. package/dist/drivers/download_url/task.cjs +2 -2
  48. package/dist/drivers/download_url/task.cjs.map +1 -1
  49. package/dist/drivers/download_url/task.js +2 -2
  50. package/dist/drivers/download_url/task.js.map +1 -1
  51. package/dist/drivers/logs_stream.cjs.map +1 -1
  52. package/dist/drivers/logs_stream.js.map +1 -1
  53. package/dist/helpers/download.cjs +5 -24
  54. package/dist/helpers/download.cjs.map +1 -1
  55. package/dist/helpers/download.d.ts +0 -13
  56. package/dist/helpers/download.d.ts.map +1 -1
  57. package/dist/helpers/download.js +5 -21
  58. package/dist/helpers/download.js.map +1 -1
  59. package/dist/helpers/download_errors.cjs +43 -0
  60. package/dist/helpers/download_errors.cjs.map +1 -0
  61. package/dist/helpers/download_errors.d.ts +23 -0
  62. package/dist/helpers/download_errors.d.ts.map +1 -0
  63. package/dist/helpers/download_errors.js +36 -0
  64. package/dist/helpers/download_errors.js.map +1 -0
  65. package/dist/index.cjs +7 -0
  66. package/dist/index.cjs.map +1 -1
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +1 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs +2 -2
  72. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs.map +1 -0
  73. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs.map +1 -0
  74. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -0
  75. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js.map +1 -0
  76. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -0
  77. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js +2 -2
  78. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js.map +1 -0
  79. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs +2 -2
  80. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs.map +1 -0
  81. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs.map +1 -0
  82. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +1 -0
  83. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js.map +1 -0
  84. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -0
  85. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js +2 -2
  86. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js.map +1 -0
  87. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs +3 -3
  88. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs.map +1 -0
  89. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs.map +1 -0
  90. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -0
  91. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js.map +1 -0
  92. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -0
  93. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js +3 -3
  94. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js.map +1 -0
  95. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs +6 -6
  96. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs.map +1 -0
  97. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs.map +1 -0
  98. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -0
  99. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js.map +1 -0
  100. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -0
  101. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js +6 -6
  102. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js.map +1 -0
  103. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs +84 -84
  104. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs.map +1 -0
  105. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs.map +1 -0
  106. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts +16 -16
  107. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +1 -0
  108. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js.map +1 -0
  109. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts +118 -118
  110. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +1 -0
  111. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js +76 -76
  112. package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js.map +1 -0
  113. package/dist/proto-grpc/google/api/http.d.ts.map +1 -0
  114. package/dist/{proto → proto-grpc}/google/protobuf/descriptor.d.ts +5 -149
  115. package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +1 -0
  116. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -0
  117. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -0
  118. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -0
  119. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -0
  120. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -0
  121. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -0
  122. package/dist/proto-rest/downloadapi.d.ts +105 -0
  123. package/dist/proto-rest/downloadapi.d.ts.map +1 -0
  124. package/dist/proto-rest/index.d.ts +17 -0
  125. package/dist/proto-rest/index.d.ts.map +1 -0
  126. package/dist/proto-rest/lsapi.d.ts +148 -0
  127. package/dist/proto-rest/lsapi.d.ts.map +1 -0
  128. package/dist/proto-rest/progressapi.d.ts +159 -0
  129. package/dist/proto-rest/progressapi.d.ts.map +1 -0
  130. package/dist/proto-rest/streamingapi.d.ts +469 -0
  131. package/dist/proto-rest/streamingapi.d.ts.map +1 -0
  132. package/dist/proto-rest/uploadapi.d.ts +355 -0
  133. package/dist/proto-rest/uploadapi.d.ts.map +1 -0
  134. package/package.json +12 -8
  135. package/src/clients/constructors.ts +11 -11
  136. package/src/clients/download.ts +34 -11
  137. package/src/clients/logs.ts +69 -21
  138. package/src/clients/ls_api.ts +58 -14
  139. package/src/clients/progress.ts +41 -44
  140. package/src/clients/upload.ts +117 -53
  141. package/src/drivers/download_blob/download_blob.ts +1 -1
  142. package/src/drivers/download_blob/download_blob_task.ts +2 -2
  143. package/src/drivers/download_blob_url/task.ts +2 -2
  144. package/src/drivers/download_url/task.ts +2 -2
  145. package/src/drivers/logs_stream.ts +1 -1
  146. package/src/drivers/upload.test.ts +6 -25
  147. package/src/helpers/download.ts +4 -26
  148. package/src/helpers/download_errors.ts +40 -0
  149. package/src/index.ts +1 -0
  150. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +1 -1
  151. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +2 -2
  152. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +1 -1
  153. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +2 -2
  154. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +1 -1
  155. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +3 -3
  156. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +1 -1
  157. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +6 -6
  158. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.ts +21 -21
  159. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.ts +159 -159
  160. package/src/{proto → proto-grpc}/google/api/http.ts +1 -1
  161. package/src/{proto → proto-grpc}/google/protobuf/descriptor.ts +9 -217
  162. package/src/{proto → proto-grpc}/google/protobuf/duration.ts +1 -1
  163. package/src/{proto → proto-grpc}/google/protobuf/timestamp.ts +1 -1
  164. package/src/proto-rest/downloadapi.ts +105 -0
  165. package/src/proto-rest/index.ts +28 -0
  166. package/src/proto-rest/lsapi.ts +148 -0
  167. package/src/proto-rest/progressapi.ts +159 -0
  168. package/src/proto-rest/streamingapi.ts +469 -0
  169. package/src/proto-rest/uploadapi.ts +355 -0
  170. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +0 -53
  171. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
  172. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs.map +0 -1
  173. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs.map +0 -1
  174. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +0 -1
  175. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js.map +0 -1
  176. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +0 -1
  177. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js.map +0 -1
  178. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs.map +0 -1
  179. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs.map +0 -1
  180. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +0 -1
  181. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js.map +0 -1
  182. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +0 -1
  183. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js.map +0 -1
  184. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs.map +0 -1
  185. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs.map +0 -1
  186. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +0 -1
  187. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js.map +0 -1
  188. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +0 -1
  189. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js.map +0 -1
  190. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs.map +0 -1
  191. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs.map +0 -1
  192. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +0 -1
  193. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js.map +0 -1
  194. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +0 -1
  195. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js.map +0 -1
  196. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs.map +0 -1
  197. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs.map +0 -1
  198. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +0 -1
  199. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js.map +0 -1
  200. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +0 -1
  201. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js.map +0 -1
  202. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +0 -329
  203. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
  204. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +0 -5358
  205. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
  206. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +0 -537
  207. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
  208. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +0 -87
  209. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
  210. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -106
  211. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
  212. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +0 -256
  213. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
  214. package/dist/proto/google/api/http.d.ts.map +0 -1
  215. package/dist/proto/google/protobuf/any.d.ts +0 -181
  216. package/dist/proto/google/protobuf/any.d.ts.map +0 -1
  217. package/dist/proto/google/protobuf/descriptor.d.ts.map +0 -1
  218. package/dist/proto/google/protobuf/duration.cjs.map +0 -1
  219. package/dist/proto/google/protobuf/duration.d.ts.map +0 -1
  220. package/dist/proto/google/protobuf/duration.js.map +0 -1
  221. package/dist/proto/google/protobuf/empty.d.ts +0 -32
  222. package/dist/proto/google/protobuf/empty.d.ts.map +0 -1
  223. package/dist/proto/google/protobuf/struct.d.ts +0 -187
  224. package/dist/proto/google/protobuf/struct.d.ts.map +0 -1
  225. package/dist/proto/google/protobuf/timestamp.cjs.map +0 -1
  226. package/dist/proto/google/protobuf/timestamp.d.ts.map +0 -1
  227. package/dist/proto/google/protobuf/timestamp.js.map +0 -1
  228. package/dist/proto/google/protobuf/wrappers.d.ts +0 -335
  229. package/dist/proto/google/protobuf/wrappers.d.ts.map +0 -1
  230. package/src/proto/github.com/googleapis/googleapis/google/rpc/status.ts +0 -125
  231. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +0 -406
  232. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.ts +0 -14986
  233. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +0 -1474
  234. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +0 -181
  235. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/import.ts +0 -251
  236. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.ts +0 -693
  237. package/src/proto/google/protobuf/any.ts +0 -326
  238. package/src/proto/google/protobuf/empty.ts +0 -94
  239. package/src/proto/google/protobuf/struct.ts +0 -484
  240. package/src/proto/google/protobuf/wrappers.ts +0 -785
  241. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs +0 -0
  242. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +0 -0
  243. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js +0 -0
  244. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +0 -0
  245. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs +0 -0
  246. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +0 -0
  247. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js +0 -0
  248. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +0 -0
  249. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs +0 -0
  250. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +0 -0
  251. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js +0 -0
  252. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +0 -0
  253. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs +0 -0
  254. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +0 -0
  255. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js +0 -0
  256. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +0 -0
  257. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs +0 -0
  258. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js +0 -0
  259. /package/dist/{proto → proto-grpc}/google/api/http.d.ts +0 -0
  260. /package/dist/{proto → proto-grpc}/google/protobuf/duration.cjs +0 -0
  261. /package/dist/{proto → proto-grpc}/google/protobuf/duration.d.ts +0 -0
  262. /package/dist/{proto → proto-grpc}/google/protobuf/duration.js +0 -0
  263. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.cjs +0 -0
  264. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.d.ts +0 -0
  265. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.js +0 -0
@@ -9,31 +9,31 @@ var ls_api = require('./ls_api.cjs');
9
9
  function createDownloadClient(logger, client, localProjections) {
10
10
  return client.getDriver({
11
11
  name: 'DownloadBlob',
12
- init: (_, grpcClientProviderFactory, httpDispatcher) => new download.ClientDownload(grpcClientProviderFactory, httpDispatcher, logger, localProjections),
12
+ init: (_, wireClientFactory, httpDispatcher) => new download.ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),
13
13
  });
14
14
  }
15
15
  function createLogsClient(client, logger) {
16
16
  return client.getDriver({
17
17
  name: 'StreamLogs',
18
- init: (_, grpcClientProviderFactory, httpDispatcher) => new logs.ClientLogs(grpcClientProviderFactory, httpDispatcher, logger),
18
+ init: (_, wireClientFactory, httpDispatcher) => new logs.ClientLogs(wireClientFactory, httpDispatcher, logger),
19
19
  });
20
20
  }
21
21
  function createUploadProgressClient(client, logger) {
22
22
  return client.getDriver({
23
23
  name: 'UploadProgress',
24
- init: (_, grpcClientProviderFactory, httpDispatcher) => new progress.ClientProgress(grpcClientProviderFactory, httpDispatcher, client, logger),
24
+ init: (_, wireClientFactory, httpDispatcher) => new progress.ClientProgress(wireClientFactory, httpDispatcher, client, logger),
25
25
  });
26
26
  }
27
27
  function createUploadBlobClient(client, logger) {
28
28
  return client.getDriver({
29
29
  name: 'UploadBlob',
30
- init: (_, grpcClientProviderFactory, httpDispatcher) => new upload.ClientUpload(grpcClientProviderFactory, httpDispatcher, client, logger),
30
+ init: (_, wireClientFactory, httpDispatcher) => new upload.ClientUpload(wireClientFactory, httpDispatcher, client, logger),
31
31
  });
32
32
  }
33
33
  function createLsFilesClient(client, logger) {
34
34
  return client.getDriver({
35
35
  name: 'LsFiles',
36
- init: (_client, grpcClientProviderFactory, _httpDispatcher) => new ls_api.ClientLs(grpcClientProviderFactory, logger),
36
+ init: (_client, wireClientFactory, _httpDispatcher) => new ls_api.ClientLs(wireClientFactory, logger),
37
37
  });
38
38
  }
39
39
 
@@ -1 +1 @@
1
- {"version":3,"file":"constructors.cjs","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { GrpcClientProviderFactory, PlClient } from '@milaboratories/pl-client';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport { ClientDownload } from './download';\nimport { ClientLogs } from './logs';\nimport { ClientProgress } from './progress';\nimport { ClientUpload } from './upload';\nimport { ClientLs } from './ls_api';\nimport type { LocalStorageProjection } from '../drivers/types';\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: 'DownloadBlob',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(grpcClientProviderFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'StreamLogs',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(grpcClientProviderFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadProgress',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(grpcClientProviderFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadBlob',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(grpcClientProviderFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'LsFiles',\n init: (_client: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, _httpDispatcher: Dispatcher) =>\n new ClientLs(grpcClientProviderFactory, logger),\n });\n}\n"],"names":["ClientDownload","ClientLogs","ClientProgress","ClientUpload","ClientLs"],"mappings":";;;;;;;;SAUgB,oBAAoB,CAClC,MAAgB,EAChB,MAAgB,EAChB,gBAA0C,EAAA;IAE1C,OAAO,MAAM,CAAC,SAAS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,CAAC,yBAAyB,EAAE,MAAM,CAAC;AAClD,KAAA,CAAC;AACJ;;;;;;;;"}
1
+ {"version":3,"file":"constructors.cjs","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from '@milaboratories/pl-client';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport { ClientDownload } from './download';\nimport { ClientLogs } from './logs';\nimport { ClientProgress } from './progress';\nimport { ClientUpload } from './upload';\nimport { ClientLs } from './ls_api';\nimport type { LocalStorageProjection } from '../drivers/types';\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: 'DownloadBlob',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'StreamLogs',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadProgress',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadBlob',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'LsFiles',\n init: (_client: PlClient, wireClientFactory: WireClientProviderFactory, _httpDispatcher: Dispatcher) =>\n new ClientLs(wireClientFactory, logger),\n });\n}\n"],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AgB,EAAA;IACpE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,IAAI,EAAE,CAAC,OAAiB,EAAE,iBAA4C,EAAE,eAA2B,KACjG,IAAIC,eAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;AAC1C,KAAA,CAAC;AACJ;;;;;;;;"}
@@ -7,31 +7,31 @@ import { ClientLs } from './ls_api.js';
7
7
  function createDownloadClient(logger, client, localProjections) {
8
8
  return client.getDriver({
9
9
  name: 'DownloadBlob',
10
- init: (_, grpcClientProviderFactory, httpDispatcher) => new ClientDownload(grpcClientProviderFactory, httpDispatcher, logger, localProjections),
10
+ init: (_, wireClientFactory, httpDispatcher) => new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),
11
11
  });
12
12
  }
13
13
  function createLogsClient(client, logger) {
14
14
  return client.getDriver({
15
15
  name: 'StreamLogs',
16
- init: (_, grpcClientProviderFactory, httpDispatcher) => new ClientLogs(grpcClientProviderFactory, httpDispatcher, logger),
16
+ init: (_, wireClientFactory, httpDispatcher) => new ClientLogs(wireClientFactory, httpDispatcher, logger),
17
17
  });
18
18
  }
19
19
  function createUploadProgressClient(client, logger) {
20
20
  return client.getDriver({
21
21
  name: 'UploadProgress',
22
- init: (_, grpcClientProviderFactory, httpDispatcher) => new ClientProgress(grpcClientProviderFactory, httpDispatcher, client, logger),
22
+ init: (_, wireClientFactory, httpDispatcher) => new ClientProgress(wireClientFactory, httpDispatcher, client, logger),
23
23
  });
24
24
  }
25
25
  function createUploadBlobClient(client, logger) {
26
26
  return client.getDriver({
27
27
  name: 'UploadBlob',
28
- init: (_, grpcClientProviderFactory, httpDispatcher) => new ClientUpload(grpcClientProviderFactory, httpDispatcher, client, logger),
28
+ init: (_, wireClientFactory, httpDispatcher) => new ClientUpload(wireClientFactory, httpDispatcher, client, logger),
29
29
  });
30
30
  }
31
31
  function createLsFilesClient(client, logger) {
32
32
  return client.getDriver({
33
33
  name: 'LsFiles',
34
- init: (_client, grpcClientProviderFactory, _httpDispatcher) => new ClientLs(grpcClientProviderFactory, logger),
34
+ init: (_client, wireClientFactory, _httpDispatcher) => new ClientLs(wireClientFactory, logger),
35
35
  });
36
36
  }
37
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"constructors.js","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { GrpcClientProviderFactory, PlClient } from '@milaboratories/pl-client';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport { ClientDownload } from './download';\nimport { ClientLogs } from './logs';\nimport { ClientProgress } from './progress';\nimport { ClientUpload } from './upload';\nimport { ClientLs } from './ls_api';\nimport type { LocalStorageProjection } from '../drivers/types';\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: 'DownloadBlob',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(grpcClientProviderFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'StreamLogs',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(grpcClientProviderFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadProgress',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(grpcClientProviderFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadBlob',\n init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(grpcClientProviderFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'LsFiles',\n init: (_client: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, _httpDispatcher: Dispatcher) =>\n new ClientLs(grpcClientProviderFactory, logger),\n });\n}\n"],"names":[],"mappings":";;;;;;SAUgB,oBAAoB,CAClC,MAAgB,EAChB,MAAgB,EAChB,gBAA0C,EAAA;IAE1C,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC,CAAW,EAAE,yBAAoD,EAAE,cAA0B,KAClG,IAAI,cAAc,CAAC,yBAAyB,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC;AAC1F,KAAA,CAAC;AACJ;AAEM,SAAU,gBAAgB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACjE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE,CAAC,CAAW,EAAE,yBAAoD,EAAE,cAA0B,KAClG,IAAI,UAAU,CAAC,yBAAyB,EAAE,cAAc,EAAE,MAAM,CAAC;AACpE,KAAA,CAAC;AACJ;AAEM,SAAU,0BAA0B,CAAC,MAAgB,EAAE,MAAgB,EAAA;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,CAAC,CAAW,EAAE,yBAAoD,EAAE,cAA0B,KAClG,IAAI,cAAc,CAAC,yBAAyB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AAChF,KAAA,CAAC;AACJ;AAEM,SAAU,sBAAsB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACvE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,CAAC,CAAW,EAAE,yBAAoD,EAAE,cAA0B,KAClG,IAAI,YAAY,CAAC,yBAAyB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AAC9E,KAAA,CAAC;AACJ;AAEM,SAAU,mBAAmB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACpE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,IAAI,EAAE,CAAC,OAAiB,EAAE,yBAAoD,EAAE,eAA2B,KACzG,IAAI,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;AAClD,KAAA,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"constructors.js","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from '@milaboratories/pl-client';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport { ClientDownload } from './download';\nimport { ClientLogs } from './logs';\nimport { ClientProgress } from './progress';\nimport { ClientUpload } from './upload';\nimport { ClientLs } from './ls_api';\nimport type { LocalStorageProjection } from '../drivers/types';\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: 'DownloadBlob',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'StreamLogs',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadProgress',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'UploadBlob',\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: 'LsFiles',\n init: (_client: PlClient, wireClientFactory: WireClientProviderFactory, _httpDispatcher: Dispatcher) =>\n new ClientLs(wireClientFactory, logger),\n });\n}\n"],"names":[],"mappings":";;;;;;SAUgB,oBAAoB,CAClC,MAAgB,EAChB,MAAgB,EAChB,gBAA0C,EAAA;IAE1C,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAI,cAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC;AAClF,KAAA,CAAC;AACJ;AAEM,SAAU,gBAAgB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACjE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAI,UAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,CAAC;AAC5D,KAAA,CAAC;AACJ;AAEM,SAAU,0BAA0B,CAAC,MAAgB,EAAE,MAAgB,EAAA;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAI,cAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AACxE,KAAA,CAAC;AACJ;AAEM,SAAU,sBAAsB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACvE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAI,YAAY,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AACtE,KAAA,CAAC;AACJ;AAEM,SAAU,mBAAmB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACpE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,IAAI,EAAE,CAAC,OAAiB,EAAE,iBAA4C,EAAE,eAA2B,KACjG,IAAI,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;AAC1C,KAAA,CAAC;AACJ;;;;"}
@@ -9,7 +9,7 @@ var path = require('node:path');
9
9
  var node_stream = require('node:stream');
10
10
  var download = require('../helpers/download.cjs');
11
11
  var validate = require('../helpers/validate.cjs');
12
- var protocol_client = require('../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs');
12
+ var protocol_client = require('../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs');
13
13
 
14
14
  function _interopNamespaceDefault(e) {
15
15
  var n = Object.create(null);
@@ -37,18 +37,30 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
37
37
  class ClientDownload {
38
38
  httpClient;
39
39
  logger;
40
- grpcClient;
40
+ wire;
41
41
  remoteFileDownloader;
42
42
  /** Helps to find a storage root directory by a storage id from URL scheme. */
43
43
  localStorageIdsToRoot;
44
44
  /** Concurrency limiter for local file reads - limit to 32 parallel reads */
45
45
  localFileReadLimiter = new tsHelpers.ConcurrencyLimitingExecutor(32);
46
- constructor(grpcClientProviderFactory, httpClient, logger,
46
+ constructor(wireClientProviderFactory, httpClient, logger,
47
47
  /** Pl storages available locally */
48
48
  localProjections) {
49
49
  this.httpClient = httpClient;
50
50
  this.logger = logger;
51
- this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new protocol_client.DownloadClient(transport));
51
+ this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {
52
+ if (wireConn.type === 'grpc') {
53
+ return new protocol_client.DownloadClient(wireConn.Transport);
54
+ }
55
+ else {
56
+ return plClient.RestAPI.createClient({
57
+ hostAndPort: wireConn.Config.hostAndPort,
58
+ ssl: wireConn.Config.ssl,
59
+ dispatcher: wireConn.Dispatcher,
60
+ middlewares: wireConn.Middlewares,
61
+ });
62
+ }
63
+ });
52
64
  this.remoteFileDownloader = new download.RemoteFileDownloader(httpClient);
53
65
  this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);
54
66
  }
@@ -104,7 +116,19 @@ class ClientDownload {
104
116
  async grpcGetDownloadUrl({ id, type }, options, signal) {
105
117
  const withAbort = options ?? {};
106
118
  withAbort.abort = signal;
107
- return await this.grpcClient.get().getDownloadURL({ resourceId: id, isInternalUse: false }, plClient.addRTypeToMetadata(type, withAbort)).response;
119
+ const client = this.wire.get();
120
+ if (client instanceof protocol_client.DownloadClient) {
121
+ return await client.getDownloadURL({ resourceId: id, isInternalUse: false }, plClient.addRTypeToMetadata(type, withAbort)).response;
122
+ }
123
+ else {
124
+ return (await client.POST('/v1/get-download-url', {
125
+ body: {
126
+ resourceId: id.toString(),
127
+ isInternalUse: false,
128
+ },
129
+ headers: { ...plClient.createRTypeRoutingHeader(type) },
130
+ })).data;
131
+ }
108
132
  }
109
133
  }
110
134
  function parseLocalUrl(url) {
@@ -1 +1 @@
1
- {"version":3,"file":"download.cjs","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly grpcClient: GrpcClientProvider<DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n grpcClientProviderFactory: GrpcClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new DownloadClient(transport));\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n return await this.grpcClient.get().getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":["ConcurrencyLimitingExecutor","DownloadClient","RemoteFileDownloader","stringifyWithResourceId","PerfTimer","fsp","fs","Readable","addRTypeToMetadata","path","validateAbsolute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,UAAU;AACT,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAIA,qCAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;AAItB,QAAA,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,SAAS,KAAK,IAA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AAC;AACxC;AAEA;AACM,MAAO,iBAAkB,SAAQ,KAAK,CAAA;IAC1C,IAAI,GAAG,mBAAmB;AAC3B;AAED;AACM,MAAO,mBAAoB,SAAQ,KAAK,CAAA;IAC5C,IAAI,GAAG,qBAAqB;AAC7B;AAEK,SAAU,wBAAwB,CAAC,WAAqC,EAAA;AAC5E,IAAA,MAAM,QAAQ,GAAwB,IAAI,GAAG,EAAE;AAC/C,IAAA,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE;;AAE5B,QAAA,IAAI,EAAE,CAAC,SAAS,KAAK,EAAE,EAAE;AACvB,YAAAC,yBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC;QAChC;QACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;;;;;;"}
1
+ {"version":3,"file":"download.cjs","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId, RestAPI, createRTypeRoutingHeader } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport type { DownloadApiPaths, DownloadRestClientType } from '../proto-rest';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === 'grpc') {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (await client.POST('/v1/get-download-url', {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":["ConcurrencyLimitingExecutor","DownloadClient","RestAPI","RemoteFileDownloader","stringifyWithResourceId","PerfTimer","fsp","fs","Readable","addRTypeToMetadata","createRTypeRoutingHeader","path","validateAbsolute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,IAAI;AACH,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAIA,qCAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;QAItB,IAAI,CAAC,IAAI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,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;;;;;;"}
@@ -1,24 +1,25 @@
1
- import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
1
+ import type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';
2
2
  import type { ResourceInfo } from '@milaboratories/pl-tree';
3
3
  import type { MiLogger } from '@milaboratories/ts-helpers';
4
4
  import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
5
5
  import type { Dispatcher } from 'undici';
6
6
  import type { LocalStorageProjection } from '../drivers/types';
7
7
  import { type ContentHandler } from '../helpers/download';
8
- import { DownloadClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';
8
+ import { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';
9
+ import type { DownloadRestClientType } from '../proto-rest';
9
10
  import { type GetContentOptions } from '@milaboratories/pl-model-common';
10
11
  /** Gets URLs for downloading from pl-core, parses them and reads or downloads
11
12
  * files locally and from the web. */
12
13
  export declare class ClientDownload {
13
14
  readonly httpClient: Dispatcher;
14
15
  readonly logger: MiLogger;
15
- readonly grpcClient: GrpcClientProvider<DownloadClient>;
16
+ readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;
16
17
  private readonly remoteFileDownloader;
17
18
  /** Helps to find a storage root directory by a storage id from URL scheme. */
18
19
  private readonly localStorageIdsToRoot;
19
20
  /** Concurrency limiter for local file reads - limit to 32 parallel reads */
20
21
  private readonly localFileReadLimiter;
21
- constructor(grpcClientProviderFactory: GrpcClientProviderFactory, httpClient: Dispatcher, logger: MiLogger,
22
+ constructor(wireClientProviderFactory: WireClientProviderFactory, httpClient: Dispatcher, logger: MiLogger,
22
23
  /** Pl storages available locally */
23
24
  localProjections: LocalStorageProjection[]);
24
25
  close(): void;
@@ -1 +1 @@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gB,wBAAwB,CAAC,WAAW,EAAE,sBAAsB,EAAE,uBAW7E"}
@@ -1,4 +1,4 @@
1
- import { stringifyWithResourceId, addRTypeToMetadata } from '@milaboratories/pl-client';
1
+ import { RestAPI, stringifyWithResourceId, addRTypeToMetadata, createRTypeRoutingHeader } from '@milaboratories/pl-client';
2
2
  import { PerfTimer } from '@milaboratories/helpers';
3
3
  import { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';
4
4
  import * as fs from 'node:fs';
@@ -7,25 +7,37 @@ import * as path from 'node:path';
7
7
  import { Readable } from 'node:stream';
8
8
  import { RemoteFileDownloader } from '../helpers/download.js';
9
9
  import { validateAbsolute } from '../helpers/validate.js';
10
- import { DownloadClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js';
10
+ import { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js';
11
11
 
12
12
  /** Gets URLs for downloading from pl-core, parses them and reads or downloads
13
13
  * files locally and from the web. */
14
14
  class ClientDownload {
15
15
  httpClient;
16
16
  logger;
17
- grpcClient;
17
+ wire;
18
18
  remoteFileDownloader;
19
19
  /** Helps to find a storage root directory by a storage id from URL scheme. */
20
20
  localStorageIdsToRoot;
21
21
  /** Concurrency limiter for local file reads - limit to 32 parallel reads */
22
22
  localFileReadLimiter = new ConcurrencyLimitingExecutor(32);
23
- constructor(grpcClientProviderFactory, httpClient, logger,
23
+ constructor(wireClientProviderFactory, httpClient, logger,
24
24
  /** Pl storages available locally */
25
25
  localProjections) {
26
26
  this.httpClient = httpClient;
27
27
  this.logger = logger;
28
- this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new DownloadClient(transport));
28
+ this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {
29
+ if (wireConn.type === 'grpc') {
30
+ return new DownloadClient(wireConn.Transport);
31
+ }
32
+ else {
33
+ return RestAPI.createClient({
34
+ hostAndPort: wireConn.Config.hostAndPort,
35
+ ssl: wireConn.Config.ssl,
36
+ dispatcher: wireConn.Dispatcher,
37
+ middlewares: wireConn.Middlewares,
38
+ });
39
+ }
40
+ });
29
41
  this.remoteFileDownloader = new RemoteFileDownloader(httpClient);
30
42
  this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);
31
43
  }
@@ -81,7 +93,19 @@ class ClientDownload {
81
93
  async grpcGetDownloadUrl({ id, type }, options, signal) {
82
94
  const withAbort = options ?? {};
83
95
  withAbort.abort = signal;
84
- return await this.grpcClient.get().getDownloadURL({ resourceId: id, isInternalUse: false }, addRTypeToMetadata(type, withAbort)).response;
96
+ const client = this.wire.get();
97
+ if (client instanceof DownloadClient) {
98
+ return await client.getDownloadURL({ resourceId: id, isInternalUse: false }, addRTypeToMetadata(type, withAbort)).response;
99
+ }
100
+ else {
101
+ return (await client.POST('/v1/get-download-url', {
102
+ body: {
103
+ resourceId: id.toString(),
104
+ isInternalUse: false,
105
+ },
106
+ headers: { ...createRTypeRoutingHeader(type) },
107
+ })).data;
108
+ }
85
109
  }
86
110
  }
87
111
  function parseLocalUrl(url) {
@@ -1 +1 @@
1
- {"version":3,"file":"download.js","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly grpcClient: GrpcClientProvider<DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n grpcClientProviderFactory: GrpcClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new DownloadClient(transport));\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n return await this.grpcClient.get().getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAoBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,UAAU;AACT,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;AAItB,QAAA,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,SAAS,KAAK,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;QAClH,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC;AAChE,QAAA,IAAI,CAAC,qBAAqB,GAAG,wBAAwB,CAAC,gBAAgB,CAAC;IACzE;AAEA,IAAA,KAAK,KAAI;AAET;;;;;AAKG;IACH,MAAM,eAAe,CACnB,IAAkB,EAClB,OAA+B,EAC/B,GAAsB,EACtB,OAA0B,EAAA;AAE1B,QAAA,MAAM,EAAE,WAAW,EAAE,OA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C,SAAS,KAAK,EAAE,EAAE;AACvB,YAAA,gBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC;QAChC;QACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;"}
1
+ {"version":3,"file":"download.js","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId, RestAPI, createRTypeRoutingHeader } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport type { DownloadApiPaths, DownloadRestClientType } from '../proto-rest';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === 'grpc') {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (await client.POST('/v1/get-download-url', {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,IAAI;AACH,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;QAItB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,QAAQ,KAAI;AAC1E,YAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE;AAC5B,gBAAA,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC/C;iBAAO;gBACL,OAAO,OAAO,CAAC,YAAY,CAAmB;AAC5C,oBAAA,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW;AACxC,oBAAA,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG;oBACxB,UAAU,EAAE,QAAQ,CAAC,UAAU;oBAC/B,WAAW,EAAE,QAAQ,CAAC,WAAW;AAClC,iBAAA,CAAC;YACJ;AACF,QAAA,CAAC,CAAC;QACF,IAAI,CAAC,oBAAoB,GAAG,IA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AAmB,CAAC,6BAA6B,SAAS,CAAA,CAAE,CAAC;IAE/F,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,OAAO,YAAY;IAEpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;AACtC;AAEA,MAAM,eAAe,GAAG,YAAY;AACpC,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,OAAO,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC;AACxC;AAEA;AACM,MAAO,iBAAkB,SAAQ,KAAK,CAAA;IAC1C,IAAI,GAAG,mBAAmB;AAC3B;AAED;AACM,MAAO,mBAAoB,SAAQ,KAAK,CAAA;IAC5C,IAAI,GAAG,qBAAqB;AAC7B;AAEK,SAAU,wBAAwB,CAAC,WAAqC,EAAA;AAC5E,IAAA,MAAM,QAAQ,GAAwB,IAAI,GAAG,EAAE;AAC/C,IAAA,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE;;AAE5B,QAAA,IAAI,EAAE,CAAC,SAAS,KAAK,EAAE,EAAE;AACvB,YAAA,gBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC;QAChC;QACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;"}
@@ -1,17 +1,27 @@
1
1
  'use strict';
2
2
 
3
- var protocol_client = require('../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs');
4
3
  var tsHelpers = require('@milaboratories/ts-helpers');
5
4
  var plClient = require('@milaboratories/pl-client');
5
+ var protocol_client = require('../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs');
6
6
 
7
7
  class ClientLogs {
8
8
  httpClient;
9
9
  logger;
10
- grpcClient;
11
- constructor(grpcClientProviderFactory, httpClient, logger) {
10
+ wire;
11
+ constructor(wireClientProviderFactory, httpClient, logger) {
12
12
  this.httpClient = httpClient;
13
13
  this.logger = logger;
14
- this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new protocol_client.StreamingClient(transport));
14
+ this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {
15
+ if (wire.type === 'grpc') {
16
+ return new protocol_client.StreamingClient(wire.Transport);
17
+ }
18
+ return plClient.RestAPI.createClient({
19
+ hostAndPort: wire.Config.hostAndPort,
20
+ ssl: wire.Config.ssl,
21
+ dispatcher: wire.Dispatcher,
22
+ middlewares: wire.Middlewares,
23
+ });
24
+ });
15
25
  }
16
26
  close() { }
17
27
  /** Reads text back and returns the text,
@@ -19,24 +29,55 @@ class ClientLogs {
19
29
  * and the total size of the (currently existing) file. */
20
30
  async lastLines({ id: rId, type: rType }, lineCount, offsetBytes = 0n, // if 0n, then start from the end.
21
31
  searchStr, options) {
22
- return (await this.grpcClient.get().lastLines({
23
- resourceId: rId,
24
- lineCount: lineCount,
25
- offset: offsetBytes,
26
- search: searchStr,
27
- }, plClient.addRTypeToMetadata(rType, options))).response;
32
+ const client = this.wire.get();
33
+ if (client instanceof protocol_client.StreamingClient) {
34
+ return (await client.lastLines({ resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr }, plClient.addRTypeToMetadata(rType, options))).response;
35
+ }
36
+ const resp = (await client.POST('/v1/last-lines', {
37
+ body: {
38
+ resourceId: rId.toString(),
39
+ lineCount: lineCount,
40
+ offset: offsetBytes.toString(),
41
+ search: searchStr ?? '',
42
+ searchRe: '',
43
+ },
44
+ headers: { ...plClient.createRTypeRoutingHeader(rType) },
45
+ })).data;
46
+ return {
47
+ data: new Uint8Array(Buffer.from(resp.data)),
48
+ size: BigInt(resp.size),
49
+ newOffset: BigInt(resp.newOffset),
50
+ };
28
51
  }
29
52
  /** Reads the file forward and returns the text,
30
53
  * the new offset
31
54
  * and the total size of the (currently existing) file. */
32
55
  async readText({ id: rId, type: rType }, lineCount, offsetBytes = 0n, // if 0n, then start from the beginning.
33
56
  searchStr, options) {
34
- return (await this.grpcClient.get().readText({
35
- resourceId: tsHelpers.notEmpty(rId),
36
- readLimit: BigInt(lineCount),
37
- offset: offsetBytes,
38
- search: searchStr,
39
- }, plClient.addRTypeToMetadata(rType, options))).response;
57
+ const client = this.wire.get();
58
+ if (client instanceof protocol_client.StreamingClient) {
59
+ return (await client.readText({
60
+ resourceId: tsHelpers.notEmpty(rId),
61
+ readLimit: BigInt(lineCount),
62
+ offset: offsetBytes,
63
+ search: searchStr,
64
+ }, plClient.addRTypeToMetadata(rType, options))).response;
65
+ }
66
+ const resp = (await client.POST('/v1/read/text', {
67
+ body: {
68
+ resourceId: rId.toString(),
69
+ readLimit: lineCount.toString(),
70
+ offset: offsetBytes.toString(),
71
+ search: searchStr ?? '',
72
+ searchRe: '',
73
+ },
74
+ headers: { ...plClient.createRTypeRoutingHeader(rType) },
75
+ })).data;
76
+ return {
77
+ data: new Uint8Array(Buffer.from(resp.data)),
78
+ size: BigInt(resp.size),
79
+ newOffset: BigInt(resp.newOffset),
80
+ };
40
81
  }
41
82
  }
42
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"logs.cjs","sources":["../../src/clients/logs.ts"],"sourcesContent":["import { StreamingClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { notEmpty } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata } from '@milaboratories/pl-client';\nimport type { StreamingAPI_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\n\nexport class ClientLogs {\n public readonly grpcClient: GrpcClientProvider<StreamingClient>;\n\n constructor(\n grpcClientProviderFactory: GrpcClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new StreamingClient(transport));\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n return (\n await this.grpcClient.get().lastLines(\n {\n resourceId: rId,\n lineCount: lineCount,\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n return (\n await this.grpcClient.get().readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n}\n"],"names":["StreamingClient","addRTypeToMetadata","notEmpty"],"mappings":";;;;;;MAUa,UAAU,CAAA;AAKH,IAAA,UAAA;AACA,IAAA,MAAA;AALF,IAAA,UAAU;AAE1B,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB,EAAA;QADhB,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;AAEtB,QAAA,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,SAAS,KAAK,IAAIA,+BAAe,CAAC,SAAS,CAAC,CAAC;IACrH;AAEA,IAAA,KAAK,KAAI;AAET;;AAE0D;AACnD,IAAA,MAAM,SAAS,CACpB,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAgB,EACtC,SAAiB,EACjB,WAAA,GAAsB,EAAE;AACxB,IAAA,SAAkB,EAClB,OAAoB,EAAA;QAEpB,OAAO,CACL,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CACnC;AACE,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,SAAS,EAAE,SAAS;AACpB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,MAAM,EAAE,SAAS;SAClB,EACDC,2BAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CACnC,EACD,QAAQ;IACZ;AAEA;;AAE0D;AACnD,IAAA,MAAM,QAAQ,CACnB,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAgB,EACtC,SAAiB,EACjB,WAAA,GAAsB,EAAE;AACxB,IAAA,SAAkB,EAClB,OAAoB,EAAA;QAEpB,OAAO,CACL,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAClC;AACE,YAAA,UAAU,EAAEC,kBAAQ,CAAC,GAAG,CAAC;AACzB,YAAA,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;AAC5B,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,MAAM,EAAE,SAAS;SAClB,EACDD,2BAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CACnC,EACD,QAAQ;IACZ;AACD;;;;"}
1
+ {"version":3,"file":"logs.cjs","sources":["../../src/clients/logs.ts"],"sourcesContent":["import type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { notEmpty } from '@milaboratories/ts-helpers';\nimport type { Dispatcher } from 'undici';\nimport type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, createRTypeRoutingHeader, RestAPI } from '@milaboratories/pl-client';\nimport type { StreamingAPI_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';\nimport { StreamingClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client';\nimport type { StreamingApiPaths, StreamingRestClientType } from '../proto-rest';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\n\nexport class ClientLogs {\n public readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider(\n (wire) => {\n if (wire.type === 'grpc') {\n return new StreamingClient(wire.Transport);\n }\n\n return RestAPI.createClient<StreamingApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n if (client instanceof StreamingClient) {\n return (\n await client.lastLines(\n { resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (await client.POST('/v1/last-lines', {\n body: {\n resourceId: rId.toString(),\n lineCount: lineCount,\n offset: offsetBytes.toString(),\n search: searchStr ?? '',\n searchRe: '',\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })).data!;\n\n return {\n data: new Uint8Array(Buffer.from(resp.data)),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n\n if (client instanceof StreamingClient) {\n return (await client.readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (await client.POST('/v1/read/text', {\n body: {\n resourceId: rId.toString(),\n readLimit: lineCount.toString(),\n offset: offsetBytes.toString(),\n search: searchStr ?? '',\n searchRe: '',\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })).data!;\n\n return {\n data: new Uint8Array(Buffer.from(resp.data)),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n}\n"],"names":["StreamingClient","RestAPI","addRTypeToMetadata","createRTypeRoutingHeader","notEmpty"],"mappings":";;;;;;MAWa,UAAU,CAAA;AAKH,IAAA,UAAA;AACA,IAAA,MAAA;AALF,IAAA,IAAI;AAEpB,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB,EAAA;QADhB,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;QAEtB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,wBAAwB,CAC5D,CAAC,IAAI,KAAI;AACP,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;AACxB,gBAAA,OAAO,IAAIA,+BAAe,CAAC,IAAI,CAAC,SAAS,CAAC;YAC5C;YAEA,OAAOC,gBAAO,CAAC,YAAY,CAAoB;AAC7C,gBAAA,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;AACpC,gBAAA,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;gBACpB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;AAC9B,aAAA,CAAC;AACJ,QAAA,CAAC,CAAC;IACN;AAEA,IAAA,KAAK,KAAI;AAET;;AAE0D;AACnD,IAAA,MAAM,SAAS,CACpB,E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Options } from '@protobuf-ts/runtime-rpc';
3
2
  import type { MiLogger } from '@milaboratories/ts-helpers';
4
3
  import type { Dispatcher } from 'undici';
5
- import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
6
- import type { StreamingAPI_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';
4
+ import type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';
5
+ import type { StreamingAPI_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';
6
+ import { StreamingClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client';
7
+ import type { StreamingRestClientType } from '../proto-rest';
7
8
  import type { ResourceInfo } from '@milaboratories/pl-tree';
8
9
  export declare class ClientLogs {
9
10
  readonly httpClient: Dispatcher;
10
11
  readonly logger: MiLogger;
11
- readonly grpcClient: GrpcClientProvider<StreamingClient>;
12
- constructor(grpcClientProviderFactory: GrpcClientProviderFactory, httpClient: Dispatcher, logger: MiLogger);
12
+ readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;
13
+ constructor(wireClientProviderFactory: WireClientProviderFactory, httpClient: Dispatcher, logger: MiLogger);
13
14
  close(): void;
14
15
  /** Reads text back and returns the text,
15
16
  * the new offset
@@ -1 +1 @@
1
- {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/clients/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0FAA0F,CAAC;AAC3H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE/F,OAAO,KAAK,EAAE,qBAAqB,EAAE,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