@milaboratories/pl-drivers 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/constructors.cjs +45 -0
- package/dist/clients/constructors.cjs.map +1 -0
- package/dist/clients/constructors.d.ts +0 -1
- package/dist/clients/constructors.js +39 -0
- package/dist/clients/constructors.js.map +1 -0
- package/dist/clients/download.cjs +149 -0
- package/dist/clients/download.cjs.map +1 -0
- package/dist/clients/download.d.ts +0 -1
- package/dist/clients/download.js +121 -0
- package/dist/clients/download.js.map +1 -0
- package/dist/clients/logs.cjs +44 -0
- package/dist/clients/logs.cjs.map +1 -0
- package/dist/clients/logs.d.ts +0 -1
- package/dist/clients/logs.js +42 -0
- package/dist/clients/logs.js.map +1 -0
- package/dist/clients/ls_api.cjs +23 -0
- package/dist/clients/ls_api.cjs.map +1 -0
- package/dist/clients/ls_api.d.ts +0 -1
- package/dist/clients/ls_api.js +21 -0
- package/dist/clients/ls_api.js.map +1 -0
- package/dist/clients/progress.cjs +58 -0
- package/dist/clients/progress.cjs.map +1 -0
- package/dist/clients/progress.d.ts +1 -3
- package/dist/clients/progress.js +56 -0
- package/dist/clients/progress.js.map +1 -0
- package/dist/clients/upload.cjs +209 -0
- package/dist/clients/upload.cjs.map +1 -0
- package/dist/clients/upload.d.ts +8 -4
- package/dist/clients/upload.js +183 -0
- package/dist/clients/upload.js.map +1 -0
- package/dist/drivers/download_blob/blob_key.cjs +34 -0
- package/dist/drivers/download_blob/blob_key.cjs.map +1 -0
- package/dist/drivers/download_blob/blob_key.d.ts +0 -1
- package/dist/drivers/download_blob/blob_key.js +12 -0
- package/dist/drivers/download_blob/blob_key.js.map +1 -0
- package/dist/drivers/download_blob/download_blob.cjs +442 -0
- package/dist/drivers/download_blob/download_blob.cjs.map +1 -0
- package/dist/drivers/download_blob/download_blob.d.ts +0 -1
- package/dist/drivers/download_blob/download_blob.js +417 -0
- package/dist/drivers/download_blob/download_blob.js.map +1 -0
- package/dist/drivers/download_blob/download_blob_task.cjs +170 -0
- package/dist/drivers/download_blob/download_blob_task.cjs.map +1 -0
- package/dist/drivers/download_blob/download_blob_task.d.ts +0 -1
- package/dist/drivers/download_blob/download_blob_task.js +146 -0
- package/dist/drivers/download_blob/download_blob_task.js.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/cache.cjs +202 -0
- package/dist/drivers/download_blob/sparse_cache/cache.cjs.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts +0 -1
- package/dist/drivers/download_blob/sparse_cache/cache.js +197 -0
- package/dist/drivers/download_blob/sparse_cache/cache.js.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/file.cjs +61 -0
- package/dist/drivers/download_blob/sparse_cache/file.cjs.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/file.d.ts +0 -1
- package/dist/drivers/download_blob/sparse_cache/file.js +39 -0
- package/dist/drivers/download_blob/sparse_cache/file.js.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs +104 -0
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/ranges.d.ts +0 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.js +76 -0
- package/dist/drivers/download_blob/sparse_cache/ranges.js.map +1 -0
- package/dist/drivers/download_blob_url/driver.cjs +169 -0
- package/dist/drivers/download_blob_url/driver.cjs.map +1 -0
- package/dist/drivers/download_blob_url/driver.d.ts +0 -1
- package/dist/drivers/download_blob_url/driver.js +148 -0
- package/dist/drivers/download_blob_url/driver.js.map +1 -0
- package/dist/drivers/download_blob_url/driver_id.cjs +9 -0
- package/dist/drivers/download_blob_url/driver_id.cjs.map +1 -0
- package/dist/drivers/download_blob_url/driver_id.d.ts +0 -1
- package/dist/drivers/download_blob_url/driver_id.js +7 -0
- package/dist/drivers/download_blob_url/driver_id.js.map +1 -0
- package/dist/drivers/download_blob_url/snapshot.cjs +18 -0
- package/dist/drivers/download_blob_url/snapshot.cjs.map +1 -0
- package/dist/drivers/download_blob_url/snapshot.d.ts +2 -3
- package/dist/drivers/download_blob_url/snapshot.js +15 -0
- package/dist/drivers/download_blob_url/snapshot.js.map +1 -0
- package/dist/drivers/download_blob_url/task.cjs +209 -0
- package/dist/drivers/download_blob_url/task.cjs.map +1 -0
- package/dist/drivers/download_blob_url/task.d.ts +0 -1
- package/dist/drivers/download_blob_url/task.js +184 -0
- package/dist/drivers/download_blob_url/task.js.map +1 -0
- package/dist/drivers/download_blob_url/url.d.ts +1 -1
- package/dist/drivers/download_url/driver.cjs +149 -0
- package/dist/drivers/download_url/driver.cjs.map +1 -0
- package/dist/drivers/download_url/driver.d.ts +0 -1
- package/dist/drivers/download_url/driver.js +128 -0
- package/dist/drivers/download_url/driver.js.map +1 -0
- package/dist/drivers/download_url/task.cjs +150 -0
- package/dist/drivers/download_url/task.cjs.map +1 -0
- package/dist/drivers/download_url/task.d.ts +0 -1
- package/dist/drivers/download_url/task.js +124 -0
- package/dist/drivers/download_url/task.js.map +1 -0
- package/dist/drivers/helpers/download_local_handle.cjs +26 -0
- package/dist/drivers/helpers/download_local_handle.cjs.map +1 -0
- package/dist/drivers/helpers/download_local_handle.d.ts +0 -1
- package/dist/drivers/helpers/download_local_handle.js +22 -0
- package/dist/drivers/helpers/download_local_handle.js.map +1 -0
- package/dist/drivers/helpers/download_remote_handle.cjs +36 -0
- package/dist/drivers/helpers/download_remote_handle.cjs.map +1 -0
- package/dist/drivers/helpers/download_remote_handle.d.ts +0 -1
- package/dist/drivers/helpers/download_remote_handle.js +32 -0
- package/dist/drivers/helpers/download_remote_handle.js.map +1 -0
- package/dist/drivers/helpers/files_cache.cjs +68 -0
- package/dist/drivers/helpers/files_cache.cjs.map +1 -0
- package/dist/drivers/helpers/files_cache.d.ts +0 -1
- package/dist/drivers/helpers/files_cache.js +66 -0
- package/dist/drivers/helpers/files_cache.js.map +1 -0
- package/dist/drivers/helpers/helpers.cjs +34 -0
- package/dist/drivers/helpers/helpers.cjs.map +1 -0
- package/dist/drivers/helpers/helpers.d.ts +0 -1
- package/dist/drivers/helpers/helpers.js +31 -0
- package/dist/drivers/helpers/helpers.js.map +1 -0
- package/dist/drivers/helpers/logs_handle.cjs +50 -0
- package/dist/drivers/helpers/logs_handle.cjs.map +1 -0
- package/dist/drivers/helpers/logs_handle.d.ts +0 -1
- package/dist/drivers/helpers/logs_handle.js +43 -0
- package/dist/drivers/helpers/logs_handle.js.map +1 -0
- package/dist/drivers/helpers/ls_remote_import_handle.cjs +34 -0
- package/dist/drivers/helpers/ls_remote_import_handle.cjs.map +1 -0
- package/dist/drivers/helpers/ls_remote_import_handle.d.ts +0 -1
- package/dist/drivers/helpers/ls_remote_import_handle.js +29 -0
- package/dist/drivers/helpers/ls_remote_import_handle.js.map +1 -0
- package/dist/drivers/helpers/ls_storage_entry.cjs +64 -0
- package/dist/drivers/helpers/ls_storage_entry.cjs.map +1 -0
- package/dist/drivers/helpers/ls_storage_entry.d.ts +0 -1
- package/dist/drivers/helpers/ls_storage_entry.js +58 -0
- package/dist/drivers/helpers/ls_storage_entry.js.map +1 -0
- package/dist/drivers/helpers/polling_ops.d.ts +0 -1
- package/dist/drivers/helpers/read_file.cjs +54 -0
- package/dist/drivers/helpers/read_file.cjs.map +1 -0
- package/dist/drivers/helpers/read_file.d.ts +0 -1
- package/dist/drivers/helpers/read_file.js +33 -0
- package/dist/drivers/helpers/read_file.js.map +1 -0
- package/dist/drivers/helpers/test_helpers.d.ts +0 -1
- package/dist/drivers/logs.cjs +118 -0
- package/dist/drivers/logs.cjs.map +1 -0
- package/dist/drivers/logs.d.ts +0 -1
- package/dist/drivers/logs.js +116 -0
- package/dist/drivers/logs.js.map +1 -0
- package/dist/drivers/logs_stream.cjs +238 -0
- package/dist/drivers/logs_stream.cjs.map +1 -0
- package/dist/drivers/logs_stream.d.ts +0 -1
- package/dist/drivers/logs_stream.js +236 -0
- package/dist/drivers/logs_stream.js.map +1 -0
- package/dist/drivers/ls.cjs +236 -0
- package/dist/drivers/ls.cjs.map +1 -0
- package/dist/drivers/ls.d.ts +0 -1
- package/dist/drivers/ls.js +214 -0
- package/dist/drivers/ls.js.map +1 -0
- package/dist/drivers/types.cjs +72 -0
- package/dist/drivers/types.cjs.map +1 -0
- package/dist/drivers/types.d.ts +4 -5
- package/dist/drivers/types.js +64 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/drivers/upload.cjs +154 -0
- package/dist/drivers/upload.cjs.map +1 -0
- package/dist/drivers/upload.d.ts +0 -1
- package/dist/drivers/upload.js +151 -0
- package/dist/drivers/upload.js.map +1 -0
- package/dist/drivers/upload_task.cjs +297 -0
- package/dist/drivers/upload_task.cjs.map +1 -0
- package/dist/drivers/upload_task.d.ts +2 -3
- package/dist/drivers/upload_task.js +289 -0
- package/dist/drivers/upload_task.js.map +1 -0
- package/dist/drivers/urls/url.cjs +59 -0
- package/dist/drivers/urls/url.cjs.map +1 -0
- package/dist/drivers/urls/url.d.ts +0 -1
- package/dist/drivers/urls/url.js +54 -0
- package/dist/drivers/urls/url.js.map +1 -0
- package/dist/drivers/virtual_storages.cjs +53 -0
- package/dist/drivers/virtual_storages.cjs.map +1 -0
- package/dist/drivers/virtual_storages.d.ts +0 -1
- package/dist/drivers/virtual_storages.js +51 -0
- package/dist/drivers/virtual_storages.js.map +1 -0
- package/dist/helpers/download.cjs +63 -0
- package/dist/helpers/download.cjs.map +1 -0
- package/dist/helpers/download.d.ts +0 -1
- package/dist/helpers/download.js +60 -0
- package/dist/helpers/download.js.map +1 -0
- package/dist/helpers/validate.cjs +12 -0
- package/dist/helpers/validate.cjs.map +1 -0
- package/dist/helpers/validate.d.ts +0 -1
- package/dist/helpers/validate.js +10 -0
- package/dist/helpers/validate.js.map +1 -0
- package/dist/index.cjs +73 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs +261 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs +31 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js +29 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js +256 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs +301 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs +34 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js +32 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js +296 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs +410 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs +38 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js +36 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js +403 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs +486 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs +86 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js +84 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js +478 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs +758 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs +71 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js +69 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts +36 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js +747 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +3 -5
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +0 -1
- package/dist/proto/google/api/http.d.ts +0 -1
- package/dist/proto/google/protobuf/any.d.ts +0 -1
- package/dist/proto/google/protobuf/descriptor.d.ts +0 -1
- package/dist/proto/google/protobuf/duration.cjs +105 -0
- package/dist/proto/google/protobuf/duration.cjs.map +1 -0
- package/dist/proto/google/protobuf/duration.d.ts +0 -1
- package/dist/proto/google/protobuf/duration.js +103 -0
- package/dist/proto/google/protobuf/duration.js.map +1 -0
- package/dist/proto/google/protobuf/empty.d.ts +0 -1
- package/dist/proto/google/protobuf/struct.d.ts +0 -1
- package/dist/proto/google/protobuf/timestamp.cjs +133 -0
- package/dist/proto/google/protobuf/timestamp.cjs.map +1 -0
- package/dist/proto/google/protobuf/timestamp.d.ts +0 -1
- package/dist/proto/google/protobuf/timestamp.js +131 -0
- package/dist/proto/google/protobuf/timestamp.js.map +1 -0
- package/dist/proto/google/protobuf/wrappers.d.ts +0 -1
- package/dist/test_env.d.ts +0 -1
- package/package.json +17 -15
- package/src/clients/upload.ts +38 -14
- package/src/drivers/upload_task.ts +10 -3
- package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.ts +69 -1
- package/dist/clients/constructors.d.ts.map +0 -1
- package/dist/clients/download.d.ts.map +0 -1
- package/dist/clients/logs.d.ts.map +0 -1
- package/dist/clients/ls_api.d.ts.map +0 -1
- package/dist/clients/progress.d.ts.map +0 -1
- package/dist/clients/upload.d.ts.map +0 -1
- package/dist/drivers/download_blob/blob_key.d.ts.map +0 -1
- package/dist/drivers/download_blob/download_blob.d.ts.map +0 -1
- package/dist/drivers/download_blob/download_blob_task.d.ts.map +0 -1
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts.map +0 -1
- package/dist/drivers/download_blob/sparse_cache/file.d.ts.map +0 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.d.ts.map +0 -1
- package/dist/drivers/download_blob_url/driver.d.ts.map +0 -1
- package/dist/drivers/download_blob_url/driver_id.d.ts.map +0 -1
- package/dist/drivers/download_blob_url/snapshot.d.ts.map +0 -1
- package/dist/drivers/download_blob_url/task.d.ts.map +0 -1
- package/dist/drivers/download_blob_url/url.d.ts.map +0 -1
- package/dist/drivers/download_url/driver.d.ts.map +0 -1
- package/dist/drivers/download_url/task.d.ts.map +0 -1
- package/dist/drivers/helpers/download_local_handle.d.ts.map +0 -1
- package/dist/drivers/helpers/download_remote_handle.d.ts.map +0 -1
- package/dist/drivers/helpers/files_cache.d.ts.map +0 -1
- package/dist/drivers/helpers/helpers.d.ts.map +0 -1
- package/dist/drivers/helpers/logs_handle.d.ts.map +0 -1
- package/dist/drivers/helpers/ls_remote_import_handle.d.ts.map +0 -1
- package/dist/drivers/helpers/ls_storage_entry.d.ts.map +0 -1
- package/dist/drivers/helpers/polling_ops.d.ts.map +0 -1
- package/dist/drivers/helpers/read_file.d.ts.map +0 -1
- package/dist/drivers/helpers/test_helpers.d.ts.map +0 -1
- package/dist/drivers/logs.d.ts.map +0 -1
- package/dist/drivers/logs_stream.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/types.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/upload_task.d.ts.map +0 -1
- package/dist/drivers/urls/url.d.ts.map +0 -1
- package/dist/drivers/virtual_storages.d.ts.map +0 -1
- package/dist/helpers/download.d.ts.map +0 -1
- package/dist/helpers/validate.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -4892
- package/dist/index.mjs.map +0 -1
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
- package/dist/proto/google/api/http.d.ts.map +0 -1
- package/dist/proto/google/protobuf/any.d.ts.map +0 -1
- package/dist/proto/google/protobuf/descriptor.d.ts.map +0 -1
- package/dist/proto/google/protobuf/duration.d.ts.map +0 -1
- package/dist/proto/google/protobuf/empty.d.ts.map +0 -1
- package/dist/proto/google/protobuf/struct.d.ts.map +0 -1
- package/dist/proto/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/proto/google/protobuf/wrappers.d.ts.map +0 -1
- package/dist/test_env.d.ts.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,4892 +0,0 @@
|
|
|
1
|
-
var Ut = Object.defineProperty;
|
|
2
|
-
var Pt = (s, e, t) => e in s ? Ut(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var h = (s, e, t) => Pt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { addRTypeToMetadata as $, stringifyWithResourceId as y, bigintToResourceId as Pe, resourceIdToString as P, isNotNullResourceId as Rt } from "@milaboratories/pl-client";
|
|
5
|
-
import * as w from "node:fs/promises";
|
|
6
|
-
import { request as Ae } from "undici";
|
|
7
|
-
import { ServiceType as x, stackIntercept as R } from "@protobuf-ts/runtime-rpc";
|
|
8
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as p, PbLong as I, typeofJsonValue as Me, assertNever as Nt } from "@protobuf-ts/runtime";
|
|
9
|
-
import { notEmpty as K, ConcurrencyLimitingExecutor as He, CallersCounter as B, ensureDirExists as W, fileExists as A, createPathAtomically as X, mapGet as me, mapEntries as je, spawnAsync as $t, TaskProcessor as Y, asyncPool as Re, assertNever as St } from "@milaboratories/ts-helpers";
|
|
10
|
-
import * as Ne from "node:fs";
|
|
11
|
-
import ye, { promises as be } from "node:fs";
|
|
12
|
-
import * as T from "node:path";
|
|
13
|
-
import U from "node:path";
|
|
14
|
-
import { Readable as Ge, Writable as z, Transform as Ve } from "node:stream";
|
|
15
|
-
import { text as It, buffer as qe } from "node:stream/consumers";
|
|
16
|
-
import { ChangeSource as C, Computable as b, PollingComputableHooks as Je } from "@milaboratories/computable";
|
|
17
|
-
import { RangeBytes as Dt, validateRangeBytes as Be, isFolderURL as vt, isBlockUIURL as Bt, isImportFileHandleIndex as Ct } from "@milaboratories/pl-model-common";
|
|
18
|
-
import { rsSchema as ee, treeEntryToResourceInfo as D, isPlTreeEntry as M, makeResourceSnapshot as J, isPlTreeEntryAccessor as Ze } from "@milaboratories/pl-tree";
|
|
19
|
-
import Et from "denque";
|
|
20
|
-
import { randomUUID as S, createHash as _t } from "node:crypto";
|
|
21
|
-
import * as Ce from "node:os";
|
|
22
|
-
import Ft from "node:os";
|
|
23
|
-
import * as Ot from "node:readline/promises";
|
|
24
|
-
import { z as L } from "zod";
|
|
25
|
-
import { functions as zt } from "@milaboratories/helpers";
|
|
26
|
-
import * as Qe from "node:zlib";
|
|
27
|
-
import * as ke from "tar-fs";
|
|
28
|
-
import Wt from "decompress";
|
|
29
|
-
import { scheduler as Ke } from "node:timers/promises";
|
|
30
|
-
import xt from "node:assert";
|
|
31
|
-
import At from "node:util";
|
|
32
|
-
import { exec as Mt } from "node:child_process";
|
|
33
|
-
class Ht extends g {
|
|
34
|
-
constructor() {
|
|
35
|
-
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
36
|
-
}
|
|
37
|
-
create(e) {
|
|
38
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
39
|
-
return e !== void 0 && f(this, t, e), t;
|
|
40
|
-
}
|
|
41
|
-
internalBinaryRead(e, t, r, n) {
|
|
42
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
43
|
-
for (; e.pos < c; ) {
|
|
44
|
-
let [i, l] = e.tag();
|
|
45
|
-
switch (i) {
|
|
46
|
-
default:
|
|
47
|
-
let a = r.readUnknownField;
|
|
48
|
-
if (a === "throw")
|
|
49
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
50
|
-
let d = e.skip(l);
|
|
51
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return o;
|
|
55
|
-
}
|
|
56
|
-
internalBinaryWrite(e, t, r) {
|
|
57
|
-
let n = r.writeUnknownFields;
|
|
58
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
new Ht();
|
|
62
|
-
class jt extends g {
|
|
63
|
-
constructor() {
|
|
64
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
65
|
-
}
|
|
66
|
-
create(e) {
|
|
67
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
68
|
-
return e !== void 0 && f(this, t, e), t;
|
|
69
|
-
}
|
|
70
|
-
internalBinaryRead(e, t, r, n) {
|
|
71
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
72
|
-
for (; e.pos < c; ) {
|
|
73
|
-
let [i, l] = e.tag();
|
|
74
|
-
switch (i) {
|
|
75
|
-
default:
|
|
76
|
-
let a = r.readUnknownField;
|
|
77
|
-
if (a === "throw")
|
|
78
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
79
|
-
let d = e.skip(l);
|
|
80
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return o;
|
|
84
|
-
}
|
|
85
|
-
internalBinaryWrite(e, t, r) {
|
|
86
|
-
let n = r.writeUnknownFields;
|
|
87
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
new jt();
|
|
91
|
-
class Gt extends g {
|
|
92
|
-
constructor() {
|
|
93
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
94
|
-
{
|
|
95
|
-
no: 1,
|
|
96
|
-
name: "resource_id",
|
|
97
|
-
kind: "scalar",
|
|
98
|
-
T: 4,
|
|
99
|
-
L: 0
|
|
100
|
-
/*LongType.BIGINT*/
|
|
101
|
-
}
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
create(e) {
|
|
105
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
106
|
-
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
107
|
-
}
|
|
108
|
-
internalBinaryRead(e, t, r, n) {
|
|
109
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
110
|
-
for (; e.pos < c; ) {
|
|
111
|
-
let [i, l] = e.tag();
|
|
112
|
-
switch (i) {
|
|
113
|
-
case /* uint64 resource_id */
|
|
114
|
-
1:
|
|
115
|
-
o.resourceId = e.uint64().toBigInt();
|
|
116
|
-
break;
|
|
117
|
-
default:
|
|
118
|
-
let a = r.readUnknownField;
|
|
119
|
-
if (a === "throw")
|
|
120
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
121
|
-
let d = e.skip(l);
|
|
122
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return o;
|
|
126
|
-
}
|
|
127
|
-
internalBinaryWrite(e, t, r) {
|
|
128
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId);
|
|
129
|
-
let n = r.writeUnknownFields;
|
|
130
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const Vt = new Gt();
|
|
134
|
-
class qt extends g {
|
|
135
|
-
constructor() {
|
|
136
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
137
|
-
{
|
|
138
|
-
no: 1,
|
|
139
|
-
name: "parts_count",
|
|
140
|
-
kind: "scalar",
|
|
141
|
-
T: 4,
|
|
142
|
-
L: 0
|
|
143
|
-
/*LongType.BIGINT*/
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
no: 2,
|
|
147
|
-
name: "uploaded_parts",
|
|
148
|
-
kind: "scalar",
|
|
149
|
-
repeat: 1,
|
|
150
|
-
T: 4,
|
|
151
|
-
L: 0
|
|
152
|
-
/*LongType.BIGINT*/
|
|
153
|
-
}
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
create(e) {
|
|
157
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
158
|
-
return t.partsCount = 0n, t.uploadedParts = [], e !== void 0 && f(this, t, e), t;
|
|
159
|
-
}
|
|
160
|
-
internalBinaryRead(e, t, r, n) {
|
|
161
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
162
|
-
for (; e.pos < c; ) {
|
|
163
|
-
let [i, l] = e.tag();
|
|
164
|
-
switch (i) {
|
|
165
|
-
case /* uint64 parts_count */
|
|
166
|
-
1:
|
|
167
|
-
o.partsCount = e.uint64().toBigInt();
|
|
168
|
-
break;
|
|
169
|
-
case /* repeated uint64 uploaded_parts */
|
|
170
|
-
2:
|
|
171
|
-
if (l === p.LengthDelimited)
|
|
172
|
-
for (let N = e.int32() + e.pos; e.pos < N; )
|
|
173
|
-
o.uploadedParts.push(e.uint64().toBigInt());
|
|
174
|
-
else
|
|
175
|
-
o.uploadedParts.push(e.uint64().toBigInt());
|
|
176
|
-
break;
|
|
177
|
-
default:
|
|
178
|
-
let a = r.readUnknownField;
|
|
179
|
-
if (a === "throw")
|
|
180
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
181
|
-
let d = e.skip(l);
|
|
182
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return o;
|
|
186
|
-
}
|
|
187
|
-
internalBinaryWrite(e, t, r) {
|
|
188
|
-
if (e.partsCount !== 0n && t.tag(1, p.Varint).uint64(e.partsCount), e.uploadedParts.length) {
|
|
189
|
-
t.tag(2, p.LengthDelimited).fork();
|
|
190
|
-
for (let o = 0; o < e.uploadedParts.length; o++)
|
|
191
|
-
t.uint64(e.uploadedParts[o]);
|
|
192
|
-
t.join();
|
|
193
|
-
}
|
|
194
|
-
let n = r.writeUnknownFields;
|
|
195
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const Jt = new qt();
|
|
199
|
-
class Zt extends g {
|
|
200
|
-
constructor() {
|
|
201
|
-
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
202
|
-
}
|
|
203
|
-
create(e) {
|
|
204
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
205
|
-
return e !== void 0 && f(this, t, e), t;
|
|
206
|
-
}
|
|
207
|
-
internalBinaryRead(e, t, r, n) {
|
|
208
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
209
|
-
for (; e.pos < c; ) {
|
|
210
|
-
let [i, l] = e.tag();
|
|
211
|
-
switch (i) {
|
|
212
|
-
default:
|
|
213
|
-
let a = r.readUnknownField;
|
|
214
|
-
if (a === "throw")
|
|
215
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
216
|
-
let d = e.skip(l);
|
|
217
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return o;
|
|
221
|
-
}
|
|
222
|
-
internalBinaryWrite(e, t, r) {
|
|
223
|
-
let n = r.writeUnknownFields;
|
|
224
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
new Zt();
|
|
228
|
-
class Qt extends g {
|
|
229
|
-
constructor() {
|
|
230
|
-
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
231
|
-
{
|
|
232
|
-
no: 1,
|
|
233
|
-
name: "resource_id",
|
|
234
|
-
kind: "scalar",
|
|
235
|
-
T: 4,
|
|
236
|
-
L: 0
|
|
237
|
-
/*LongType.BIGINT*/
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
no: 2,
|
|
241
|
-
name: "bytes_processed",
|
|
242
|
-
kind: "scalar",
|
|
243
|
-
T: 3,
|
|
244
|
-
L: 0
|
|
245
|
-
/*LongType.BIGINT*/
|
|
246
|
-
}
|
|
247
|
-
]);
|
|
248
|
-
}
|
|
249
|
-
create(e) {
|
|
250
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
251
|
-
return t.resourceId = 0n, t.bytesProcessed = 0n, e !== void 0 && f(this, t, e), t;
|
|
252
|
-
}
|
|
253
|
-
internalBinaryRead(e, t, r, n) {
|
|
254
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
255
|
-
for (; e.pos < c; ) {
|
|
256
|
-
let [i, l] = e.tag();
|
|
257
|
-
switch (i) {
|
|
258
|
-
case /* uint64 resource_id */
|
|
259
|
-
1:
|
|
260
|
-
o.resourceId = e.uint64().toBigInt();
|
|
261
|
-
break;
|
|
262
|
-
case /* int64 bytes_processed */
|
|
263
|
-
2:
|
|
264
|
-
o.bytesProcessed = e.int64().toBigInt();
|
|
265
|
-
break;
|
|
266
|
-
default:
|
|
267
|
-
let a = r.readUnknownField;
|
|
268
|
-
if (a === "throw")
|
|
269
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
270
|
-
let d = e.skip(l);
|
|
271
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return o;
|
|
275
|
-
}
|
|
276
|
-
internalBinaryWrite(e, t, r) {
|
|
277
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.bytesProcessed !== 0n && t.tag(2, p.Varint).int64(e.bytesProcessed);
|
|
278
|
-
let n = r.writeUnknownFields;
|
|
279
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
const Kt = new Qt();
|
|
283
|
-
class Xt extends g {
|
|
284
|
-
constructor() {
|
|
285
|
-
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response", []);
|
|
286
|
-
}
|
|
287
|
-
create(e) {
|
|
288
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
289
|
-
return e !== void 0 && f(this, t, e), t;
|
|
290
|
-
}
|
|
291
|
-
internalBinaryRead(e, t, r, n) {
|
|
292
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
293
|
-
for (; e.pos < c; ) {
|
|
294
|
-
let [i, l] = e.tag();
|
|
295
|
-
switch (i) {
|
|
296
|
-
default:
|
|
297
|
-
let a = r.readUnknownField;
|
|
298
|
-
if (a === "throw")
|
|
299
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
300
|
-
let d = e.skip(l);
|
|
301
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return o;
|
|
305
|
-
}
|
|
306
|
-
internalBinaryWrite(e, t, r) {
|
|
307
|
-
let n = r.writeUnknownFields;
|
|
308
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
const Yt = new Xt();
|
|
312
|
-
class er extends g {
|
|
313
|
-
constructor() {
|
|
314
|
-
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
315
|
-
}
|
|
316
|
-
create(e) {
|
|
317
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
318
|
-
return e !== void 0 && f(this, t, e), t;
|
|
319
|
-
}
|
|
320
|
-
internalBinaryRead(e, t, r, n) {
|
|
321
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
322
|
-
for (; e.pos < c; ) {
|
|
323
|
-
let [i, l] = e.tag();
|
|
324
|
-
switch (i) {
|
|
325
|
-
default:
|
|
326
|
-
let a = r.readUnknownField;
|
|
327
|
-
if (a === "throw")
|
|
328
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
329
|
-
let d = e.skip(l);
|
|
330
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return o;
|
|
334
|
-
}
|
|
335
|
-
internalBinaryWrite(e, t, r) {
|
|
336
|
-
let n = r.writeUnknownFields;
|
|
337
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
new er();
|
|
341
|
-
class tr extends g {
|
|
342
|
-
constructor() {
|
|
343
|
-
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
344
|
-
{
|
|
345
|
-
no: 1,
|
|
346
|
-
name: "resource_id",
|
|
347
|
-
kind: "scalar",
|
|
348
|
-
T: 4,
|
|
349
|
-
L: 0
|
|
350
|
-
/*LongType.BIGINT*/
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
no: 2,
|
|
354
|
-
name: "part_number",
|
|
355
|
-
kind: "scalar",
|
|
356
|
-
T: 4,
|
|
357
|
-
L: 0
|
|
358
|
-
/*LongType.BIGINT*/
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
no: 3,
|
|
362
|
-
name: "uploaded_part_size",
|
|
363
|
-
kind: "scalar",
|
|
364
|
-
T: 4,
|
|
365
|
-
L: 0
|
|
366
|
-
/*LongType.BIGINT*/
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
no: 4,
|
|
370
|
-
name: "is_internal_use",
|
|
371
|
-
kind: "scalar",
|
|
372
|
-
T: 8
|
|
373
|
-
/*ScalarType.BOOL*/
|
|
374
|
-
}
|
|
375
|
-
]);
|
|
376
|
-
}
|
|
377
|
-
create(e) {
|
|
378
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
379
|
-
return t.resourceId = 0n, t.partNumber = 0n, t.uploadedPartSize = 0n, t.isInternalUse = !1, e !== void 0 && f(this, t, e), t;
|
|
380
|
-
}
|
|
381
|
-
internalBinaryRead(e, t, r, n) {
|
|
382
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
383
|
-
for (; e.pos < c; ) {
|
|
384
|
-
let [i, l] = e.tag();
|
|
385
|
-
switch (i) {
|
|
386
|
-
case /* uint64 resource_id */
|
|
387
|
-
1:
|
|
388
|
-
o.resourceId = e.uint64().toBigInt();
|
|
389
|
-
break;
|
|
390
|
-
case /* uint64 part_number */
|
|
391
|
-
2:
|
|
392
|
-
o.partNumber = e.uint64().toBigInt();
|
|
393
|
-
break;
|
|
394
|
-
case /* uint64 uploaded_part_size */
|
|
395
|
-
3:
|
|
396
|
-
o.uploadedPartSize = e.uint64().toBigInt();
|
|
397
|
-
break;
|
|
398
|
-
case /* bool is_internal_use */
|
|
399
|
-
4:
|
|
400
|
-
o.isInternalUse = e.bool();
|
|
401
|
-
break;
|
|
402
|
-
default:
|
|
403
|
-
let a = r.readUnknownField;
|
|
404
|
-
if (a === "throw")
|
|
405
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
406
|
-
let d = e.skip(l);
|
|
407
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return o;
|
|
411
|
-
}
|
|
412
|
-
internalBinaryWrite(e, t, r) {
|
|
413
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.partNumber !== 0n && t.tag(2, p.Varint).uint64(e.partNumber), e.uploadedPartSize !== 0n && t.tag(3, p.Varint).uint64(e.uploadedPartSize), e.isInternalUse !== !1 && t.tag(4, p.Varint).bool(e.isInternalUse);
|
|
414
|
-
let n = r.writeUnknownFields;
|
|
415
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
const rr = new tr();
|
|
419
|
-
class nr extends g {
|
|
420
|
-
constructor() {
|
|
421
|
-
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
422
|
-
{
|
|
423
|
-
no: 1,
|
|
424
|
-
name: "Name",
|
|
425
|
-
kind: "scalar",
|
|
426
|
-
jsonName: "Name",
|
|
427
|
-
T: 9
|
|
428
|
-
/*ScalarType.STRING*/
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
no: 2,
|
|
432
|
-
name: "Value",
|
|
433
|
-
kind: "scalar",
|
|
434
|
-
jsonName: "Value",
|
|
435
|
-
T: 9
|
|
436
|
-
/*ScalarType.STRING*/
|
|
437
|
-
}
|
|
438
|
-
]);
|
|
439
|
-
}
|
|
440
|
-
create(e) {
|
|
441
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
442
|
-
return t.name = "", t.value = "", e !== void 0 && f(this, t, e), t;
|
|
443
|
-
}
|
|
444
|
-
internalBinaryRead(e, t, r, n) {
|
|
445
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
446
|
-
for (; e.pos < c; ) {
|
|
447
|
-
let [i, l] = e.tag();
|
|
448
|
-
switch (i) {
|
|
449
|
-
case /* string Name */
|
|
450
|
-
1:
|
|
451
|
-
o.name = e.string();
|
|
452
|
-
break;
|
|
453
|
-
case /* string Value */
|
|
454
|
-
2:
|
|
455
|
-
o.value = e.string();
|
|
456
|
-
break;
|
|
457
|
-
default:
|
|
458
|
-
let a = r.readUnknownField;
|
|
459
|
-
if (a === "throw")
|
|
460
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
461
|
-
let d = e.skip(l);
|
|
462
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return o;
|
|
466
|
-
}
|
|
467
|
-
internalBinaryWrite(e, t, r) {
|
|
468
|
-
e.name !== "" && t.tag(1, p.LengthDelimited).string(e.name), e.value !== "" && t.tag(2, p.LengthDelimited).string(e.value);
|
|
469
|
-
let n = r.writeUnknownFields;
|
|
470
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
const oe = new nr();
|
|
474
|
-
class or extends g {
|
|
475
|
-
constructor() {
|
|
476
|
-
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
477
|
-
{
|
|
478
|
-
no: 1,
|
|
479
|
-
name: "upload_url",
|
|
480
|
-
kind: "scalar",
|
|
481
|
-
T: 9
|
|
482
|
-
/*ScalarType.STRING*/
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
no: 2,
|
|
486
|
-
name: "method",
|
|
487
|
-
kind: "scalar",
|
|
488
|
-
T: 9
|
|
489
|
-
/*ScalarType.STRING*/
|
|
490
|
-
},
|
|
491
|
-
{ no: 3, name: "headers", kind: "message", repeat: 2, T: () => oe },
|
|
492
|
-
{
|
|
493
|
-
no: 4,
|
|
494
|
-
name: "chunk_start",
|
|
495
|
-
kind: "scalar",
|
|
496
|
-
T: 4,
|
|
497
|
-
L: 0
|
|
498
|
-
/*LongType.BIGINT*/
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
no: 5,
|
|
502
|
-
name: "chunk_end",
|
|
503
|
-
kind: "scalar",
|
|
504
|
-
T: 4,
|
|
505
|
-
L: 0
|
|
506
|
-
/*LongType.BIGINT*/
|
|
507
|
-
}
|
|
508
|
-
]);
|
|
509
|
-
}
|
|
510
|
-
create(e) {
|
|
511
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
512
|
-
return t.uploadUrl = "", t.method = "", t.headers = [], t.chunkStart = 0n, t.chunkEnd = 0n, e !== void 0 && f(this, t, e), t;
|
|
513
|
-
}
|
|
514
|
-
internalBinaryRead(e, t, r, n) {
|
|
515
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
516
|
-
for (; e.pos < c; ) {
|
|
517
|
-
let [i, l] = e.tag();
|
|
518
|
-
switch (i) {
|
|
519
|
-
case /* string upload_url */
|
|
520
|
-
1:
|
|
521
|
-
o.uploadUrl = e.string();
|
|
522
|
-
break;
|
|
523
|
-
case /* string method */
|
|
524
|
-
2:
|
|
525
|
-
o.method = e.string();
|
|
526
|
-
break;
|
|
527
|
-
case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
|
|
528
|
-
3:
|
|
529
|
-
o.headers.push(oe.internalBinaryRead(e, e.uint32(), r));
|
|
530
|
-
break;
|
|
531
|
-
case /* uint64 chunk_start */
|
|
532
|
-
4:
|
|
533
|
-
o.chunkStart = e.uint64().toBigInt();
|
|
534
|
-
break;
|
|
535
|
-
case /* uint64 chunk_end */
|
|
536
|
-
5:
|
|
537
|
-
o.chunkEnd = e.uint64().toBigInt();
|
|
538
|
-
break;
|
|
539
|
-
default:
|
|
540
|
-
let a = r.readUnknownField;
|
|
541
|
-
if (a === "throw")
|
|
542
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
543
|
-
let d = e.skip(l);
|
|
544
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return o;
|
|
548
|
-
}
|
|
549
|
-
internalBinaryWrite(e, t, r) {
|
|
550
|
-
e.uploadUrl !== "" && t.tag(1, p.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, p.LengthDelimited).string(e.method);
|
|
551
|
-
for (let o = 0; o < e.headers.length; o++)
|
|
552
|
-
oe.internalBinaryWrite(e.headers[o], t.tag(3, p.LengthDelimited).fork(), r).join();
|
|
553
|
-
e.chunkStart !== 0n && t.tag(4, p.Varint).uint64(e.chunkStart), e.chunkEnd !== 0n && t.tag(5, p.Varint).uint64(e.chunkEnd);
|
|
554
|
-
let n = r.writeUnknownFields;
|
|
555
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
const sr = new or();
|
|
559
|
-
class ir extends g {
|
|
560
|
-
constructor() {
|
|
561
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
562
|
-
}
|
|
563
|
-
create(e) {
|
|
564
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
565
|
-
return e !== void 0 && f(this, t, e), t;
|
|
566
|
-
}
|
|
567
|
-
internalBinaryRead(e, t, r, n) {
|
|
568
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
569
|
-
for (; e.pos < c; ) {
|
|
570
|
-
let [i, l] = e.tag();
|
|
571
|
-
switch (i) {
|
|
572
|
-
default:
|
|
573
|
-
let a = r.readUnknownField;
|
|
574
|
-
if (a === "throw")
|
|
575
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
576
|
-
let d = e.skip(l);
|
|
577
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
return o;
|
|
581
|
-
}
|
|
582
|
-
internalBinaryWrite(e, t, r) {
|
|
583
|
-
let n = r.writeUnknownFields;
|
|
584
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
new ir();
|
|
588
|
-
class ar extends g {
|
|
589
|
-
constructor() {
|
|
590
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
591
|
-
{
|
|
592
|
-
no: 1,
|
|
593
|
-
name: "resource_id",
|
|
594
|
-
kind: "scalar",
|
|
595
|
-
T: 4,
|
|
596
|
-
L: 0
|
|
597
|
-
/*LongType.BIGINT*/
|
|
598
|
-
}
|
|
599
|
-
]);
|
|
600
|
-
}
|
|
601
|
-
create(e) {
|
|
602
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
603
|
-
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
604
|
-
}
|
|
605
|
-
internalBinaryRead(e, t, r, n) {
|
|
606
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
607
|
-
for (; e.pos < c; ) {
|
|
608
|
-
let [i, l] = e.tag();
|
|
609
|
-
switch (i) {
|
|
610
|
-
case /* uint64 resource_id */
|
|
611
|
-
1:
|
|
612
|
-
o.resourceId = e.uint64().toBigInt();
|
|
613
|
-
break;
|
|
614
|
-
default:
|
|
615
|
-
let a = r.readUnknownField;
|
|
616
|
-
if (a === "throw")
|
|
617
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
618
|
-
let d = e.skip(l);
|
|
619
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return o;
|
|
623
|
-
}
|
|
624
|
-
internalBinaryWrite(e, t, r) {
|
|
625
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId);
|
|
626
|
-
let n = r.writeUnknownFields;
|
|
627
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
const lr = new ar();
|
|
631
|
-
class cr extends g {
|
|
632
|
-
constructor() {
|
|
633
|
-
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
634
|
-
}
|
|
635
|
-
create(e) {
|
|
636
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
637
|
-
return e !== void 0 && f(this, t, e), t;
|
|
638
|
-
}
|
|
639
|
-
internalBinaryRead(e, t, r, n) {
|
|
640
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
641
|
-
for (; e.pos < c; ) {
|
|
642
|
-
let [i, l] = e.tag();
|
|
643
|
-
switch (i) {
|
|
644
|
-
default:
|
|
645
|
-
let a = r.readUnknownField;
|
|
646
|
-
if (a === "throw")
|
|
647
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
648
|
-
let d = e.skip(l);
|
|
649
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return o;
|
|
653
|
-
}
|
|
654
|
-
internalBinaryWrite(e, t, r) {
|
|
655
|
-
let n = r.writeUnknownFields;
|
|
656
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
const hr = new cr(), se = new x("MiLaboratories.Controller.Shared.Upload", [
|
|
660
|
-
{ name: "Init", options: {}, I: Vt, O: Jt },
|
|
661
|
-
{ name: "GetPartURL", options: {}, I: rr, O: sr },
|
|
662
|
-
{ name: "UpdateProgress", options: {}, I: Kt, O: Yt },
|
|
663
|
-
{ name: "Finalize", options: {}, I: lr, O: hr }
|
|
664
|
-
]);
|
|
665
|
-
class dr {
|
|
666
|
-
constructor(e) {
|
|
667
|
-
h(this, "typeName", se.typeName);
|
|
668
|
-
h(this, "methods", se.methods);
|
|
669
|
-
h(this, "options", se.options);
|
|
670
|
-
this._transport = e;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
*
|
|
674
|
-
* Init upload, making controller to do all required preparation steps.
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* @generated from protobuf rpc: Init
|
|
678
|
-
*/
|
|
679
|
-
init(e, t) {
|
|
680
|
-
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
681
|
-
return R("unary", this._transport, r, n, e);
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
*
|
|
685
|
-
* GetPartURL provides URL for uploading chunk of the data.
|
|
686
|
-
* Clients are expected to put their data directly to the given location.
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
* @generated from protobuf rpc: GetPartURL
|
|
690
|
-
*/
|
|
691
|
-
getPartURL(e, t) {
|
|
692
|
-
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
693
|
-
return R("unary", this._transport, r, n, e);
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
*
|
|
697
|
-
* UpdateProgress of the upload, so other clients can see how it is going.
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
* @generated from protobuf rpc: UpdateProgress
|
|
701
|
-
*/
|
|
702
|
-
updateProgress(e, t) {
|
|
703
|
-
const r = this.methods[2], n = this._transport.mergeOptions(t);
|
|
704
|
-
return R("unary", this._transport, r, n, e);
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
*
|
|
708
|
-
* Finalize informs Controller that the upload process is done.
|
|
709
|
-
* Returns an error, if the total size of all uploaded chunks is not equal to
|
|
710
|
-
* size of the upload given in Init.
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* @generated from protobuf rpc: Finalize
|
|
714
|
-
*/
|
|
715
|
-
finalize(e, t) {
|
|
716
|
-
const r = this.methods[3], n = this._transport.mergeOptions(t);
|
|
717
|
-
return R("unary", this._transport, r, n, e);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
class Xe extends Error {
|
|
721
|
-
constructor() {
|
|
722
|
-
super(...arguments);
|
|
723
|
-
h(this, "name", "MTimeError");
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
class Ye extends Error {
|
|
727
|
-
constructor() {
|
|
728
|
-
super(...arguments);
|
|
729
|
-
h(this, "name", "UnexpectedEOF");
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
class et extends Error {
|
|
733
|
-
constructor() {
|
|
734
|
-
super(...arguments);
|
|
735
|
-
h(this, "name", "NetworkError");
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
class tt extends Error {
|
|
739
|
-
constructor() {
|
|
740
|
-
super(...arguments);
|
|
741
|
-
h(this, "name", "NoFileForUploading");
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
class ur {
|
|
745
|
-
constructor(e, t, r, n) {
|
|
746
|
-
h(this, "grpcClient");
|
|
747
|
-
this.httpClient = t, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new dr(o));
|
|
748
|
-
}
|
|
749
|
-
close() {
|
|
750
|
-
}
|
|
751
|
-
async initUpload({ id: e, type: t }, r) {
|
|
752
|
-
const n = await this.grpcInit(e, t, r);
|
|
753
|
-
return {
|
|
754
|
-
overall: n.partsCount,
|
|
755
|
-
toUpload: this.partsToUpload(n.partsCount, n.uploadedParts)
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
async partUpload({ id: e, type: t }, r, n, o, c) {
|
|
759
|
-
const i = await this.grpcGetPartUrl(
|
|
760
|
-
{ id: e, type: t },
|
|
761
|
-
o,
|
|
762
|
-
0n,
|
|
763
|
-
// we update progress as a separate call later.
|
|
764
|
-
c
|
|
765
|
-
), l = await pr(r, i.chunkStart, i.chunkEnd);
|
|
766
|
-
await fr(r, n);
|
|
767
|
-
const a = Number(i.chunkEnd - i.chunkStart);
|
|
768
|
-
if (l.length !== a)
|
|
769
|
-
throw new Error(
|
|
770
|
-
`Chunk size mismatch: expected ${a} bytes, but read ${l.length} bytes from file`
|
|
771
|
-
);
|
|
772
|
-
const d = Object.fromEntries(i.headers.map(({ name: m, value: E }) => [m, E])), N = Object.keys(d).find((m) => m.toLowerCase() === "content-length");
|
|
773
|
-
if (N) {
|
|
774
|
-
const m = Number(d[N]);
|
|
775
|
-
if (m !== a)
|
|
776
|
-
throw new Error(
|
|
777
|
-
`Content-Length mismatch: expected ${a}, but got ${m} in headers`
|
|
778
|
-
);
|
|
779
|
-
}
|
|
780
|
-
try {
|
|
781
|
-
const {
|
|
782
|
-
body: m,
|
|
783
|
-
statusCode: E,
|
|
784
|
-
headers: ne
|
|
785
|
-
} = await Ae(i.uploadUrl, {
|
|
786
|
-
dispatcher: this.httpClient,
|
|
787
|
-
body: l,
|
|
788
|
-
// We got headers only after we send
|
|
789
|
-
// the whole body (in case of S3 PUT requests it's 5 MB).
|
|
790
|
-
// It might be slow with a slow connection (or with SSH),
|
|
791
|
-
// that's why we got big timeout here.
|
|
792
|
-
headersTimeout: 6e4,
|
|
793
|
-
bodyTimeout: 6e4,
|
|
794
|
-
// Prevent connection reuse by setting "Connection: close" header.
|
|
795
|
-
// This works around an issue with the backend's built-in S3 implementation
|
|
796
|
-
// that caused HTTP/1.1 protocol lines to be included in the uploaded file content.
|
|
797
|
-
reset: !0,
|
|
798
|
-
headers: d,
|
|
799
|
-
method: i.method.toUpperCase()
|
|
800
|
-
}), Lt = await m.text();
|
|
801
|
-
wr(E, Lt, ne, i);
|
|
802
|
-
} catch (m) {
|
|
803
|
-
throw m instanceof et ? m : new Error(`partUpload: error ${JSON.stringify(m)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
|
|
804
|
-
}
|
|
805
|
-
await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), c);
|
|
806
|
-
}
|
|
807
|
-
async finalize(e, t) {
|
|
808
|
-
return await this.grpcFinalize(e, t);
|
|
809
|
-
}
|
|
810
|
-
/** Calculates parts that need to be uploaded from the parts that were
|
|
811
|
-
* already uploaded. */
|
|
812
|
-
partsToUpload(e, t) {
|
|
813
|
-
const r = [], n = new Set(t);
|
|
814
|
-
for (let o = 1n; o <= e; o++)
|
|
815
|
-
n.has(o) || r.push(o);
|
|
816
|
-
return r;
|
|
817
|
-
}
|
|
818
|
-
async grpcInit(e, t, r) {
|
|
819
|
-
return await this.grpcClient.get().init({ resourceId: e }, $(t, r)).response;
|
|
820
|
-
}
|
|
821
|
-
async grpcGetPartUrl({ id: e, type: t }, r, n, o) {
|
|
822
|
-
return await this.grpcClient.get().getPartURL(
|
|
823
|
-
{ resourceId: e, partNumber: r, uploadedPartSize: n, isInternalUse: !1 },
|
|
824
|
-
$(t, o)
|
|
825
|
-
).response;
|
|
826
|
-
}
|
|
827
|
-
async grpcUpdateProgress({ id: e, type: t }, r, n) {
|
|
828
|
-
await this.grpcClient.get().updateProgress(
|
|
829
|
-
{
|
|
830
|
-
resourceId: e,
|
|
831
|
-
bytesProcessed: r
|
|
832
|
-
},
|
|
833
|
-
$(t, n)
|
|
834
|
-
).response;
|
|
835
|
-
}
|
|
836
|
-
async grpcFinalize({ id: e, type: t }, r) {
|
|
837
|
-
return await this.grpcClient.get().finalize({ resourceId: e }, $(t, r)).response;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
async function pr(s, e, t) {
|
|
841
|
-
let r;
|
|
842
|
-
try {
|
|
843
|
-
r = await w.open(s);
|
|
844
|
-
const n = Number(t - e), o = Number(e), c = Buffer.alloc(n), i = await gr(r, c, n, o);
|
|
845
|
-
return c.subarray(0, i);
|
|
846
|
-
} catch (n) {
|
|
847
|
-
throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new tt(`there is no file ${s} for uploading`) : n;
|
|
848
|
-
} finally {
|
|
849
|
-
await (r == null ? void 0 : r.close());
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
async function gr(s, e, t, r) {
|
|
853
|
-
let n = 0;
|
|
854
|
-
for (; n < t; ) {
|
|
855
|
-
const { bytesRead: o } = await s.read(
|
|
856
|
-
e,
|
|
857
|
-
n,
|
|
858
|
-
t - n,
|
|
859
|
-
r + n
|
|
860
|
-
);
|
|
861
|
-
if (o === 0)
|
|
862
|
-
throw new Ye("file ended earlier than expected.");
|
|
863
|
-
n += o;
|
|
864
|
-
}
|
|
865
|
-
return n;
|
|
866
|
-
}
|
|
867
|
-
async function fr(s, e) {
|
|
868
|
-
const t = BigInt(Math.floor((await w.stat(s)).mtimeMs / 1e3));
|
|
869
|
-
if (t > e)
|
|
870
|
-
throw new Xe(`file was modified, expected mtime: ${e}, got: ${t}.`);
|
|
871
|
-
}
|
|
872
|
-
function wr(s, e, t, r) {
|
|
873
|
-
if (s != 200)
|
|
874
|
-
throw new et(
|
|
875
|
-
`response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${r.uploadUrl}`
|
|
876
|
-
);
|
|
877
|
-
}
|
|
878
|
-
class mr extends g {
|
|
879
|
-
constructor() {
|
|
880
|
-
super("google.protobuf.Duration", [
|
|
881
|
-
{
|
|
882
|
-
no: 1,
|
|
883
|
-
name: "seconds",
|
|
884
|
-
kind: "scalar",
|
|
885
|
-
T: 3,
|
|
886
|
-
L: 0
|
|
887
|
-
/*LongType.BIGINT*/
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
no: 2,
|
|
891
|
-
name: "nanos",
|
|
892
|
-
kind: "scalar",
|
|
893
|
-
T: 5
|
|
894
|
-
/*ScalarType.INT32*/
|
|
895
|
-
}
|
|
896
|
-
]);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Encode `Duration` to JSON string like "3.000001s".
|
|
900
|
-
*/
|
|
901
|
-
internalJsonWrite(e, t) {
|
|
902
|
-
let r = I.from(e.seconds).toNumber();
|
|
903
|
-
if (r > 315576e6 || r < -315576e6)
|
|
904
|
-
throw new Error("Duration value out of range.");
|
|
905
|
-
let n = e.seconds.toString();
|
|
906
|
-
if (r === 0 && e.nanos < 0 && (n = "-" + n), e.nanos !== 0) {
|
|
907
|
-
let o = Math.abs(e.nanos).toString();
|
|
908
|
-
o = "0".repeat(9 - o.length) + o, o.substring(3) === "000000" ? o = o.substring(0, 3) : o.substring(6) === "000" && (o = o.substring(0, 6)), n += "." + o;
|
|
909
|
-
}
|
|
910
|
-
return n + "s";
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* Decode `Duration` from JSON string like "3.000001s"
|
|
914
|
-
*/
|
|
915
|
-
internalJsonRead(e, t, r) {
|
|
916
|
-
if (typeof e != "string")
|
|
917
|
-
throw new Error("Unable to parse Duration from JSON " + Me(e) + ". Expected string.");
|
|
918
|
-
let n = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
|
|
919
|
-
if (n === null)
|
|
920
|
-
throw new Error("Unable to parse Duration from JSON string. Invalid format.");
|
|
921
|
-
r || (r = this.create());
|
|
922
|
-
let [, o, c, i] = n, l = I.from(o + c);
|
|
923
|
-
if (l.toNumber() > 315576e6 || l.toNumber() < -315576e6)
|
|
924
|
-
throw new Error("Unable to parse Duration from JSON string. Value out of range.");
|
|
925
|
-
if (r.seconds = l.toBigInt(), typeof i == "string") {
|
|
926
|
-
let a = o + i + "0".repeat(9 - i.length);
|
|
927
|
-
r.nanos = parseInt(a);
|
|
928
|
-
}
|
|
929
|
-
return r;
|
|
930
|
-
}
|
|
931
|
-
create(e) {
|
|
932
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
933
|
-
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
934
|
-
}
|
|
935
|
-
internalBinaryRead(e, t, r, n) {
|
|
936
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
937
|
-
for (; e.pos < c; ) {
|
|
938
|
-
let [i, l] = e.tag();
|
|
939
|
-
switch (i) {
|
|
940
|
-
case /* int64 seconds */
|
|
941
|
-
1:
|
|
942
|
-
o.seconds = e.int64().toBigInt();
|
|
943
|
-
break;
|
|
944
|
-
case /* int32 nanos */
|
|
945
|
-
2:
|
|
946
|
-
o.nanos = e.int32();
|
|
947
|
-
break;
|
|
948
|
-
default:
|
|
949
|
-
let a = r.readUnknownField;
|
|
950
|
-
if (a === "throw")
|
|
951
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
952
|
-
let d = e.skip(l);
|
|
953
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return o;
|
|
957
|
-
}
|
|
958
|
-
internalBinaryWrite(e, t, r) {
|
|
959
|
-
e.seconds !== 0n && t.tag(1, p.Varint).int64(e.seconds), e.nanos !== 0 && t.tag(2, p.Varint).int32(e.nanos);
|
|
960
|
-
let n = r.writeUnknownFields;
|
|
961
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
const q = new mr();
|
|
965
|
-
class yr extends g {
|
|
966
|
-
constructor() {
|
|
967
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
968
|
-
}
|
|
969
|
-
create(e) {
|
|
970
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
971
|
-
return e !== void 0 && f(this, t, e), t;
|
|
972
|
-
}
|
|
973
|
-
internalBinaryRead(e, t, r, n) {
|
|
974
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
975
|
-
for (; e.pos < c; ) {
|
|
976
|
-
let [i, l] = e.tag();
|
|
977
|
-
switch (i) {
|
|
978
|
-
default:
|
|
979
|
-
let a = r.readUnknownField;
|
|
980
|
-
if (a === "throw")
|
|
981
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
982
|
-
let d = e.skip(l);
|
|
983
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
return o;
|
|
987
|
-
}
|
|
988
|
-
internalBinaryWrite(e, t, r) {
|
|
989
|
-
let n = r.writeUnknownFields;
|
|
990
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
new yr();
|
|
994
|
-
class br extends g {
|
|
995
|
-
constructor() {
|
|
996
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
997
|
-
{
|
|
998
|
-
no: 1,
|
|
999
|
-
name: "progress",
|
|
1000
|
-
kind: "scalar",
|
|
1001
|
-
T: 2
|
|
1002
|
-
/*ScalarType.FLOAT*/
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
no: 2,
|
|
1006
|
-
name: "bytes_processed",
|
|
1007
|
-
kind: "scalar",
|
|
1008
|
-
T: 4,
|
|
1009
|
-
L: 0
|
|
1010
|
-
/*LongType.BIGINT*/
|
|
1011
|
-
},
|
|
1012
|
-
{
|
|
1013
|
-
no: 3,
|
|
1014
|
-
name: "bytes_total",
|
|
1015
|
-
kind: "scalar",
|
|
1016
|
-
T: 4,
|
|
1017
|
-
L: 0
|
|
1018
|
-
/*LongType.BIGINT*/
|
|
1019
|
-
},
|
|
1020
|
-
{
|
|
1021
|
-
no: 4,
|
|
1022
|
-
name: "done",
|
|
1023
|
-
kind: "scalar",
|
|
1024
|
-
T: 8
|
|
1025
|
-
/*ScalarType.BOOL*/
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
no: 5,
|
|
1029
|
-
name: "name",
|
|
1030
|
-
kind: "scalar",
|
|
1031
|
-
T: 9
|
|
1032
|
-
/*ScalarType.STRING*/
|
|
1033
|
-
}
|
|
1034
|
-
]);
|
|
1035
|
-
}
|
|
1036
|
-
create(e) {
|
|
1037
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1038
|
-
return t.progress = 0, t.bytesProcessed = 0n, t.bytesTotal = 0n, t.done = !1, t.name = "", e !== void 0 && f(this, t, e), t;
|
|
1039
|
-
}
|
|
1040
|
-
internalBinaryRead(e, t, r, n) {
|
|
1041
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1042
|
-
for (; e.pos < c; ) {
|
|
1043
|
-
let [i, l] = e.tag();
|
|
1044
|
-
switch (i) {
|
|
1045
|
-
case /* float progress */
|
|
1046
|
-
1:
|
|
1047
|
-
o.progress = e.float();
|
|
1048
|
-
break;
|
|
1049
|
-
case /* uint64 bytes_processed */
|
|
1050
|
-
2:
|
|
1051
|
-
o.bytesProcessed = e.uint64().toBigInt();
|
|
1052
|
-
break;
|
|
1053
|
-
case /* uint64 bytes_total */
|
|
1054
|
-
3:
|
|
1055
|
-
o.bytesTotal = e.uint64().toBigInt();
|
|
1056
|
-
break;
|
|
1057
|
-
case /* bool done */
|
|
1058
|
-
4:
|
|
1059
|
-
o.done = e.bool();
|
|
1060
|
-
break;
|
|
1061
|
-
case /* string name */
|
|
1062
|
-
5:
|
|
1063
|
-
o.name = e.string();
|
|
1064
|
-
break;
|
|
1065
|
-
default:
|
|
1066
|
-
let a = r.readUnknownField;
|
|
1067
|
-
if (a === "throw")
|
|
1068
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1069
|
-
let d = e.skip(l);
|
|
1070
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
return o;
|
|
1074
|
-
}
|
|
1075
|
-
internalBinaryWrite(e, t, r) {
|
|
1076
|
-
e.progress !== 0 && t.tag(1, p.Bit32).float(e.progress), e.bytesProcessed !== 0n && t.tag(2, p.Varint).uint64(e.bytesProcessed), e.bytesTotal !== 0n && t.tag(3, p.Varint).uint64(e.bytesTotal), e.done !== !1 && t.tag(4, p.Varint).bool(e.done), e.name !== "" && t.tag(5, p.LengthDelimited).string(e.name);
|
|
1077
|
-
let n = r.writeUnknownFields;
|
|
1078
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
const v = new br();
|
|
1082
|
-
class kr extends g {
|
|
1083
|
-
constructor() {
|
|
1084
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1085
|
-
}
|
|
1086
|
-
create(e) {
|
|
1087
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1088
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1089
|
-
}
|
|
1090
|
-
internalBinaryRead(e, t, r, n) {
|
|
1091
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1092
|
-
for (; e.pos < c; ) {
|
|
1093
|
-
let [i, l] = e.tag();
|
|
1094
|
-
switch (i) {
|
|
1095
|
-
default:
|
|
1096
|
-
let a = r.readUnknownField;
|
|
1097
|
-
if (a === "throw")
|
|
1098
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1099
|
-
let d = e.skip(l);
|
|
1100
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return o;
|
|
1104
|
-
}
|
|
1105
|
-
internalBinaryWrite(e, t, r) {
|
|
1106
|
-
let n = r.writeUnknownFields;
|
|
1107
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
new kr();
|
|
1111
|
-
class Tr extends g {
|
|
1112
|
-
constructor() {
|
|
1113
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1114
|
-
{
|
|
1115
|
-
no: 1,
|
|
1116
|
-
name: "resource_id",
|
|
1117
|
-
kind: "scalar",
|
|
1118
|
-
T: 4,
|
|
1119
|
-
L: 0
|
|
1120
|
-
/*LongType.BIGINT*/
|
|
1121
|
-
}
|
|
1122
|
-
]);
|
|
1123
|
-
}
|
|
1124
|
-
create(e) {
|
|
1125
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1126
|
-
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
1127
|
-
}
|
|
1128
|
-
internalBinaryRead(e, t, r, n) {
|
|
1129
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1130
|
-
for (; e.pos < c; ) {
|
|
1131
|
-
let [i, l] = e.tag();
|
|
1132
|
-
switch (i) {
|
|
1133
|
-
case /* uint64 resource_id */
|
|
1134
|
-
1:
|
|
1135
|
-
o.resourceId = e.uint64().toBigInt();
|
|
1136
|
-
break;
|
|
1137
|
-
default:
|
|
1138
|
-
let a = r.readUnknownField;
|
|
1139
|
-
if (a === "throw")
|
|
1140
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1141
|
-
let d = e.skip(l);
|
|
1142
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
return o;
|
|
1146
|
-
}
|
|
1147
|
-
internalBinaryWrite(e, t, r) {
|
|
1148
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId);
|
|
1149
|
-
let n = r.writeUnknownFields;
|
|
1150
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
const Lr = new Tr();
|
|
1154
|
-
class Ur extends g {
|
|
1155
|
-
constructor() {
|
|
1156
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1157
|
-
{ no: 1, name: "report", kind: "message", T: () => v }
|
|
1158
|
-
]);
|
|
1159
|
-
}
|
|
1160
|
-
create(e) {
|
|
1161
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1162
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1163
|
-
}
|
|
1164
|
-
internalBinaryRead(e, t, r, n) {
|
|
1165
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1166
|
-
for (; e.pos < c; ) {
|
|
1167
|
-
let [i, l] = e.tag();
|
|
1168
|
-
switch (i) {
|
|
1169
|
-
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1170
|
-
1:
|
|
1171
|
-
o.report = v.internalBinaryRead(e, e.uint32(), r, o.report);
|
|
1172
|
-
break;
|
|
1173
|
-
default:
|
|
1174
|
-
let a = r.readUnknownField;
|
|
1175
|
-
if (a === "throw")
|
|
1176
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1177
|
-
let d = e.skip(l);
|
|
1178
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
return o;
|
|
1182
|
-
}
|
|
1183
|
-
internalBinaryWrite(e, t, r) {
|
|
1184
|
-
e.report && v.internalBinaryWrite(e.report, t.tag(1, p.LengthDelimited).fork(), r).join();
|
|
1185
|
-
let n = r.writeUnknownFields;
|
|
1186
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
const Pr = new Ur();
|
|
1190
|
-
class Rr extends g {
|
|
1191
|
-
constructor() {
|
|
1192
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1193
|
-
}
|
|
1194
|
-
create(e) {
|
|
1195
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1196
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1197
|
-
}
|
|
1198
|
-
internalBinaryRead(e, t, r, n) {
|
|
1199
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1200
|
-
for (; e.pos < c; ) {
|
|
1201
|
-
let [i, l] = e.tag();
|
|
1202
|
-
switch (i) {
|
|
1203
|
-
default:
|
|
1204
|
-
let a = r.readUnknownField;
|
|
1205
|
-
if (a === "throw")
|
|
1206
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1207
|
-
let d = e.skip(l);
|
|
1208
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
return o;
|
|
1212
|
-
}
|
|
1213
|
-
internalBinaryWrite(e, t, r) {
|
|
1214
|
-
let n = r.writeUnknownFields;
|
|
1215
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
new Rr();
|
|
1219
|
-
class Nr extends g {
|
|
1220
|
-
constructor() {
|
|
1221
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request", [
|
|
1222
|
-
{
|
|
1223
|
-
no: 1,
|
|
1224
|
-
name: "resource_id",
|
|
1225
|
-
kind: "scalar",
|
|
1226
|
-
T: 4,
|
|
1227
|
-
L: 0
|
|
1228
|
-
/*LongType.BIGINT*/
|
|
1229
|
-
},
|
|
1230
|
-
{ no: 2, name: "update_interval", kind: "message", T: () => q }
|
|
1231
|
-
]);
|
|
1232
|
-
}
|
|
1233
|
-
create(e) {
|
|
1234
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1235
|
-
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
1236
|
-
}
|
|
1237
|
-
internalBinaryRead(e, t, r, n) {
|
|
1238
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1239
|
-
for (; e.pos < c; ) {
|
|
1240
|
-
let [i, l] = e.tag();
|
|
1241
|
-
switch (i) {
|
|
1242
|
-
case /* uint64 resource_id */
|
|
1243
|
-
1:
|
|
1244
|
-
o.resourceId = e.uint64().toBigInt();
|
|
1245
|
-
break;
|
|
1246
|
-
case /* google.protobuf.Duration update_interval */
|
|
1247
|
-
2:
|
|
1248
|
-
o.updateInterval = q.internalBinaryRead(e, e.uint32(), r, o.updateInterval);
|
|
1249
|
-
break;
|
|
1250
|
-
default:
|
|
1251
|
-
let a = r.readUnknownField;
|
|
1252
|
-
if (a === "throw")
|
|
1253
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1254
|
-
let d = e.skip(l);
|
|
1255
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
return o;
|
|
1259
|
-
}
|
|
1260
|
-
internalBinaryWrite(e, t, r) {
|
|
1261
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.updateInterval && q.internalBinaryWrite(e.updateInterval, t.tag(2, p.LengthDelimited).fork(), r).join();
|
|
1262
|
-
let n = r.writeUnknownFields;
|
|
1263
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
const $r = new Nr();
|
|
1267
|
-
class Sr extends g {
|
|
1268
|
-
constructor() {
|
|
1269
|
-
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response", [
|
|
1270
|
-
{ no: 1, name: "report", kind: "message", T: () => v }
|
|
1271
|
-
]);
|
|
1272
|
-
}
|
|
1273
|
-
create(e) {
|
|
1274
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1275
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1276
|
-
}
|
|
1277
|
-
internalBinaryRead(e, t, r, n) {
|
|
1278
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1279
|
-
for (; e.pos < c; ) {
|
|
1280
|
-
let [i, l] = e.tag();
|
|
1281
|
-
switch (i) {
|
|
1282
|
-
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1283
|
-
1:
|
|
1284
|
-
o.report = v.internalBinaryRead(e, e.uint32(), r, o.report);
|
|
1285
|
-
break;
|
|
1286
|
-
default:
|
|
1287
|
-
let a = r.readUnknownField;
|
|
1288
|
-
if (a === "throw")
|
|
1289
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1290
|
-
let d = e.skip(l);
|
|
1291
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return o;
|
|
1295
|
-
}
|
|
1296
|
-
internalBinaryWrite(e, t, r) {
|
|
1297
|
-
e.report && v.internalBinaryWrite(e.report, t.tag(1, p.LengthDelimited).fork(), r).join();
|
|
1298
|
-
let n = r.writeUnknownFields;
|
|
1299
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
const Ir = new Sr(), ie = new x("MiLaboratories.Controller.Shared.Progress", [
|
|
1303
|
-
{ name: "GetStatus", options: { "google.api.http": { get: "/resources/{resource_id}/get-progress" } }, I: Lr, O: Pr },
|
|
1304
|
-
{ name: "RealtimeStatus", serverStreaming: !0, options: {}, I: $r, O: Ir }
|
|
1305
|
-
]);
|
|
1306
|
-
class Dr {
|
|
1307
|
-
constructor(e) {
|
|
1308
|
-
h(this, "typeName", ie.typeName);
|
|
1309
|
-
h(this, "methods", ie.methods);
|
|
1310
|
-
h(this, "options", ie.options);
|
|
1311
|
-
this._transport = e;
|
|
1312
|
-
}
|
|
1313
|
-
/**
|
|
1314
|
-
* @generated from protobuf rpc: GetStatus
|
|
1315
|
-
*/
|
|
1316
|
-
getStatus(e, t) {
|
|
1317
|
-
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1318
|
-
return R("unary", this._transport, r, n, e);
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* @generated from protobuf rpc: RealtimeStatus
|
|
1322
|
-
*/
|
|
1323
|
-
realtimeStatus(e, t) {
|
|
1324
|
-
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
1325
|
-
return R("serverStreaming", this._transport, r, n, e);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
class vr {
|
|
1329
|
-
constructor(e, t, r, n) {
|
|
1330
|
-
h(this, "grpcClient");
|
|
1331
|
-
this.client = r, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new Dr(o));
|
|
1332
|
-
}
|
|
1333
|
-
close() {
|
|
1334
|
-
}
|
|
1335
|
-
/** getStatus gets a progress status by given rId and rType. */
|
|
1336
|
-
async getStatus({ id: e, type: t }, r) {
|
|
1337
|
-
const n = await this.grpcClient.get().getStatus(
|
|
1338
|
-
{ resourceId: e },
|
|
1339
|
-
$(t, r)
|
|
1340
|
-
), o = K(n.response.report);
|
|
1341
|
-
return {
|
|
1342
|
-
done: o.done,
|
|
1343
|
-
progress: o.progress,
|
|
1344
|
-
bytesProcessed: String(o.bytesProcessed),
|
|
1345
|
-
bytesTotal: String(o.bytesTotal)
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1348
|
-
// realtimeStatus returns a async generator that takes statuses from
|
|
1349
|
-
// GRPC stream every updateIntervalMs milliseconds.
|
|
1350
|
-
async *realtimeStatus({ id: e, type: t }, r = 100, n) {
|
|
1351
|
-
n = $(t, n);
|
|
1352
|
-
const o = Math.floor(r / 1e3), c = (r - o * 1e3) * 1e6, i = q.create({
|
|
1353
|
-
seconds: BigInt(o),
|
|
1354
|
-
nanos: c
|
|
1355
|
-
});
|
|
1356
|
-
try {
|
|
1357
|
-
const { responses: l } = this.grpcClient.get().realtimeStatus(
|
|
1358
|
-
{
|
|
1359
|
-
resourceId: e,
|
|
1360
|
-
updateInterval: i
|
|
1361
|
-
},
|
|
1362
|
-
n
|
|
1363
|
-
);
|
|
1364
|
-
yield* l;
|
|
1365
|
-
} catch (l) {
|
|
1366
|
-
throw this.logger.warn("Failed to get realtime status" + String(l)), l;
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
class te extends Error {
|
|
1371
|
-
constructor() {
|
|
1372
|
-
super(...arguments);
|
|
1373
|
-
h(this, "name", "NetworkError400");
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
class rt {
|
|
1377
|
-
constructor(e) {
|
|
1378
|
-
this.httpClient = e;
|
|
1379
|
-
}
|
|
1380
|
-
async withContent(e, t, r, n) {
|
|
1381
|
-
const o = { ...t };
|
|
1382
|
-
r.range && (o.Range = `bytes=${r.range.from}-${r.range.to - 1}`);
|
|
1383
|
-
const { statusCode: c, body: i, headers: l } = await Ae(e, {
|
|
1384
|
-
dispatcher: this.httpClient,
|
|
1385
|
-
headers: o,
|
|
1386
|
-
signal: r.signal
|
|
1387
|
-
}), a = Ge.toWeb(i);
|
|
1388
|
-
let d = !1;
|
|
1389
|
-
try {
|
|
1390
|
-
await Br(c, a, e);
|
|
1391
|
-
const N = Number(l["content-length"]), m = await n(a, N);
|
|
1392
|
-
return d = !0, m;
|
|
1393
|
-
} catch (N) {
|
|
1394
|
-
if (!d && !a.locked)
|
|
1395
|
-
try {
|
|
1396
|
-
await a.cancel();
|
|
1397
|
-
} catch {
|
|
1398
|
-
}
|
|
1399
|
-
throw N;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
async function Br(s, e, t) {
|
|
1404
|
-
if (s != 200 && s != 206) {
|
|
1405
|
-
const r = (await It(e)).substring(0, 1e3);
|
|
1406
|
-
throw 400 <= s && s < 500 ? new te(
|
|
1407
|
-
`Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${r}`
|
|
1408
|
-
) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
function O(s) {
|
|
1412
|
-
if (!U.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1413
|
-
return s;
|
|
1414
|
-
}
|
|
1415
|
-
class Cr extends g {
|
|
1416
|
-
constructor() {
|
|
1417
|
-
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1418
|
-
}
|
|
1419
|
-
create(e) {
|
|
1420
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1421
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1422
|
-
}
|
|
1423
|
-
internalBinaryRead(e, t, r, n) {
|
|
1424
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1425
|
-
for (; e.pos < c; ) {
|
|
1426
|
-
let [i, l] = e.tag();
|
|
1427
|
-
switch (i) {
|
|
1428
|
-
default:
|
|
1429
|
-
let a = r.readUnknownField;
|
|
1430
|
-
if (a === "throw")
|
|
1431
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1432
|
-
let d = e.skip(l);
|
|
1433
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
return o;
|
|
1437
|
-
}
|
|
1438
|
-
internalBinaryWrite(e, t, r) {
|
|
1439
|
-
let n = r.writeUnknownFields;
|
|
1440
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
new Cr();
|
|
1444
|
-
class Er extends g {
|
|
1445
|
-
constructor() {
|
|
1446
|
-
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1447
|
-
}
|
|
1448
|
-
create(e) {
|
|
1449
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1450
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1451
|
-
}
|
|
1452
|
-
internalBinaryRead(e, t, r, n) {
|
|
1453
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1454
|
-
for (; e.pos < c; ) {
|
|
1455
|
-
let [i, l] = e.tag();
|
|
1456
|
-
switch (i) {
|
|
1457
|
-
default:
|
|
1458
|
-
let a = r.readUnknownField;
|
|
1459
|
-
if (a === "throw")
|
|
1460
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1461
|
-
let d = e.skip(l);
|
|
1462
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return o;
|
|
1466
|
-
}
|
|
1467
|
-
internalBinaryWrite(e, t, r) {
|
|
1468
|
-
let n = r.writeUnknownFields;
|
|
1469
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
new Er();
|
|
1473
|
-
class _r extends g {
|
|
1474
|
-
constructor() {
|
|
1475
|
-
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request", [
|
|
1476
|
-
{
|
|
1477
|
-
no: 1,
|
|
1478
|
-
name: "resource_id",
|
|
1479
|
-
kind: "scalar",
|
|
1480
|
-
T: 4,
|
|
1481
|
-
L: 0
|
|
1482
|
-
/*LongType.BIGINT*/
|
|
1483
|
-
},
|
|
1484
|
-
{
|
|
1485
|
-
no: 2,
|
|
1486
|
-
name: "is_internal_use",
|
|
1487
|
-
kind: "scalar",
|
|
1488
|
-
T: 8
|
|
1489
|
-
/*ScalarType.BOOL*/
|
|
1490
|
-
}
|
|
1491
|
-
]);
|
|
1492
|
-
}
|
|
1493
|
-
create(e) {
|
|
1494
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1495
|
-
return t.resourceId = 0n, t.isInternalUse = !1, e !== void 0 && f(this, t, e), t;
|
|
1496
|
-
}
|
|
1497
|
-
internalBinaryRead(e, t, r, n) {
|
|
1498
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1499
|
-
for (; e.pos < c; ) {
|
|
1500
|
-
let [i, l] = e.tag();
|
|
1501
|
-
switch (i) {
|
|
1502
|
-
case /* uint64 resource_id */
|
|
1503
|
-
1:
|
|
1504
|
-
o.resourceId = e.uint64().toBigInt();
|
|
1505
|
-
break;
|
|
1506
|
-
case /* bool is_internal_use */
|
|
1507
|
-
2:
|
|
1508
|
-
o.isInternalUse = e.bool();
|
|
1509
|
-
break;
|
|
1510
|
-
default:
|
|
1511
|
-
let a = r.readUnknownField;
|
|
1512
|
-
if (a === "throw")
|
|
1513
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1514
|
-
let d = e.skip(l);
|
|
1515
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
return o;
|
|
1519
|
-
}
|
|
1520
|
-
internalBinaryWrite(e, t, r) {
|
|
1521
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.isInternalUse !== !1 && t.tag(2, p.Varint).bool(e.isInternalUse);
|
|
1522
|
-
let n = r.writeUnknownFields;
|
|
1523
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
const Fr = new _r();
|
|
1527
|
-
class Or extends g {
|
|
1528
|
-
constructor() {
|
|
1529
|
-
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader", [
|
|
1530
|
-
{
|
|
1531
|
-
no: 1,
|
|
1532
|
-
name: "Name",
|
|
1533
|
-
kind: "scalar",
|
|
1534
|
-
jsonName: "Name",
|
|
1535
|
-
T: 9
|
|
1536
|
-
/*ScalarType.STRING*/
|
|
1537
|
-
},
|
|
1538
|
-
{
|
|
1539
|
-
no: 2,
|
|
1540
|
-
name: "Value",
|
|
1541
|
-
kind: "scalar",
|
|
1542
|
-
jsonName: "Value",
|
|
1543
|
-
T: 9
|
|
1544
|
-
/*ScalarType.STRING*/
|
|
1545
|
-
}
|
|
1546
|
-
]);
|
|
1547
|
-
}
|
|
1548
|
-
create(e) {
|
|
1549
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1550
|
-
return t.name = "", t.value = "", e !== void 0 && f(this, t, e), t;
|
|
1551
|
-
}
|
|
1552
|
-
internalBinaryRead(e, t, r, n) {
|
|
1553
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1554
|
-
for (; e.pos < c; ) {
|
|
1555
|
-
let [i, l] = e.tag();
|
|
1556
|
-
switch (i) {
|
|
1557
|
-
case /* string Name */
|
|
1558
|
-
1:
|
|
1559
|
-
o.name = e.string();
|
|
1560
|
-
break;
|
|
1561
|
-
case /* string Value */
|
|
1562
|
-
2:
|
|
1563
|
-
o.value = e.string();
|
|
1564
|
-
break;
|
|
1565
|
-
default:
|
|
1566
|
-
let a = r.readUnknownField;
|
|
1567
|
-
if (a === "throw")
|
|
1568
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1569
|
-
let d = e.skip(l);
|
|
1570
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
return o;
|
|
1574
|
-
}
|
|
1575
|
-
internalBinaryWrite(e, t, r) {
|
|
1576
|
-
e.name !== "" && t.tag(1, p.LengthDelimited).string(e.name), e.value !== "" && t.tag(2, p.LengthDelimited).string(e.value);
|
|
1577
|
-
let n = r.writeUnknownFields;
|
|
1578
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
const ae = new Or();
|
|
1582
|
-
class zr extends g {
|
|
1583
|
-
constructor() {
|
|
1584
|
-
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response", [
|
|
1585
|
-
{
|
|
1586
|
-
no: 1,
|
|
1587
|
-
name: "download_url",
|
|
1588
|
-
kind: "scalar",
|
|
1589
|
-
T: 9
|
|
1590
|
-
/*ScalarType.STRING*/
|
|
1591
|
-
},
|
|
1592
|
-
{ no: 2, name: "headers", kind: "message", repeat: 2, T: () => ae }
|
|
1593
|
-
]);
|
|
1594
|
-
}
|
|
1595
|
-
create(e) {
|
|
1596
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1597
|
-
return t.downloadUrl = "", t.headers = [], e !== void 0 && f(this, t, e), t;
|
|
1598
|
-
}
|
|
1599
|
-
internalBinaryRead(e, t, r, n) {
|
|
1600
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1601
|
-
for (; e.pos < c; ) {
|
|
1602
|
-
let [i, l] = e.tag();
|
|
1603
|
-
switch (i) {
|
|
1604
|
-
case /* string download_url */
|
|
1605
|
-
1:
|
|
1606
|
-
o.downloadUrl = e.string();
|
|
1607
|
-
break;
|
|
1608
|
-
case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
|
|
1609
|
-
2:
|
|
1610
|
-
o.headers.push(ae.internalBinaryRead(e, e.uint32(), r));
|
|
1611
|
-
break;
|
|
1612
|
-
default:
|
|
1613
|
-
let a = r.readUnknownField;
|
|
1614
|
-
if (a === "throw")
|
|
1615
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1616
|
-
let d = e.skip(l);
|
|
1617
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
return o;
|
|
1621
|
-
}
|
|
1622
|
-
internalBinaryWrite(e, t, r) {
|
|
1623
|
-
e.downloadUrl !== "" && t.tag(1, p.LengthDelimited).string(e.downloadUrl);
|
|
1624
|
-
for (let o = 0; o < e.headers.length; o++)
|
|
1625
|
-
ae.internalBinaryWrite(e.headers[o], t.tag(2, p.LengthDelimited).fork(), r).join();
|
|
1626
|
-
let n = r.writeUnknownFields;
|
|
1627
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
const Wr = new zr(), le = new x("MiLaboratories.Controller.Shared.Download", [
|
|
1631
|
-
{ name: "GetDownloadURL", options: { "google.api.http": { get: "/resources/{resource_id}/get-download-url" } }, I: Fr, O: Wr }
|
|
1632
|
-
]);
|
|
1633
|
-
class xr {
|
|
1634
|
-
constructor(e) {
|
|
1635
|
-
h(this, "typeName", le.typeName);
|
|
1636
|
-
h(this, "methods", le.methods);
|
|
1637
|
-
h(this, "options", le.options);
|
|
1638
|
-
this._transport = e;
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* @generated from protobuf rpc: GetDownloadURL
|
|
1642
|
-
*/
|
|
1643
|
-
getDownloadURL(e, t) {
|
|
1644
|
-
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1645
|
-
return R("unary", this._transport, r, n, e);
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
class Ar {
|
|
1649
|
-
constructor(e, t, r, n) {
|
|
1650
|
-
h(this, "grpcClient");
|
|
1651
|
-
h(this, "remoteFileDownloader");
|
|
1652
|
-
/** Helps to find a storage root directory by a storage id from URL scheme. */
|
|
1653
|
-
h(this, "localStorageIdsToRoot");
|
|
1654
|
-
/** Concurrency limiter for local file reads - limit to 32 parallel reads */
|
|
1655
|
-
h(this, "localFileReadLimiter", new He(32));
|
|
1656
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((o) => new xr(o)), this.remoteFileDownloader = new rt(t), this.localStorageIdsToRoot = Vr(n);
|
|
1657
|
-
}
|
|
1658
|
-
close() {
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* Gets a presign URL and downloads the file.
|
|
1662
|
-
* An optional range with 2 numbers from what byte and to what byte to download can be provided.
|
|
1663
|
-
* @param fromBytes - from byte including this byte
|
|
1664
|
-
* @param toBytes - to byte excluding this byte
|
|
1665
|
-
*/
|
|
1666
|
-
async withBlobContent(e, t, r, n) {
|
|
1667
|
-
const { downloadUrl: o, headers: c } = await this.grpcGetDownloadUrl(e, t, r.signal), i = Object.fromEntries(c.map(({ name: l, value: a }) => [l, a]));
|
|
1668
|
-
return this.logger.info(`download blob ${y(e)} from url ${o}, ops: ${JSON.stringify(r)}`), Gr(o) ? await this.withLocalFileContent(o, r, n) : await this.remoteFileDownloader.withContent(o, i, r, n);
|
|
1669
|
-
}
|
|
1670
|
-
async withLocalFileContent(e, t, r) {
|
|
1671
|
-
const { storageId: n, relativePath: o } = Mr(e), c = Hr(n, this.localStorageIdsToRoot, o);
|
|
1672
|
-
return await this.localFileReadLimiter.run(async () => {
|
|
1673
|
-
var d, N;
|
|
1674
|
-
const i = {
|
|
1675
|
-
start: (d = t.range) == null ? void 0 : d.from,
|
|
1676
|
-
end: ((N = t.range) == null ? void 0 : N.to) !== void 0 ? t.range.to - 1 : void 0
|
|
1677
|
-
};
|
|
1678
|
-
let l, a = !1;
|
|
1679
|
-
try {
|
|
1680
|
-
const m = await w.stat(c);
|
|
1681
|
-
l = Ne.createReadStream(c, i);
|
|
1682
|
-
const E = Ge.toWeb(l), ne = await r(E, m.size);
|
|
1683
|
-
return a = !0, ne;
|
|
1684
|
-
} catch (m) {
|
|
1685
|
-
throw !a && l && !l.destroyed && l.destroy(), m;
|
|
1686
|
-
}
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1689
|
-
async grpcGetDownloadUrl({ id: e, type: t }, r, n) {
|
|
1690
|
-
const o = r ?? {};
|
|
1691
|
-
return o.abort = n, await this.grpcClient.get().getDownloadURL(
|
|
1692
|
-
{ resourceId: e, isInternalUse: !1 },
|
|
1693
|
-
$(t, o)
|
|
1694
|
-
).response;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
function Mr(s) {
|
|
1698
|
-
const e = new URL(s);
|
|
1699
|
-
if (e.pathname == "")
|
|
1700
|
-
throw new $e(`url for local filepath ${s} does not match url scheme`);
|
|
1701
|
-
return {
|
|
1702
|
-
storageId: e.host,
|
|
1703
|
-
relativePath: decodeURIComponent(e.pathname.slice(1))
|
|
1704
|
-
};
|
|
1705
|
-
}
|
|
1706
|
-
function Hr(s, e, t) {
|
|
1707
|
-
const r = e.get(s);
|
|
1708
|
-
if (r === void 0) throw new Se(`Unknown storage location: ${s}`);
|
|
1709
|
-
return r === "" ? t : T.join(r, t);
|
|
1710
|
-
}
|
|
1711
|
-
const jr = "storage://";
|
|
1712
|
-
function Gr(s) {
|
|
1713
|
-
return s.startsWith(jr);
|
|
1714
|
-
}
|
|
1715
|
-
class $e extends Error {
|
|
1716
|
-
constructor() {
|
|
1717
|
-
super(...arguments);
|
|
1718
|
-
h(this, "name", "WrongLocalFileUrl");
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
class Se extends Error {
|
|
1722
|
-
constructor() {
|
|
1723
|
-
super(...arguments);
|
|
1724
|
-
h(this, "name", "UnknownStorageError");
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
function Vr(s) {
|
|
1728
|
-
const e = /* @__PURE__ */ new Map();
|
|
1729
|
-
for (const t of s)
|
|
1730
|
-
t.localPath !== "" && O(t.localPath), e.set(t.storageId, t.localPath);
|
|
1731
|
-
return e;
|
|
1732
|
-
}
|
|
1733
|
-
class qr extends g {
|
|
1734
|
-
constructor() {
|
|
1735
|
-
super("google.protobuf.Timestamp", [
|
|
1736
|
-
{
|
|
1737
|
-
no: 1,
|
|
1738
|
-
name: "seconds",
|
|
1739
|
-
kind: "scalar",
|
|
1740
|
-
T: 3,
|
|
1741
|
-
L: 0
|
|
1742
|
-
/*LongType.BIGINT*/
|
|
1743
|
-
},
|
|
1744
|
-
{
|
|
1745
|
-
no: 2,
|
|
1746
|
-
name: "nanos",
|
|
1747
|
-
kind: "scalar",
|
|
1748
|
-
T: 5
|
|
1749
|
-
/*ScalarType.INT32*/
|
|
1750
|
-
}
|
|
1751
|
-
]);
|
|
1752
|
-
}
|
|
1753
|
-
/**
|
|
1754
|
-
* Creates a new `Timestamp` for the current time.
|
|
1755
|
-
*/
|
|
1756
|
-
now() {
|
|
1757
|
-
const e = this.create(), t = Date.now();
|
|
1758
|
-
return e.seconds = I.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Converts a `Timestamp` to a JavaScript Date.
|
|
1762
|
-
*/
|
|
1763
|
-
toDate(e) {
|
|
1764
|
-
return new Date(I.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6));
|
|
1765
|
-
}
|
|
1766
|
-
/**
|
|
1767
|
-
* Converts a JavaScript Date to a `Timestamp`.
|
|
1768
|
-
*/
|
|
1769
|
-
fromDate(e) {
|
|
1770
|
-
const t = this.create(), r = e.getTime();
|
|
1771
|
-
return t.seconds = I.from(Math.floor(r / 1e3)).toBigInt(), t.nanos = (r % 1e3 + (r < 0 && r % 1e3 !== 0 ? 1e3 : 0)) * 1e6, t;
|
|
1772
|
-
}
|
|
1773
|
-
/**
|
|
1774
|
-
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1775
|
-
* in the RFC 3339 format.
|
|
1776
|
-
*/
|
|
1777
|
-
internalJsonWrite(e, t) {
|
|
1778
|
-
let r = I.from(e.seconds).toNumber() * 1e3;
|
|
1779
|
-
if (r < Date.parse("0001-01-01T00:00:00Z") || r > Date.parse("9999-12-31T23:59:59Z"))
|
|
1780
|
-
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
1781
|
-
if (e.nanos < 0)
|
|
1782
|
-
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
|
1783
|
-
let n = "Z";
|
|
1784
|
-
if (e.nanos > 0) {
|
|
1785
|
-
let o = (e.nanos + 1e9).toString().substring(1);
|
|
1786
|
-
o.substring(3) === "000000" ? n = "." + o.substring(0, 3) + "Z" : o.substring(6) === "000" ? n = "." + o.substring(0, 6) + "Z" : n = "." + o + "Z";
|
|
1787
|
-
}
|
|
1788
|
-
return new Date(r).toISOString().replace(".000Z", n);
|
|
1789
|
-
}
|
|
1790
|
-
/**
|
|
1791
|
-
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1792
|
-
* in the RFC 3339 format.
|
|
1793
|
-
*/
|
|
1794
|
-
internalJsonRead(e, t, r) {
|
|
1795
|
-
if (typeof e != "string")
|
|
1796
|
-
throw new Error("Unable to parse Timestamp from JSON " + Me(e) + ".");
|
|
1797
|
-
let n = e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
|
1798
|
-
if (!n)
|
|
1799
|
-
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
|
1800
|
-
let o = Date.parse(n[1] + "-" + n[2] + "-" + n[3] + "T" + n[4] + ":" + n[5] + ":" + n[6] + (n[8] ? n[8] : "Z"));
|
|
1801
|
-
if (Number.isNaN(o))
|
|
1802
|
-
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
|
1803
|
-
if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
|
|
1804
|
-
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
|
1805
|
-
return r || (r = this.create()), r.seconds = I.from(o / 1e3).toBigInt(), r.nanos = 0, n[7] && (r.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), r;
|
|
1806
|
-
}
|
|
1807
|
-
create(e) {
|
|
1808
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1809
|
-
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
1810
|
-
}
|
|
1811
|
-
internalBinaryRead(e, t, r, n) {
|
|
1812
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1813
|
-
for (; e.pos < c; ) {
|
|
1814
|
-
let [i, l] = e.tag();
|
|
1815
|
-
switch (i) {
|
|
1816
|
-
case /* int64 seconds */
|
|
1817
|
-
1:
|
|
1818
|
-
o.seconds = e.int64().toBigInt();
|
|
1819
|
-
break;
|
|
1820
|
-
case /* int32 nanos */
|
|
1821
|
-
2:
|
|
1822
|
-
o.nanos = e.int32();
|
|
1823
|
-
break;
|
|
1824
|
-
default:
|
|
1825
|
-
let a = r.readUnknownField;
|
|
1826
|
-
if (a === "throw")
|
|
1827
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1828
|
-
let d = e.skip(l);
|
|
1829
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
return o;
|
|
1833
|
-
}
|
|
1834
|
-
internalBinaryWrite(e, t, r) {
|
|
1835
|
-
e.seconds !== 0n && t.tag(1, p.Varint).int64(e.seconds), e.nanos !== 0 && t.tag(2, p.Varint).int32(e.nanos);
|
|
1836
|
-
let n = r.writeUnknownFields;
|
|
1837
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
const ce = new qr();
|
|
1841
|
-
class Jr extends g {
|
|
1842
|
-
constructor() {
|
|
1843
|
-
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
1844
|
-
}
|
|
1845
|
-
create(e) {
|
|
1846
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1847
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1848
|
-
}
|
|
1849
|
-
internalBinaryRead(e, t, r, n) {
|
|
1850
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1851
|
-
for (; e.pos < c; ) {
|
|
1852
|
-
let [i, l] = e.tag();
|
|
1853
|
-
switch (i) {
|
|
1854
|
-
default:
|
|
1855
|
-
let a = r.readUnknownField;
|
|
1856
|
-
if (a === "throw")
|
|
1857
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1858
|
-
let d = e.skip(l);
|
|
1859
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
return o;
|
|
1863
|
-
}
|
|
1864
|
-
internalBinaryWrite(e, t, r) {
|
|
1865
|
-
let n = r.writeUnknownFields;
|
|
1866
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
new Jr();
|
|
1870
|
-
class Zr extends g {
|
|
1871
|
-
constructor() {
|
|
1872
|
-
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
1873
|
-
{
|
|
1874
|
-
no: 1,
|
|
1875
|
-
name: "name",
|
|
1876
|
-
kind: "scalar",
|
|
1877
|
-
T: 9
|
|
1878
|
-
/*ScalarType.STRING*/
|
|
1879
|
-
},
|
|
1880
|
-
{
|
|
1881
|
-
no: 2,
|
|
1882
|
-
name: "size",
|
|
1883
|
-
kind: "scalar",
|
|
1884
|
-
T: 4,
|
|
1885
|
-
L: 0
|
|
1886
|
-
/*LongType.BIGINT*/
|
|
1887
|
-
},
|
|
1888
|
-
{
|
|
1889
|
-
no: 3,
|
|
1890
|
-
name: "is_dir",
|
|
1891
|
-
kind: "scalar",
|
|
1892
|
-
T: 8
|
|
1893
|
-
/*ScalarType.BOOL*/
|
|
1894
|
-
},
|
|
1895
|
-
{
|
|
1896
|
-
no: 10,
|
|
1897
|
-
name: "full_name",
|
|
1898
|
-
kind: "scalar",
|
|
1899
|
-
T: 9
|
|
1900
|
-
/*ScalarType.STRING*/
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
no: 11,
|
|
1904
|
-
name: "directory",
|
|
1905
|
-
kind: "scalar",
|
|
1906
|
-
T: 9
|
|
1907
|
-
/*ScalarType.STRING*/
|
|
1908
|
-
},
|
|
1909
|
-
{ no: 12, name: "last_modified", kind: "message", T: () => ce },
|
|
1910
|
-
{
|
|
1911
|
-
no: 13,
|
|
1912
|
-
name: "version",
|
|
1913
|
-
kind: "scalar",
|
|
1914
|
-
T: 9
|
|
1915
|
-
/*ScalarType.STRING*/
|
|
1916
|
-
}
|
|
1917
|
-
]);
|
|
1918
|
-
}
|
|
1919
|
-
create(e) {
|
|
1920
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1921
|
-
return t.name = "", t.size = 0n, t.isDir = !1, t.fullName = "", t.directory = "", t.version = "", e !== void 0 && f(this, t, e), t;
|
|
1922
|
-
}
|
|
1923
|
-
internalBinaryRead(e, t, r, n) {
|
|
1924
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1925
|
-
for (; e.pos < c; ) {
|
|
1926
|
-
let [i, l] = e.tag();
|
|
1927
|
-
switch (i) {
|
|
1928
|
-
case /* string name */
|
|
1929
|
-
1:
|
|
1930
|
-
o.name = e.string();
|
|
1931
|
-
break;
|
|
1932
|
-
case /* uint64 size */
|
|
1933
|
-
2:
|
|
1934
|
-
o.size = e.uint64().toBigInt();
|
|
1935
|
-
break;
|
|
1936
|
-
case /* bool is_dir */
|
|
1937
|
-
3:
|
|
1938
|
-
o.isDir = e.bool();
|
|
1939
|
-
break;
|
|
1940
|
-
case /* string full_name */
|
|
1941
|
-
10:
|
|
1942
|
-
o.fullName = e.string();
|
|
1943
|
-
break;
|
|
1944
|
-
case /* string directory */
|
|
1945
|
-
11:
|
|
1946
|
-
o.directory = e.string();
|
|
1947
|
-
break;
|
|
1948
|
-
case /* google.protobuf.Timestamp last_modified */
|
|
1949
|
-
12:
|
|
1950
|
-
o.lastModified = ce.internalBinaryRead(e, e.uint32(), r, o.lastModified);
|
|
1951
|
-
break;
|
|
1952
|
-
case /* string version */
|
|
1953
|
-
13:
|
|
1954
|
-
o.version = e.string();
|
|
1955
|
-
break;
|
|
1956
|
-
default:
|
|
1957
|
-
let a = r.readUnknownField;
|
|
1958
|
-
if (a === "throw")
|
|
1959
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1960
|
-
let d = e.skip(l);
|
|
1961
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
return o;
|
|
1965
|
-
}
|
|
1966
|
-
internalBinaryWrite(e, t, r) {
|
|
1967
|
-
e.name !== "" && t.tag(1, p.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, p.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, p.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, p.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, p.LengthDelimited).string(e.directory), e.lastModified && ce.internalBinaryWrite(e.lastModified, t.tag(12, p.LengthDelimited).fork(), r).join(), e.version !== "" && t.tag(13, p.LengthDelimited).string(e.version);
|
|
1968
|
-
let n = r.writeUnknownFields;
|
|
1969
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
const he = new Zr();
|
|
1973
|
-
class Qr extends g {
|
|
1974
|
-
constructor() {
|
|
1975
|
-
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
1976
|
-
}
|
|
1977
|
-
create(e) {
|
|
1978
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
1979
|
-
return e !== void 0 && f(this, t, e), t;
|
|
1980
|
-
}
|
|
1981
|
-
internalBinaryRead(e, t, r, n) {
|
|
1982
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
1983
|
-
for (; e.pos < c; ) {
|
|
1984
|
-
let [i, l] = e.tag();
|
|
1985
|
-
switch (i) {
|
|
1986
|
-
default:
|
|
1987
|
-
let a = r.readUnknownField;
|
|
1988
|
-
if (a === "throw")
|
|
1989
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
1990
|
-
let d = e.skip(l);
|
|
1991
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
return o;
|
|
1995
|
-
}
|
|
1996
|
-
internalBinaryWrite(e, t, r) {
|
|
1997
|
-
let n = r.writeUnknownFields;
|
|
1998
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
new Qr();
|
|
2002
|
-
class Kr extends g {
|
|
2003
|
-
constructor() {
|
|
2004
|
-
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
2005
|
-
{
|
|
2006
|
-
no: 1,
|
|
2007
|
-
name: "resource_id",
|
|
2008
|
-
kind: "scalar",
|
|
2009
|
-
T: 4,
|
|
2010
|
-
L: 0
|
|
2011
|
-
/*LongType.BIGINT*/
|
|
2012
|
-
},
|
|
2013
|
-
{
|
|
2014
|
-
no: 2,
|
|
2015
|
-
name: "location",
|
|
2016
|
-
kind: "scalar",
|
|
2017
|
-
T: 9
|
|
2018
|
-
/*ScalarType.STRING*/
|
|
2019
|
-
}
|
|
2020
|
-
]);
|
|
2021
|
-
}
|
|
2022
|
-
create(e) {
|
|
2023
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2024
|
-
return t.resourceId = 0n, t.location = "", e !== void 0 && f(this, t, e), t;
|
|
2025
|
-
}
|
|
2026
|
-
internalBinaryRead(e, t, r, n) {
|
|
2027
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2028
|
-
for (; e.pos < c; ) {
|
|
2029
|
-
let [i, l] = e.tag();
|
|
2030
|
-
switch (i) {
|
|
2031
|
-
case /* uint64 resource_id */
|
|
2032
|
-
1:
|
|
2033
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2034
|
-
break;
|
|
2035
|
-
case /* string location */
|
|
2036
|
-
2:
|
|
2037
|
-
o.location = e.string();
|
|
2038
|
-
break;
|
|
2039
|
-
default:
|
|
2040
|
-
let a = r.readUnknownField;
|
|
2041
|
-
if (a === "throw")
|
|
2042
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2043
|
-
let d = e.skip(l);
|
|
2044
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
return o;
|
|
2048
|
-
}
|
|
2049
|
-
internalBinaryWrite(e, t, r) {
|
|
2050
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.location !== "" && t.tag(2, p.LengthDelimited).string(e.location);
|
|
2051
|
-
let n = r.writeUnknownFields;
|
|
2052
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
const Xr = new Kr();
|
|
2056
|
-
class Yr extends g {
|
|
2057
|
-
constructor() {
|
|
2058
|
-
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2059
|
-
{ no: 1, name: "items", kind: "message", repeat: 2, T: () => he },
|
|
2060
|
-
{
|
|
2061
|
-
no: 2,
|
|
2062
|
-
name: "delimiter",
|
|
2063
|
-
kind: "scalar",
|
|
2064
|
-
T: 9
|
|
2065
|
-
/*ScalarType.STRING*/
|
|
2066
|
-
}
|
|
2067
|
-
]);
|
|
2068
|
-
}
|
|
2069
|
-
create(e) {
|
|
2070
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2071
|
-
return t.items = [], t.delimiter = "", e !== void 0 && f(this, t, e), t;
|
|
2072
|
-
}
|
|
2073
|
-
internalBinaryRead(e, t, r, n) {
|
|
2074
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2075
|
-
for (; e.pos < c; ) {
|
|
2076
|
-
let [i, l] = e.tag();
|
|
2077
|
-
switch (i) {
|
|
2078
|
-
case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
|
|
2079
|
-
1:
|
|
2080
|
-
o.items.push(he.internalBinaryRead(e, e.uint32(), r));
|
|
2081
|
-
break;
|
|
2082
|
-
case /* string delimiter */
|
|
2083
|
-
2:
|
|
2084
|
-
o.delimiter = e.string();
|
|
2085
|
-
break;
|
|
2086
|
-
default:
|
|
2087
|
-
let a = r.readUnknownField;
|
|
2088
|
-
if (a === "throw")
|
|
2089
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2090
|
-
let d = e.skip(l);
|
|
2091
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
return o;
|
|
2095
|
-
}
|
|
2096
|
-
internalBinaryWrite(e, t, r) {
|
|
2097
|
-
for (let o = 0; o < e.items.length; o++)
|
|
2098
|
-
he.internalBinaryWrite(e.items[o], t.tag(1, p.LengthDelimited).fork(), r).join();
|
|
2099
|
-
e.delimiter !== "" && t.tag(2, p.LengthDelimited).string(e.delimiter);
|
|
2100
|
-
let n = r.writeUnknownFields;
|
|
2101
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
const en = new Yr(), de = new x("MiLaboratories.Controller.Shared.LS", [
|
|
2105
|
-
{ name: "List", options: {}, I: Xr, O: en }
|
|
2106
|
-
]);
|
|
2107
|
-
class tn {
|
|
2108
|
-
constructor(e) {
|
|
2109
|
-
h(this, "typeName", de.typeName);
|
|
2110
|
-
h(this, "methods", de.methods);
|
|
2111
|
-
h(this, "options", de.options);
|
|
2112
|
-
this._transport = e;
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
* @generated from protobuf rpc: List
|
|
2116
|
-
*/
|
|
2117
|
-
list(e, t) {
|
|
2118
|
-
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
2119
|
-
return R("unary", this._transport, r, n, e);
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
class rn {
|
|
2123
|
-
constructor(e, t) {
|
|
2124
|
-
h(this, "grpcClient");
|
|
2125
|
-
this.logger = t, this.grpcClient = e.createGrpcClientProvider((r) => new tn(r));
|
|
2126
|
-
}
|
|
2127
|
-
close() {
|
|
2128
|
-
}
|
|
2129
|
-
async list(e, t, r) {
|
|
2130
|
-
return await this.grpcClient.get().list(
|
|
2131
|
-
{
|
|
2132
|
-
resourceId: e.id,
|
|
2133
|
-
location: t
|
|
2134
|
-
},
|
|
2135
|
-
$(e.type, r)
|
|
2136
|
-
).response;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
class nn extends g {
|
|
2140
|
-
constructor() {
|
|
2141
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2142
|
-
}
|
|
2143
|
-
create(e) {
|
|
2144
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2145
|
-
return e !== void 0 && f(this, t, e), t;
|
|
2146
|
-
}
|
|
2147
|
-
internalBinaryRead(e, t, r, n) {
|
|
2148
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2149
|
-
for (; e.pos < c; ) {
|
|
2150
|
-
let [i, l] = e.tag();
|
|
2151
|
-
switch (i) {
|
|
2152
|
-
default:
|
|
2153
|
-
let a = r.readUnknownField;
|
|
2154
|
-
if (a === "throw")
|
|
2155
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2156
|
-
let d = e.skip(l);
|
|
2157
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
return o;
|
|
2161
|
-
}
|
|
2162
|
-
internalBinaryWrite(e, t, r) {
|
|
2163
|
-
let n = r.writeUnknownFields;
|
|
2164
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
new nn();
|
|
2168
|
-
class on extends g {
|
|
2169
|
-
constructor() {
|
|
2170
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2171
|
-
{
|
|
2172
|
-
no: 1,
|
|
2173
|
-
name: "resource_id",
|
|
2174
|
-
kind: "scalar",
|
|
2175
|
-
T: 4,
|
|
2176
|
-
L: 0
|
|
2177
|
-
/*LongType.BIGINT*/
|
|
2178
|
-
},
|
|
2179
|
-
{
|
|
2180
|
-
no: 2,
|
|
2181
|
-
name: "offset",
|
|
2182
|
-
kind: "scalar",
|
|
2183
|
-
T: 3,
|
|
2184
|
-
L: 0
|
|
2185
|
-
/*LongType.BIGINT*/
|
|
2186
|
-
},
|
|
2187
|
-
{
|
|
2188
|
-
no: 11,
|
|
2189
|
-
name: "chunk_size",
|
|
2190
|
-
kind: "scalar",
|
|
2191
|
-
opt: !0,
|
|
2192
|
-
T: 13
|
|
2193
|
-
/*ScalarType.UINT32*/
|
|
2194
|
-
},
|
|
2195
|
-
{
|
|
2196
|
-
no: 20,
|
|
2197
|
-
name: "read_limit",
|
|
2198
|
-
kind: "scalar",
|
|
2199
|
-
opt: !0,
|
|
2200
|
-
T: 3,
|
|
2201
|
-
L: 0
|
|
2202
|
-
/*LongType.BIGINT*/
|
|
2203
|
-
}
|
|
2204
|
-
]);
|
|
2205
|
-
}
|
|
2206
|
-
create(e) {
|
|
2207
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2208
|
-
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2209
|
-
}
|
|
2210
|
-
internalBinaryRead(e, t, r, n) {
|
|
2211
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2212
|
-
for (; e.pos < c; ) {
|
|
2213
|
-
let [i, l] = e.tag();
|
|
2214
|
-
switch (i) {
|
|
2215
|
-
case /* uint64 resource_id */
|
|
2216
|
-
1:
|
|
2217
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2218
|
-
break;
|
|
2219
|
-
case /* int64 offset */
|
|
2220
|
-
2:
|
|
2221
|
-
o.offset = e.int64().toBigInt();
|
|
2222
|
-
break;
|
|
2223
|
-
case /* optional uint32 chunk_size */
|
|
2224
|
-
11:
|
|
2225
|
-
o.chunkSize = e.uint32();
|
|
2226
|
-
break;
|
|
2227
|
-
case /* optional int64 read_limit */
|
|
2228
|
-
20:
|
|
2229
|
-
o.readLimit = e.int64().toBigInt();
|
|
2230
|
-
break;
|
|
2231
|
-
default:
|
|
2232
|
-
let a = r.readUnknownField;
|
|
2233
|
-
if (a === "throw")
|
|
2234
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2235
|
-
let d = e.skip(l);
|
|
2236
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
return o;
|
|
2240
|
-
}
|
|
2241
|
-
internalBinaryWrite(e, t, r) {
|
|
2242
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, p.Varint).int64(e.offset), e.chunkSize !== void 0 && t.tag(11, p.Varint).uint32(e.chunkSize), e.readLimit !== void 0 && t.tag(20, p.Varint).int64(e.readLimit);
|
|
2243
|
-
let n = r.writeUnknownFields;
|
|
2244
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
const sn = new on();
|
|
2248
|
-
class an extends g {
|
|
2249
|
-
constructor() {
|
|
2250
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2251
|
-
{
|
|
2252
|
-
no: 1,
|
|
2253
|
-
name: "resource_id",
|
|
2254
|
-
kind: "scalar",
|
|
2255
|
-
T: 4,
|
|
2256
|
-
L: 0
|
|
2257
|
-
/*LongType.BIGINT*/
|
|
2258
|
-
},
|
|
2259
|
-
{
|
|
2260
|
-
no: 2,
|
|
2261
|
-
name: "offset",
|
|
2262
|
-
kind: "scalar",
|
|
2263
|
-
T: 3,
|
|
2264
|
-
L: 0
|
|
2265
|
-
/*LongType.BIGINT*/
|
|
2266
|
-
},
|
|
2267
|
-
{
|
|
2268
|
-
no: 11,
|
|
2269
|
-
name: "chunk_size",
|
|
2270
|
-
kind: "scalar",
|
|
2271
|
-
opt: !0,
|
|
2272
|
-
T: 13
|
|
2273
|
-
/*ScalarType.UINT32*/
|
|
2274
|
-
}
|
|
2275
|
-
]);
|
|
2276
|
-
}
|
|
2277
|
-
create(e) {
|
|
2278
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2279
|
-
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2280
|
-
}
|
|
2281
|
-
internalBinaryRead(e, t, r, n) {
|
|
2282
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2283
|
-
for (; e.pos < c; ) {
|
|
2284
|
-
let [i, l] = e.tag();
|
|
2285
|
-
switch (i) {
|
|
2286
|
-
case /* uint64 resource_id */
|
|
2287
|
-
1:
|
|
2288
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2289
|
-
break;
|
|
2290
|
-
case /* int64 offset */
|
|
2291
|
-
2:
|
|
2292
|
-
o.offset = e.int64().toBigInt();
|
|
2293
|
-
break;
|
|
2294
|
-
case /* optional uint32 chunk_size */
|
|
2295
|
-
11:
|
|
2296
|
-
o.chunkSize = e.uint32();
|
|
2297
|
-
break;
|
|
2298
|
-
default:
|
|
2299
|
-
let a = r.readUnknownField;
|
|
2300
|
-
if (a === "throw")
|
|
2301
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2302
|
-
let d = e.skip(l);
|
|
2303
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
return o;
|
|
2307
|
-
}
|
|
2308
|
-
internalBinaryWrite(e, t, r) {
|
|
2309
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, p.Varint).int64(e.offset), e.chunkSize !== void 0 && t.tag(11, p.Varint).uint32(e.chunkSize);
|
|
2310
|
-
let n = r.writeUnknownFields;
|
|
2311
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2312
|
-
}
|
|
2313
|
-
}
|
|
2314
|
-
const ln = new an();
|
|
2315
|
-
class cn extends g {
|
|
2316
|
-
constructor() {
|
|
2317
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2318
|
-
{
|
|
2319
|
-
no: 1,
|
|
2320
|
-
name: "resource_id",
|
|
2321
|
-
kind: "scalar",
|
|
2322
|
-
T: 4,
|
|
2323
|
-
L: 0
|
|
2324
|
-
/*LongType.BIGINT*/
|
|
2325
|
-
},
|
|
2326
|
-
{
|
|
2327
|
-
no: 2,
|
|
2328
|
-
name: "offset",
|
|
2329
|
-
kind: "scalar",
|
|
2330
|
-
T: 3,
|
|
2331
|
-
L: 0
|
|
2332
|
-
/*LongType.BIGINT*/
|
|
2333
|
-
},
|
|
2334
|
-
{
|
|
2335
|
-
no: 20,
|
|
2336
|
-
name: "read_limit",
|
|
2337
|
-
kind: "scalar",
|
|
2338
|
-
opt: !0,
|
|
2339
|
-
T: 3,
|
|
2340
|
-
L: 0
|
|
2341
|
-
/*LongType.BIGINT*/
|
|
2342
|
-
},
|
|
2343
|
-
{
|
|
2344
|
-
no: 21,
|
|
2345
|
-
name: "search",
|
|
2346
|
-
kind: "scalar",
|
|
2347
|
-
opt: !0,
|
|
2348
|
-
T: 9
|
|
2349
|
-
/*ScalarType.STRING*/
|
|
2350
|
-
},
|
|
2351
|
-
{
|
|
2352
|
-
no: 22,
|
|
2353
|
-
name: "search_re",
|
|
2354
|
-
kind: "scalar",
|
|
2355
|
-
opt: !0,
|
|
2356
|
-
T: 9
|
|
2357
|
-
/*ScalarType.STRING*/
|
|
2358
|
-
}
|
|
2359
|
-
]);
|
|
2360
|
-
}
|
|
2361
|
-
create(e) {
|
|
2362
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2363
|
-
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2364
|
-
}
|
|
2365
|
-
internalBinaryRead(e, t, r, n) {
|
|
2366
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2367
|
-
for (; e.pos < c; ) {
|
|
2368
|
-
let [i, l] = e.tag();
|
|
2369
|
-
switch (i) {
|
|
2370
|
-
case /* uint64 resource_id */
|
|
2371
|
-
1:
|
|
2372
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2373
|
-
break;
|
|
2374
|
-
case /* int64 offset */
|
|
2375
|
-
2:
|
|
2376
|
-
o.offset = e.int64().toBigInt();
|
|
2377
|
-
break;
|
|
2378
|
-
case /* optional int64 read_limit */
|
|
2379
|
-
20:
|
|
2380
|
-
o.readLimit = e.int64().toBigInt();
|
|
2381
|
-
break;
|
|
2382
|
-
case /* optional string search */
|
|
2383
|
-
21:
|
|
2384
|
-
o.search = e.string();
|
|
2385
|
-
break;
|
|
2386
|
-
case /* optional string search_re */
|
|
2387
|
-
22:
|
|
2388
|
-
o.searchRe = e.string();
|
|
2389
|
-
break;
|
|
2390
|
-
default:
|
|
2391
|
-
let a = r.readUnknownField;
|
|
2392
|
-
if (a === "throw")
|
|
2393
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2394
|
-
let d = e.skip(l);
|
|
2395
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
return o;
|
|
2399
|
-
}
|
|
2400
|
-
internalBinaryWrite(e, t, r) {
|
|
2401
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, p.Varint).int64(e.offset), e.readLimit !== void 0 && t.tag(20, p.Varint).int64(e.readLimit), e.search !== void 0 && t.tag(21, p.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, p.LengthDelimited).string(e.searchRe);
|
|
2402
|
-
let n = r.writeUnknownFields;
|
|
2403
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
const hn = new cn();
|
|
2407
|
-
class dn extends g {
|
|
2408
|
-
constructor() {
|
|
2409
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2410
|
-
{
|
|
2411
|
-
no: 1,
|
|
2412
|
-
name: "resource_id",
|
|
2413
|
-
kind: "scalar",
|
|
2414
|
-
T: 4,
|
|
2415
|
-
L: 0
|
|
2416
|
-
/*LongType.BIGINT*/
|
|
2417
|
-
},
|
|
2418
|
-
{
|
|
2419
|
-
no: 2,
|
|
2420
|
-
name: "offset",
|
|
2421
|
-
kind: "scalar",
|
|
2422
|
-
T: 3,
|
|
2423
|
-
L: 0
|
|
2424
|
-
/*LongType.BIGINT*/
|
|
2425
|
-
},
|
|
2426
|
-
{
|
|
2427
|
-
no: 20,
|
|
2428
|
-
name: "read_limit",
|
|
2429
|
-
kind: "scalar",
|
|
2430
|
-
opt: !0,
|
|
2431
|
-
T: 3,
|
|
2432
|
-
L: 0
|
|
2433
|
-
/*LongType.BIGINT*/
|
|
2434
|
-
},
|
|
2435
|
-
{
|
|
2436
|
-
no: 21,
|
|
2437
|
-
name: "search",
|
|
2438
|
-
kind: "scalar",
|
|
2439
|
-
opt: !0,
|
|
2440
|
-
T: 9
|
|
2441
|
-
/*ScalarType.STRING*/
|
|
2442
|
-
},
|
|
2443
|
-
{
|
|
2444
|
-
no: 22,
|
|
2445
|
-
name: "search_re",
|
|
2446
|
-
kind: "scalar",
|
|
2447
|
-
opt: !0,
|
|
2448
|
-
T: 9
|
|
2449
|
-
/*ScalarType.STRING*/
|
|
2450
|
-
}
|
|
2451
|
-
]);
|
|
2452
|
-
}
|
|
2453
|
-
create(e) {
|
|
2454
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2455
|
-
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2456
|
-
}
|
|
2457
|
-
internalBinaryRead(e, t, r, n) {
|
|
2458
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2459
|
-
for (; e.pos < c; ) {
|
|
2460
|
-
let [i, l] = e.tag();
|
|
2461
|
-
switch (i) {
|
|
2462
|
-
case /* uint64 resource_id */
|
|
2463
|
-
1:
|
|
2464
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2465
|
-
break;
|
|
2466
|
-
case /* int64 offset */
|
|
2467
|
-
2:
|
|
2468
|
-
o.offset = e.int64().toBigInt();
|
|
2469
|
-
break;
|
|
2470
|
-
case /* optional int64 read_limit */
|
|
2471
|
-
20:
|
|
2472
|
-
o.readLimit = e.int64().toBigInt();
|
|
2473
|
-
break;
|
|
2474
|
-
case /* optional string search */
|
|
2475
|
-
21:
|
|
2476
|
-
o.search = e.string();
|
|
2477
|
-
break;
|
|
2478
|
-
case /* optional string search_re */
|
|
2479
|
-
22:
|
|
2480
|
-
o.searchRe = e.string();
|
|
2481
|
-
break;
|
|
2482
|
-
default:
|
|
2483
|
-
let a = r.readUnknownField;
|
|
2484
|
-
if (a === "throw")
|
|
2485
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2486
|
-
let d = e.skip(l);
|
|
2487
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
return o;
|
|
2491
|
-
}
|
|
2492
|
-
internalBinaryWrite(e, t, r) {
|
|
2493
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, p.Varint).int64(e.offset), e.readLimit !== void 0 && t.tag(20, p.Varint).int64(e.readLimit), e.search !== void 0 && t.tag(21, p.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, p.LengthDelimited).string(e.searchRe);
|
|
2494
|
-
let n = r.writeUnknownFields;
|
|
2495
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
const un = new dn();
|
|
2499
|
-
class pn extends g {
|
|
2500
|
-
constructor() {
|
|
2501
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2502
|
-
{
|
|
2503
|
-
no: 1,
|
|
2504
|
-
name: "resource_id",
|
|
2505
|
-
kind: "scalar",
|
|
2506
|
-
T: 4,
|
|
2507
|
-
L: 0
|
|
2508
|
-
/*LongType.BIGINT*/
|
|
2509
|
-
},
|
|
2510
|
-
{
|
|
2511
|
-
no: 2,
|
|
2512
|
-
name: "offset",
|
|
2513
|
-
kind: "scalar",
|
|
2514
|
-
opt: !0,
|
|
2515
|
-
T: 3,
|
|
2516
|
-
L: 0
|
|
2517
|
-
/*LongType.BIGINT*/
|
|
2518
|
-
},
|
|
2519
|
-
{
|
|
2520
|
-
no: 3,
|
|
2521
|
-
name: "line_count",
|
|
2522
|
-
kind: "scalar",
|
|
2523
|
-
opt: !0,
|
|
2524
|
-
T: 5
|
|
2525
|
-
/*ScalarType.INT32*/
|
|
2526
|
-
},
|
|
2527
|
-
{
|
|
2528
|
-
no: 21,
|
|
2529
|
-
name: "search",
|
|
2530
|
-
kind: "scalar",
|
|
2531
|
-
opt: !0,
|
|
2532
|
-
T: 9
|
|
2533
|
-
/*ScalarType.STRING*/
|
|
2534
|
-
},
|
|
2535
|
-
{
|
|
2536
|
-
no: 22,
|
|
2537
|
-
name: "search_re",
|
|
2538
|
-
kind: "scalar",
|
|
2539
|
-
opt: !0,
|
|
2540
|
-
T: 9
|
|
2541
|
-
/*ScalarType.STRING*/
|
|
2542
|
-
}
|
|
2543
|
-
]);
|
|
2544
|
-
}
|
|
2545
|
-
create(e) {
|
|
2546
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2547
|
-
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
2548
|
-
}
|
|
2549
|
-
internalBinaryRead(e, t, r, n) {
|
|
2550
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2551
|
-
for (; e.pos < c; ) {
|
|
2552
|
-
let [i, l] = e.tag();
|
|
2553
|
-
switch (i) {
|
|
2554
|
-
case /* uint64 resource_id */
|
|
2555
|
-
1:
|
|
2556
|
-
o.resourceId = e.uint64().toBigInt();
|
|
2557
|
-
break;
|
|
2558
|
-
case /* optional int64 offset */
|
|
2559
|
-
2:
|
|
2560
|
-
o.offset = e.int64().toBigInt();
|
|
2561
|
-
break;
|
|
2562
|
-
case /* optional int32 line_count */
|
|
2563
|
-
3:
|
|
2564
|
-
o.lineCount = e.int32();
|
|
2565
|
-
break;
|
|
2566
|
-
case /* optional string search */
|
|
2567
|
-
21:
|
|
2568
|
-
o.search = e.string();
|
|
2569
|
-
break;
|
|
2570
|
-
case /* optional string search_re */
|
|
2571
|
-
22:
|
|
2572
|
-
o.searchRe = e.string();
|
|
2573
|
-
break;
|
|
2574
|
-
default:
|
|
2575
|
-
let a = r.readUnknownField;
|
|
2576
|
-
if (a === "throw")
|
|
2577
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2578
|
-
let d = e.skip(l);
|
|
2579
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
return o;
|
|
2583
|
-
}
|
|
2584
|
-
internalBinaryWrite(e, t, r) {
|
|
2585
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.offset !== void 0 && t.tag(2, p.Varint).int64(e.offset), e.lineCount !== void 0 && t.tag(3, p.Varint).int32(e.lineCount), e.search !== void 0 && t.tag(21, p.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, p.LengthDelimited).string(e.searchRe);
|
|
2586
|
-
let n = r.writeUnknownFields;
|
|
2587
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
const gn = new pn();
|
|
2591
|
-
class fn extends g {
|
|
2592
|
-
constructor() {
|
|
2593
|
-
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2594
|
-
{
|
|
2595
|
-
no: 1,
|
|
2596
|
-
name: "data",
|
|
2597
|
-
kind: "scalar",
|
|
2598
|
-
T: 12
|
|
2599
|
-
/*ScalarType.BYTES*/
|
|
2600
|
-
},
|
|
2601
|
-
{
|
|
2602
|
-
no: 2,
|
|
2603
|
-
name: "size",
|
|
2604
|
-
kind: "scalar",
|
|
2605
|
-
T: 4,
|
|
2606
|
-
L: 0
|
|
2607
|
-
/*LongType.BIGINT*/
|
|
2608
|
-
},
|
|
2609
|
-
{
|
|
2610
|
-
no: 3,
|
|
2611
|
-
name: "new_offset",
|
|
2612
|
-
kind: "scalar",
|
|
2613
|
-
T: 4,
|
|
2614
|
-
L: 0
|
|
2615
|
-
/*LongType.BIGINT*/
|
|
2616
|
-
}
|
|
2617
|
-
]);
|
|
2618
|
-
}
|
|
2619
|
-
create(e) {
|
|
2620
|
-
const t = globalThis.Object.create(this.messagePrototype);
|
|
2621
|
-
return t.data = new Uint8Array(0), t.size = 0n, t.newOffset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2622
|
-
}
|
|
2623
|
-
internalBinaryRead(e, t, r, n) {
|
|
2624
|
-
let o = n ?? this.create(), c = e.pos + t;
|
|
2625
|
-
for (; e.pos < c; ) {
|
|
2626
|
-
let [i, l] = e.tag();
|
|
2627
|
-
switch (i) {
|
|
2628
|
-
case /* bytes data */
|
|
2629
|
-
1:
|
|
2630
|
-
o.data = e.bytes();
|
|
2631
|
-
break;
|
|
2632
|
-
case /* uint64 size */
|
|
2633
|
-
2:
|
|
2634
|
-
o.size = e.uint64().toBigInt();
|
|
2635
|
-
break;
|
|
2636
|
-
case /* uint64 new_offset */
|
|
2637
|
-
3:
|
|
2638
|
-
o.newOffset = e.uint64().toBigInt();
|
|
2639
|
-
break;
|
|
2640
|
-
default:
|
|
2641
|
-
let a = r.readUnknownField;
|
|
2642
|
-
if (a === "throw")
|
|
2643
|
-
throw new globalThis.Error(`Unknown field ${i} (wire type ${l}) for ${this.typeName}`);
|
|
2644
|
-
let d = e.skip(l);
|
|
2645
|
-
a !== !1 && (a === !0 ? u.onRead : a)(this.typeName, o, i, l, d);
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
return o;
|
|
2649
|
-
}
|
|
2650
|
-
internalBinaryWrite(e, t, r) {
|
|
2651
|
-
e.data.length && t.tag(1, p.LengthDelimited).bytes(e.data), e.size !== 0n && t.tag(2, p.Varint).uint64(e.size), e.newOffset !== 0n && t.tag(3, p.Varint).uint64(e.newOffset);
|
|
2652
|
-
let n = r.writeUnknownFields;
|
|
2653
|
-
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
const _ = new fn(), ue = new x("MiLaboratories.Controller.Shared.Streaming", [
|
|
2657
|
-
{ name: "StreamBinary", serverStreaming: !0, options: {}, I: sn, O: _ },
|
|
2658
|
-
{ name: "ReadBinary", options: {}, I: ln, O: _ },
|
|
2659
|
-
{ name: "StreamText", serverStreaming: !0, options: {}, I: hn, O: _ },
|
|
2660
|
-
{ name: "ReadText", options: {}, I: un, O: _ },
|
|
2661
|
-
{ name: "LastLines", options: {}, I: gn, O: _ }
|
|
2662
|
-
]);
|
|
2663
|
-
class wn {
|
|
2664
|
-
constructor(e) {
|
|
2665
|
-
h(this, "typeName", ue.typeName);
|
|
2666
|
-
h(this, "methods", ue.methods);
|
|
2667
|
-
h(this, "options", ue.options);
|
|
2668
|
-
this._transport = e;
|
|
2669
|
-
}
|
|
2670
|
-
/**
|
|
2671
|
-
* StreamBinary provides stream of binary file. Each response message keeps
|
|
2672
|
-
* one single chunk of binary data from data source. See StreamingAPI.Binary message
|
|
2673
|
-
* for more info on available options.
|
|
2674
|
-
*
|
|
2675
|
-
* @generated from protobuf rpc: StreamBinary
|
|
2676
|
-
*/
|
|
2677
|
-
streamBinary(e, t) {
|
|
2678
|
-
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
2679
|
-
return R("serverStreaming", this._transport, r, n, e);
|
|
2680
|
-
}
|
|
2681
|
-
/**
|
|
2682
|
-
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
2683
|
-
* The difference to StreamBinary is that the client receives single response for each
|
|
2684
|
-
* call and has to send new calls to the server to get fresh data from remote item.
|
|
2685
|
-
* Each response (each chunk from server) keeps not more than 3.9MiB of data.
|
|
2686
|
-
*
|
|
2687
|
-
* @generated from protobuf rpc: ReadBinary
|
|
2688
|
-
*/
|
|
2689
|
-
readBinary(e, t) {
|
|
2690
|
-
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
2691
|
-
return R("unary", this._transport, r, n, e);
|
|
2692
|
-
}
|
|
2693
|
-
/**
|
|
2694
|
-
* StreamText provides stream of textual file, splitting the data by newline symbol.
|
|
2695
|
-
* Each response message keeps one single line of text from data source.
|
|
2696
|
-
*
|
|
2697
|
-
* @generated from protobuf rpc: StreamText
|
|
2698
|
-
*/
|
|
2699
|
-
streamText(e, t) {
|
|
2700
|
-
const r = this.methods[2], n = this._transport.mergeOptions(t);
|
|
2701
|
-
return R("serverStreaming", this._transport, r, n, e);
|
|
2702
|
-
}
|
|
2703
|
-
/**
|
|
2704
|
-
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
2705
|
-
* The difference to StreamBinary is that the client receives single response for each
|
|
2706
|
-
* call and has to send new calls to the server to get fresh data from remote item.
|
|
2707
|
-
* Each response (each chunk from server) keeps not more than 3.9MiB of data.
|
|
2708
|
-
*
|
|
2709
|
-
* @generated from protobuf rpc: ReadText
|
|
2710
|
-
*/
|
|
2711
|
-
readText(e, t) {
|
|
2712
|
-
const r = this.methods[3], n = this._transport.mergeOptions(t);
|
|
2713
|
-
return R("unary", this._transport, r, n, e);
|
|
2714
|
-
}
|
|
2715
|
-
/**
|
|
2716
|
-
* LastLines provides single message with the last lines from data source.
|
|
2717
|
-
* When search pattern is specified, the last lines matching the given pattern are returned.
|
|
2718
|
-
* The lines are returned in reversed order, as server reads data source from the end.
|
|
2719
|
-
* Consider it as equivalent to 'tac <file> | grep <search> | head -n <line_count>'
|
|
2720
|
-
* The <new_offset> returned in the response points to the _beginning_ of the last
|
|
2721
|
-
* line found, so client can continue reading the file backwards in subsequent calls.
|
|
2722
|
-
* This means, that use of this <new_offset> in ReadText() will return you the same line
|
|
2723
|
-
* returned last in LastLines() data.
|
|
2724
|
-
*
|
|
2725
|
-
* @generated from protobuf rpc: LastLines
|
|
2726
|
-
*/
|
|
2727
|
-
lastLines(e, t) {
|
|
2728
|
-
const r = this.methods[4], n = this._transport.mergeOptions(t);
|
|
2729
|
-
return R("unary", this._transport, r, n, e);
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
class mn {
|
|
2733
|
-
constructor(e, t, r) {
|
|
2734
|
-
h(this, "grpcClient");
|
|
2735
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((n) => new wn(n));
|
|
2736
|
-
}
|
|
2737
|
-
close() {
|
|
2738
|
-
}
|
|
2739
|
-
/** Reads text back and returns the text,
|
|
2740
|
-
* the new offset
|
|
2741
|
-
* and the total size of the (currently existing) file. */
|
|
2742
|
-
async lastLines({ id: e, type: t }, r, n = 0n, o, c) {
|
|
2743
|
-
return (await this.grpcClient.get().lastLines(
|
|
2744
|
-
{
|
|
2745
|
-
resourceId: e,
|
|
2746
|
-
lineCount: r,
|
|
2747
|
-
offset: n,
|
|
2748
|
-
search: o
|
|
2749
|
-
},
|
|
2750
|
-
$(t, c)
|
|
2751
|
-
)).response;
|
|
2752
|
-
}
|
|
2753
|
-
/** Reads the file forward and returns the text,
|
|
2754
|
-
* the new offset
|
|
2755
|
-
* and the total size of the (currently existing) file. */
|
|
2756
|
-
async readText({ id: e, type: t }, r, n = 0n, o, c) {
|
|
2757
|
-
return (await this.grpcClient.get().readText(
|
|
2758
|
-
{
|
|
2759
|
-
resourceId: K(e),
|
|
2760
|
-
readLimit: BigInt(r),
|
|
2761
|
-
offset: n,
|
|
2762
|
-
search: o
|
|
2763
|
-
},
|
|
2764
|
-
$(t, c)
|
|
2765
|
-
)).response;
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
function rs(s, e, t) {
|
|
2769
|
-
return e.getDriver({
|
|
2770
|
-
name: "DownloadBlob",
|
|
2771
|
-
init: (r, n, o) => new Ar(n, o, s, t)
|
|
2772
|
-
});
|
|
2773
|
-
}
|
|
2774
|
-
function ns(s, e) {
|
|
2775
|
-
return s.getDriver({
|
|
2776
|
-
name: "StreamLogs",
|
|
2777
|
-
init: (t, r, n) => new mn(r, n, e)
|
|
2778
|
-
});
|
|
2779
|
-
}
|
|
2780
|
-
function os(s, e) {
|
|
2781
|
-
return s.getDriver({
|
|
2782
|
-
name: "UploadProgress",
|
|
2783
|
-
init: (t, r, n) => new vr(r, n, s, e)
|
|
2784
|
-
});
|
|
2785
|
-
}
|
|
2786
|
-
function ss(s, e) {
|
|
2787
|
-
return s.getDriver({
|
|
2788
|
-
name: "UploadBlob",
|
|
2789
|
-
init: (t, r, n) => new ur(r, n, s, e)
|
|
2790
|
-
});
|
|
2791
|
-
}
|
|
2792
|
-
function yn(s, e) {
|
|
2793
|
-
return s.getDriver({
|
|
2794
|
-
name: "LsFiles",
|
|
2795
|
-
init: (t, r, n) => new rn(r, e)
|
|
2796
|
-
});
|
|
2797
|
-
}
|
|
2798
|
-
const bn = new He(32);
|
|
2799
|
-
async function Ee(s, e) {
|
|
2800
|
-
return await bn.run(async () => {
|
|
2801
|
-
const t = {};
|
|
2802
|
-
e && (t.start = e.from, t.end = e.to - 1);
|
|
2803
|
-
let r;
|
|
2804
|
-
try {
|
|
2805
|
-
return r = Ne.createReadStream(s, t), await qe(r);
|
|
2806
|
-
} catch (n) {
|
|
2807
|
-
throw r && !r.destroyed && r.destroy(), n;
|
|
2808
|
-
}
|
|
2809
|
-
});
|
|
2810
|
-
}
|
|
2811
|
-
const nt = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
2812
|
-
function kn(s, e) {
|
|
2813
|
-
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
2814
|
-
}
|
|
2815
|
-
function Tn(s) {
|
|
2816
|
-
return !!s.match(nt);
|
|
2817
|
-
}
|
|
2818
|
-
function pe(s, e) {
|
|
2819
|
-
const t = s.match(nt);
|
|
2820
|
-
if (t === null)
|
|
2821
|
-
throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
2822
|
-
const { path: r, signature: n } = t.groups;
|
|
2823
|
-
return e.verify(r, n, `Signature verification failed for: ${s}`), { path: r, signature: n };
|
|
2824
|
-
}
|
|
2825
|
-
const Ln = ee({
|
|
2826
|
-
kv: {
|
|
2827
|
-
"ctl/file/blobInfo": L.object({
|
|
2828
|
-
sizeBytes: L.coerce.number()
|
|
2829
|
-
})
|
|
2830
|
-
}
|
|
2831
|
-
});
|
|
2832
|
-
function ot(s, e) {
|
|
2833
|
-
const t = s.kv["ctl/file/blobInfo"].sizeBytes;
|
|
2834
|
-
if (e) {
|
|
2835
|
-
const r = e.to - e.from;
|
|
2836
|
-
if (r > t)
|
|
2837
|
-
throw new Error(`getSize: range (${JSON.stringify(e)}, newSize: ${r}) is greater than size (${t})`);
|
|
2838
|
-
return r;
|
|
2839
|
-
}
|
|
2840
|
-
return t;
|
|
2841
|
-
}
|
|
2842
|
-
const re = L.object({
|
|
2843
|
-
/** Local file path, to take data for upload */
|
|
2844
|
-
localPath: L.string(),
|
|
2845
|
-
/** Path signature, to check this data was generated by us */
|
|
2846
|
-
pathSignature: L.string(),
|
|
2847
|
-
/** File size in bytes */
|
|
2848
|
-
sizeBytes: L.string(),
|
|
2849
|
-
/** Modification time unix timestamp in seconds */
|
|
2850
|
-
modificationTime: L.string()
|
|
2851
|
-
}), st = L.object({
|
|
2852
|
-
/** Pl storage id */
|
|
2853
|
-
storageId: L.string(),
|
|
2854
|
-
/** Path inside storage */
|
|
2855
|
-
path: L.string()
|
|
2856
|
-
}), is = L.union([
|
|
2857
|
-
re,
|
|
2858
|
-
st
|
|
2859
|
-
]), Un = ee({
|
|
2860
|
-
data: re,
|
|
2861
|
-
fields: {
|
|
2862
|
-
blob: !1
|
|
2863
|
-
}
|
|
2864
|
-
}), Pn = ee({
|
|
2865
|
-
fields: {
|
|
2866
|
-
incarnation: !1
|
|
2867
|
-
}
|
|
2868
|
-
}), it = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.+)\/(?<resourceVersion>.+?)\/(?<resourceId>\d+?)\/(?<size>\d+?))#(?<signature>.*)$/;
|
|
2869
|
-
function Rn(s, e) {
|
|
2870
|
-
let t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}/${ot(s)}`;
|
|
2871
|
-
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
2872
|
-
}
|
|
2873
|
-
function Nn(s) {
|
|
2874
|
-
return !!s.match(it);
|
|
2875
|
-
}
|
|
2876
|
-
function $n(s, e) {
|
|
2877
|
-
const t = s.match(it);
|
|
2878
|
-
if (t === null)
|
|
2879
|
-
throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
2880
|
-
const { content: r, resourceType: n, resourceVersion: o, resourceId: c, size: i, signature: l } = t.groups;
|
|
2881
|
-
return e.verify(r, l, `Signature verification failed for ${s}`), {
|
|
2882
|
-
info: {
|
|
2883
|
-
id: Pe(BigInt(c)),
|
|
2884
|
-
type: { name: n, version: o }
|
|
2885
|
-
},
|
|
2886
|
-
size: Number(i)
|
|
2887
|
-
};
|
|
2888
|
-
}
|
|
2889
|
-
class Ie extends Error {
|
|
2890
|
-
constructor() {
|
|
2891
|
-
super(...arguments);
|
|
2892
|
-
h(this, "name", "WrongResourceTypeError");
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
class Sn {
|
|
2896
|
-
constructor(e) {
|
|
2897
|
-
h(this, "updating");
|
|
2898
|
-
this.onUpdate = e;
|
|
2899
|
-
}
|
|
2900
|
-
schedule() {
|
|
2901
|
-
this.updating == null && (this.updating = (async () => {
|
|
2902
|
-
try {
|
|
2903
|
-
await this.onUpdate();
|
|
2904
|
-
} catch (e) {
|
|
2905
|
-
console.log(`error while updating in Updater: ${e}`);
|
|
2906
|
-
} finally {
|
|
2907
|
-
this.updating = void 0;
|
|
2908
|
-
}
|
|
2909
|
-
})());
|
|
2910
|
-
}
|
|
2911
|
-
}
|
|
2912
|
-
function at(s, e) {
|
|
2913
|
-
return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
|
|
2914
|
-
}
|
|
2915
|
-
const lt = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
2916
|
-
function Z(s) {
|
|
2917
|
-
return lt.test(s);
|
|
2918
|
-
}
|
|
2919
|
-
const ct = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
2920
|
-
function In(s) {
|
|
2921
|
-
return ct.test(s);
|
|
2922
|
-
}
|
|
2923
|
-
function Q(s) {
|
|
2924
|
-
let e;
|
|
2925
|
-
if (Z(s))
|
|
2926
|
-
e = s.match(lt);
|
|
2927
|
-
else if (In(s))
|
|
2928
|
-
e = s.match(ct);
|
|
2929
|
-
else throw new Error(`Log handle is malformed: ${s}`);
|
|
2930
|
-
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
2931
|
-
const { resourceType: t, resourceVersion: r, resourceId: n } = e.groups;
|
|
2932
|
-
return {
|
|
2933
|
-
id: Pe(BigInt(n)),
|
|
2934
|
-
type: { name: t, version: r }
|
|
2935
|
-
};
|
|
2936
|
-
}
|
|
2937
|
-
function k(s) {
|
|
2938
|
-
return `${BigInt(s)}`;
|
|
2939
|
-
}
|
|
2940
|
-
function _e(s) {
|
|
2941
|
-
return T.basename(s);
|
|
2942
|
-
}
|
|
2943
|
-
class Dn {
|
|
2944
|
-
constructor(e, t, r, n, o) {
|
|
2945
|
-
h(this, "change", new C());
|
|
2946
|
-
h(this, "signalCtl", new AbortController());
|
|
2947
|
-
h(this, "counter", new B());
|
|
2948
|
-
h(this, "error");
|
|
2949
|
-
h(this, "done", !1);
|
|
2950
|
-
h(this, "size", 0);
|
|
2951
|
-
h(this, "state", {});
|
|
2952
|
-
this.logger = e, this.clientDownload = t, this.rInfo = r, this.handle = n, this.path = o;
|
|
2953
|
-
}
|
|
2954
|
-
/** Returns a simple object that describes this task for debugging purposes. */
|
|
2955
|
-
info() {
|
|
2956
|
-
return {
|
|
2957
|
-
rInfo: this.rInfo,
|
|
2958
|
-
fPath: this.path,
|
|
2959
|
-
done: this.done,
|
|
2960
|
-
error: this.error,
|
|
2961
|
-
state: this.state
|
|
2962
|
-
};
|
|
2963
|
-
}
|
|
2964
|
-
attach(e, t) {
|
|
2965
|
-
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
2966
|
-
}
|
|
2967
|
-
async download() {
|
|
2968
|
-
try {
|
|
2969
|
-
const e = await this.ensureDownloaded();
|
|
2970
|
-
this.setDone(e), this.change.markChanged(`blob download for ${P(this.rInfo.id)} finished`);
|
|
2971
|
-
} catch (e) {
|
|
2972
|
-
throw this.logger.error(`download blob ${y(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`), De(e) && (this.setError(e), this.change.markChanged(`blob download for ${P(this.rInfo.id)} failed`), await w.rm(this.path, { force: !0 })), e;
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
async ensureDownloaded() {
|
|
2976
|
-
this.signalCtl.signal.throwIfAborted(), this.state = {}, this.state.filePath = this.path, await W(T.dirname(this.state.filePath)), this.signalCtl.signal.throwIfAborted(), this.state.dirExists = !0;
|
|
2977
|
-
const e = await A(this.state.filePath);
|
|
2978
|
-
if (this.signalCtl.signal.throwIfAborted(), e) {
|
|
2979
|
-
this.state.fileExists = !0, this.logger.info(`a blob was already downloaded: ${this.state.filePath}`);
|
|
2980
|
-
const r = await w.stat(this.state.filePath);
|
|
2981
|
-
return this.signalCtl.signal.throwIfAborted(), this.state.fileSize = r.size, this.state.fileSize;
|
|
2982
|
-
}
|
|
2983
|
-
return await this.clientDownload.withBlobContent(
|
|
2984
|
-
this.rInfo,
|
|
2985
|
-
{},
|
|
2986
|
-
{ signal: this.signalCtl.signal },
|
|
2987
|
-
async (r, n) => (this.state.fileSize = n, this.state.downloaded = !0, await X(this.logger, this.state.filePath, async (o) => {
|
|
2988
|
-
const c = z.toWeb(ye.createWriteStream(o, { flags: "wx" }));
|
|
2989
|
-
await r.pipeTo(c, { signal: this.signalCtl.signal }), this.state.tempWritten = !0;
|
|
2990
|
-
}), this.state.done = !0, n)
|
|
2991
|
-
);
|
|
2992
|
-
}
|
|
2993
|
-
abort(e) {
|
|
2994
|
-
this.signalCtl.abort(new ht(e));
|
|
2995
|
-
}
|
|
2996
|
-
getBlob() {
|
|
2997
|
-
return this.done ? {
|
|
2998
|
-
done: this.done,
|
|
2999
|
-
result: vn(this.handle, this.size, this.error)
|
|
3000
|
-
} : { done: !1 };
|
|
3001
|
-
}
|
|
3002
|
-
setDone(e) {
|
|
3003
|
-
this.done = !0, this.size = e;
|
|
3004
|
-
}
|
|
3005
|
-
setError(e) {
|
|
3006
|
-
this.done = !0, this.error = e;
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
function De(s) {
|
|
3010
|
-
return s instanceof ht || s instanceof te || s instanceof Se || s instanceof $e || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
|
|
3011
|
-
}
|
|
3012
|
-
class ht extends Error {
|
|
3013
|
-
constructor() {
|
|
3014
|
-
super(...arguments);
|
|
3015
|
-
h(this, "name", "DownloadAborted");
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
function vn(s, e, t) {
|
|
3019
|
-
return t ? { ok: !1, error: t } : s ? {
|
|
3020
|
-
ok: !0,
|
|
3021
|
-
value: {
|
|
3022
|
-
handle: s,
|
|
3023
|
-
size: e
|
|
3024
|
-
}
|
|
3025
|
-
} : { ok: !1, error: new Error("No file or handle provided") };
|
|
3026
|
-
}
|
|
3027
|
-
class ve {
|
|
3028
|
-
constructor(e) {
|
|
3029
|
-
h(this, "cache", /* @__PURE__ */ new Map());
|
|
3030
|
-
h(this, "totalSizeBytes", 0);
|
|
3031
|
-
this.softSizeBytes = e;
|
|
3032
|
-
}
|
|
3033
|
-
existsFile(e) {
|
|
3034
|
-
return this.cache.get(e) != null;
|
|
3035
|
-
}
|
|
3036
|
-
getFile(e, t) {
|
|
3037
|
-
const r = this.cache.get(e);
|
|
3038
|
-
return r != null && r.counter.inc(t), r;
|
|
3039
|
-
}
|
|
3040
|
-
/** Decrements a counter in a cache and if we exceeds
|
|
3041
|
-
* a soft limit, removes files with zero counters. */
|
|
3042
|
-
removeFile(e, t) {
|
|
3043
|
-
return me(this.cache, e).counter.dec(t), this.toDelete();
|
|
3044
|
-
}
|
|
3045
|
-
/** Returns what results should be deleted to comply with the soft limit. */
|
|
3046
|
-
toDelete() {
|
|
3047
|
-
if (this.totalSizeBytes <= this.softSizeBytes) return [];
|
|
3048
|
-
const e = [];
|
|
3049
|
-
let t = 0;
|
|
3050
|
-
return je(this.cache).filter(([r, n]) => n.counter.isZero()).forEach(([r, n]) => {
|
|
3051
|
-
if (this.totalSizeBytes - t <= this.softSizeBytes)
|
|
3052
|
-
return;
|
|
3053
|
-
const o = me(this.cache, r);
|
|
3054
|
-
t += o.size, e.push(o);
|
|
3055
|
-
}), e;
|
|
3056
|
-
}
|
|
3057
|
-
addCache(e, t) {
|
|
3058
|
-
const r = this.cache.get(e.path) == null;
|
|
3059
|
-
if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0)
|
|
3060
|
-
throw new Error(`empty sizeBytes: ${e}`);
|
|
3061
|
-
r && (this.totalSizeBytes += e.size);
|
|
3062
|
-
}
|
|
3063
|
-
removeCache(e) {
|
|
3064
|
-
this.cache.delete(e.path), this.totalSizeBytes -= e.size;
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
const Bn = L.object({
|
|
3068
|
-
ranges: L.array(Dt)
|
|
3069
|
-
}), Cn = ".ranges.json";
|
|
3070
|
-
function En(s) {
|
|
3071
|
-
return s + Cn;
|
|
3072
|
-
}
|
|
3073
|
-
async function _n(s, e) {
|
|
3074
|
-
let t = { ranges: [] };
|
|
3075
|
-
try {
|
|
3076
|
-
const r = await w.readFile(e, "utf8");
|
|
3077
|
-
t = Bn.parse(JSON.parse(r));
|
|
3078
|
-
} catch (r) {
|
|
3079
|
-
if (r instanceof SyntaxError || r instanceof L.ZodError) {
|
|
3080
|
-
const n = `readRangesFile: the file ${e} was corrupted: ${r}`;
|
|
3081
|
-
throw s.error(n), new ut(n);
|
|
3082
|
-
}
|
|
3083
|
-
if (!(r instanceof Error && "code" in r && r.code === "ENOENT"))
|
|
3084
|
-
throw r;
|
|
3085
|
-
}
|
|
3086
|
-
return dt(t), t;
|
|
3087
|
-
}
|
|
3088
|
-
async function Fn(s, e, t) {
|
|
3089
|
-
await X(s, e, async (r) => {
|
|
3090
|
-
await w.writeFile(r, JSON.stringify(t, null, 2), { flag: "wx" });
|
|
3091
|
-
});
|
|
3092
|
-
}
|
|
3093
|
-
function dt(s) {
|
|
3094
|
-
s.ranges.sort((e, t) => e.from - t.from);
|
|
3095
|
-
for (let e = 0; e < s.ranges.length - 1; e++)
|
|
3096
|
-
s.ranges[e].to >= s.ranges[e + 1].from && (On(s, e), e--);
|
|
3097
|
-
}
|
|
3098
|
-
function On(s, e) {
|
|
3099
|
-
const t = Math.min(s.ranges[e].from, s.ranges[e + 1].from), r = Math.max(s.ranges[e].to, s.ranges[e + 1].to);
|
|
3100
|
-
s.ranges.splice(e, 2, { from: t, to: r });
|
|
3101
|
-
}
|
|
3102
|
-
function H(s) {
|
|
3103
|
-
return s.ranges.reduce((e, t) => e + t.to - t.from, 0);
|
|
3104
|
-
}
|
|
3105
|
-
function zn(s, e) {
|
|
3106
|
-
for (const t of s.ranges)
|
|
3107
|
-
if (t.from <= e.from && e.to <= t.to)
|
|
3108
|
-
return !0;
|
|
3109
|
-
return !1;
|
|
3110
|
-
}
|
|
3111
|
-
function Wn(s, e) {
|
|
3112
|
-
return s.ranges.push(e), dt(s), s;
|
|
3113
|
-
}
|
|
3114
|
-
async function xn(s, e, t) {
|
|
3115
|
-
try {
|
|
3116
|
-
await (await w.open(e, "w")).close(), await An(e, t);
|
|
3117
|
-
} catch (r) {
|
|
3118
|
-
s.error(`Error creating file ${e} on platform ${t}: ${r}`);
|
|
3119
|
-
}
|
|
3120
|
-
}
|
|
3121
|
-
async function An(s, e) {
|
|
3122
|
-
e === "win32" && await $t("fsutil", ["sparse", "setflag", `"${s}"`], { stdio: "pipe" });
|
|
3123
|
-
}
|
|
3124
|
-
async function Mn(s, e, t, r, n) {
|
|
3125
|
-
await A(t) || await xn(s, t, e);
|
|
3126
|
-
const o = await w.open(t, "r+");
|
|
3127
|
-
await o.write(r, 0, r.length, n), await o.close();
|
|
3128
|
-
}
|
|
3129
|
-
class ut extends Error {
|
|
3130
|
-
constructor() {
|
|
3131
|
-
super(...arguments);
|
|
3132
|
-
h(this, "name", "CorruptedRangesError");
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
class Hn {
|
|
3136
|
-
constructor(e, t) {
|
|
3137
|
-
this.logger = e, this.cacheDir = t;
|
|
3138
|
-
}
|
|
3139
|
-
fPath(e) {
|
|
3140
|
-
return U.join(this.cacheDir, En(e));
|
|
3141
|
-
}
|
|
3142
|
-
async get(e) {
|
|
3143
|
-
return await _n(this.logger, this.fPath(e));
|
|
3144
|
-
}
|
|
3145
|
-
async set(e, t) {
|
|
3146
|
-
return await Fn(this.logger, this.fPath(e), t);
|
|
3147
|
-
}
|
|
3148
|
-
async delete(e) {
|
|
3149
|
-
await be.rm(this.fPath(e));
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
class jn {
|
|
3153
|
-
constructor(e, t) {
|
|
3154
|
-
h(this, "suffix", ".sparse.bin");
|
|
3155
|
-
this.logger = e, this.cacheDir = t;
|
|
3156
|
-
}
|
|
3157
|
-
async all() {
|
|
3158
|
-
return await W(this.cacheDir), (await be.readdir(this.cacheDir)).filter((t) => t.endsWith(this.suffix));
|
|
3159
|
-
}
|
|
3160
|
-
async exists(e) {
|
|
3161
|
-
return await A(this.path(e));
|
|
3162
|
-
}
|
|
3163
|
-
path(e) {
|
|
3164
|
-
return U.join(this.cacheDir, e + this.suffix);
|
|
3165
|
-
}
|
|
3166
|
-
async write(e, t, r) {
|
|
3167
|
-
await W(this.cacheDir), await Mn(this.logger, process.platform, this.path(e), t, r);
|
|
3168
|
-
}
|
|
3169
|
-
async delete(e) {
|
|
3170
|
-
await be.rm(this.path(e));
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
class Gn {
|
|
3174
|
-
constructor(e, t, r, n) {
|
|
3175
|
-
/** Fields are public for tests. */
|
|
3176
|
-
/** The lock to make sure cache requests are done one by one. */
|
|
3177
|
-
h(this, "lock", new zt.AwaitLock());
|
|
3178
|
-
h(this, "keyToLastAccessTime", /* @__PURE__ */ new Map());
|
|
3179
|
-
h(this, "size", 0);
|
|
3180
|
-
this.logger = e, this.maxSize = t, this.ranges = r, this.storage = n;
|
|
3181
|
-
}
|
|
3182
|
-
/** Resets a cache's size by rereading everything we already store.
|
|
3183
|
-
* Safe for concurrent use. */
|
|
3184
|
-
async reset() {
|
|
3185
|
-
await ge(this.lock, async () => {
|
|
3186
|
-
await this.resetUnsafe();
|
|
3187
|
-
});
|
|
3188
|
-
}
|
|
3189
|
-
/** Returns a path to the key if the range exists in a cache, otherwise returns undefined.
|
|
3190
|
-
* Safe for concurrent use. */
|
|
3191
|
-
async get(e, t) {
|
|
3192
|
-
return await ge(this.lock, async () => await this.getUnsafe(e, t));
|
|
3193
|
-
}
|
|
3194
|
-
/** Sets data to the cache's file and clear the cache if it's needed.
|
|
3195
|
-
* Safe for concurrent use. */
|
|
3196
|
-
async set(e, t, r) {
|
|
3197
|
-
await ge(this.lock, async () => {
|
|
3198
|
-
await this.setUnsafe(e, t, r);
|
|
3199
|
-
});
|
|
3200
|
-
}
|
|
3201
|
-
async resetUnsafe() {
|
|
3202
|
-
this.size = 0, this.keyToLastAccessTime = /* @__PURE__ */ new Map();
|
|
3203
|
-
const e = /* @__PURE__ */ new Date();
|
|
3204
|
-
for (const t of await this.storage.all()) {
|
|
3205
|
-
const r = await this.ranges.get(t);
|
|
3206
|
-
this.size += H(r), this.keyToLastAccessTime.set(t, e);
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
async getUnsafe(e, t) {
|
|
3210
|
-
if (await this.storage.exists(e)) {
|
|
3211
|
-
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3212
|
-
const r = await this.getRanges(e);
|
|
3213
|
-
return zn(r, t) ? this.storage.path(e) : void 0;
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
async setUnsafe(e, t, r) {
|
|
3217
|
-
await this.setWithoutEviction(e, t, r), await this.ensureEvicted();
|
|
3218
|
-
}
|
|
3219
|
-
/** Sets a key and recalculates a size, but doesn't ensures that the size is less than the hard limit. */
|
|
3220
|
-
async setWithoutEviction(e, t, r) {
|
|
3221
|
-
if (t.to - t.from !== r.length)
|
|
3222
|
-
throw new Error(
|
|
3223
|
-
`SparseCache.set: trying to set ${e} with wrong range length: range: ${JSON.stringify(t)}, data: ${r.length}`
|
|
3224
|
-
);
|
|
3225
|
-
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3226
|
-
const n = await this.getRanges(e);
|
|
3227
|
-
this.size -= H(n), await this.storage.write(e, r, t.from);
|
|
3228
|
-
const o = Wn(n, t);
|
|
3229
|
-
this.size += H(o), await this.ranges.set(e, o);
|
|
3230
|
-
}
|
|
3231
|
-
/** Ensures the size is less than hard limit by deleting the oldest keys. */
|
|
3232
|
-
async ensureEvicted() {
|
|
3233
|
-
const e = je(this.keyToLastAccessTime);
|
|
3234
|
-
for (e.sort(([t, r], [n, o]) => o.getTime() - r.getTime()); this.size > this.maxSize; ) {
|
|
3235
|
-
const t = e.pop();
|
|
3236
|
-
if (!t)
|
|
3237
|
-
break;
|
|
3238
|
-
const [r, n] = t, o = await this.getRanges(r);
|
|
3239
|
-
this.size -= H(o), this.rmKey(r);
|
|
3240
|
-
}
|
|
3241
|
-
}
|
|
3242
|
-
/** Gets ranges and if they were corrupted, then remove the file from the cache and reset the cache's size. */
|
|
3243
|
-
async getRanges(e) {
|
|
3244
|
-
try {
|
|
3245
|
-
return await this.ranges.get(e);
|
|
3246
|
-
} catch (t) {
|
|
3247
|
-
if (t instanceof ut)
|
|
3248
|
-
return await this.rmKey(e), await this.resetUnsafe(), await this.ranges.get(e);
|
|
3249
|
-
throw t;
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
/** Removes a key the state of the cache. The size should be updated. */
|
|
3253
|
-
async rmKey(e) {
|
|
3254
|
-
await this.storage.delete(e), await this.ranges.delete(e), this.keyToLastAccessTime.delete(e);
|
|
3255
|
-
}
|
|
3256
|
-
}
|
|
3257
|
-
async function ge(s, e) {
|
|
3258
|
-
try {
|
|
3259
|
-
return await s.acquireAsync(), await e();
|
|
3260
|
-
} finally {
|
|
3261
|
-
s.release();
|
|
3262
|
-
}
|
|
3263
|
-
}
|
|
3264
|
-
class pt {
|
|
3265
|
-
constructor(e, t, r, n, o, c, i) {
|
|
3266
|
-
/** Represents a unique key to the path of a blob as a map. */
|
|
3267
|
-
h(this, "keyToDownload", /* @__PURE__ */ new Map());
|
|
3268
|
-
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3269
|
-
* file that should be kept. */
|
|
3270
|
-
h(this, "cache");
|
|
3271
|
-
h(this, "rangesCache");
|
|
3272
|
-
/** Downloads files and writes them to the local dir. */
|
|
3273
|
-
h(this, "downloadQueue");
|
|
3274
|
-
h(this, "keyToOnDemand", /* @__PURE__ */ new Map());
|
|
3275
|
-
h(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3276
|
-
h(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3277
|
-
h(this, "saveDir");
|
|
3278
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.rangesCacheDir = o, this.signer = c, this.ops = i, this.cache = new ve(this.ops.cacheSoftSizeBytes);
|
|
3279
|
-
const l = new Hn(this.logger, this.rangesCacheDir), a = new jn(this.logger, this.rangesCacheDir);
|
|
3280
|
-
this.rangesCache = new Gn(this.logger, this.ops.rangesCacheMaxSizeBytes, l, a), this.downloadQueue = new Y(this.logger, i.nConcurrentDownloads), this.saveDir = T.resolve(n);
|
|
3281
|
-
}
|
|
3282
|
-
static async init(e, t, r, n, o, c, i) {
|
|
3283
|
-
const l = new pt(e, t, r, n, o, c, i);
|
|
3284
|
-
return await l.rangesCache.reset(), l;
|
|
3285
|
-
}
|
|
3286
|
-
getDownloadedBlob(e, t) {
|
|
3287
|
-
if (t === void 0)
|
|
3288
|
-
return b.make((c) => this.getDownloadedBlob(e, c));
|
|
3289
|
-
const r = D(e, t), n = S();
|
|
3290
|
-
t.addOnDestroy(() => this.releaseBlob(r, n));
|
|
3291
|
-
const o = this.getDownloadedBlobNoCtx(t.watcher, r, n);
|
|
3292
|
-
return o == null && t.markUnstable("download blob is still undefined"), o;
|
|
3293
|
-
}
|
|
3294
|
-
getDownloadedBlobNoCtx(e, t, r) {
|
|
3295
|
-
F("getDownloadedBlob", t.type);
|
|
3296
|
-
const n = this.getOrSetNewTask(t, r);
|
|
3297
|
-
n.attach(e, r);
|
|
3298
|
-
const o = n.getBlob();
|
|
3299
|
-
if (o.done) {
|
|
3300
|
-
if (o.result.ok)
|
|
3301
|
-
return o.result.value;
|
|
3302
|
-
throw o.result.error;
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
getOrSetNewTask(e, t) {
|
|
3306
|
-
const r = k(e.id), n = this.keyToDownload.get(r);
|
|
3307
|
-
if (n)
|
|
3308
|
-
return n;
|
|
3309
|
-
const o = T.resolve(this.saveDir, r), c = new Dn(
|
|
3310
|
-
this.logger,
|
|
3311
|
-
this.clientDownload,
|
|
3312
|
-
e,
|
|
3313
|
-
kn(o, this.signer),
|
|
3314
|
-
o
|
|
3315
|
-
);
|
|
3316
|
-
return this.keyToDownload.set(r, c), this.downloadQueue.push({
|
|
3317
|
-
fn: () => this.downloadBlob(c, t),
|
|
3318
|
-
recoverableErrorPredicate: (i) => !De(i)
|
|
3319
|
-
}), c;
|
|
3320
|
-
}
|
|
3321
|
-
async downloadBlob(e, t) {
|
|
3322
|
-
await e.download();
|
|
3323
|
-
const r = e.getBlob();
|
|
3324
|
-
r.done && r.result.ok && this.cache.addCache(e, t);
|
|
3325
|
-
}
|
|
3326
|
-
getOnDemandBlob(e, t) {
|
|
3327
|
-
if (t === void 0) return b.make((c) => this.getOnDemandBlob(e, c));
|
|
3328
|
-
const r = M(e) ? J(e, Ln, t) : e, n = S();
|
|
3329
|
-
return t.addOnDestroy(() => this.releaseOnDemandBlob(r.id, n)), this.getOnDemandBlobNoCtx(r, n);
|
|
3330
|
-
}
|
|
3331
|
-
getOnDemandBlobNoCtx(e, t) {
|
|
3332
|
-
F("getOnDemandBlob", e.type);
|
|
3333
|
-
let r = this.keyToOnDemand.get(k(e.id));
|
|
3334
|
-
return r === void 0 && (r = new Vn(ot(e), Rn(e, this.signer)), this.keyToOnDemand.set(k(e.id), r)), r.attach(t), r.getHandle();
|
|
3335
|
-
}
|
|
3336
|
-
/** Gets a path from a handle. */
|
|
3337
|
-
getLocalPath(e) {
|
|
3338
|
-
const { path: t } = pe(e, this.signer);
|
|
3339
|
-
return t;
|
|
3340
|
-
}
|
|
3341
|
-
/** Gets a content of a blob by a handle. */
|
|
3342
|
-
async getContent(e, t) {
|
|
3343
|
-
if (t && Be(t, "getContent"), Tn(e))
|
|
3344
|
-
return await Ee(this.getLocalPath(e), t);
|
|
3345
|
-
if (Nn(e)) {
|
|
3346
|
-
const r = $n(e, this.signer), n = k(r.info.id), o = await this.rangesCache.get(n, t ?? { from: 0, to: r.size });
|
|
3347
|
-
if (o)
|
|
3348
|
-
return await Ee(o, t);
|
|
3349
|
-
const c = await this.clientDownload.withBlobContent(
|
|
3350
|
-
{ id: r.info.id, type: r.info.type },
|
|
3351
|
-
void 0,
|
|
3352
|
-
{ range: t },
|
|
3353
|
-
async (i) => await qe(i)
|
|
3354
|
-
);
|
|
3355
|
-
return await this.rangesCache.set(n, t ?? { from: 0, to: r.size }, c), c;
|
|
3356
|
-
}
|
|
3357
|
-
throw new Error("Malformed remote handle");
|
|
3358
|
-
}
|
|
3359
|
-
/**
|
|
3360
|
-
* Creates computable that will return blob content once it is downloaded.
|
|
3361
|
-
* Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
|
|
3362
|
-
*/
|
|
3363
|
-
getComputableContent(e, t) {
|
|
3364
|
-
return t && Be(t, "getComputableContent"), b.make(
|
|
3365
|
-
(r) => this.getDownloadedBlob(e, r),
|
|
3366
|
-
{
|
|
3367
|
-
postprocessValue: (r) => r ? this.getContent(r.handle, t) : void 0
|
|
3368
|
-
}
|
|
3369
|
-
).withStableType();
|
|
3370
|
-
}
|
|
3371
|
-
getLastLogs(e, t, r) {
|
|
3372
|
-
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
3373
|
-
const n = D(e, r), o = S();
|
|
3374
|
-
r.addOnDestroy(() => this.releaseBlob(n, o));
|
|
3375
|
-
const c = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
3376
|
-
return c == null && r.markUnstable("either a file was not downloaded or logs was not read"), c;
|
|
3377
|
-
}
|
|
3378
|
-
getLastLogsNoCtx(e, t, r, n) {
|
|
3379
|
-
F("getLastLogs", t.type);
|
|
3380
|
-
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3381
|
-
if (o == null) return;
|
|
3382
|
-
const { path: c } = pe(o.handle, this.signer);
|
|
3383
|
-
let i = this.idToLastLines.get(k(t.id));
|
|
3384
|
-
if (i == null) {
|
|
3385
|
-
const a = new Fe(c, r);
|
|
3386
|
-
this.idToLastLines.set(k(t.id), a), i = a;
|
|
3387
|
-
}
|
|
3388
|
-
const l = i.getOrSchedule(e);
|
|
3389
|
-
if (l.error) throw l.error;
|
|
3390
|
-
return l.log;
|
|
3391
|
-
}
|
|
3392
|
-
getProgressLog(e, t, r) {
|
|
3393
|
-
if (r == null)
|
|
3394
|
-
return b.make((i) => this.getProgressLog(e, t, i));
|
|
3395
|
-
const n = D(e, r), o = S();
|
|
3396
|
-
r.addOnDestroy(() => this.releaseBlob(n, o));
|
|
3397
|
-
const c = this.getProgressLogNoCtx(
|
|
3398
|
-
r.watcher,
|
|
3399
|
-
n,
|
|
3400
|
-
t,
|
|
3401
|
-
o
|
|
3402
|
-
);
|
|
3403
|
-
return c === void 0 && r.markUnstable("either a file was not downloaded or a progress log was not read"), c;
|
|
3404
|
-
}
|
|
3405
|
-
getProgressLogNoCtx(e, t, r, n) {
|
|
3406
|
-
F("getProgressLog", t.type);
|
|
3407
|
-
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3408
|
-
if (o == null) return;
|
|
3409
|
-
const { path: c } = pe(o.handle, this.signer);
|
|
3410
|
-
let i = this.idToProgressLog.get(k(t.id));
|
|
3411
|
-
if (i == null) {
|
|
3412
|
-
const a = new Fe(c, 1, r);
|
|
3413
|
-
this.idToProgressLog.set(k(t.id), a), i = a;
|
|
3414
|
-
}
|
|
3415
|
-
const l = i.getOrSchedule(e);
|
|
3416
|
-
if (l.error) throw l.error;
|
|
3417
|
-
return l.log;
|
|
3418
|
-
}
|
|
3419
|
-
getLogHandle(e, t) {
|
|
3420
|
-
if (t == null) return b.make((n) => this.getLogHandle(e, n));
|
|
3421
|
-
const r = D(e, t);
|
|
3422
|
-
return this.getLogHandleNoCtx(r);
|
|
3423
|
-
}
|
|
3424
|
-
getLogHandleNoCtx(e) {
|
|
3425
|
-
return F("getLogHandle", e.type), at(!1, e);
|
|
3426
|
-
}
|
|
3427
|
-
async lastLines(e, t, r, n) {
|
|
3428
|
-
const o = await this.clientLogs.lastLines(
|
|
3429
|
-
Q(e),
|
|
3430
|
-
t,
|
|
3431
|
-
BigInt(r ?? 0),
|
|
3432
|
-
n
|
|
3433
|
-
);
|
|
3434
|
-
return {
|
|
3435
|
-
live: !1,
|
|
3436
|
-
shouldUpdateHandle: !1,
|
|
3437
|
-
data: o.data,
|
|
3438
|
-
size: Number(o.size),
|
|
3439
|
-
newOffset: Number(o.newOffset)
|
|
3440
|
-
};
|
|
3441
|
-
}
|
|
3442
|
-
async readText(e, t, r, n) {
|
|
3443
|
-
const o = await this.clientLogs.readText(
|
|
3444
|
-
Q(e),
|
|
3445
|
-
t,
|
|
3446
|
-
BigInt(r ?? 0),
|
|
3447
|
-
n
|
|
3448
|
-
);
|
|
3449
|
-
return {
|
|
3450
|
-
live: !1,
|
|
3451
|
-
shouldUpdateHandle: !1,
|
|
3452
|
-
data: o.data,
|
|
3453
|
-
size: Number(o.size),
|
|
3454
|
-
newOffset: Number(o.newOffset)
|
|
3455
|
-
};
|
|
3456
|
-
}
|
|
3457
|
-
async releaseBlob(e, t) {
|
|
3458
|
-
const r = this.keyToDownload.get(k(e.id));
|
|
3459
|
-
if (r != null)
|
|
3460
|
-
if (this.cache.existsFile(k(e.id))) {
|
|
3461
|
-
const n = this.cache.removeFile(k(e.id), t);
|
|
3462
|
-
await Promise.all(
|
|
3463
|
-
n.map(async (o) => {
|
|
3464
|
-
await w.rm(o.path), this.cache.removeCache(o), this.removeTask(
|
|
3465
|
-
me(this.keyToDownload, _e(o.path)),
|
|
3466
|
-
`the task ${y(o)} was removedfrom cache along with ${y(n.map((c) => c.path))}`
|
|
3467
|
-
);
|
|
3468
|
-
})
|
|
3469
|
-
);
|
|
3470
|
-
} else
|
|
3471
|
-
r.counter.dec(t) && this.removeTask(
|
|
3472
|
-
r,
|
|
3473
|
-
`the task ${y(r.info())} was removed from cache`
|
|
3474
|
-
);
|
|
3475
|
-
}
|
|
3476
|
-
removeTask(e, t) {
|
|
3477
|
-
e.abort(t), e.change.markChanged(`download task for ${e.path} removed: ${t}`), this.keyToDownload.delete(_e(e.path)), this.idToLastLines.delete(k(e.rInfo.id)), this.idToProgressLog.delete(k(e.rInfo.id));
|
|
3478
|
-
}
|
|
3479
|
-
async releaseOnDemandBlob(e, t) {
|
|
3480
|
-
var n;
|
|
3481
|
-
(((n = this.keyToOnDemand.get(k(e))) == null ? void 0 : n.release(t)) ?? !1) && this.keyToOnDemand.delete(k(e));
|
|
3482
|
-
}
|
|
3483
|
-
/** Removes all files from a hard drive. */
|
|
3484
|
-
async releaseAll() {
|
|
3485
|
-
this.downloadQueue.stop(), this.keyToDownload.forEach((e, t) => {
|
|
3486
|
-
this.keyToDownload.delete(t), e.change.markChanged(`task ${P(e.rInfo.id)} released`);
|
|
3487
|
-
});
|
|
3488
|
-
}
|
|
3489
|
-
}
|
|
3490
|
-
class Vn {
|
|
3491
|
-
constructor(e, t) {
|
|
3492
|
-
h(this, "counter", new B());
|
|
3493
|
-
this.size = e, this.handle = t;
|
|
3494
|
-
}
|
|
3495
|
-
getHandle() {
|
|
3496
|
-
return { handle: this.handle, size: this.size };
|
|
3497
|
-
}
|
|
3498
|
-
attach(e) {
|
|
3499
|
-
this.counter.inc(e);
|
|
3500
|
-
}
|
|
3501
|
-
release(e) {
|
|
3502
|
-
return this.counter.dec(e);
|
|
3503
|
-
}
|
|
3504
|
-
}
|
|
3505
|
-
class Fe {
|
|
3506
|
-
constructor(e, t, r) {
|
|
3507
|
-
h(this, "updater");
|
|
3508
|
-
h(this, "log");
|
|
3509
|
-
h(this, "change", new C());
|
|
3510
|
-
h(this, "error");
|
|
3511
|
-
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new Sn(async () => this.update());
|
|
3512
|
-
}
|
|
3513
|
-
getOrSchedule(e) {
|
|
3514
|
-
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
3515
|
-
log: this.log,
|
|
3516
|
-
error: this.error
|
|
3517
|
-
};
|
|
3518
|
-
}
|
|
3519
|
-
async update() {
|
|
3520
|
-
try {
|
|
3521
|
-
const e = await qn(this.path, this.lines, this.patternToSearch);
|
|
3522
|
-
this.log != e && this.change.markChanged(`logs for ${this.path} updated`), this.log = e;
|
|
3523
|
-
} catch (e) {
|
|
3524
|
-
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
3525
|
-
this.log = "", this.error = e, this.change.markChanged(`log update for ${this.path} failed, resource not found`);
|
|
3526
|
-
return;
|
|
3527
|
-
}
|
|
3528
|
-
throw e;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
}
|
|
3532
|
-
async function qn(s, e, t) {
|
|
3533
|
-
let r, n;
|
|
3534
|
-
try {
|
|
3535
|
-
r = Ne.createReadStream(s), n = Ot.createInterface({ input: r, crlfDelay: 1 / 0 });
|
|
3536
|
-
const o = new Et();
|
|
3537
|
-
for await (const c of n)
|
|
3538
|
-
t != null && !c.includes(t) || (o.push(c), o.length > e && o.shift());
|
|
3539
|
-
return o.toArray().join(Ce.EOL) + Ce.EOL;
|
|
3540
|
-
} finally {
|
|
3541
|
-
try {
|
|
3542
|
-
n && n.close();
|
|
3543
|
-
} catch (o) {
|
|
3544
|
-
console.error("Error closing readline interface:", o);
|
|
3545
|
-
}
|
|
3546
|
-
try {
|
|
3547
|
-
r && !r.destroyed && r.destroy();
|
|
3548
|
-
} catch (o) {
|
|
3549
|
-
console.error("Error destroying read stream:", o);
|
|
3550
|
-
}
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
function F(s, e) {
|
|
3554
|
-
if (!e.name.startsWith("Blob/")) {
|
|
3555
|
-
let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
|
|
3556
|
-
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Ie(t);
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
const Jn = ee({});
|
|
3560
|
-
function Zn(s, e) {
|
|
3561
|
-
const t = M(s) ? e.accessor(s).node() : Ze(s) ? s.node() : s;
|
|
3562
|
-
return J(t, Jn);
|
|
3563
|
-
}
|
|
3564
|
-
function Qn(s, e, t) {
|
|
3565
|
-
const r = U.relative(e, t);
|
|
3566
|
-
return `plblob+folder://${s.sign(r)}.${r}.blob`;
|
|
3567
|
-
}
|
|
3568
|
-
function Kn(s, e, t) {
|
|
3569
|
-
const r = U.relative(e, t);
|
|
3570
|
-
return `block-ui://${s.sign(r)}.${r}.uidir`;
|
|
3571
|
-
}
|
|
3572
|
-
function Xn(s, e, t) {
|
|
3573
|
-
return gt(s, e, t);
|
|
3574
|
-
}
|
|
3575
|
-
function Yn(s, e, t) {
|
|
3576
|
-
return gt(s, e, t);
|
|
3577
|
-
}
|
|
3578
|
-
function gt(s, e, t) {
|
|
3579
|
-
const r = new URL(e), [n, o, c] = r.host.split(".");
|
|
3580
|
-
s.verify(o, n, `signature verification failed for url: ${e}, subfolder: ${o}`);
|
|
3581
|
-
const i = decodeURIComponent(r.pathname.slice(1));
|
|
3582
|
-
let l = eo(U.join(t, `${o}`), i);
|
|
3583
|
-
return (r.pathname == "" || r.pathname == "/") && (l = U.join(l, "index.html")), U.resolve(l);
|
|
3584
|
-
}
|
|
3585
|
-
function eo(s, e) {
|
|
3586
|
-
const t = U.resolve(s, e), r = U.resolve(s);
|
|
3587
|
-
if (!t.startsWith(r))
|
|
3588
|
-
throw new Error("Path validation failed.");
|
|
3589
|
-
return t;
|
|
3590
|
-
}
|
|
3591
|
-
class to {
|
|
3592
|
-
constructor(e, t, r, n, o, c, i) {
|
|
3593
|
-
h(this, "counter", new B());
|
|
3594
|
-
h(this, "change", new C());
|
|
3595
|
-
h(this, "signalCtl", new AbortController());
|
|
3596
|
-
h(this, "error");
|
|
3597
|
-
h(this, "done", !1);
|
|
3598
|
-
h(this, "size", 0);
|
|
3599
|
-
h(this, "url");
|
|
3600
|
-
h(this, "state");
|
|
3601
|
-
this.logger = e, this.signer = t, this.saveDir = r, this.path = n, this.rInfo = o, this.format = c, this.clientDownload = i;
|
|
3602
|
-
}
|
|
3603
|
-
/** A debug info of the task. */
|
|
3604
|
-
info() {
|
|
3605
|
-
return {
|
|
3606
|
-
rInfo: this.rInfo,
|
|
3607
|
-
format: this.format,
|
|
3608
|
-
path: this.path,
|
|
3609
|
-
done: this.done,
|
|
3610
|
-
size: this.size,
|
|
3611
|
-
error: this.error,
|
|
3612
|
-
taskHistory: this.state
|
|
3613
|
-
};
|
|
3614
|
-
}
|
|
3615
|
-
attach(e, t) {
|
|
3616
|
-
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
3617
|
-
}
|
|
3618
|
-
async download() {
|
|
3619
|
-
try {
|
|
3620
|
-
const e = await this.downloadAndDecompress(this.signalCtl.signal);
|
|
3621
|
-
this.setDone(e), this.change.markChanged(`download and decompress for ${P(this.rInfo.id)} finished`), this.logger.info(`blob to URL task is done: ${y(this.info())}`);
|
|
3622
|
-
} catch (e) {
|
|
3623
|
-
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), ro(e)) {
|
|
3624
|
-
this.setError(e), this.change.markChanged(`download and decompress for ${P(this.rInfo.id)} failed`), await Te(this.path);
|
|
3625
|
-
return;
|
|
3626
|
-
}
|
|
3627
|
-
throw e;
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3630
|
-
/** Does the download part and keeps a state of the process. */
|
|
3631
|
-
async downloadAndDecompress(e) {
|
|
3632
|
-
return this.state = {}, this.state.parentDir = U.dirname(this.path), await W(this.state.parentDir), this.state.fileExisted = await A(this.path), this.state.fileExisted ? await ft(this.path) : await this.clientDownload.withBlobContent(
|
|
3633
|
-
this.rInfo,
|
|
3634
|
-
{},
|
|
3635
|
-
{ signal: e },
|
|
3636
|
-
async (r, n) => (this.state.downloaded = !0, await X(this.logger, this.path, async (o) => {
|
|
3637
|
-
switch (this.state.tempPath = o, this.state.archiveFormat = this.format, this.format) {
|
|
3638
|
-
case "tar":
|
|
3639
|
-
await w.mkdir(o);
|
|
3640
|
-
const c = z.toWeb(ke.extract(o));
|
|
3641
|
-
await r.pipeTo(c, { signal: e });
|
|
3642
|
-
return;
|
|
3643
|
-
case "tgz":
|
|
3644
|
-
await w.mkdir(o);
|
|
3645
|
-
const i = Ve.toWeb(Qe.createGunzip()), l = z.toWeb(ke.extract(o));
|
|
3646
|
-
await r.pipeThrough(i, { signal: e }).pipeTo(l, { signal: e });
|
|
3647
|
-
return;
|
|
3648
|
-
case "zip":
|
|
3649
|
-
this.state.zipPath = this.path + ".zip";
|
|
3650
|
-
const a = z.toWeb(ye.createWriteStream(this.state.zipPath));
|
|
3651
|
-
await r.pipeTo(a, { signal: e }), this.state.zipPathCreated = !0, await Wt(this.state.zipPath, o, {
|
|
3652
|
-
filter: (d) => !d.path.endsWith("/")
|
|
3653
|
-
}), this.state.zipDecompressed = !0, await ye.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
|
|
3654
|
-
return;
|
|
3655
|
-
default:
|
|
3656
|
-
Nt(this.format);
|
|
3657
|
-
}
|
|
3658
|
-
}), this.state.pathCreated = !0, n)
|
|
3659
|
-
);
|
|
3660
|
-
}
|
|
3661
|
-
getURL() {
|
|
3662
|
-
if (this.done) return { url: K(this.url) };
|
|
3663
|
-
if (this.error) return { error: this.error };
|
|
3664
|
-
}
|
|
3665
|
-
setDone(e) {
|
|
3666
|
-
this.done = !0, this.size = e, this.url = Qn(this.signer, this.saveDir, this.path);
|
|
3667
|
-
}
|
|
3668
|
-
setError(e) {
|
|
3669
|
-
this.error = String(e);
|
|
3670
|
-
}
|
|
3671
|
-
abort(e) {
|
|
3672
|
-
this.signalCtl.abort(new wt(e));
|
|
3673
|
-
}
|
|
3674
|
-
}
|
|
3675
|
-
async function ft(s) {
|
|
3676
|
-
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
3677
|
-
return (await Promise.all(
|
|
3678
|
-
e.map(async (r) => {
|
|
3679
|
-
const n = U.join(s, r.name);
|
|
3680
|
-
return r.isDirectory() ? await ft(n) : (await w.stat(n)).size;
|
|
3681
|
-
})
|
|
3682
|
-
)).reduce((r, n) => r + n, 0);
|
|
3683
|
-
}
|
|
3684
|
-
async function Te(s) {
|
|
3685
|
-
await w.rm(s, { recursive: !0, force: !0 });
|
|
3686
|
-
}
|
|
3687
|
-
let wt = class extends Error {
|
|
3688
|
-
constructor() {
|
|
3689
|
-
super(...arguments);
|
|
3690
|
-
h(this, "name", "URLAborted");
|
|
3691
|
-
}
|
|
3692
|
-
};
|
|
3693
|
-
function ro(s) {
|
|
3694
|
-
return s instanceof wt || s instanceof te || s instanceof Se || s instanceof $e || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
|
|
3695
|
-
}
|
|
3696
|
-
function j(s, e) {
|
|
3697
|
-
return `id:${String(BigInt(s))}-${e}`;
|
|
3698
|
-
}
|
|
3699
|
-
class ls {
|
|
3700
|
-
constructor(e, t, r, n, o = {
|
|
3701
|
-
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
3702
|
-
nConcurrentDownloads: 50
|
|
3703
|
-
}) {
|
|
3704
|
-
h(this, "idToDownload", /* @__PURE__ */ new Map());
|
|
3705
|
-
h(this, "downloadQueue");
|
|
3706
|
-
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3707
|
-
* file that should be kept. */
|
|
3708
|
-
h(this, "cache");
|
|
3709
|
-
this.logger = e, this.signer = t, this.clientDownload = r, this.saveDir = n, this.opts = o, this.downloadQueue = new Y(this.logger, this.opts.nConcurrentDownloads, {
|
|
3710
|
-
type: "exponentialWithMaxDelayBackoff",
|
|
3711
|
-
initialDelay: 1e4,
|
|
3712
|
-
maxDelay: 3e4,
|
|
3713
|
-
backoffMultiplier: 1.5,
|
|
3714
|
-
jitter: 0.5
|
|
3715
|
-
}), this.cache = new ve(this.opts.cacheSoftSizeBytes);
|
|
3716
|
-
}
|
|
3717
|
-
info() {
|
|
3718
|
-
return {
|
|
3719
|
-
saveDir: this.saveDir,
|
|
3720
|
-
opts: this.opts,
|
|
3721
|
-
idToDownloadSize: this.idToDownload.size,
|
|
3722
|
-
idToDownloadKeys: this.idToDownload.keys(),
|
|
3723
|
-
idToDownload: Array.from(this.idToDownload.entries()).map(([e, t]) => [e, t.info()])
|
|
3724
|
-
};
|
|
3725
|
-
}
|
|
3726
|
-
/**
|
|
3727
|
-
* @returns full path to the referenced file
|
|
3728
|
-
*/
|
|
3729
|
-
getPathForCustomProtocol(e) {
|
|
3730
|
-
if (vt(e))
|
|
3731
|
-
return Xn(this.signer, e, this.saveDir);
|
|
3732
|
-
throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
|
|
3733
|
-
}
|
|
3734
|
-
extractArchiveAndGetURL(e, t, r) {
|
|
3735
|
-
if (r === void 0)
|
|
3736
|
-
return b.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
3737
|
-
const n = M(e) ? Zn(e, r) : e, o = S();
|
|
3738
|
-
r.addOnDestroy(() => this.releasePath(n.id, t, o));
|
|
3739
|
-
const c = this.extractArchiveAndGetURLNoCtx(n, t, r.watcher, o);
|
|
3740
|
-
if ((c == null ? void 0 : c.url) === void 0 && r.markUnstable(
|
|
3741
|
-
`a path to the downloaded archive might be undefined. The current result: ${c}`
|
|
3742
|
-
), (c == null ? void 0 : c.error) !== void 0)
|
|
3743
|
-
throw c == null ? void 0 : c.error;
|
|
3744
|
-
return c == null ? void 0 : c.url;
|
|
3745
|
-
}
|
|
3746
|
-
extractArchiveAndGetURLNoCtx(e, t, r, n) {
|
|
3747
|
-
const o = this.idToDownload.get(j(e.id, t));
|
|
3748
|
-
if (o != null)
|
|
3749
|
-
return o.attach(r, n), o.getURL();
|
|
3750
|
-
const c = this.setNewTask(r, e, t, n);
|
|
3751
|
-
return this.downloadQueue.push({
|
|
3752
|
-
fn: async () => this.downloadUrl(c, n),
|
|
3753
|
-
recoverableErrorPredicate: (i) => !De(i)
|
|
3754
|
-
}), c.getURL();
|
|
3755
|
-
}
|
|
3756
|
-
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
3757
|
-
async downloadUrl(e, t) {
|
|
3758
|
-
var r;
|
|
3759
|
-
await e.download(), ((r = e.getURL()) == null ? void 0 : r.url) != null && this.cache.addCache(e, t);
|
|
3760
|
-
}
|
|
3761
|
-
/** Removes a directory and aborts a downloading task when all callers
|
|
3762
|
-
* are not interested in it. */
|
|
3763
|
-
async releasePath(e, t, r) {
|
|
3764
|
-
const n = this.idToDownload.get(j(e, t));
|
|
3765
|
-
if (n != null)
|
|
3766
|
-
if (this.cache.existsFile(n.path)) {
|
|
3767
|
-
const o = this.cache.removeFile(n.path, r);
|
|
3768
|
-
await Promise.all(
|
|
3769
|
-
o.map(async (c) => {
|
|
3770
|
-
await Te(c.path), this.cache.removeCache(c), this.removeTask(
|
|
3771
|
-
c,
|
|
3772
|
-
`the task ${y(c.info())} was removedfrom cache along with ${y(o.map((i) => i.info()))}`
|
|
3773
|
-
);
|
|
3774
|
-
})
|
|
3775
|
-
);
|
|
3776
|
-
} else
|
|
3777
|
-
n.counter.dec(r) && this.removeTask(
|
|
3778
|
-
n,
|
|
3779
|
-
`the task ${y(n.info())} was removed from cache`
|
|
3780
|
-
);
|
|
3781
|
-
}
|
|
3782
|
-
/** Removes all files from a hard drive. */
|
|
3783
|
-
async releaseAll() {
|
|
3784
|
-
this.downloadQueue.stop(), await Promise.all(
|
|
3785
|
-
Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
|
|
3786
|
-
await Te(t.path), this.cache.removeCache(t), this.removeTask(
|
|
3787
|
-
t,
|
|
3788
|
-
`the task ${y(t.info())} was released when the driver was closed`
|
|
3789
|
-
);
|
|
3790
|
-
})
|
|
3791
|
-
);
|
|
3792
|
-
}
|
|
3793
|
-
setNewTask(e, t, r, n) {
|
|
3794
|
-
const o = new to(
|
|
3795
|
-
this.logger,
|
|
3796
|
-
this.signer,
|
|
3797
|
-
this.saveDir,
|
|
3798
|
-
this.getFilePath(t.id, r),
|
|
3799
|
-
t,
|
|
3800
|
-
r,
|
|
3801
|
-
this.clientDownload
|
|
3802
|
-
);
|
|
3803
|
-
return o.attach(e, n), this.idToDownload.set(j(t.id, r), o), o;
|
|
3804
|
-
}
|
|
3805
|
-
removeTask(e, t) {
|
|
3806
|
-
e.abort(t), e.change.markChanged(`task for ${P(e.rInfo.id)} removed: ${t}`), this.idToDownload.delete(j(e.rInfo.id, e.format));
|
|
3807
|
-
}
|
|
3808
|
-
getFilePath(e, t) {
|
|
3809
|
-
return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
|
|
3810
|
-
}
|
|
3811
|
-
}
|
|
3812
|
-
class no {
|
|
3813
|
-
constructor(e, t, r, n, o, c) {
|
|
3814
|
-
h(this, "change", new C());
|
|
3815
|
-
h(this, "counter", new B());
|
|
3816
|
-
h(this, "nMaxUploads");
|
|
3817
|
-
h(this, "nPartsWithThisUploadSpeed", 0);
|
|
3818
|
-
h(this, "nPartsToIncreaseUpload", 10);
|
|
3819
|
-
// how many parts we have to wait to increase concurrency, 50 mb, 10 parts by 5 mb each.
|
|
3820
|
-
/** If this is upload progress this field will be defined */
|
|
3821
|
-
h(this, "uploadData");
|
|
3822
|
-
h(this, "progress");
|
|
3823
|
-
/** If failed, then getting a progress is terminally failed. */
|
|
3824
|
-
h(this, "failed");
|
|
3825
|
-
/** True if the blob was existed.
|
|
3826
|
-
* At this case, the task will show progress == 1.0. */
|
|
3827
|
-
h(this, "alreadyExisted", !1);
|
|
3828
|
-
this.logger = e, this.clientBlob = t, this.clientProgress = r, this.maxNConcurrentPartsUpload = n, this.res = c, this.nMaxUploads = this.maxNConcurrentPartsUpload;
|
|
3829
|
-
const { uploadData: i, progress: l } = so(c, o);
|
|
3830
|
-
this.uploadData = i, this.progress = l;
|
|
3831
|
-
}
|
|
3832
|
-
getProgress(e, t) {
|
|
3833
|
-
if (this.incCounter(e, t), this.failed)
|
|
3834
|
-
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3835
|
-
return ao(this.progress);
|
|
3836
|
-
}
|
|
3837
|
-
shouldScheduleUpload() {
|
|
3838
|
-
return io(this.progress);
|
|
3839
|
-
}
|
|
3840
|
-
/** Uploads a blob if it's not BlobIndex. */
|
|
3841
|
-
async uploadBlobTask() {
|
|
3842
|
-
try {
|
|
3843
|
-
await oo(
|
|
3844
|
-
this.logger,
|
|
3845
|
-
this.clientBlob,
|
|
3846
|
-
this.res,
|
|
3847
|
-
this.uploadData,
|
|
3848
|
-
this.isComputableDone.bind(this),
|
|
3849
|
-
{
|
|
3850
|
-
nPartsWithThisUploadSpeed: this.nPartsWithThisUploadSpeed,
|
|
3851
|
-
nPartsToIncreaseUpload: this.nPartsToIncreaseUpload,
|
|
3852
|
-
currentSpeed: this.nMaxUploads,
|
|
3853
|
-
maxSpeed: this.maxNConcurrentPartsUpload
|
|
3854
|
-
}
|
|
3855
|
-
), this.change.markChanged(`blob upload for ${P(this.res.id)} finished`);
|
|
3856
|
-
} catch (e) {
|
|
3857
|
-
if (this.setRetriableError(e), Oe(e)) {
|
|
3858
|
-
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${P(this.res.id)} aborted, resource was deleted`), this.setDone(!0);
|
|
3859
|
-
return;
|
|
3860
|
-
}
|
|
3861
|
-
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${P(this.res.id)} failed`), mt(e)) {
|
|
3862
|
-
this.setTerminalError(e);
|
|
3863
|
-
return;
|
|
3864
|
-
}
|
|
3865
|
-
throw po(e) && (this.nMaxUploads = fo(this.logger, this.nMaxUploads, 1)), e;
|
|
3866
|
-
}
|
|
3867
|
-
}
|
|
3868
|
-
async updateStatus() {
|
|
3869
|
-
var e;
|
|
3870
|
-
try {
|
|
3871
|
-
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), r = this.progress.status, n = uo(this.alreadyExisted, ho(t));
|
|
3872
|
-
this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (r == null ? void 0 : r.progress)) && this.change.markChanged(`upload status for ${P(this.res.id)} changed`);
|
|
3873
|
-
} catch (t) {
|
|
3874
|
-
if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
|
|
3875
|
-
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
3876
|
-
return;
|
|
3877
|
-
}
|
|
3878
|
-
if (Oe(t)) {
|
|
3879
|
-
this.logger.warn(
|
|
3880
|
-
`resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
|
|
3881
|
-
), this.change.markChanged(`upload status for ${P(this.res.id)} changed, resource not found`), this.setDone(!0);
|
|
3882
|
-
return;
|
|
3883
|
-
}
|
|
3884
|
-
this.logger.error(`retryable error while updating a status of BlobImport: ${t}`);
|
|
3885
|
-
}
|
|
3886
|
-
}
|
|
3887
|
-
/** Set non-terminal error, that task can be retried. */
|
|
3888
|
-
setRetriableError(e) {
|
|
3889
|
-
this.progress.lastError = String(e);
|
|
3890
|
-
}
|
|
3891
|
-
/** Set a terminal error, the task will throw a error instead of a progress. */
|
|
3892
|
-
setTerminalError(e) {
|
|
3893
|
-
this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
|
|
3894
|
-
}
|
|
3895
|
-
setDoneIfOutputSet(e) {
|
|
3896
|
-
lo(e) && (this.setDone(!0), this.alreadyExisted = !0);
|
|
3897
|
-
}
|
|
3898
|
-
setDone(e) {
|
|
3899
|
-
this.progress.done = e, e && (this.progress.lastError = void 0);
|
|
3900
|
-
}
|
|
3901
|
-
incCounter(e, t) {
|
|
3902
|
-
this.change.attachWatcher(e), this.counter.inc(t);
|
|
3903
|
-
}
|
|
3904
|
-
decCounter(e) {
|
|
3905
|
-
return this.counter.dec(e);
|
|
3906
|
-
}
|
|
3907
|
-
isComputableDone() {
|
|
3908
|
-
return this.counter.isZero();
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
async function oo(s, e, t, r, n, o) {
|
|
3912
|
-
xt(Le(t), "the upload operation can be done only for BlobUploads");
|
|
3913
|
-
const c = 1e4;
|
|
3914
|
-
if (n()) return;
|
|
3915
|
-
const i = await e.initUpload(t, { timeout: c });
|
|
3916
|
-
s.info(
|
|
3917
|
-
`started to upload blob ${t.id}, parts overall: ${i.overall}, parts remained: ${i.toUpload.length}, number of concurrent uploads: ${o.currentSpeed}`
|
|
3918
|
-
);
|
|
3919
|
-
const l = (a) => async (d) => {
|
|
3920
|
-
n() || (await e.partUpload(
|
|
3921
|
-
t,
|
|
3922
|
-
r.localPath,
|
|
3923
|
-
BigInt(r.modificationTime),
|
|
3924
|
-
a,
|
|
3925
|
-
{ timeout: c }
|
|
3926
|
-
), s.info(`uploaded chunk ${a}/${i.overall} of resource: ${t.id}`), o.nPartsWithThisUploadSpeed++, o.nPartsWithThisUploadSpeed >= o.nPartsToIncreaseUpload && (o.nPartsWithThisUploadSpeed = 0, o.currentSpeed = go(s, o.currentSpeed, o.maxSpeed), d.setConcurrency(o.currentSpeed)));
|
|
3927
|
-
};
|
|
3928
|
-
await Re(o.currentSpeed, i.toUpload.map(l)), !n() && (await e.finalize(t, { timeout: c }), s.info(`uploading of resource ${t.id} finished.`));
|
|
3929
|
-
}
|
|
3930
|
-
function so(s, e) {
|
|
3931
|
-
let t, r;
|
|
3932
|
-
return Le(s) && (r = re.parse(s.data), t = co(e, r.localPath, r.pathSignature)), {
|
|
3933
|
-
uploadData: r,
|
|
3934
|
-
progress: {
|
|
3935
|
-
done: !1,
|
|
3936
|
-
status: void 0,
|
|
3937
|
-
isUpload: Le(s),
|
|
3938
|
-
isUploadSignMatch: t,
|
|
3939
|
-
lastError: void 0
|
|
3940
|
-
}
|
|
3941
|
-
};
|
|
3942
|
-
}
|
|
3943
|
-
function io(s) {
|
|
3944
|
-
return s.isUpload && (s.isUploadSignMatch ?? !1);
|
|
3945
|
-
}
|
|
3946
|
-
function ao(s) {
|
|
3947
|
-
return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
|
|
3948
|
-
}
|
|
3949
|
-
function lo(s) {
|
|
3950
|
-
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
3951
|
-
}
|
|
3952
|
-
function Le(s) {
|
|
3953
|
-
return s.type.name.startsWith("BlobUpload");
|
|
3954
|
-
}
|
|
3955
|
-
function co(s, e, t) {
|
|
3956
|
-
try {
|
|
3957
|
-
return s.verify(e, t), !0;
|
|
3958
|
-
} catch {
|
|
3959
|
-
return !1;
|
|
3960
|
-
}
|
|
3961
|
-
}
|
|
3962
|
-
function ho(s) {
|
|
3963
|
-
return {
|
|
3964
|
-
progress: s.progress ?? 0,
|
|
3965
|
-
bytesProcessed: Number(s.bytesProcessed),
|
|
3966
|
-
bytesTotal: Number(s.bytesTotal)
|
|
3967
|
-
};
|
|
3968
|
-
}
|
|
3969
|
-
function uo(s, e) {
|
|
3970
|
-
return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
|
|
3971
|
-
progress: 1,
|
|
3972
|
-
bytesProcessed: Number(e.bytesTotal),
|
|
3973
|
-
bytesTotal: Number(e.bytesTotal)
|
|
3974
|
-
} : e;
|
|
3975
|
-
}
|
|
3976
|
-
function Oe(s) {
|
|
3977
|
-
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
3978
|
-
}
|
|
3979
|
-
function mt(s) {
|
|
3980
|
-
return s instanceof Xe || s instanceof Ye || s instanceof tt;
|
|
3981
|
-
}
|
|
3982
|
-
function po(s) {
|
|
3983
|
-
return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
|
|
3984
|
-
}
|
|
3985
|
-
function go(s, e, t) {
|
|
3986
|
-
const r = Math.min(e + 2, t);
|
|
3987
|
-
return r != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${r}`), r;
|
|
3988
|
-
}
|
|
3989
|
-
function fo(s, e, t) {
|
|
3990
|
-
const r = Math.max(Math.round(e / 2), t);
|
|
3991
|
-
return r != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${r}`), r;
|
|
3992
|
-
}
|
|
3993
|
-
function wo(s, e) {
|
|
3994
|
-
const t = M(s) ? e.accessor(s).node() : Ze(s) ? s.node() : s;
|
|
3995
|
-
return t.resourceType.name.startsWith("BlobUpload") ? J(t, Un) : J(t, Pn);
|
|
3996
|
-
}
|
|
3997
|
-
class cs {
|
|
3998
|
-
constructor(e, t, r, n, o = {
|
|
3999
|
-
nConcurrentPartUploads: 10,
|
|
4000
|
-
nConcurrentGetProgresses: 10,
|
|
4001
|
-
pollingInterval: 1e3,
|
|
4002
|
-
stopPollingDelay: 1e3
|
|
4003
|
-
}) {
|
|
4004
|
-
h(this, "idToProgress", /* @__PURE__ */ new Map());
|
|
4005
|
-
/** Holds a queue that upload blobs. */
|
|
4006
|
-
h(this, "uploadQueue");
|
|
4007
|
-
h(this, "hooks");
|
|
4008
|
-
h(this, "scheduledOnNextState", []);
|
|
4009
|
-
/** If true, main loop will continue polling pl state. */
|
|
4010
|
-
h(this, "keepRunning", !1);
|
|
4011
|
-
/** Actual state of main loop. */
|
|
4012
|
-
h(this, "currentLoop");
|
|
4013
|
-
this.logger = e, this.signer = t, this.clientBlob = r, this.clientProgress = n, this.opts = o, this.uploadQueue = new Y(this.logger, 1, {
|
|
4014
|
-
type: "exponentialWithMaxDelayBackoff",
|
|
4015
|
-
initialDelay: 20,
|
|
4016
|
-
maxDelay: 15e3,
|
|
4017
|
-
// 15 seconds
|
|
4018
|
-
backoffMultiplier: 1.5,
|
|
4019
|
-
jitter: 0.5
|
|
4020
|
-
}), this.hooks = new Je(
|
|
4021
|
-
() => this.startUpdating(),
|
|
4022
|
-
() => this.stopUpdating(),
|
|
4023
|
-
{ stopDebounce: o.stopPollingDelay },
|
|
4024
|
-
(c, i) => this.scheduleOnNextState(c, i)
|
|
4025
|
-
);
|
|
4026
|
-
}
|
|
4027
|
-
getProgressId(e, t) {
|
|
4028
|
-
if (t == null) return b.make((c) => this.getProgressId(e, c));
|
|
4029
|
-
const r = M(e) ? wo(e, t) : e, n = S();
|
|
4030
|
-
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(r.id, n)), this.getProgressIdNoCtx(t.watcher, r, n);
|
|
4031
|
-
}
|
|
4032
|
-
getProgressIdNoCtx(e, t, r) {
|
|
4033
|
-
yo("getProgressId", t.type);
|
|
4034
|
-
const n = this.idToProgress.get(t.id);
|
|
4035
|
-
if (n != null)
|
|
4036
|
-
return n.setDoneIfOutputSet(t), n.getProgress(e, r);
|
|
4037
|
-
const o = new no(
|
|
4038
|
-
this.logger,
|
|
4039
|
-
this.clientBlob,
|
|
4040
|
-
this.clientProgress,
|
|
4041
|
-
this.opts.nConcurrentPartUploads,
|
|
4042
|
-
this.signer,
|
|
4043
|
-
t
|
|
4044
|
-
);
|
|
4045
|
-
return this.idToProgress.set(t.id, o), o.shouldScheduleUpload() && this.uploadQueue.push({
|
|
4046
|
-
fn: () => o.uploadBlobTask(),
|
|
4047
|
-
recoverableErrorPredicate: (c) => !mt(c)
|
|
4048
|
-
}), o.setDoneIfOutputSet(t), o.getProgress(e, r);
|
|
4049
|
-
}
|
|
4050
|
-
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
4051
|
-
async release(e, t) {
|
|
4052
|
-
const r = this.idToProgress.get(e);
|
|
4053
|
-
if (r === void 0) return;
|
|
4054
|
-
r.decCounter(t) && this.idToProgress.delete(e);
|
|
4055
|
-
}
|
|
4056
|
-
/** Must be called when the driver is closing. */
|
|
4057
|
-
async releaseAll() {
|
|
4058
|
-
this.uploadQueue.stop();
|
|
4059
|
-
}
|
|
4060
|
-
scheduleOnNextState(e, t) {
|
|
4061
|
-
this.scheduledOnNextState.push({ resolve: e, reject: t });
|
|
4062
|
-
}
|
|
4063
|
-
/** Called from observer */
|
|
4064
|
-
startUpdating() {
|
|
4065
|
-
this.keepRunning = !0, this.currentLoop === void 0 && (this.currentLoop = this.mainLoop());
|
|
4066
|
-
}
|
|
4067
|
-
/** Called from observer */
|
|
4068
|
-
stopUpdating() {
|
|
4069
|
-
this.keepRunning = !1;
|
|
4070
|
-
}
|
|
4071
|
-
async mainLoop() {
|
|
4072
|
-
for (; this.keepRunning; ) {
|
|
4073
|
-
const e = this.scheduledOnNextState;
|
|
4074
|
-
this.scheduledOnNextState = [];
|
|
4075
|
-
try {
|
|
4076
|
-
await Re(
|
|
4077
|
-
this.opts.nConcurrentGetProgresses,
|
|
4078
|
-
this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
|
|
4079
|
-
), e.forEach((t) => t.resolve());
|
|
4080
|
-
} catch (t) {
|
|
4081
|
-
console.error(t), e.forEach((r) => r.reject(t));
|
|
4082
|
-
}
|
|
4083
|
-
if (!this.keepRunning) break;
|
|
4084
|
-
await Ke.wait(this.opts.pollingInterval);
|
|
4085
|
-
}
|
|
4086
|
-
this.currentLoop = void 0;
|
|
4087
|
-
}
|
|
4088
|
-
getAllNotDoneProgresses() {
|
|
4089
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !mo(t.progress)).map(([e, t]) => t);
|
|
4090
|
-
}
|
|
4091
|
-
}
|
|
4092
|
-
function mo(s) {
|
|
4093
|
-
var e;
|
|
4094
|
-
return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
|
|
4095
|
-
}
|
|
4096
|
-
function yo(s, e) {
|
|
4097
|
-
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
4098
|
-
throw new Ie(
|
|
4099
|
-
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
4100
|
-
);
|
|
4101
|
-
}
|
|
4102
|
-
class hs {
|
|
4103
|
-
constructor(e, t, r = {
|
|
4104
|
-
nConcurrentGetLogs: 10,
|
|
4105
|
-
pollingInterval: 1e3,
|
|
4106
|
-
stopPollingDelay: 1e3
|
|
4107
|
-
}) {
|
|
4108
|
-
/** Holds a map of StreamManager Resource Id to all logs of this stream. */
|
|
4109
|
-
h(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
4110
|
-
/** Holds a map of StreamManager Resource Id to the last log line of this stream. */
|
|
4111
|
-
h(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
4112
|
-
/** Holds a map of StreamManager Resource Id to log id smart object. */
|
|
4113
|
-
h(this, "hooks");
|
|
4114
|
-
h(this, "scheduledOnNextState", []);
|
|
4115
|
-
/** If true, main loop will continue polling pl state. */
|
|
4116
|
-
h(this, "keepRunning", !1);
|
|
4117
|
-
/** Actual state of main loop. */
|
|
4118
|
-
h(this, "currentLoop");
|
|
4119
|
-
this.logger = e, this.clientLogs = t, this.opts = r, this.hooks = new Je(
|
|
4120
|
-
() => this.startUpdating(),
|
|
4121
|
-
() => this.stopUpdating(),
|
|
4122
|
-
{ stopDebounce: r.stopPollingDelay },
|
|
4123
|
-
(n, o) => this.scheduleOnNextState(n, o)
|
|
4124
|
-
);
|
|
4125
|
-
}
|
|
4126
|
-
getLastLogs(e, t, r) {
|
|
4127
|
-
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
4128
|
-
const n = D(e, r), o = S();
|
|
4129
|
-
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseLastLogs(n.id, o));
|
|
4130
|
-
const c = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
4131
|
-
return r.markUnstable(
|
|
4132
|
-
"The logs are from stream, so we consider them unstable. Final values will be got from blobs."
|
|
4133
|
-
), c;
|
|
4134
|
-
}
|
|
4135
|
-
getLastLogsNoCtx(e, t, r, n) {
|
|
4136
|
-
fe("getLastLogs", t.type);
|
|
4137
|
-
let o = this.idToLastLines.get(t.id);
|
|
4138
|
-
if (o == null) {
|
|
4139
|
-
const i = new ze(this.logger, this.clientLogs, t, r);
|
|
4140
|
-
this.idToLastLines.set(t.id, i), o = i;
|
|
4141
|
-
}
|
|
4142
|
-
o.attach(e, n);
|
|
4143
|
-
const c = o.getLog();
|
|
4144
|
-
if (c.error != null) throw c.error;
|
|
4145
|
-
return c.log;
|
|
4146
|
-
}
|
|
4147
|
-
getProgressLog(e, t, r) {
|
|
4148
|
-
if (r == null)
|
|
4149
|
-
return b.make((i) => this.getProgressLog(e, t, i));
|
|
4150
|
-
const n = D(e, r), o = S();
|
|
4151
|
-
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseProgressLog(n.id, o));
|
|
4152
|
-
const c = this.getProgressLogNoCtx(r.watcher, n, t, o);
|
|
4153
|
-
return r.markUnstable(
|
|
4154
|
-
"The progress log is from the stream, so we consider it unstable. Final value will be got from blobs."
|
|
4155
|
-
), c;
|
|
4156
|
-
}
|
|
4157
|
-
getProgressLogNoCtx(e, t, r, n) {
|
|
4158
|
-
fe("getProgressLog", t.type);
|
|
4159
|
-
let o = this.idToProgressLog.get(t.id);
|
|
4160
|
-
if (o == null) {
|
|
4161
|
-
const i = new ze(this.logger, this.clientLogs, t, 1, r);
|
|
4162
|
-
this.idToProgressLog.set(t.id, i), o = i;
|
|
4163
|
-
}
|
|
4164
|
-
o.attach(e, n);
|
|
4165
|
-
const c = o.getLog();
|
|
4166
|
-
if (c.error) throw c.error;
|
|
4167
|
-
return c.log;
|
|
4168
|
-
}
|
|
4169
|
-
getLogHandle(e, t) {
|
|
4170
|
-
if (t == null) return b.make((o) => this.getLogHandle(e, o));
|
|
4171
|
-
const r = D(e, t), n = this.getLogHandleNoCtx(r);
|
|
4172
|
-
return t.markUnstable(`live_log:${P(r.id)}`), n;
|
|
4173
|
-
}
|
|
4174
|
-
getLogHandleNoCtx(e) {
|
|
4175
|
-
return fe("getLogHandle", e.type), at(!0, e);
|
|
4176
|
-
}
|
|
4177
|
-
async lastLines(e, t, r, n) {
|
|
4178
|
-
return await this.tryWithNotFound(
|
|
4179
|
-
e,
|
|
4180
|
-
() => this.clientLogs.lastLines(
|
|
4181
|
-
Q(e),
|
|
4182
|
-
t,
|
|
4183
|
-
BigInt(r ?? 0),
|
|
4184
|
-
n
|
|
4185
|
-
)
|
|
4186
|
-
);
|
|
4187
|
-
}
|
|
4188
|
-
async readText(e, t, r, n) {
|
|
4189
|
-
return await this.tryWithNotFound(
|
|
4190
|
-
e,
|
|
4191
|
-
() => this.clientLogs.readText(
|
|
4192
|
-
Q(e),
|
|
4193
|
-
t,
|
|
4194
|
-
BigInt(r ?? 0),
|
|
4195
|
-
n
|
|
4196
|
-
)
|
|
4197
|
-
);
|
|
4198
|
-
}
|
|
4199
|
-
async tryWithNotFound(e, t) {
|
|
4200
|
-
if (!Z(e))
|
|
4201
|
-
throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
|
|
4202
|
-
try {
|
|
4203
|
-
const r = await t();
|
|
4204
|
-
return {
|
|
4205
|
-
live: !0,
|
|
4206
|
-
shouldUpdateHandle: !1,
|
|
4207
|
-
data: r.data,
|
|
4208
|
-
size: Number(r.size),
|
|
4209
|
-
newOffset: Number(r.newOffset)
|
|
4210
|
-
};
|
|
4211
|
-
} catch (r) {
|
|
4212
|
-
if (r.name == "RpcError" && r.code == "NOT_FOUND")
|
|
4213
|
-
return { shouldUpdateHandle: !0 };
|
|
4214
|
-
throw r;
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
async releaseLastLogs(e, t) {
|
|
4218
|
-
var n;
|
|
4219
|
-
((n = this.idToLastLines.get(e)) == null ? void 0 : n.release(t)) && this.idToLastLines.delete(e);
|
|
4220
|
-
}
|
|
4221
|
-
async releaseProgressLog(e, t) {
|
|
4222
|
-
var n;
|
|
4223
|
-
((n = this.idToProgressLog.get(e)) == null ? void 0 : n.release(t)) && this.idToProgressLog.delete(e);
|
|
4224
|
-
}
|
|
4225
|
-
async releaseAll() {
|
|
4226
|
-
}
|
|
4227
|
-
scheduleOnNextState(e, t) {
|
|
4228
|
-
this.scheduledOnNextState.push({ resolve: e, reject: t });
|
|
4229
|
-
}
|
|
4230
|
-
/** Called from observer */
|
|
4231
|
-
startUpdating() {
|
|
4232
|
-
this.keepRunning = !0, this.currentLoop === void 0 && (this.currentLoop = this.mainLoop());
|
|
4233
|
-
}
|
|
4234
|
-
/** Called from observer */
|
|
4235
|
-
stopUpdating() {
|
|
4236
|
-
this.keepRunning = !1;
|
|
4237
|
-
}
|
|
4238
|
-
async mainLoop() {
|
|
4239
|
-
for (; this.keepRunning; ) {
|
|
4240
|
-
const e = this.scheduledOnNextState;
|
|
4241
|
-
this.scheduledOnNextState = [];
|
|
4242
|
-
try {
|
|
4243
|
-
const t = this.getAllLogs();
|
|
4244
|
-
await Re(
|
|
4245
|
-
this.opts.nConcurrentGetLogs,
|
|
4246
|
-
t.map((r) => async () => await r.update())
|
|
4247
|
-
), e.forEach((r) => r.resolve());
|
|
4248
|
-
} catch (t) {
|
|
4249
|
-
console.error(t), e.forEach((r) => r.reject(t));
|
|
4250
|
-
}
|
|
4251
|
-
if (!this.keepRunning) break;
|
|
4252
|
-
await Ke.wait(this.opts.pollingInterval);
|
|
4253
|
-
}
|
|
4254
|
-
this.currentLoop = void 0;
|
|
4255
|
-
}
|
|
4256
|
-
getAllLogs() {
|
|
4257
|
-
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
|
|
4258
|
-
}
|
|
4259
|
-
}
|
|
4260
|
-
class ze {
|
|
4261
|
-
constructor(e, t, r, n, o) {
|
|
4262
|
-
h(this, "logs");
|
|
4263
|
-
h(this, "error");
|
|
4264
|
-
h(this, "change", new C());
|
|
4265
|
-
h(this, "counter", new B());
|
|
4266
|
-
this.logger = e, this.clientLogs = t, this.rInfo = r, this.lines = n, this.patternToSearch = o;
|
|
4267
|
-
}
|
|
4268
|
-
getLog() {
|
|
4269
|
-
return {
|
|
4270
|
-
log: this.logs,
|
|
4271
|
-
error: this.error
|
|
4272
|
-
};
|
|
4273
|
-
}
|
|
4274
|
-
attach(e, t) {
|
|
4275
|
-
this.change.attachWatcher(e), this.counter.inc(t);
|
|
4276
|
-
}
|
|
4277
|
-
release(e) {
|
|
4278
|
-
return this.counter.dec(e);
|
|
4279
|
-
}
|
|
4280
|
-
async update() {
|
|
4281
|
-
try {
|
|
4282
|
-
const e = await this.clientLogs.lastLines(
|
|
4283
|
-
this.rInfo,
|
|
4284
|
-
this.lines,
|
|
4285
|
-
0n,
|
|
4286
|
-
this.patternToSearch
|
|
4287
|
-
), t = new TextDecoder().decode(e.data);
|
|
4288
|
-
this.logs != t && this.change.markChanged(`logs for ${P(this.rInfo.id)} updated`), this.logs = t, this.error = void 0;
|
|
4289
|
-
return;
|
|
4290
|
-
} catch (e) {
|
|
4291
|
-
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
4292
|
-
this.logs = "", this.error = e, this.change.markChanged();
|
|
4293
|
-
return;
|
|
4294
|
-
}
|
|
4295
|
-
throw this.logger.error(
|
|
4296
|
-
`Stream log lines for ${y(this.rInfo.id)} failed, reason: ${e}`
|
|
4297
|
-
), e;
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
}
|
|
4301
|
-
function fe(s, e) {
|
|
4302
|
-
if (!e.name.startsWith("StreamWorkdir"))
|
|
4303
|
-
throw new Ie(
|
|
4304
|
-
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4305
|
-
);
|
|
4306
|
-
}
|
|
4307
|
-
class ds {
|
|
4308
|
-
constructor(e, t, r) {
|
|
4309
|
-
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = r;
|
|
4310
|
-
}
|
|
4311
|
-
getLastLogs(e, t, r) {
|
|
4312
|
-
if (r === void 0) return b.make((o) => this.getLastLogs(e, t, o));
|
|
4313
|
-
const n = V(r, e);
|
|
4314
|
-
if (n === void 0) {
|
|
4315
|
-
r.markUnstable("no stream in stream manager");
|
|
4316
|
-
return;
|
|
4317
|
-
}
|
|
4318
|
-
if (G(n)) return this.downloadDriver.getLastLogs(n, t, r);
|
|
4319
|
-
try {
|
|
4320
|
-
return this.logsStreamDriver.getLastLogs(n, t, r);
|
|
4321
|
-
} catch (o) {
|
|
4322
|
-
if (o.name == "RpcError" && o.code == "NOT_FOUND") {
|
|
4323
|
-
r.markUnstable(`NOT_FOUND in logs stream driver while getting last logs: ${o}`);
|
|
4324
|
-
return;
|
|
4325
|
-
}
|
|
4326
|
-
throw o;
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
getProgressLog(e, t, r) {
|
|
4330
|
-
if (r === void 0)
|
|
4331
|
-
return b.make((o) => this.getProgressLog(e, t, o));
|
|
4332
|
-
const n = V(r, e);
|
|
4333
|
-
if (n === void 0) {
|
|
4334
|
-
r.markUnstable("no stream in stream manager");
|
|
4335
|
-
return;
|
|
4336
|
-
}
|
|
4337
|
-
if (G(n)) return this.downloadDriver.getProgressLog(n, t, r);
|
|
4338
|
-
try {
|
|
4339
|
-
return this.logsStreamDriver.getProgressLog(n, t, r);
|
|
4340
|
-
} catch (o) {
|
|
4341
|
-
if (o.name == "RpcError" && o.code == "NOT_FOUND") {
|
|
4342
|
-
r.markUnstable(`NOT_FOUND in logs stream driver while getting a progress log: ${o}`);
|
|
4343
|
-
return;
|
|
4344
|
-
}
|
|
4345
|
-
throw o;
|
|
4346
|
-
}
|
|
4347
|
-
}
|
|
4348
|
-
getProgressLogWithInfo(e, t, r) {
|
|
4349
|
-
if (r === void 0)
|
|
4350
|
-
return b.make((o) => this.getProgressLogWithInfo(e, t, o));
|
|
4351
|
-
const n = V(r, e);
|
|
4352
|
-
if (n === void 0) {
|
|
4353
|
-
r.markUnstable("no stream in stream manager");
|
|
4354
|
-
return;
|
|
4355
|
-
}
|
|
4356
|
-
if (G(n))
|
|
4357
|
-
return {
|
|
4358
|
-
progressLine: this.downloadDriver.getProgressLog(n, t, r),
|
|
4359
|
-
live: !1
|
|
4360
|
-
};
|
|
4361
|
-
try {
|
|
4362
|
-
return {
|
|
4363
|
-
progressLine: this.logsStreamDriver.getProgressLog(n, t, r),
|
|
4364
|
-
live: !0
|
|
4365
|
-
};
|
|
4366
|
-
} catch (o) {
|
|
4367
|
-
if (o.name == "RpcError" && o.code == "NOT_FOUND") {
|
|
4368
|
-
r.markUnstable(`NOT_FOUND in logs stream driver while getting a progress log with info: ${o}`);
|
|
4369
|
-
return;
|
|
4370
|
-
}
|
|
4371
|
-
throw o;
|
|
4372
|
-
}
|
|
4373
|
-
}
|
|
4374
|
-
getLogHandle(e, t) {
|
|
4375
|
-
if (t === void 0) return b.make((n) => this.getLogHandle(e, n));
|
|
4376
|
-
const r = V(t, e);
|
|
4377
|
-
if (r === void 0) {
|
|
4378
|
-
t.markUnstable("no stream in stream manager");
|
|
4379
|
-
return;
|
|
4380
|
-
}
|
|
4381
|
-
return G(r) ? this.downloadDriver.getLogHandle(r, t) : this.logsStreamDriver.getLogHandle(r, t);
|
|
4382
|
-
}
|
|
4383
|
-
async lastLines(e, t, r, n) {
|
|
4384
|
-
return Z(e) ? await this.logsStreamDriver.lastLines(e, t, r, n) : await this.downloadDriver.lastLines(e, t, r, n);
|
|
4385
|
-
}
|
|
4386
|
-
async readText(e, t, r, n) {
|
|
4387
|
-
return Z(e) ? await this.logsStreamDriver.readText(e, t, r, n) : await this.downloadDriver.readText(e, t, r, n);
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
function G(s) {
|
|
4391
|
-
return !s.type.name.startsWith("StreamWorkdir");
|
|
4392
|
-
}
|
|
4393
|
-
function V(s, e) {
|
|
4394
|
-
var t;
|
|
4395
|
-
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4396
|
-
}
|
|
4397
|
-
class bo {
|
|
4398
|
-
constructor(e, t, r, n, o) {
|
|
4399
|
-
h(this, "counter", new B());
|
|
4400
|
-
h(this, "change", new C());
|
|
4401
|
-
h(this, "signalCtl", new AbortController());
|
|
4402
|
-
h(this, "error");
|
|
4403
|
-
h(this, "done", !1);
|
|
4404
|
-
h(this, "size", 0);
|
|
4405
|
-
this.logger = e, this.path = t, this.url = r, this.signer = n, this.saveDir = o;
|
|
4406
|
-
}
|
|
4407
|
-
info() {
|
|
4408
|
-
return {
|
|
4409
|
-
url: this.url.toString(),
|
|
4410
|
-
path: this.path,
|
|
4411
|
-
done: this.done,
|
|
4412
|
-
size: this.size,
|
|
4413
|
-
error: this.error
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
attach(e, t) {
|
|
4417
|
-
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
4418
|
-
}
|
|
4419
|
-
async download(e, t) {
|
|
4420
|
-
try {
|
|
4421
|
-
const r = await this.downloadAndUntar(e, t, this.signalCtl.signal);
|
|
4422
|
-
this.setDone(r), this.change.markChanged(`download of ${this.url} finished`);
|
|
4423
|
-
} catch (r) {
|
|
4424
|
-
if (r instanceof We || r instanceof te) {
|
|
4425
|
-
this.setError(r), this.change.markChanged(`download of ${this.url} failed`), await Ue(this.path);
|
|
4426
|
-
return;
|
|
4427
|
-
}
|
|
4428
|
-
throw r;
|
|
4429
|
-
}
|
|
4430
|
-
}
|
|
4431
|
-
async downloadAndUntar(e, t, r) {
|
|
4432
|
-
return await W(T.dirname(this.path)), await A(this.path) ? await yt(this.path) : await e.withContent(
|
|
4433
|
-
this.url.toString(),
|
|
4434
|
-
{},
|
|
4435
|
-
{ signal: r },
|
|
4436
|
-
async (o, c) => {
|
|
4437
|
-
let i = o;
|
|
4438
|
-
if (t) {
|
|
4439
|
-
const l = Ve.toWeb(Qe.createGunzip());
|
|
4440
|
-
i = o.pipeThrough(l, { signal: r });
|
|
4441
|
-
}
|
|
4442
|
-
return await X(this.logger, this.path, async (l) => {
|
|
4443
|
-
await w.mkdir(l);
|
|
4444
|
-
const a = z.toWeb(ke.extract(l));
|
|
4445
|
-
await i.pipeTo(a, { signal: r });
|
|
4446
|
-
}), c;
|
|
4447
|
-
}
|
|
4448
|
-
);
|
|
4449
|
-
}
|
|
4450
|
-
getUrl() {
|
|
4451
|
-
if (this.done) return {
|
|
4452
|
-
url: Kn(this.signer, this.saveDir, K(this.path))
|
|
4453
|
-
};
|
|
4454
|
-
if (this.error) return { error: this.error };
|
|
4455
|
-
}
|
|
4456
|
-
setDone(e) {
|
|
4457
|
-
this.done = !0, this.size = e;
|
|
4458
|
-
}
|
|
4459
|
-
setError(e) {
|
|
4460
|
-
this.error = String(e);
|
|
4461
|
-
}
|
|
4462
|
-
abort(e) {
|
|
4463
|
-
this.signalCtl.abort(new We(e));
|
|
4464
|
-
}
|
|
4465
|
-
}
|
|
4466
|
-
class We extends Error {
|
|
4467
|
-
constructor() {
|
|
4468
|
-
super(...arguments);
|
|
4469
|
-
h(this, "name", "URLAborted");
|
|
4470
|
-
}
|
|
4471
|
-
}
|
|
4472
|
-
async function yt(s) {
|
|
4473
|
-
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
4474
|
-
return (await Promise.all(
|
|
4475
|
-
e.map(async (r) => {
|
|
4476
|
-
const n = T.join(s, r.name);
|
|
4477
|
-
return r.isDirectory() ? await yt(n) : (await w.stat(n)).size;
|
|
4478
|
-
})
|
|
4479
|
-
)).reduce((r, n) => r + n, 0);
|
|
4480
|
-
}
|
|
4481
|
-
async function Ue(s) {
|
|
4482
|
-
await w.rm(s, { recursive: !0, force: !0 });
|
|
4483
|
-
}
|
|
4484
|
-
class us {
|
|
4485
|
-
constructor(e, t, r, n, o = {
|
|
4486
|
-
cacheSoftSizeBytes: 1 * 1024 * 1024 * 1024,
|
|
4487
|
-
// 1 GB
|
|
4488
|
-
withGunzip: !0,
|
|
4489
|
-
nConcurrentDownloads: 50
|
|
4490
|
-
}) {
|
|
4491
|
-
h(this, "downloadHelper");
|
|
4492
|
-
h(this, "urlToDownload", /* @__PURE__ */ new Map());
|
|
4493
|
-
h(this, "downloadQueue");
|
|
4494
|
-
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4495
|
-
* file that should be kept. */
|
|
4496
|
-
h(this, "cache");
|
|
4497
|
-
this.logger = e, this.saveDir = r, this.signer = n, this.opts = o, this.downloadQueue = new Y(this.logger, this.opts.nConcurrentDownloads), this.cache = new ve(this.opts.cacheSoftSizeBytes), this.downloadHelper = new rt(t);
|
|
4498
|
-
}
|
|
4499
|
-
/** Returns a computable that returns a custom protocol URL to the downloaded and unarchived path. */
|
|
4500
|
-
getUrl(e, t) {
|
|
4501
|
-
if (t === void 0) return b.make((o) => this.getUrl(e, o));
|
|
4502
|
-
const r = S();
|
|
4503
|
-
t.addOnDestroy(() => this.releasePath(e, r));
|
|
4504
|
-
const n = this.getUrlNoCtx(e, t.watcher, r);
|
|
4505
|
-
return (n == null ? void 0 : n.url) === void 0 && t.markUnstable(
|
|
4506
|
-
`a path to the downloaded and untared archive might be undefined. The current result: ${n}`
|
|
4507
|
-
), n;
|
|
4508
|
-
}
|
|
4509
|
-
getUrlNoCtx(e, t, r) {
|
|
4510
|
-
const n = e.toString(), o = this.urlToDownload.get(n);
|
|
4511
|
-
if (o !== void 0)
|
|
4512
|
-
return o.attach(t, r), o.getUrl();
|
|
4513
|
-
const c = this.setNewTask(t, e, r);
|
|
4514
|
-
return this.downloadQueue.push({
|
|
4515
|
-
fn: async () => this.downloadUrl(c, r),
|
|
4516
|
-
recoverableErrorPredicate: (i) => !0
|
|
4517
|
-
}), c.getUrl();
|
|
4518
|
-
}
|
|
4519
|
-
getPathForBlockUI(e) {
|
|
4520
|
-
if (!Bt(e))
|
|
4521
|
-
throw new Error(`getPathForBlockUI: ${e} is invalid`);
|
|
4522
|
-
return Yn(this.signer, e, this.saveDir);
|
|
4523
|
-
}
|
|
4524
|
-
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4525
|
-
async downloadUrl(e, t) {
|
|
4526
|
-
var r;
|
|
4527
|
-
await e.download(this.downloadHelper, this.opts.withGunzip), ((r = e.getUrl()) == null ? void 0 : r.url) !== void 0 && this.cache.addCache(e, t);
|
|
4528
|
-
}
|
|
4529
|
-
/** Removes a directory and aborts a downloading task when all callers
|
|
4530
|
-
* are not interested in it. */
|
|
4531
|
-
async releasePath(e, t) {
|
|
4532
|
-
const r = e.toString(), n = this.urlToDownload.get(r);
|
|
4533
|
-
if (n != null)
|
|
4534
|
-
if (this.cache.existsFile(n.path)) {
|
|
4535
|
-
const o = this.cache.removeFile(n.path, t);
|
|
4536
|
-
await Promise.all(
|
|
4537
|
-
o.map(async (c) => {
|
|
4538
|
-
await Ue(c.path), this.cache.removeCache(c), this.removeTask(
|
|
4539
|
-
c,
|
|
4540
|
-
`the task ${y(c.info())} was removedfrom cache along with ${y(o.map((i) => i.info()))}`
|
|
4541
|
-
);
|
|
4542
|
-
})
|
|
4543
|
-
);
|
|
4544
|
-
} else
|
|
4545
|
-
n.counter.dec(t) && this.removeTask(
|
|
4546
|
-
n,
|
|
4547
|
-
`the task ${y(n.info())} was removed from cache`
|
|
4548
|
-
);
|
|
4549
|
-
}
|
|
4550
|
-
/** Removes all files from a hard drive. */
|
|
4551
|
-
async releaseAll() {
|
|
4552
|
-
this.downloadQueue.stop(), await Promise.all(
|
|
4553
|
-
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4554
|
-
await Ue(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4555
|
-
t,
|
|
4556
|
-
`the task ${y(t.info())} was released when the driver was closed`
|
|
4557
|
-
);
|
|
4558
|
-
})
|
|
4559
|
-
);
|
|
4560
|
-
}
|
|
4561
|
-
setNewTask(e, t, r) {
|
|
4562
|
-
const n = new bo(
|
|
4563
|
-
this.logger,
|
|
4564
|
-
this.getFilePath(t),
|
|
4565
|
-
t,
|
|
4566
|
-
this.signer,
|
|
4567
|
-
this.saveDir
|
|
4568
|
-
);
|
|
4569
|
-
return n.attach(e, r), this.urlToDownload.set(t.toString(), n), n;
|
|
4570
|
-
}
|
|
4571
|
-
removeTask(e, t) {
|
|
4572
|
-
e.abort(t), e.change.markChanged(`task for url ${e.url} removed: ${t}`), this.urlToDownload.delete(e.url.toString());
|
|
4573
|
-
}
|
|
4574
|
-
getFilePath(e) {
|
|
4575
|
-
const t = _t("sha256").update(e.toString()).digest("hex");
|
|
4576
|
-
return T.join(this.saveDir, t);
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
function we(s, e) {
|
|
4580
|
-
return `index://index/${encodeURIComponent(JSON.stringify({
|
|
4581
|
-
storageId: s,
|
|
4582
|
-
path: e
|
|
4583
|
-
}))}`;
|
|
4584
|
-
}
|
|
4585
|
-
function ko(s, e, t, r) {
|
|
4586
|
-
const n = {
|
|
4587
|
-
localPath: s,
|
|
4588
|
-
pathSignature: e.sign(s),
|
|
4589
|
-
sizeBytes: String(t),
|
|
4590
|
-
modificationTime: String(r)
|
|
4591
|
-
};
|
|
4592
|
-
return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
|
|
4593
|
-
}
|
|
4594
|
-
function To(s) {
|
|
4595
|
-
const e = new URL(s);
|
|
4596
|
-
return re.parse(
|
|
4597
|
-
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4598
|
-
);
|
|
4599
|
-
}
|
|
4600
|
-
function Lo(s) {
|
|
4601
|
-
const e = new URL(s);
|
|
4602
|
-
return st.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4603
|
-
}
|
|
4604
|
-
function xe(s) {
|
|
4605
|
-
if (No(s))
|
|
4606
|
-
return So(s);
|
|
4607
|
-
if (Uo(s))
|
|
4608
|
-
return Ro(s);
|
|
4609
|
-
St(s);
|
|
4610
|
-
}
|
|
4611
|
-
const bt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4612
|
-
function Uo(s) {
|
|
4613
|
-
return bt.test(s);
|
|
4614
|
-
}
|
|
4615
|
-
function Po(s, e) {
|
|
4616
|
-
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4617
|
-
}
|
|
4618
|
-
function Ro(s) {
|
|
4619
|
-
const e = s.match(bt);
|
|
4620
|
-
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4621
|
-
const { name: t, path: r } = e.groups;
|
|
4622
|
-
return {
|
|
4623
|
-
rootPath: decodeURIComponent(r),
|
|
4624
|
-
name: t,
|
|
4625
|
-
isRemote: !1
|
|
4626
|
-
};
|
|
4627
|
-
}
|
|
4628
|
-
const kt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4629
|
-
function No(s) {
|
|
4630
|
-
return kt.test(s);
|
|
4631
|
-
}
|
|
4632
|
-
function $o(s, e) {
|
|
4633
|
-
return `remote://${s}/${BigInt(e)}`;
|
|
4634
|
-
}
|
|
4635
|
-
function So(s) {
|
|
4636
|
-
const e = s.match(kt);
|
|
4637
|
-
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4638
|
-
const { name: t, resourceId: r } = e.groups;
|
|
4639
|
-
return {
|
|
4640
|
-
id: Pe(BigInt(r)),
|
|
4641
|
-
type: Io(t),
|
|
4642
|
-
name: t,
|
|
4643
|
-
isRemote: !0
|
|
4644
|
-
};
|
|
4645
|
-
}
|
|
4646
|
-
function Io(s) {
|
|
4647
|
-
return { name: `LS/${s}`, version: "1" };
|
|
4648
|
-
}
|
|
4649
|
-
async function Do() {
|
|
4650
|
-
const s = Ft.homedir();
|
|
4651
|
-
if (U.sep == "/")
|
|
4652
|
-
return [
|
|
4653
|
-
{
|
|
4654
|
-
name: "local",
|
|
4655
|
-
root: "/",
|
|
4656
|
-
initialPath: s
|
|
4657
|
-
}
|
|
4658
|
-
];
|
|
4659
|
-
{
|
|
4660
|
-
const t = U.parse(s).root.replaceAll(":\\", "");
|
|
4661
|
-
try {
|
|
4662
|
-
return (await At.promisify(Mt)("wmic logicaldisk get name")).stdout.split(`\r
|
|
4663
|
-
`).filter((o) => o.includes(":")).map((o) => o.trim().replaceAll(":", "")).map((o) => {
|
|
4664
|
-
const c = o == t;
|
|
4665
|
-
return {
|
|
4666
|
-
name: `local_disk_${o}`,
|
|
4667
|
-
root: `${o}:\\`,
|
|
4668
|
-
initialPath: c ? s : `${o}:\\`
|
|
4669
|
-
};
|
|
4670
|
-
});
|
|
4671
|
-
} catch {
|
|
4672
|
-
return [
|
|
4673
|
-
{
|
|
4674
|
-
name: `local_disk_${t}`,
|
|
4675
|
-
root: `${t}:\\`,
|
|
4676
|
-
initialPath: s
|
|
4677
|
-
}
|
|
4678
|
-
];
|
|
4679
|
-
}
|
|
4680
|
-
}
|
|
4681
|
-
}
|
|
4682
|
-
class Tt {
|
|
4683
|
-
constructor(e, t, r, n, o, c, i) {
|
|
4684
|
-
this.logger = e, this.lsClient = t, this.storageIdToResourceId = r, this.signer = n, this.virtualStoragesMap = o, this.localProjectionsMap = c, this.openFileDialogCallback = i;
|
|
4685
|
-
}
|
|
4686
|
-
async getLocalFileContent(e, t) {
|
|
4687
|
-
const r = await this.tryResolveLocalFileHandle(e);
|
|
4688
|
-
if (t) throw new Error("Range request not yet supported.");
|
|
4689
|
-
return await w.readFile(r);
|
|
4690
|
-
}
|
|
4691
|
-
async getLocalFileSize(e) {
|
|
4692
|
-
const t = await this.tryResolveLocalFileHandle(e);
|
|
4693
|
-
return (await w.stat(t)).size;
|
|
4694
|
-
}
|
|
4695
|
-
async showOpenMultipleFilesDialog(e) {
|
|
4696
|
-
const t = await this.openFileDialogCallback(!0, e);
|
|
4697
|
-
return t === void 0 ? {} : {
|
|
4698
|
-
files: await Promise.all(t.map((r) => this.getLocalFileHandle(r)))
|
|
4699
|
-
};
|
|
4700
|
-
}
|
|
4701
|
-
async showOpenSingleFileDialog(e) {
|
|
4702
|
-
const t = await this.openFileDialogCallback(!1, e);
|
|
4703
|
-
return t === void 0 ? {} : {
|
|
4704
|
-
file: await this.getLocalFileHandle(t[0])
|
|
4705
|
-
};
|
|
4706
|
-
}
|
|
4707
|
-
/**
|
|
4708
|
-
* Resolves local handle to local file path.
|
|
4709
|
-
*
|
|
4710
|
-
* @param handle handle to be resolved
|
|
4711
|
-
* @private
|
|
4712
|
-
*/
|
|
4713
|
-
async tryResolveLocalFileHandle(e) {
|
|
4714
|
-
if (Ct(e)) {
|
|
4715
|
-
const t = Lo(e), r = this.localProjectionsMap.get(t.storageId);
|
|
4716
|
-
if (!r)
|
|
4717
|
-
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4718
|
-
return T.join(r.localPath, t.path);
|
|
4719
|
-
} else {
|
|
4720
|
-
const t = To(e);
|
|
4721
|
-
this.signer.verify(
|
|
4722
|
-
t.localPath,
|
|
4723
|
-
t.pathSignature,
|
|
4724
|
-
"Failed to validate local file handle signature."
|
|
4725
|
-
);
|
|
4726
|
-
const r = t.localPath, n = await w.stat(r, { bigint: !0 });
|
|
4727
|
-
if (String(n.mtimeMs / 1000n) !== t.modificationTime)
|
|
4728
|
-
throw new Error("File has changed since the handle was created.");
|
|
4729
|
-
return r;
|
|
4730
|
-
}
|
|
4731
|
-
}
|
|
4732
|
-
async getLocalFileHandle(e) {
|
|
4733
|
-
O(e);
|
|
4734
|
-
for (const r of this.localProjectionsMap.values())
|
|
4735
|
-
if (e.startsWith(r.localPath)) {
|
|
4736
|
-
const n = r.localPath === "" ? e : T.relative(r.localPath, e);
|
|
4737
|
-
return we(
|
|
4738
|
-
r.storageId,
|
|
4739
|
-
n
|
|
4740
|
-
);
|
|
4741
|
-
}
|
|
4742
|
-
const t = await w.stat(e, { bigint: !0 });
|
|
4743
|
-
return ko(
|
|
4744
|
-
e,
|
|
4745
|
-
this.signer,
|
|
4746
|
-
t.size,
|
|
4747
|
-
t.mtimeMs / 1000n
|
|
4748
|
-
// integer division
|
|
4749
|
-
);
|
|
4750
|
-
}
|
|
4751
|
-
async getStorageList() {
|
|
4752
|
-
const e = [...this.virtualStoragesMap.values()].map((n) => ({
|
|
4753
|
-
name: n.name,
|
|
4754
|
-
handle: Po(n.name, n.root),
|
|
4755
|
-
initialFullPath: n.initialPath
|
|
4756
|
-
})), r = Object.entries(this.storageIdToResourceId).map(
|
|
4757
|
-
([n, o]) => ({
|
|
4758
|
-
name: n,
|
|
4759
|
-
handle: $o(n, o),
|
|
4760
|
-
initialFullPath: "",
|
|
4761
|
-
// we don't have any additional information from where to start browsing remote storages
|
|
4762
|
-
isInitialPathHome: !1
|
|
4763
|
-
})
|
|
4764
|
-
).filter((n) => n.name !== "root");
|
|
4765
|
-
return [...e, ...r];
|
|
4766
|
-
}
|
|
4767
|
-
async listFiles(e, t) {
|
|
4768
|
-
const r = xe(e);
|
|
4769
|
-
if (r.isRemote)
|
|
4770
|
-
return {
|
|
4771
|
-
entries: (await this.lsClient.list(r, t)).items.map((i) => ({
|
|
4772
|
-
type: i.isDir ? "dir" : "file",
|
|
4773
|
-
name: i.name,
|
|
4774
|
-
fullPath: i.fullName,
|
|
4775
|
-
handle: we(r.name, i.fullName)
|
|
4776
|
-
}))
|
|
4777
|
-
};
|
|
4778
|
-
T.sep === "/" && t === "" && (t = "/"), r.rootPath === "" && O(t);
|
|
4779
|
-
const n = T.isAbsolute(t) ? t : T.join(r.rootPath, t), o = [];
|
|
4780
|
-
for await (const c of await w.opendir(n)) {
|
|
4781
|
-
if (!c.isFile() && !c.isDirectory()) continue;
|
|
4782
|
-
const i = T.join(n, c.name);
|
|
4783
|
-
o.push({
|
|
4784
|
-
type: c.isFile() ? "file" : "dir",
|
|
4785
|
-
name: c.name,
|
|
4786
|
-
fullPath: i,
|
|
4787
|
-
handle: await this.getLocalFileHandle(i)
|
|
4788
|
-
});
|
|
4789
|
-
}
|
|
4790
|
-
return { entries: o };
|
|
4791
|
-
}
|
|
4792
|
-
async listRemoteFilesWithAdditionalInfo(e, t) {
|
|
4793
|
-
const r = xe(e);
|
|
4794
|
-
if (!r.isRemote)
|
|
4795
|
-
throw new Error(`Storage ${r.name} is not remote`);
|
|
4796
|
-
return {
|
|
4797
|
-
entries: (await this.lsClient.list(r, t)).items.map((o) => ({
|
|
4798
|
-
type: o.isDir ? "dir" : "file",
|
|
4799
|
-
name: o.name,
|
|
4800
|
-
fullPath: o.fullName,
|
|
4801
|
-
handle: we(r.name, o.fullName),
|
|
4802
|
-
size: Number(o.size)
|
|
4803
|
-
}))
|
|
4804
|
-
};
|
|
4805
|
-
}
|
|
4806
|
-
async fileToImportHandle(e) {
|
|
4807
|
-
throw new Error(
|
|
4808
|
-
"Not implemented. This method must be implemented and intercepted in desktop preload script."
|
|
4809
|
-
);
|
|
4810
|
-
}
|
|
4811
|
-
static async init(e, t, r, n, o, c) {
|
|
4812
|
-
const i = yn(t, e);
|
|
4813
|
-
c || (c = await Do());
|
|
4814
|
-
for (const d of c) O(d.root);
|
|
4815
|
-
for (const d of n) d.localPath !== "" && O(d.localPath);
|
|
4816
|
-
const l = new Map(c.map((d) => [d.name, d])), a = new Map(n.map((d) => [d.storageId, d]));
|
|
4817
|
-
if ((/* @__PURE__ */ new Set([...l.keys(), ...a.keys()])).size !== l.size + a.size)
|
|
4818
|
-
throw new Error(
|
|
4819
|
-
"Intersection between local projection storage ids and virtual storages names detected."
|
|
4820
|
-
);
|
|
4821
|
-
return new Tt(
|
|
4822
|
-
e,
|
|
4823
|
-
i,
|
|
4824
|
-
await vo(t),
|
|
4825
|
-
r,
|
|
4826
|
-
l,
|
|
4827
|
-
a,
|
|
4828
|
-
o
|
|
4829
|
-
);
|
|
4830
|
-
}
|
|
4831
|
-
}
|
|
4832
|
-
async function vo(s) {
|
|
4833
|
-
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4834
|
-
const t = await e.getResourceByName("LSProvider"), r = await e.getResourceData(t, !0);
|
|
4835
|
-
return Bo(r);
|
|
4836
|
-
});
|
|
4837
|
-
}
|
|
4838
|
-
function Bo(s) {
|
|
4839
|
-
return Object.fromEntries(
|
|
4840
|
-
s.fields.filter((e) => e.type == "Dynamic" && Rt(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4841
|
-
);
|
|
4842
|
-
}
|
|
4843
|
-
export {
|
|
4844
|
-
Ar as ClientDownload,
|
|
4845
|
-
mn as ClientLogs,
|
|
4846
|
-
rn as ClientLs,
|
|
4847
|
-
vr as ClientProgress,
|
|
4848
|
-
ur as ClientUpload,
|
|
4849
|
-
Do as DefaultVirtualLocalStorages,
|
|
4850
|
-
ls as DownloadBlobToURLDriver,
|
|
4851
|
-
pt as DownloadDriver,
|
|
4852
|
-
us as DownloadUrlDriver,
|
|
4853
|
-
Jn as DownloadableBlobSnapshot,
|
|
4854
|
-
is as ImportFileHandleData,
|
|
4855
|
-
st as ImportFileHandleIndexData,
|
|
4856
|
-
re as ImportFileHandleUploadData,
|
|
4857
|
-
Pn as IndexResourceSnapshot,
|
|
4858
|
-
ds as LogsDriver,
|
|
4859
|
-
hs as LogsStreamDriver,
|
|
4860
|
-
Tt as LsDriver,
|
|
4861
|
-
Xe as MTimeError,
|
|
4862
|
-
et as NetworkError,
|
|
4863
|
-
tt as NoFileForUploading,
|
|
4864
|
-
Ln as OnDemandBlobResourceSnapshot,
|
|
4865
|
-
Ye as UnexpectedEOF,
|
|
4866
|
-
Se as UnknownStorageError,
|
|
4867
|
-
Sn as Updater,
|
|
4868
|
-
cs as UploadDriver,
|
|
4869
|
-
Un as UploadResourceSnapshot,
|
|
4870
|
-
no as UploadTask,
|
|
4871
|
-
$e as WrongLocalFileUrl,
|
|
4872
|
-
Ie as WrongResourceTypeError,
|
|
4873
|
-
rs as createDownloadClient,
|
|
4874
|
-
ns as createLogsClient,
|
|
4875
|
-
yn as createLsFilesClient,
|
|
4876
|
-
ss as createUploadBlobClient,
|
|
4877
|
-
os as createUploadProgressClient,
|
|
4878
|
-
Hr as getFullPath,
|
|
4879
|
-
ot as getSize,
|
|
4880
|
-
io as isMyUpload,
|
|
4881
|
-
Oe as isResourceWasDeletedError,
|
|
4882
|
-
co as isSignMatch,
|
|
4883
|
-
Le as isUpload,
|
|
4884
|
-
wo as makeBlobImportSnapshot,
|
|
4885
|
-
Zn as makeDownloadableBlobSnapshot,
|
|
4886
|
-
Vr as newLocalStorageIdsToRoot,
|
|
4887
|
-
mt as nonRecoverableError,
|
|
4888
|
-
Mr as parseLocalUrl,
|
|
4889
|
-
oo as uploadBlob,
|
|
4890
|
-
O as validateAbsolute
|
|
4891
|
-
};
|
|
4892
|
-
//# sourceMappingURL=index.mjs.map
|