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