@milaboratories/pl-drivers 1.12.7 → 1.12.9
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/_virtual/_rolldown/runtime.cjs +7 -13
- package/dist/clients/constructors.cjs +6 -7
- package/dist/clients/constructors.cjs.map +1 -1
- package/dist/clients/constructors.d.ts.map +1 -0
- package/dist/clients/constructors.js +1 -2
- package/dist/clients/constructors.js.map +1 -1
- package/dist/clients/crc32c.cjs +1 -2
- package/dist/clients/crc32c.cjs.map +1 -1
- package/dist/clients/crc32c.js +1 -1
- package/dist/clients/download.cjs +6 -6
- package/dist/clients/download.cjs.map +1 -1
- package/dist/clients/download.d.ts.map +1 -0
- package/dist/clients/download.js +2 -2
- package/dist/clients/download.js.map +1 -1
- package/dist/clients/logs.cjs +5 -4
- package/dist/clients/logs.cjs.map +1 -1
- package/dist/clients/logs.d.ts.map +1 -0
- package/dist/clients/logs.js +3 -2
- package/dist/clients/logs.js.map +1 -1
- package/dist/clients/ls_api.cjs +4 -4
- package/dist/clients/ls_api.cjs.map +1 -1
- package/dist/clients/ls_api.d.ts.map +1 -0
- package/dist/clients/ls_api.js +2 -2
- package/dist/clients/ls_api.js.map +1 -1
- package/dist/clients/progress.cjs +7 -5
- package/dist/clients/progress.cjs.map +1 -1
- package/dist/clients/progress.d.ts.map +1 -0
- package/dist/clients/progress.js +5 -3
- package/dist/clients/progress.js.map +1 -1
- package/dist/clients/upload.cjs +22 -9
- package/dist/clients/upload.cjs.map +1 -1
- package/dist/clients/upload.d.ts.map +1 -0
- package/dist/clients/upload.js +18 -5
- package/dist/clients/upload.js.map +1 -1
- package/dist/drivers/download_blob/blob_key.cjs +3 -4
- package/dist/drivers/download_blob/blob_key.cjs.map +1 -1
- package/dist/drivers/download_blob/blob_key.js +2 -3
- package/dist/drivers/download_blob/blob_key.js.map +1 -1
- package/dist/drivers/download_blob/download_blob.cjs +13 -14
- package/dist/drivers/download_blob/download_blob.cjs.map +1 -1
- package/dist/drivers/download_blob/download_blob.d.ts.map +1 -0
- package/dist/drivers/download_blob/download_blob.js +1 -2
- package/dist/drivers/download_blob/download_blob.js.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.cjs +4 -5
- package/dist/drivers/download_blob/download_blob_task.cjs.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.js +1 -2
- package/dist/drivers/download_blob/download_blob_task.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/cache.cjs +4 -5
- package/dist/drivers/download_blob/sparse_cache/cache.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/cache.js +1 -2
- package/dist/drivers/download_blob/sparse_cache/cache.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/file.cjs +2 -3
- package/dist/drivers/download_blob/sparse_cache/file.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/file.js +1 -2
- package/dist/drivers/download_blob/sparse_cache/file.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs +3 -4
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.js +1 -2
- package/dist/drivers/download_blob/sparse_cache/ranges.js.map +1 -1
- package/dist/drivers/download_blob_url/driver.cjs +8 -9
- package/dist/drivers/download_blob_url/driver.cjs.map +1 -1
- package/dist/drivers/download_blob_url/driver.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/driver.js +1 -2
- package/dist/drivers/download_blob_url/driver.js.map +1 -1
- package/dist/drivers/download_blob_url/driver_id.cjs +1 -2
- package/dist/drivers/download_blob_url/driver_id.cjs.map +1 -1
- package/dist/drivers/download_blob_url/driver_id.js +1 -1
- package/dist/drivers/download_blob_url/snapshot.cjs +2 -3
- package/dist/drivers/download_blob_url/snapshot.cjs.map +1 -1
- package/dist/drivers/download_blob_url/snapshot.d.ts +2 -2
- package/dist/drivers/download_blob_url/snapshot.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/snapshot.js +1 -2
- package/dist/drivers/download_blob_url/snapshot.js.map +1 -1
- package/dist/drivers/download_blob_url/task.cjs +5 -6
- package/dist/drivers/download_blob_url/task.cjs.map +1 -1
- package/dist/drivers/download_blob_url/task.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/task.js +1 -2
- package/dist/drivers/download_blob_url/task.js.map +1 -1
- package/dist/drivers/download_url/driver.cjs +7 -8
- package/dist/drivers/download_url/driver.cjs.map +1 -1
- package/dist/drivers/download_url/driver.d.ts.map +1 -0
- package/dist/drivers/download_url/driver.js +1 -2
- package/dist/drivers/download_url/driver.js.map +1 -1
- package/dist/drivers/download_url/task.cjs +4 -5
- package/dist/drivers/download_url/task.cjs.map +1 -1
- package/dist/drivers/download_url/task.d.ts.map +1 -0
- package/dist/drivers/download_url/task.js +1 -2
- package/dist/drivers/download_url/task.js.map +1 -1
- package/dist/drivers/helpers/download_local_handle.cjs +1 -2
- package/dist/drivers/helpers/download_local_handle.cjs.map +1 -1
- package/dist/drivers/helpers/download_local_handle.js +1 -1
- package/dist/drivers/helpers/download_remote_handle.cjs +3 -4
- package/dist/drivers/helpers/download_remote_handle.cjs.map +1 -1
- package/dist/drivers/helpers/download_remote_handle.js +1 -2
- package/dist/drivers/helpers/download_remote_handle.js.map +1 -1
- package/dist/drivers/helpers/files_cache.cjs +2 -3
- package/dist/drivers/helpers/files_cache.cjs.map +1 -1
- package/dist/drivers/helpers/files_cache.js +1 -2
- package/dist/drivers/helpers/files_cache.js.map +1 -1
- package/dist/drivers/helpers/helpers.cjs +1 -2
- package/dist/drivers/helpers/helpers.cjs.map +1 -1
- package/dist/drivers/helpers/helpers.d.ts.map +1 -0
- package/dist/drivers/helpers/helpers.js +1 -1
- package/dist/drivers/helpers/helpers.js.map +1 -1
- package/dist/drivers/helpers/logs_handle.cjs +2 -3
- package/dist/drivers/helpers/logs_handle.cjs.map +1 -1
- package/dist/drivers/helpers/logs_handle.js +1 -2
- package/dist/drivers/helpers/logs_handle.js.map +1 -1
- package/dist/drivers/helpers/ls_remote_import_handle.cjs +4 -6
- package/dist/drivers/helpers/ls_remote_import_handle.cjs.map +1 -1
- package/dist/drivers/helpers/ls_remote_import_handle.js +3 -5
- package/dist/drivers/helpers/ls_remote_import_handle.js.map +1 -1
- package/dist/drivers/helpers/ls_storage_entry.cjs +2 -3
- package/dist/drivers/helpers/ls_storage_entry.cjs.map +1 -1
- package/dist/drivers/helpers/ls_storage_entry.js +1 -2
- package/dist/drivers/helpers/ls_storage_entry.js.map +1 -1
- package/dist/drivers/helpers/polling_ops.d.ts.map +1 -0
- package/dist/drivers/helpers/read_file.cjs +2 -3
- package/dist/drivers/helpers/read_file.cjs.map +1 -1
- package/dist/drivers/helpers/read_file.js +1 -2
- package/dist/drivers/helpers/read_file.js.map +1 -1
- package/dist/drivers/logs.cjs +3 -4
- package/dist/drivers/logs.cjs.map +1 -1
- package/dist/drivers/logs.d.ts.map +1 -0
- package/dist/drivers/logs.js +1 -2
- package/dist/drivers/logs.js.map +1 -1
- package/dist/drivers/logs_stream.cjs +4 -5
- package/dist/drivers/logs_stream.cjs.map +1 -1
- package/dist/drivers/logs_stream.d.ts.map +1 -0
- package/dist/drivers/logs_stream.js +1 -2
- package/dist/drivers/logs_stream.js.map +1 -1
- package/dist/drivers/ls.cjs +7 -8
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts.map +1 -0
- package/dist/drivers/ls.js +1 -2
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/types.cjs +2 -3
- package/dist/drivers/types.cjs.map +1 -1
- package/dist/drivers/types.d.ts +4 -4
- package/dist/drivers/types.d.ts.map +1 -0
- package/dist/drivers/types.js +1 -2
- package/dist/drivers/types.js.map +1 -1
- package/dist/drivers/upload.cjs +5 -6
- package/dist/drivers/upload.cjs.map +1 -1
- package/dist/drivers/upload.d.ts.map +1 -0
- package/dist/drivers/upload.js +1 -2
- package/dist/drivers/upload.js.map +1 -1
- package/dist/drivers/upload_task.cjs +4 -5
- package/dist/drivers/upload_task.cjs.map +1 -1
- package/dist/drivers/upload_task.d.ts.map +1 -0
- package/dist/drivers/upload_task.js +1 -2
- package/dist/drivers/upload_task.js.map +1 -1
- package/dist/drivers/urls/url.cjs +2 -3
- package/dist/drivers/urls/url.cjs.map +1 -1
- package/dist/drivers/urls/url.js +1 -2
- package/dist/drivers/urls/url.js.map +1 -1
- package/dist/drivers/virtual_storages.cjs +2 -3
- package/dist/drivers/virtual_storages.cjs.map +1 -1
- package/dist/drivers/virtual_storages.d.ts.map +1 -0
- package/dist/drivers/virtual_storages.js +1 -2
- package/dist/drivers/virtual_storages.js.map +1 -1
- package/dist/helpers/download.cjs +3 -4
- package/dist/helpers/download.cjs.map +1 -1
- package/dist/helpers/download.d.ts.map +1 -0
- package/dist/helpers/download.js +1 -2
- package/dist/helpers/download.js.map +1 -1
- package/dist/helpers/download_errors.cjs +1 -2
- package/dist/helpers/download_errors.cjs.map +1 -1
- package/dist/helpers/download_errors.d.ts.map +1 -0
- package/dist/helpers/download_errors.js +1 -1
- package/dist/helpers/validate.cjs +2 -3
- package/dist/helpers/validate.cjs.map +1 -1
- package/dist/helpers/validate.d.ts.map +1 -0
- package/dist/helpers/validate.js +1 -2
- package/dist/helpers/validate.js.map +1 -1
- package/dist/index.cjs +22 -23
- package/dist/index.js +1 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs +32 -27
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs +4 -5
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +6 -6
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js +2 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +11 -5
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js +32 -31
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs +31 -24
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs +7 -8
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js +5 -6
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +16 -16
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js +30 -27
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs +42 -28
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs +4 -5
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +6 -6
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js +2 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +8 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js +40 -26
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs +32 -196
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs +23 -45
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +40 -70
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js +21 -43
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +52 -137
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js +31 -195
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs +228 -46
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs +24 -11
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js +22 -9
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +1 -0
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js +227 -45
- package/dist/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.cjs +2 -3
- package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -0
- package/dist/proto-grpc/google/protobuf/duration.js +1 -2
- package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.cjs +2 -3
- package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -0
- package/dist/proto-grpc/google/protobuf/timestamp.js +1 -2
- package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto-rest/downloadapi.d.ts +8 -3
- package/dist/proto-rest/downloadapi.d.ts.map +1 -0
- package/dist/proto-rest/index.d.ts.map +1 -0
- package/dist/proto-rest/progressapi.d.ts +4 -2
- package/dist/proto-rest/progressapi.d.ts.map +1 -0
- package/dist/proto-rest/streamingapi.d.ts +64 -203
- package/dist/proto-rest/streamingapi.d.ts.map +1 -0
- package/package.json +10 -10
- package/src/clients/download.ts +1 -0
- package/src/clients/logs.ts +2 -0
- package/src/clients/ls_api.ts +1 -0
- package/src/clients/progress.ts +1 -1
- package/src/clients/upload.ts +14 -1
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +2 -2
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +24 -11
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +8 -8
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +31 -18
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +2 -2
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +23 -1
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +39 -78
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +72 -263
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.ts +41 -14
- package/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.ts +286 -44
- package/src/proto-grpc/google/protobuf/descriptor.ts +2 -5
- package/src/proto-rest/downloadapi.ts +8 -3
- package/src/proto-rest/lsapi.ts +23 -18
- package/src/proto-rest/progressapi.ts +4 -0
- package/src/proto-rest/streamingapi.ts +65 -211
- package/src/proto-rest/uploadapi.ts +141 -39
|
@@ -6,16 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
19
15
|
}
|
|
20
16
|
return to;
|
|
21
17
|
};
|
|
@@ -23,7 +19,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
19
|
value: mod,
|
|
24
20
|
enumerable: true
|
|
25
21
|
}) : target, mod));
|
|
26
|
-
|
|
27
22
|
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|
|
23
|
+
exports.__toESM = __toESM;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const require_upload = require(
|
|
2
|
-
const require_progress = require(
|
|
3
|
-
const require_download = require(
|
|
4
|
-
const require_ls_api = require(
|
|
5
|
-
const require_logs = require(
|
|
6
|
-
|
|
1
|
+
const require_upload = require("./upload.cjs");
|
|
2
|
+
const require_progress = require("./progress.cjs");
|
|
3
|
+
const require_download = require("./download.cjs");
|
|
4
|
+
const require_ls_api = require("./ls_api.cjs");
|
|
5
|
+
const require_logs = require("./logs.cjs");
|
|
7
6
|
//#region src/clients/constructors.ts
|
|
8
7
|
function createDownloadClient(logger, client, localProjections) {
|
|
9
8
|
return client.getDriver({
|
|
@@ -35,11 +34,11 @@ function createLsFilesClient(client, logger) {
|
|
|
35
34
|
init: (_client, wireClientFactory, _httpDispatcher) => new require_ls_api.ClientLs(wireClientFactory, logger)
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
exports.createDownloadClient = createDownloadClient;
|
|
41
39
|
exports.createLogsClient = createLogsClient;
|
|
42
40
|
exports.createLsFilesClient = createLsFilesClient;
|
|
43
41
|
exports.createUploadBlobClient = createUploadBlobClient;
|
|
44
42
|
exports.createUploadProgressClient = createUploadProgressClient;
|
|
43
|
+
|
|
45
44
|
//# sourceMappingURL=constructors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.cjs","names":["ClientDownload","ClientLogs","ClientProgress","ClientUpload","ClientLs"],"sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constructors.cjs","names":["ClientDownload","ClientLogs","ClientProgress","ClientUpload","ClientLs"],"sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"mappings":";;;;;;AAUA,SAAgB,qBACd,QACA,QACA,kBACA;AACA,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAIA,iBAAAA,eAAe,mBAAmB,gBAAgB,QAAQ,iBAAiB;EAClF,CAAC;;AAGJ,SAAgB,iBAAiB,QAAkB,QAAkB;AACnE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAIC,aAAAA,WAAW,mBAAmB,gBAAgB,OAAO;EAC5D,CAAC;;AAGJ,SAAgB,2BAA2B,QAAkB,QAAkB;AAC7E,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAIC,iBAAAA,eAAe,mBAAmB,gBAAgB,QAAQ,OAAO;EACxE,CAAC;;AAGJ,SAAgB,uBAAuB,QAAkB,QAAkB;AACzE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAIC,eAAAA,aAAa,mBAAmB,gBAAgB,QAAQ,OAAO;EACtE,CAAC;;AAGJ,SAAgB,oBAAoB,QAAkB,QAAkB;AACtE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OACE,SACA,mBACA,oBACG,IAAIC,eAAAA,SAAS,mBAAmB,OAAO;EAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructors.d.ts","names":[],"sources":["../../src/clients/constructors.ts"],"mappings":";;;;;;;;;;iBAUgB,oBAAA,CACd,MAAA,EAAQ,QAAA,EACR,MAAA,EAAQ,QAAA,EACR,gBAAA,EAAkB,sBAAA,KAAwB,cAAA;AAAA,iBAS5B,gBAAA,CAAiB,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAA,GAAQ,UAAA;AAAA,iBAQnD,0BAAA,CAA2B,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAA,GAAQ,cAAA;AAAA,iBAQ7D,sBAAA,CAAuB,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAA,GAAQ,YAAA;AAAA,iBAQzD,mBAAA,CAAoB,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAA,GAAQ,QAAA"}
|
|
@@ -3,7 +3,6 @@ import { ClientProgress } from "./progress.js";
|
|
|
3
3
|
import { ClientDownload } from "./download.js";
|
|
4
4
|
import { ClientLs } from "./ls_api.js";
|
|
5
5
|
import { ClientLogs } from "./logs.js";
|
|
6
|
-
|
|
7
6
|
//#region src/clients/constructors.ts
|
|
8
7
|
function createDownloadClient(logger, client, localProjections) {
|
|
9
8
|
return client.getDriver({
|
|
@@ -35,7 +34,7 @@ function createLsFilesClient(client, logger) {
|
|
|
35
34
|
init: (_client, wireClientFactory, _httpDispatcher) => new ClientLs(wireClientFactory, logger)
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
export { createDownloadClient, createLogsClient, createLsFilesClient, createUploadBlobClient, createUploadProgressClient };
|
|
39
|
+
|
|
41
40
|
//# sourceMappingURL=constructors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.js","names":[],"sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constructors.js","names":[],"sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"mappings":";;;;;;AAUA,SAAgB,qBACd,QACA,QACA,kBACA;AACA,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAI,eAAe,mBAAmB,gBAAgB,QAAQ,iBAAiB;EAClF,CAAC;;AAGJ,SAAgB,iBAAiB,QAAkB,QAAkB;AACnE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAI,WAAW,mBAAmB,gBAAgB,OAAO;EAC5D,CAAC;;AAGJ,SAAgB,2BAA2B,QAAkB,QAAkB;AAC7E,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAI,eAAe,mBAAmB,gBAAgB,QAAQ,OAAO;EACxE,CAAC;;AAGJ,SAAgB,uBAAuB,QAAkB,QAAkB;AACzE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OAAO,GAAa,mBAA8C,mBAChE,IAAI,aAAa,mBAAmB,gBAAgB,QAAQ,OAAO;EACtE,CAAC;;AAGJ,SAAgB,oBAAoB,QAAkB,QAAkB;AACtE,QAAO,OAAO,UAAU;EACtB,MAAM;EACN,OACE,SACA,mBACA,oBACG,IAAI,SAAS,mBAAmB,OAAO;EAC7C,CAAC"}
|
package/dist/clients/crc32c.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/clients/crc32c.ts
|
|
3
2
|
const kCRCTable = Int32Array.of(0, 4067132163, 3778769143, 324072436, 3348797215, 904991772, 648144872, 3570033899, 2329499855, 2024987596, 1809983544, 2575936315, 1296289744, 3207089363, 2893594407, 1578318884, 274646895, 3795141740, 4049975192, 51262619, 3619967088, 632279923, 922689671, 3298075524, 2592579488, 1760304291, 2075979607, 2312596564, 1562183871, 2943781820, 3156637768, 1313733451, 549293790, 3537243613, 3246849577, 871202090, 3878099393, 357341890, 102525238, 4101499445, 2858735121, 1477399826, 1264559846, 3107202533, 1845379342, 2677391885, 2361733625, 2125378298, 820201905, 3263744690, 3520608582, 598981189, 4151959214, 85089709, 373468761, 3827903834, 3124367742, 1213305469, 1526817161, 2842354314, 2107672161, 2412447074, 2627466902, 1861252501, 1098587580, 3004210879, 2688576843, 1378610760, 2262928035, 1955203488, 1742404180, 2511436119, 3416409459, 969524848, 714683780, 3639785095, 205050476, 4266873199, 3976438427, 526918040, 1361435347, 2739821008, 2954799652, 1114974503, 2529119692, 1691668175, 2005155131, 2247081528, 3690758684, 697762079, 986182379, 3366744552, 476452099, 3993867776, 4250756596, 255256311, 1640403810, 2477592673, 2164122517, 1922457750, 2791048317, 1412925310, 1197962378, 3037525897, 3944729517, 427051182, 170179418, 4165941337, 746937522, 3740196785, 3451792453, 1070968646, 1905808397, 2213795598, 2426610938, 1657317369, 3053634322, 1147748369, 1463399397, 2773627110, 4215344322, 153784257, 444234805, 3893493558, 1021025245, 3467647198, 3722505002, 797665321, 2197175160, 1889384571, 1674398607, 2443626636, 1164749927, 3070701412, 2757221520, 1446797203, 137323447, 4198817972, 3910406976, 461344835, 3484808360, 1037989803, 781091935, 3705997148, 2460548119, 1623424788, 1939049696, 2180517859, 1429367560, 2807687179, 3020495871, 1180866812, 410100952, 3927582683, 4182430767, 186734380, 3756733383, 763408580, 1053836080, 3434856499, 2722870694, 1344288421, 1131464017, 2971354706, 1708204729, 2545590714, 2229949006, 1988219213, 680717673, 3673779818, 3383336350, 1002577565, 4010310262, 493091189, 238226049, 4233660802, 2987750089, 1082061258, 1395524158, 2705686845, 1972364758, 2279892693, 2494862625, 1725896226, 952904198, 3399985413, 3656866545, 731699698, 4283874585, 222117402, 510512622, 3959836397, 3280807620, 837199303, 582374963, 3504198960, 68661723, 4135334616, 3844915500, 390545967, 1230274059, 3141532936, 2825850620, 1510247935, 2395924756, 2091215383, 1878366691, 2644384480, 3553878443, 565732008, 854102364, 3229815391, 340358836, 3861050807, 4117890627, 119113024, 1493875044, 2875275879, 3090270611, 1247431312, 2660249211, 1828433272, 2141937292, 2378227087, 3811616794, 291187481, 34330861, 4032846830, 615137029, 3603020806, 3314634738, 939183345, 1776939221, 2609017814, 2295496738, 2058945313, 2926798794, 1545135305, 1330124605, 3173225534, 4084100981, 17165430, 307568514, 3762199681, 888469610, 3332340585, 3587147933, 665062302, 2042050490, 2346497209, 2559330125, 1793573966, 3190661285, 1279665062, 1595330642, 2910671697);
|
|
4
3
|
function crc32c(buf, initial = 0) {
|
|
@@ -7,7 +6,7 @@ function crc32c(buf, initial = 0) {
|
|
|
7
6
|
for (let i = 0; i < buf.length; i++) crc = kCRCTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;
|
|
8
7
|
return (crc ^ -1) >>> 0;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
//#endregion
|
|
12
10
|
exports.crc32c = crc32c;
|
|
11
|
+
|
|
13
12
|
//# sourceMappingURL=crc32c.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crc32c.cjs","names":[],"sources":["../../src/clients/crc32c.ts"],"sourcesContent":["// copy from https://github.com/ashi009/node-fast-crc32c/blob/master/impls/js_crc32c.js\n// can not use fast-crc32c because it try to use native solution that brokes in electron\nconst kCRCTable = Int32Array.of(\n 0x00000000,\n 0xf26b8303,\n 0xe13b70f7,\n 0x1350f3f4,\n 0xc79a971f,\n 0x35f1141c,\n 0x26a1e7e8,\n 0xd4ca64eb,\n 0x8ad958cf,\n 0x78b2dbcc,\n 0x6be22838,\n 0x9989ab3b,\n 0x4d43cfd0,\n 0xbf284cd3,\n 0xac78bf27,\n 0x5e133c24,\n 0x105ec76f,\n 0xe235446c,\n 0xf165b798,\n 0x030e349b,\n 0xd7c45070,\n 0x25afd373,\n 0x36ff2087,\n 0xc494a384,\n 0x9a879fa0,\n 0x68ec1ca3,\n 0x7bbcef57,\n 0x89d76c54,\n 0x5d1d08bf,\n 0xaf768bbc,\n 0xbc267848,\n 0x4e4dfb4b,\n 0x20bd8ede,\n 0xd2d60ddd,\n 0xc186fe29,\n 0x33ed7d2a,\n 0xe72719c1,\n 0x154c9ac2,\n 0x061c6936,\n 0xf477ea35,\n 0xaa64d611,\n 0x580f5512,\n 0x4b5fa6e6,\n 0xb93425e5,\n 0x6dfe410e,\n 0x9f95c20d,\n 0x8cc531f9,\n 0x7eaeb2fa,\n 0x30e349b1,\n 0xc288cab2,\n 0xd1d83946,\n 0x23b3ba45,\n 0xf779deae,\n 0x05125dad,\n 0x1642ae59,\n 0xe4292d5a,\n 0xba3a117e,\n 0x4851927d,\n 0x5b016189,\n 0xa96ae28a,\n 0x7da08661,\n 0x8fcb0562,\n 0x9c9bf696,\n 0x6ef07595,\n 0x417b1dbc,\n 0xb3109ebf,\n 0xa0406d4b,\n 0x522bee48,\n 0x86e18aa3,\n 0x748a09a0,\n 0x67dafa54,\n 0x95b17957,\n 0xcba24573,\n 0x39c9c670,\n 0x2a993584,\n 0xd8f2b687,\n 0x0c38d26c,\n 0xfe53516f,\n 0xed03a29b,\n 0x1f682198,\n 0x5125dad3,\n 0xa34e59d0,\n 0xb01eaa24,\n 0x42752927,\n 0x96bf4dcc,\n 0x64d4cecf,\n 0x77843d3b,\n 0x85efbe38,\n 0xdbfc821c,\n 0x2997011f,\n 0x3ac7f2eb,\n 0xc8ac71e8,\n 0x1c661503,\n 0xee0d9600,\n 0xfd5d65f4,\n 0x0f36e6f7,\n 0x61c69362,\n 0x93ad1061,\n 0x80fde395,\n 0x72966096,\n 0xa65c047d,\n 0x5437877e,\n 0x4767748a,\n 0xb50cf789,\n 0xeb1fcbad,\n 0x197448ae,\n 0x0a24bb5a,\n 0xf84f3859,\n 0x2c855cb2,\n 0xdeeedfb1,\n 0xcdbe2c45,\n 0x3fd5af46,\n 0x7198540d,\n 0x83f3d70e,\n 0x90a324fa,\n 0x62c8a7f9,\n 0xb602c312,\n 0x44694011,\n 0x5739b3e5,\n 0xa55230e6,\n 0xfb410cc2,\n 0x092a8fc1,\n 0x1a7a7c35,\n 0xe811ff36,\n 0x3cdb9bdd,\n 0xceb018de,\n 0xdde0eb2a,\n 0x2f8b6829,\n 0x82f63b78,\n 0x709db87b,\n 0x63cd4b8f,\n 0x91a6c88c,\n 0x456cac67,\n 0xb7072f64,\n 0xa457dc90,\n 0x563c5f93,\n 0x082f63b7,\n 0xfa44e0b4,\n 0xe9141340,\n 0x1b7f9043,\n 0xcfb5f4a8,\n 0x3dde77ab,\n 0x2e8e845f,\n 0xdce5075c,\n 0x92a8fc17,\n 0x60c37f14,\n 0x73938ce0,\n 0x81f80fe3,\n 0x55326b08,\n 0xa759e80b,\n 0xb4091bff,\n 0x466298fc,\n 0x1871a4d8,\n 0xea1a27db,\n 0xf94ad42f,\n 0x0b21572c,\n 0xdfeb33c7,\n 0x2d80b0c4,\n 0x3ed04330,\n 0xccbbc033,\n 0xa24bb5a6,\n 0x502036a5,\n 0x4370c551,\n 0xb11b4652,\n 0x65d122b9,\n 0x97baa1ba,\n 0x84ea524e,\n 0x7681d14d,\n 0x2892ed69,\n 0xdaf96e6a,\n 0xc9a99d9e,\n 0x3bc21e9d,\n 0xef087a76,\n 0x1d63f975,\n 0x0e330a81,\n 0xfc588982,\n 0xb21572c9,\n 0x407ef1ca,\n 0x532e023e,\n 0xa145813d,\n 0x758fe5d6,\n 0x87e466d5,\n 0x94b49521,\n 0x66df1622,\n 0x38cc2a06,\n 0xcaa7a905,\n 0xd9f75af1,\n 0x2b9cd9f2,\n 0xff56bd19,\n 0x0d3d3e1a,\n 0x1e6dcdee,\n 0xec064eed,\n 0xc38d26c4,\n 0x31e6a5c7,\n 0x22b65633,\n 0xd0ddd530,\n 0x0417b1db,\n 0xf67c32d8,\n 0xe52cc12c,\n 0x1747422f,\n 0x49547e0b,\n 0xbb3ffd08,\n 0xa86f0efc,\n 0x5a048dff,\n 0x8ecee914,\n 0x7ca56a17,\n 0x6ff599e3,\n 0x9d9e1ae0,\n 0xd3d3e1ab,\n 0x21b862a8,\n 0x32e8915c,\n 0xc083125f,\n 0x144976b4,\n 0xe622f5b7,\n 0xf5720643,\n 0x07198540,\n 0x590ab964,\n 0xab613a67,\n 0xb831c993,\n 0x4a5a4a90,\n 0x9e902e7b,\n 0x6cfbad78,\n 0x7fab5e8c,\n 0x8dc0dd8f,\n 0xe330a81a,\n 0x115b2b19,\n 0x020bd8ed,\n 0xf0605bee,\n 0x24aa3f05,\n 0xd6c1bc06,\n 0xc5914ff2,\n 0x37faccf1,\n 0x69e9f0d5,\n 0x9b8273d6,\n 0x88d28022,\n 0x7ab90321,\n 0xae7367ca,\n 0x5c18e4c9,\n 0x4f48173d,\n 0xbd23943e,\n 0xf36e6f75,\n 0x0105ec76,\n 0x12551f82,\n 0xe03e9c81,\n 0x34f4f86a,\n 0xc69f7b69,\n 0xd5cf889d,\n 0x27a40b9e,\n 0x79b737ba,\n 0x8bdcb4b9,\n 0x988c474d,\n 0x6ae7c44e,\n 0xbe2da0a5,\n 0x4c4623a6,\n 0x5f16d052,\n 0xad7d5351,\n);\n\nexport function crc32c(buf: Buffer | string, initial: number = 0) {\n if (!Buffer.isBuffer(buf)) {\n buf = Buffer.from(buf);\n }\n let crc = (initial | 0) ^ -1;\n for (let i = 0; i < buf.length; i++) {\n crc = kCRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8);\n }\n return (crc ^ -1) >>> 0;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"crc32c.cjs","names":[],"sources":["../../src/clients/crc32c.ts"],"sourcesContent":["// copy from https://github.com/ashi009/node-fast-crc32c/blob/master/impls/js_crc32c.js\n// can not use fast-crc32c because it try to use native solution that brokes in electron\nconst kCRCTable = Int32Array.of(\n 0x00000000,\n 0xf26b8303,\n 0xe13b70f7,\n 0x1350f3f4,\n 0xc79a971f,\n 0x35f1141c,\n 0x26a1e7e8,\n 0xd4ca64eb,\n 0x8ad958cf,\n 0x78b2dbcc,\n 0x6be22838,\n 0x9989ab3b,\n 0x4d43cfd0,\n 0xbf284cd3,\n 0xac78bf27,\n 0x5e133c24,\n 0x105ec76f,\n 0xe235446c,\n 0xf165b798,\n 0x030e349b,\n 0xd7c45070,\n 0x25afd373,\n 0x36ff2087,\n 0xc494a384,\n 0x9a879fa0,\n 0x68ec1ca3,\n 0x7bbcef57,\n 0x89d76c54,\n 0x5d1d08bf,\n 0xaf768bbc,\n 0xbc267848,\n 0x4e4dfb4b,\n 0x20bd8ede,\n 0xd2d60ddd,\n 0xc186fe29,\n 0x33ed7d2a,\n 0xe72719c1,\n 0x154c9ac2,\n 0x061c6936,\n 0xf477ea35,\n 0xaa64d611,\n 0x580f5512,\n 0x4b5fa6e6,\n 0xb93425e5,\n 0x6dfe410e,\n 0x9f95c20d,\n 0x8cc531f9,\n 0x7eaeb2fa,\n 0x30e349b1,\n 0xc288cab2,\n 0xd1d83946,\n 0x23b3ba45,\n 0xf779deae,\n 0x05125dad,\n 0x1642ae59,\n 0xe4292d5a,\n 0xba3a117e,\n 0x4851927d,\n 0x5b016189,\n 0xa96ae28a,\n 0x7da08661,\n 0x8fcb0562,\n 0x9c9bf696,\n 0x6ef07595,\n 0x417b1dbc,\n 0xb3109ebf,\n 0xa0406d4b,\n 0x522bee48,\n 0x86e18aa3,\n 0x748a09a0,\n 0x67dafa54,\n 0x95b17957,\n 0xcba24573,\n 0x39c9c670,\n 0x2a993584,\n 0xd8f2b687,\n 0x0c38d26c,\n 0xfe53516f,\n 0xed03a29b,\n 0x1f682198,\n 0x5125dad3,\n 0xa34e59d0,\n 0xb01eaa24,\n 0x42752927,\n 0x96bf4dcc,\n 0x64d4cecf,\n 0x77843d3b,\n 0x85efbe38,\n 0xdbfc821c,\n 0x2997011f,\n 0x3ac7f2eb,\n 0xc8ac71e8,\n 0x1c661503,\n 0xee0d9600,\n 0xfd5d65f4,\n 0x0f36e6f7,\n 0x61c69362,\n 0x93ad1061,\n 0x80fde395,\n 0x72966096,\n 0xa65c047d,\n 0x5437877e,\n 0x4767748a,\n 0xb50cf789,\n 0xeb1fcbad,\n 0x197448ae,\n 0x0a24bb5a,\n 0xf84f3859,\n 0x2c855cb2,\n 0xdeeedfb1,\n 0xcdbe2c45,\n 0x3fd5af46,\n 0x7198540d,\n 0x83f3d70e,\n 0x90a324fa,\n 0x62c8a7f9,\n 0xb602c312,\n 0x44694011,\n 0x5739b3e5,\n 0xa55230e6,\n 0xfb410cc2,\n 0x092a8fc1,\n 0x1a7a7c35,\n 0xe811ff36,\n 0x3cdb9bdd,\n 0xceb018de,\n 0xdde0eb2a,\n 0x2f8b6829,\n 0x82f63b78,\n 0x709db87b,\n 0x63cd4b8f,\n 0x91a6c88c,\n 0x456cac67,\n 0xb7072f64,\n 0xa457dc90,\n 0x563c5f93,\n 0x082f63b7,\n 0xfa44e0b4,\n 0xe9141340,\n 0x1b7f9043,\n 0xcfb5f4a8,\n 0x3dde77ab,\n 0x2e8e845f,\n 0xdce5075c,\n 0x92a8fc17,\n 0x60c37f14,\n 0x73938ce0,\n 0x81f80fe3,\n 0x55326b08,\n 0xa759e80b,\n 0xb4091bff,\n 0x466298fc,\n 0x1871a4d8,\n 0xea1a27db,\n 0xf94ad42f,\n 0x0b21572c,\n 0xdfeb33c7,\n 0x2d80b0c4,\n 0x3ed04330,\n 0xccbbc033,\n 0xa24bb5a6,\n 0x502036a5,\n 0x4370c551,\n 0xb11b4652,\n 0x65d122b9,\n 0x97baa1ba,\n 0x84ea524e,\n 0x7681d14d,\n 0x2892ed69,\n 0xdaf96e6a,\n 0xc9a99d9e,\n 0x3bc21e9d,\n 0xef087a76,\n 0x1d63f975,\n 0x0e330a81,\n 0xfc588982,\n 0xb21572c9,\n 0x407ef1ca,\n 0x532e023e,\n 0xa145813d,\n 0x758fe5d6,\n 0x87e466d5,\n 0x94b49521,\n 0x66df1622,\n 0x38cc2a06,\n 0xcaa7a905,\n 0xd9f75af1,\n 0x2b9cd9f2,\n 0xff56bd19,\n 0x0d3d3e1a,\n 0x1e6dcdee,\n 0xec064eed,\n 0xc38d26c4,\n 0x31e6a5c7,\n 0x22b65633,\n 0xd0ddd530,\n 0x0417b1db,\n 0xf67c32d8,\n 0xe52cc12c,\n 0x1747422f,\n 0x49547e0b,\n 0xbb3ffd08,\n 0xa86f0efc,\n 0x5a048dff,\n 0x8ecee914,\n 0x7ca56a17,\n 0x6ff599e3,\n 0x9d9e1ae0,\n 0xd3d3e1ab,\n 0x21b862a8,\n 0x32e8915c,\n 0xc083125f,\n 0x144976b4,\n 0xe622f5b7,\n 0xf5720643,\n 0x07198540,\n 0x590ab964,\n 0xab613a67,\n 0xb831c993,\n 0x4a5a4a90,\n 0x9e902e7b,\n 0x6cfbad78,\n 0x7fab5e8c,\n 0x8dc0dd8f,\n 0xe330a81a,\n 0x115b2b19,\n 0x020bd8ed,\n 0xf0605bee,\n 0x24aa3f05,\n 0xd6c1bc06,\n 0xc5914ff2,\n 0x37faccf1,\n 0x69e9f0d5,\n 0x9b8273d6,\n 0x88d28022,\n 0x7ab90321,\n 0xae7367ca,\n 0x5c18e4c9,\n 0x4f48173d,\n 0xbd23943e,\n 0xf36e6f75,\n 0x0105ec76,\n 0x12551f82,\n 0xe03e9c81,\n 0x34f4f86a,\n 0xc69f7b69,\n 0xd5cf889d,\n 0x27a40b9e,\n 0x79b737ba,\n 0x8bdcb4b9,\n 0x988c474d,\n 0x6ae7c44e,\n 0xbe2da0a5,\n 0x4c4623a6,\n 0x5f16d052,\n 0xad7d5351,\n);\n\nexport function crc32c(buf: Buffer | string, initial: number = 0) {\n if (!Buffer.isBuffer(buf)) {\n buf = Buffer.from(buf);\n }\n let crc = (initial | 0) ^ -1;\n for (let i = 0; i < buf.length; i++) {\n crc = kCRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8);\n }\n return (crc ^ -1) >>> 0;\n}\n"],"mappings":";AAEA,MAAM,YAAY,WAAW,GAC3B,GACA,YACA,YACA,WACA,YACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,UACA,YACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,UACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,YACA,YACA,WACA,YACA,WACA,WACA,YACA,YACA,WACA,WACA,YACA,UACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,WACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACA,UACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,UACA,WACA,YACA,WACA,YACA,YACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,WACD;AAED,SAAgB,OAAO,KAAsB,UAAkB,GAAG;AAChE,KAAI,CAAC,OAAO,SAAS,IAAI,CACvB,OAAM,OAAO,KAAK,IAAI;CAExB,IAAI,OAAO,UAAU,KAAK;AAC1B,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,IAC9B,OAAM,WAAW,MAAM,IAAI,MAAM,OAAS,QAAQ;AAEpD,SAAQ,MAAM,QAAQ"}
|
package/dist/clients/crc32c.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_download = require(
|
|
3
|
-
const require_validate = require(
|
|
4
|
-
const require_protocol_client = require(
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_download = require("../helpers/download.cjs");
|
|
3
|
+
const require_validate = require("../helpers/validate.cjs");
|
|
4
|
+
const require_protocol_client = require("../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.cjs");
|
|
5
5
|
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
6
6
|
let node_fs_promises = require("node:fs/promises");
|
|
7
7
|
node_fs_promises = require_runtime.__toESM(node_fs_promises);
|
|
@@ -12,7 +12,6 @@ node_fs = require_runtime.__toESM(node_fs);
|
|
|
12
12
|
let node_path = require("node:path");
|
|
13
13
|
node_path = require_runtime.__toESM(node_path);
|
|
14
14
|
let node_stream = require("node:stream");
|
|
15
|
-
|
|
16
15
|
//#region src/clients/download.ts
|
|
17
16
|
/** Gets URLs for downloading from pl-core, parses them and reads or downloads
|
|
18
17
|
* files locally and from the web. */
|
|
@@ -88,6 +87,7 @@ var ClientDownload = class {
|
|
|
88
87
|
else return (await client.POST("/v1/get-download-url", {
|
|
89
88
|
body: {
|
|
90
89
|
resourceId: id.toString(),
|
|
90
|
+
resourceSignature: "",
|
|
91
91
|
isInternalUse: false
|
|
92
92
|
},
|
|
93
93
|
headers: { ...(0, _milaboratories_pl_client.createRTypeRoutingHeader)(type) }
|
|
@@ -128,7 +128,6 @@ function newLocalStorageIdsToRoot(projections) {
|
|
|
128
128
|
}
|
|
129
129
|
return idToRoot;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
131
|
//#endregion
|
|
133
132
|
exports.ClientDownload = ClientDownload;
|
|
134
133
|
exports.UnknownStorageError = UnknownStorageError;
|
|
@@ -136,4 +135,5 @@ exports.WrongLocalFileUrl = WrongLocalFileUrl;
|
|
|
136
135
|
exports.getFullPath = getFullPath;
|
|
137
136
|
exports.newLocalStorageIdsToRoot = newLocalStorageIdsToRoot;
|
|
138
137
|
exports.parseLocalUrl = parseLocalUrl;
|
|
138
|
+
|
|
139
139
|
//# sourceMappingURL=download.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.cjs","names":["ConcurrencyLimitingExecutor","DownloadClient","RestAPI","RemoteFileDownloader","PerfTimer","fsp","fs","Readable","path"],"sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\n addRTypeToMetadata,\n stringifyWithResourceId,\n RestAPI,\n createRTypeRoutingHeader,\n} from \"@milaboratories/pl-client\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\nimport { PerfTimer } from \"@milaboratories/helpers\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ConcurrencyLimitingExecutor } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { Dispatcher } from \"undici\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\nimport { type ContentHandler, RemoteFileDownloader } from \"../helpers/download\";\nimport { validateAbsolute } from \"../helpers/validate\";\nimport type { DownloadAPI_GetDownloadURL_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol\";\nimport { DownloadClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client\";\nimport type { DownloadApiPaths, DownloadRestClientType } from \"../proto-rest\";\nimport { type GetContentOptions } from \"@milaboratories/pl-model-common\";\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === \"grpc\") {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, ` +\n `url: ${downloadUrl}, ` +\n `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (\n await client.POST(\"/v1/get-download-url\", {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })\n ).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == \"\")\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === \"\") return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = \"storage://\";\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = \"WrongLocalFileUrl\";\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = \"UnknownStorageError\";\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== \"\") {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,IAAa,iBAAb,MAA4B;CAC1B,AAAgB;CAChB,AAAiB;;CAGjB,AAAiB;;CAGjB,AAAiB,uBAAuB,IAAIA,uDAA4B,GAAG;CAE3E,YACE,2BACA,AAAgB,YAChB,AAAgB,QAEhB,kBACA;EAJgB;EACA;AAIhB,OAAK,OAAO,0BAA0B,0BAA0B,aAAa;AAC3E,OAAI,SAAS,SAAS,OACpB,QAAO,IAAIC,uCAAe,SAAS,UAAU;OAE7C,QAAOC,kCAAQ,aAA+B;IAC5C,aAAa,SAAS,OAAO;IAC7B,KAAK,SAAS,OAAO;IACrB,YAAY,SAAS;IACrB,aAAa,SAAS;IACvB,CAAC;IAEJ;AACF,OAAK,uBAAuB,IAAIC,sCAAqB,WAAW;AAChE,OAAK,wBAAwB,yB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encyLimitingExecutor","DownloadClient","RestAPI","RemoteFileDownloader","PerfTimer","fsp","fs","Readable","path"],"sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\n addRTypeToMetadata,\n stringifyWithResourceId,\n RestAPI,\n createRTypeRoutingHeader,\n} from \"@milaboratories/pl-client\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\nimport { PerfTimer } from \"@milaboratories/helpers\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ConcurrencyLimitingExecutor } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { Dispatcher } from \"undici\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\nimport { type ContentHandler, RemoteFileDownloader } from \"../helpers/download\";\nimport { validateAbsolute } from \"../helpers/validate\";\nimport type { DownloadAPI_GetDownloadURL_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol\";\nimport { DownloadClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client\";\nimport type { DownloadApiPaths, DownloadRestClientType } from \"../proto-rest\";\nimport { type GetContentOptions } from \"@milaboratories/pl-model-common\";\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === \"grpc\") {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, ` +\n `url: ${downloadUrl}, ` +\n `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (\n await client.POST(\"/v1/get-download-url\", {\n body: {\n resourceId: id.toString(),\n resourceSignature: \"\",\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })\n ).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == \"\")\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === \"\") return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = \"storage://\";\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = \"WrongLocalFileUrl\";\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = \"UnknownStorageError\";\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== \"\") {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAa,iBAAb,MAA4B;CAC1B;CACA;;CAGA;;CAGA,uBAAwC,IAAIA,2BAAAA,4BAA4B,GAAG;CAE3E,YACE,2BACA,YACA,QAEA,kBACA;AAJgB,OAAA,aAAA;AACA,OAAA,SAAA;AAIhB,OAAK,OAAO,0BAA0B,0BAA0B,aAAa;AAC3E,OAAI,SAAS,SAAS,OACpB,QAAO,IAAIC,wBAAAA,eAAe,SAAS,UAAU;OAE7C,QAAOC,0BAAAA,QAAQ,aAA+B;IAC5C,aAAa,SAAS,OAAO;IAC7B,KAAK,SAAS,OAAO;IACrB,YAAY,SAAS;IACrB,aAAa,SAAS;IACvB,CAAC;IAEJ;AACF,OAAK,uBAAuB,IAAIC,iBAAAA,qBAAqB,WAAW;AAChE,OAAK,wBAAwB,yBAAyB,iBAAiB;;CAGzE,QAAQ;;;;;;;CAQR,MAAM,gBACJ,MACA,SACA,KACA,SACY;EACZ,MAAM,EAAE,aAAa,YAAY,MAAM,KAAK,mBAAmB,MAAM,SAAS,IAAI,OAAO;EAEzF,MAAM,gBAAgB,OAAO,YAAY,QAAQ,KAAK,EAAE,MAAM,YAAY,CAAC,MAAM,MAAM,CAAC,CAAC;AACzF,OAAK,OAAO,KACV,SAAA,GAAA,0BAAA,yBAAgC,KAAK,CAAC,0BAC5B,YAAY,WACV,KAAK,UAAU,IAAI,SAAS,KAAK,GAC9C;EAED,MAAM,QAAQC,wBAAAA,UAAU,OAAO;EAC/B,MAAM,SAAS,QAAQ,YAAY,GAC/B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X,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,QAAA,EAAA;;EAExB,gBAAA,EAAkB,sBAAA;EAkBpB,KAAA,CAAA;EAUW;;;;;;EAFL,eAAA,GAAA,CACJ,IAAA,EAAM,YAAA,EACN,OAAA,EAAS,UAAA,cACT,GAAA,EAAK,iBAAA,EACL,OAAA,EAAS,gBAAA,CAAe,CAAA,IACvB,OAAA,CAAQ,CAAA;EAqBL,oBAAA,GAAA,CACJ,GAAA,UACA,GAAA,EAAK,iBAAA,EACL,OAAA,EAAS,gBAAA,CAAe,CAAA,IACvB,OAAA,CAAQ,CAAA;EAAA,QA+BG,kBAAA;AAAA;AAAA,iBA6BA,aAAA,CAAc,GAAA;;;;iBAWd,WAAA,CACd,SAAA,UACA,qBAAA,EAAuB,GAAA,kBACvB,YAAA;;cAgBW,iBAAA,SAA0B,KAAA;EACrC,IAAA;AAAA;;cAIW,mBAAA,SAA4B,KAAA;EACvC,IAAA;AAAA;AAAA,iBAGc,wBAAA,CAAyB,WAAA,EAAa,sBAAA,KAAwB,GAAA"}
|
package/dist/clients/download.js
CHANGED
|
@@ -8,7 +8,6 @@ import { PerfTimer } from "@milaboratories/helpers";
|
|
|
8
8
|
import * as fs$1 from "node:fs";
|
|
9
9
|
import * as path$1 from "node:path";
|
|
10
10
|
import { Readable } from "node:stream";
|
|
11
|
-
|
|
12
11
|
//#region src/clients/download.ts
|
|
13
12
|
/** Gets URLs for downloading from pl-core, parses them and reads or downloads
|
|
14
13
|
* files locally and from the web. */
|
|
@@ -84,6 +83,7 @@ var ClientDownload = class {
|
|
|
84
83
|
else return (await client.POST("/v1/get-download-url", {
|
|
85
84
|
body: {
|
|
86
85
|
resourceId: id.toString(),
|
|
86
|
+
resourceSignature: "",
|
|
87
87
|
isInternalUse: false
|
|
88
88
|
},
|
|
89
89
|
headers: { ...createRTypeRoutingHeader(type) }
|
|
@@ -124,7 +124,7 @@ function newLocalStorageIdsToRoot(projections) {
|
|
|
124
124
|
}
|
|
125
125
|
return idToRoot;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
127
|
//#endregion
|
|
129
128
|
export { ClientDownload, UnknownStorageError, WrongLocalFileUrl, getFullPath, newLocalStorageIdsToRoot, parseLocalUrl };
|
|
129
|
+
|
|
130
130
|
//# sourceMappingURL=download.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","names":["fs","path"],"sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\n addRTypeToMetadata,\n stringifyWithResourceId,\n RestAPI,\n createRTypeRoutingHeader,\n} from \"@milaboratories/pl-client\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\nimport { PerfTimer } from \"@milaboratories/helpers\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ConcurrencyLimitingExecutor } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { Dispatcher } from \"undici\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\nimport { type ContentHandler, RemoteFileDownloader } from \"../helpers/download\";\nimport { validateAbsolute } from \"../helpers/validate\";\nimport type { DownloadAPI_GetDownloadURL_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol\";\nimport { DownloadClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client\";\nimport type { DownloadApiPaths, DownloadRestClientType } from \"../proto-rest\";\nimport { type GetContentOptions } from \"@milaboratories/pl-model-common\";\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === \"grpc\") {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, ` +\n `url: ${downloadUrl}, ` +\n `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (\n await client.POST(\"/v1/get-download-url\", {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })\n ).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == \"\")\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === \"\") return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = \"storage://\";\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = \"WrongLocalFileUrl\";\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = \"UnknownStorageError\";\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== \"\") {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,IAAa,iBAAb,MAA4B;CAC1B,AAAgB;CAChB,AAAiB;;CAGjB,AAAiB;;CAGjB,AAAiB,uBAAuB,IAAI,4BAA4B,GAAG;CAE3E,YACE,2BACA,AAAgB,YAChB,AAAgB,QAEhB,kBACA;EAJgB;EACA;AAIhB,OAAK,OAAO,0BAA0B,0BAA0B,aAAa;AAC3E,OAAI,SAAS,SAAS,OACpB,QAAO,IAAI,eAAe,SAAS,UAAU;OAE7C,QAAO,QAAQ,aAA+B;IAC5C,aAAa,SAAS,OAAO;IAC7B,KAAK,SAAS,OAAO;IACrB,YAAY,SAAS;IACrB,aAAa,SAAS;IACvB,CAAC;IAEJ;AACF,OAAK,uBAAuB,IAAI,qBAAqB,WAAW;AAChE,OAAK,wBAAwB,yBAAyB,iBAAiB;;CAGzE,QAAQ;;;;;;;CAQR,MAAM,gBACJ,MACA,SACA,KACA,SACY;EACZ,MAAM,EAAE,aAAa,YAAY,MAAM,KAAK,mBAAmB,MAAM,SAAS,IAAI,OAAO;EAEzF,MAAM,gBAAgB,OAAO,YAAY,QAAQ,KAAK,EAAE,MAAM,YAAY,CAAC,MAAM,MAAM,CAAC,CAAC;AACzF,OAAK,OAAO,KACV,QAAQ,wBAAwB,KAAK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,MAAM;IACJ,YAAY,GAAG,UAAU;IACzB,eAAe;IAChB;GACD,SAAS,EAAE,GAAG,yBAAyB,KAAK,EAAE;GAC/C,CAAC,EACF;;;AAKR,SAAgB,cAAc,KAAa;CACzC,MAAM,SAAS,IAAI,IAAI,IAAI;AAC3B,KAAI,OAAO,YAAY,GACrB,OAAM,IAAI,kBAAkB,0BAA0B,IAAI,4BAA4B;AAExF,QAAO;EACL,WAAW,OAAO;EAClB,cAAc,mBAAmB,OAAO,SAAS,MAAM,EAAE,CAAC;EAC3D;;AAGH,SAAgB,YACd,WACA,uBACA,cACA;CACA,MAAM,OAAO,sBAAsB,IAAI,UAAU;AACjD,KAAI,SAAS,OAAW,OAAM,IAAI,oBAAoB,6BAA6B,YAAY;AAE/F,KAAI,SAAS,GAAI,QAAO;AAExB,QAAOC,OAAK,KAAK,MAAM,aAAa;;AAGtC,MAAM,kBAAkB;AACxB,SAAS,QAAQ,KAAa;AAC5B,QAAO,IAAI,WAAW,gBAAgB;;;AAIxC,IAAa,oBAAb,cAAuC,MAAM;CAC3C,OAAO;;;AAIT,IAAa,sBAAb,cAAyC,MAAM;CAC7C,OAAO;;AAGT,SAAgB,yBAAyB,aAAuC;CAC9E,MAAM,2BAAgC,IAAI,KAAK;AAC/C,MAAK,MAAM,MAAM,aAAa;AAE5B,MAAI,GAAG,cAAc,GACnB,kBAAiB,GAAG,UAAU;AAEhC,WAAS,IAAI,GAAG,WAAW,GAAG,UAAU;;AAG1C,QAAO"}
|
|
1
|
+
{"version":3,"file":"download.js","names":["fs","path"],"sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\n addRTypeToMetadata,\n stringifyWithResourceId,\n RestAPI,\n createRTypeRoutingHeader,\n} from \"@milaboratories/pl-client\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\nimport { PerfTimer } from \"@milaboratories/helpers\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { ConcurrencyLimitingExecutor } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport * as fs from \"node:fs\";\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { Dispatcher } from \"undici\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\nimport { type ContentHandler, RemoteFileDownloader } from \"../helpers/download\";\nimport { validateAbsolute } from \"../helpers/validate\";\nimport type { DownloadAPI_GetDownloadURL_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol\";\nimport { DownloadClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client\";\nimport type { DownloadApiPaths, DownloadRestClientType } from \"../proto-rest\";\nimport { type GetContentOptions } from \"@milaboratories/pl-model-common\";\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === \"grpc\") {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, ` +\n `url: ${downloadUrl}, ` +\n `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (\n await client.POST(\"/v1/get-download-url\", {\n body: {\n resourceId: id.toString(),\n resourceSignature: \"\",\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })\n ).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == \"\")\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === \"\") return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = \"storage://\";\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = \"WrongLocalFileUrl\";\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = \"UnknownStorageError\";\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== \"\") {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,IAAa,iBAAb,MAA4B;CAC1B;CACA;;CAG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B,QAAOC,OAAK,KAAK,MAAM,aAAa;;AAGtC,MAAM,kBAAkB;AACxB,SAAS,QAAQ,KAAa;AAC5B,QAAO,IAAI,WAAW,gBAAgB;;;AAIxC,IAAa,oBAAb,cAAuC,MAAM;CAC3C,OAAO;;;AAIT,IAAa,sBAAb,cAAyC,MAAM;CAC7C,OAAO;;AAGT,SAAgB,yBAAyB,aAAuC;CAC9E,MAAM,2BAAgC,IAAI,KAAK;AAC/C,MAAK,MAAM,MAAM,aAAa;AAE5B,MAAI,GAAG,cAAc,GACnB,kBAAiB,GAAG,UAAU;AAEhC,WAAS,IAAI,GAAG,WAAW,GAAG,UAAU;;AAG1C,QAAO"}
|
package/dist/clients/logs.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const require_protocol_client = require(
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_protocol_client = require("../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.cjs");
|
|
3
3
|
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
4
4
|
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
5
|
-
|
|
6
5
|
//#region src/clients/logs.ts
|
|
7
6
|
var ClientLogs = class {
|
|
8
7
|
wire;
|
|
@@ -34,6 +33,7 @@ var ClientLogs = class {
|
|
|
34
33
|
const resp = (await client.POST("/v1/last-lines", {
|
|
35
34
|
body: {
|
|
36
35
|
resourceId: rId.toString(),
|
|
36
|
+
resourceSignature: "",
|
|
37
37
|
lineCount,
|
|
38
38
|
offset: offsetBytes.toString(),
|
|
39
39
|
search: searchStr ?? "",
|
|
@@ -61,6 +61,7 @@ var ClientLogs = class {
|
|
|
61
61
|
const resp = (await client.POST("/v1/read/text", {
|
|
62
62
|
body: {
|
|
63
63
|
resourceId: rId.toString(),
|
|
64
|
+
resourceSignature: "",
|
|
64
65
|
readLimit: lineCount.toString(),
|
|
65
66
|
offset: offsetBytes.toString(),
|
|
66
67
|
search: searchStr ?? "",
|
|
@@ -75,7 +76,7 @@ var ClientLogs = class {
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
|
-
|
|
79
79
|
//#endregion
|
|
80
80
|
exports.ClientLogs = ClientLogs;
|
|
81
|
+
|
|
81
82
|
//# sourceMappingURL=logs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.cjs","names":["StreamingClient","RestAPI"],"sources":["../../src/clients/logs.ts"],"sourcesContent":["import type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader, RestAPI } from \"@milaboratories/pl-client\";\nimport type { StreamingAPI_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol\";\nimport { StreamingClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client\";\nimport type { StreamingApiPaths, StreamingRestClientType } from \"../proto-rest\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLogs {\n public readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new StreamingClient(wire.Transport);\n }\n\n return RestAPI.createClient<StreamingApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n if (client instanceof StreamingClient) {\n return (\n await client.lastLines(\n { resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/last-lines\", {\n body: {\n resourceId: rId.toString(),\n lineCount: lineCount,\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n\n if (client instanceof StreamingClient) {\n return (\n await client.readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/read/text\", {\n body: {\n resourceId: rId.toString(),\n readLimit: lineCount.toString(),\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"logs.cjs","names":["StreamingClient","RestAPI"],"sources":["../../src/clients/logs.ts"],"sourcesContent":["import type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader, RestAPI } from \"@milaboratories/pl-client\";\nimport type { StreamingAPI_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol\";\nimport { StreamingClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client\";\nimport type { StreamingApiPaths, StreamingRestClientType } from \"../proto-rest\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLogs {\n public readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new StreamingClient(wire.Transport);\n }\n\n return RestAPI.createClient<StreamingApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n if (client instanceof StreamingClient) {\n return (\n await client.lastLines(\n { resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/last-lines\", {\n body: {\n resourceId: rId.toString(),\n resourceSignature: \"\",\n lineCount: lineCount,\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n\n if (client instanceof StreamingClient) {\n return (\n await client.readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/read/text\", {\n body: {\n resourceId: rId.toString(),\n resourceSignature: \"\",\n readLimit: lineCount.toString(),\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n}\n"],"mappings":";;;;;AAWA,IAAa,aAAb,MAAwB;CACtB;CAEA,YACE,2BACA,YACA,QACA;AAFgB,OAAA,aAAA;AACA,OAAA,SAAA;AAEhB,OAAK,OAAO,0BAA0B,0BAA0B,SAAS;AACvE,OAAI,KAAK,SAAS,OAChB,QAAO,IAAIA,wBAAAA,gBAAgB,KAAK,UAAU;AAG5C,UAAOC,0BAAAA,QAAQ,aAAgC;IAC7C,aAAa,KAAK,OAAO;IACzB,KAAK,KAAK,OAAO;IACjB,YAAY,KAAK;IACjB,aAAa,KAAK;IACnB,CAAC;IACF;;CAGJ,QAAQ;;;;CAKR,MAAa,UACX,EAAE,IAAI,KAAK,MAAM,S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,OAAO,KAAK,KAAK;GACvB,WAAW,OAAO,KAAK,UAAU;GAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","names":[],"sources":["../../src/clients/logs.ts"],"mappings":";;;;;;;;;;cAWa,UAAA;EAAA,SAKO,UAAA,EAAY,UAAA;EAAA,SACZ,MAAA,EAAQ,QAAA;EAAA,SALV,IAAA,EAAM,kBAAA,CAAmB,uBAAA,GAA0B,eAAA;cAGjE,yBAAA,EAA2B,yBAAA,EACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,QAAA;EAgB1B,KAAA,CAAA;EAhB0B;;;EAqBb,SAAA,CAAA;IACT,EAAA,EAAI,GAAA;IAAK,IAAA,EAAM;EAAA,GAAS,YAAA,EAC1B,SAAA,UACA,WAAA;EACA,SAAA,WACA,OAAA,GAAU,UAAA,GACT,OAAA,CAAQ,qBAAA;EA5BmB;;;EA+DjB,QAAA,CAAA;IACT,EAAA,EAAI,GAAA;IAAK,IAAA,EAAM;EAAA,GAAS,YAAA,EAC1B,SAAA,UACA,WAAA;EACA,SAAA,WACA,OAAA,GAAU,UAAA,GACT,OAAA,CAAQ,qBAAA;AAAA"}
|
package/dist/clients/logs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { StreamingClient } from "../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.js";
|
|
2
2
|
import { RestAPI, addRTypeToMetadata, createRTypeRoutingHeader } from "@milaboratories/pl-client";
|
|
3
3
|
import { notEmpty } from "@milaboratories/ts-helpers";
|
|
4
|
-
|
|
5
4
|
//#region src/clients/logs.ts
|
|
6
5
|
var ClientLogs = class {
|
|
7
6
|
wire;
|
|
@@ -33,6 +32,7 @@ var ClientLogs = class {
|
|
|
33
32
|
const resp = (await client.POST("/v1/last-lines", {
|
|
34
33
|
body: {
|
|
35
34
|
resourceId: rId.toString(),
|
|
35
|
+
resourceSignature: "",
|
|
36
36
|
lineCount,
|
|
37
37
|
offset: offsetBytes.toString(),
|
|
38
38
|
search: searchStr ?? "",
|
|
@@ -60,6 +60,7 @@ var ClientLogs = class {
|
|
|
60
60
|
const resp = (await client.POST("/v1/read/text", {
|
|
61
61
|
body: {
|
|
62
62
|
resourceId: rId.toString(),
|
|
63
|
+
resourceSignature: "",
|
|
63
64
|
readLimit: lineCount.toString(),
|
|
64
65
|
offset: offsetBytes.toString(),
|
|
65
66
|
search: searchStr ?? "",
|
|
@@ -74,7 +75,7 @@ var ClientLogs = class {
|
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
|
-
|
|
78
78
|
//#endregion
|
|
79
79
|
export { ClientLogs };
|
|
80
|
+
|
|
80
81
|
//# sourceMappingURL=logs.js.map
|
package/dist/clients/logs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","names":[],"sources":["../../src/clients/logs.ts"],"sourcesContent":["import type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader, RestAPI } from \"@milaboratories/pl-client\";\nimport type { StreamingAPI_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol\";\nimport { StreamingClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client\";\nimport type { StreamingApiPaths, StreamingRestClientType } from \"../proto-rest\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLogs {\n public readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new StreamingClient(wire.Transport);\n }\n\n return RestAPI.createClient<StreamingApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n if (client instanceof StreamingClient) {\n return (\n await client.lastLines(\n { resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/last-lines\", {\n body: {\n resourceId: rId.toString(),\n lineCount: lineCount,\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n\n if (client instanceof StreamingClient) {\n return (\n await client.readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/read/text\", {\n body: {\n resourceId: rId.toString(),\n readLimit: lineCount.toString(),\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"logs.js","names":[],"sources":["../../src/clients/logs.ts"],"sourcesContent":["import type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader, RestAPI } from \"@milaboratories/pl-client\";\nimport type { StreamingAPI_Response } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol\";\nimport { StreamingClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client\";\nimport type { StreamingApiPaths, StreamingRestClientType } from \"../proto-rest\";\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLogs {\n public readonly wire: WireClientProvider<StreamingRestClientType | StreamingClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new StreamingClient(wire.Transport);\n }\n\n return RestAPI.createClient<StreamingApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n /** Reads text back and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async lastLines(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the end.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n if (client instanceof StreamingClient) {\n return (\n await client.lastLines(\n { resourceId: rId, lineCount: lineCount, offset: offsetBytes, search: searchStr },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/last-lines\", {\n body: {\n resourceId: rId.toString(),\n resourceSignature: \"\",\n lineCount: lineCount,\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n\n /** Reads the file forward and returns the text,\n * the new offset\n * and the total size of the (currently existing) file. */\n public async readText(\n { id: rId, type: rType }: ResourceInfo,\n lineCount: number,\n offsetBytes: bigint = 0n, // if 0n, then start from the beginning.\n searchStr?: string,\n options?: RpcOptions,\n ): Promise<StreamingAPI_Response> {\n const client = this.wire.get();\n\n if (client instanceof StreamingClient) {\n return (\n await client.readText(\n {\n resourceId: notEmpty(rId),\n readLimit: BigInt(lineCount),\n offset: offsetBytes,\n search: searchStr,\n },\n addRTypeToMetadata(rType, options),\n )\n ).response;\n }\n\n const resp = (\n await client.POST(\"/v1/read/text\", {\n body: {\n resourceId: rId.toString(),\n resourceSignature: \"\",\n readLimit: lineCount.toString(),\n offset: offsetBytes.toString(),\n search: searchStr ?? \"\",\n searchRe: \"\",\n },\n headers: { ...createRTypeRoutingHeader(rType) },\n })\n ).data!;\n\n return {\n data: Buffer.from(resp.data, \"base64\"),\n size: BigInt(resp.size),\n newOffset: BigInt(resp.newOffset),\n };\n }\n}\n"],"mappings":";;;;AAWA,IAAa,aAAb,MAAwB;CACtB;CAEA,YACE,2BACA,YACA,QACA;AAFgB,OAAA,aAAA;AACA,OAAA,SAAA;AAEhB,OAAK,OAAO,0BAA0B,0BAA0B,SAAS;AACvE,OAAI,KAAK,SAAS,OAChB,QAAO,IAAI,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;GACD,SAAS,EAAE,GAAG,yBAAyB,MAAM,EAAE;GAChD,CAAC,EACF;AAEF,SAAO;GACL,MAAM,OAAO,KAAK,KAAK,MAAM,SAAS;GACtC,MAAM,OAAO,KAAK,KAAK;GACvB,WAAW,OAAO,KAAK,UAAU;GAClC"}
|
package/dist/clients/ls_api.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const require_protocol_client = require(
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_protocol_client = require("../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.cjs");
|
|
3
3
|
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
4
|
-
|
|
5
4
|
//#region src/clients/ls_api.ts
|
|
6
5
|
var ClientLs = class {
|
|
7
6
|
wire;
|
|
@@ -28,6 +27,7 @@ var ClientLs = class {
|
|
|
28
27
|
const resp = (await client.POST("/v1/list", {
|
|
29
28
|
body: {
|
|
30
29
|
resourceId: rInfo.id.toString(),
|
|
30
|
+
resourceSignature: "",
|
|
31
31
|
location: path
|
|
32
32
|
},
|
|
33
33
|
headers: { ...(0, _milaboratories_pl_client.createRTypeRoutingHeader)(rInfo.type) }
|
|
@@ -61,7 +61,7 @@ function parseTimestamp(timestamp) {
|
|
|
61
61
|
nanos
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
|
|
65
64
|
//#endregion
|
|
66
65
|
exports.ClientLs = ClientLs;
|
|
66
|
+
|
|
67
67
|
//# sourceMappingURL=ls_api.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls_api.cjs","names":["LSClient","RestAPI"],"sources":["../../src/clients/ls_api.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { RestAPI } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader } from \"@milaboratories/pl-client\";\nimport type {\n LsAPI_List_Response,\n LsAPI_ListItem,\n} from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol\";\nimport { LSClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client\";\nimport type { LsApiPaths, LsRestClientType } from \"../proto-rest\";\n\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLs {\n private readonly wire: WireClientProvider<LsRestClientType | LSClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n private readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new LSClient(wire.Transport);\n }\n\n return RestAPI.createClient<LsApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n public async list(\n rInfo: ResourceInfo,\n path: string,\n options?: RpcOptions,\n ): Promise<LsAPI_List_Response> {\n const client = this.wire.get();\n\n if (client instanceof LSClient) {\n return await client.list(\n {\n resourceId: rInfo.id,\n location: path,\n },\n addRTypeToMetadata(rInfo.type, options),\n ).response;\n } else {\n const resp = (\n await client.POST(\"/v1/list\", {\n body: {\n resourceId: rInfo.id.toString(),\n location: path,\n },\n headers: { ...createRTypeRoutingHeader(rInfo.type) },\n })\n ).data!;\n\n const items: LsAPI_ListItem[] = resp.items.map((item) => ({\n name: item.name,\n size: BigInt(item.size),\n isDir: item.isDir,\n fullName: item.fullName,\n directory: item.directory,\n lastModified: parseTimestamp(item.lastModified),\n version: item.version,\n }));\n\n return {\n items,\n delimiter: resp.delimiter,\n };\n }\n }\n}\n\nfunction parseTimestamp(timestamp: string): { seconds: bigint; nanos: number } {\n // Parse ISO 8601 format: 2025-08-08T11:12:44.145635532Z\n const date = new Date(timestamp);\n const seconds = BigInt(Math.floor(date.getTime() / 1000));\n\n // Extract fractional seconds from the original string\n const fractionalMatch = timestamp.match(/\\.(\\d+)Z?$/);\n let nanos = 0;\n if (fractionalMatch) {\n const fractionalPart = fractionalMatch[1];\n // Pad or truncate to 9 digits (nanoseconds)\n const padded = fractionalPart.padEnd(9, \"0\").slice(0, 9);\n nanos = parseInt(padded, 10);\n }\n\n return { seconds, nanos };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ls_api.cjs","names":["LSClient","RestAPI"],"sources":["../../src/clients/ls_api.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { RestAPI } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader } from \"@milaboratories/pl-client\";\nimport type {\n LsAPI_List_Response,\n LsAPI_ListItem,\n} from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol\";\nimport { LSClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client\";\nimport type { LsApiPaths, LsRestClientType } from \"../proto-rest\";\n\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLs {\n private readonly wire: WireClientProvider<LsRestClientType | LSClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n private readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new LSClient(wire.Transport);\n }\n\n return RestAPI.createClient<LsApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n public async list(\n rInfo: ResourceInfo,\n path: string,\n options?: RpcOptions,\n ): Promise<LsAPI_List_Response> {\n const client = this.wire.get();\n\n if (client instanceof LSClient) {\n return await client.list(\n {\n resourceId: rInfo.id,\n location: path,\n },\n addRTypeToMetadata(rInfo.type, options),\n ).response;\n } else {\n const resp = (\n await client.POST(\"/v1/list\", {\n body: {\n resourceId: rInfo.id.toString(),\n resourceSignature: \"\",\n location: path,\n },\n headers: { ...createRTypeRoutingHeader(rInfo.type) },\n })\n ).data!;\n\n const items: LsAPI_ListItem[] = resp.items.map((item) => ({\n name: item.name,\n size: BigInt(item.size),\n isDir: item.isDir,\n fullName: item.fullName,\n directory: item.directory,\n lastModified: parseTimestamp(item.lastModified),\n version: item.version,\n }));\n\n return {\n items,\n delimiter: resp.delimiter,\n };\n }\n }\n}\n\nfunction parseTimestamp(timestamp: string): { seconds: bigint; nanos: number } {\n // Parse ISO 8601 format: 2025-08-08T11:12:44.145635532Z\n const date = new Date(timestamp);\n const seconds = BigInt(Math.floor(date.getTime() / 1000));\n\n // Extract fractional seconds from the original string\n const fractionalMatch = timestamp.match(/\\.(\\d+)Z?$/);\n let nanos = 0;\n if (fractionalMatch) {\n const fractionalPart = fractionalMatch[1];\n // Pad or truncate to 9 digits (nanoseconds)\n const padded = fractionalPart.padEnd(9, \"0\").slice(0, 9);\n nanos = parseInt(padded, 10);\n }\n\n return { seconds, nanos };\n}\n"],"mappings":";;;;AAcA,IAAa,WAAb,MAAsB;CACpB;CAEA,YACE,2BACA,QACA;AADiB,OAAA,SAAA;AAEjB,OAAK,OAAO,0BAA0B,0BAA0B,SAAS;AACvE,OAAI,KAAK,SAAS,OAChB,QAAO,IAAIA,wBAAAA,SAAS,KAAK,UAAU;AAGrC,UAAOC,0BAAAA,QAAQ,aAAyB;IACtC,aAAa,KAAK,OAAO;IACzB,KAAK,KAAK,OAAO;IACjB,YAAY,KAAK;IACjB,aAAa,KAAK;IACnB,CAAC;IACF;;CAGJ,QAAQ;CAER,MAAa,KACX,OACA,MACA,SAC8B;EAC9B,MAAM,SAAS,KAAK,KAAK,KAAK;AAE9B,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,OAAA,CAAQ,mBAAA;AAAA"}
|
package/dist/clients/ls_api.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LSClient } from "../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.js";
|
|
2
2
|
import { RestAPI, addRTypeToMetadata, createRTypeRoutingHeader } from "@milaboratories/pl-client";
|
|
3
|
-
|
|
4
3
|
//#region src/clients/ls_api.ts
|
|
5
4
|
var ClientLs = class {
|
|
6
5
|
wire;
|
|
@@ -27,6 +26,7 @@ var ClientLs = class {
|
|
|
27
26
|
const resp = (await client.POST("/v1/list", {
|
|
28
27
|
body: {
|
|
29
28
|
resourceId: rInfo.id.toString(),
|
|
29
|
+
resourceSignature: "",
|
|
30
30
|
location: path
|
|
31
31
|
},
|
|
32
32
|
headers: { ...createRTypeRoutingHeader(rInfo.type) }
|
|
@@ -60,7 +60,7 @@ function parseTimestamp(timestamp) {
|
|
|
60
60
|
nanos
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
|
|
64
63
|
//#endregion
|
|
65
64
|
export { ClientLs };
|
|
65
|
+
|
|
66
66
|
//# sourceMappingURL=ls_api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls_api.js","names":[],"sources":["../../src/clients/ls_api.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { RestAPI } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader } from \"@milaboratories/pl-client\";\nimport type {\n LsAPI_List_Response,\n LsAPI_ListItem,\n} from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol\";\nimport { LSClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client\";\nimport type { LsApiPaths, LsRestClientType } from \"../proto-rest\";\n\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLs {\n private readonly wire: WireClientProvider<LsRestClientType | LSClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n private readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new LSClient(wire.Transport);\n }\n\n return RestAPI.createClient<LsApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n public async list(\n rInfo: ResourceInfo,\n path: string,\n options?: RpcOptions,\n ): Promise<LsAPI_List_Response> {\n const client = this.wire.get();\n\n if (client instanceof LSClient) {\n return await client.list(\n {\n resourceId: rInfo.id,\n location: path,\n },\n addRTypeToMetadata(rInfo.type, options),\n ).response;\n } else {\n const resp = (\n await client.POST(\"/v1/list\", {\n body: {\n resourceId: rInfo.id.toString(),\n location: path,\n },\n headers: { ...createRTypeRoutingHeader(rInfo.type) },\n })\n ).data!;\n\n const items: LsAPI_ListItem[] = resp.items.map((item) => ({\n name: item.name,\n size: BigInt(item.size),\n isDir: item.isDir,\n fullName: item.fullName,\n directory: item.directory,\n lastModified: parseTimestamp(item.lastModified),\n version: item.version,\n }));\n\n return {\n items,\n delimiter: resp.delimiter,\n };\n }\n }\n}\n\nfunction parseTimestamp(timestamp: string): { seconds: bigint; nanos: number } {\n // Parse ISO 8601 format: 2025-08-08T11:12:44.145635532Z\n const date = new Date(timestamp);\n const seconds = BigInt(Math.floor(date.getTime() / 1000));\n\n // Extract fractional seconds from the original string\n const fractionalMatch = timestamp.match(/\\.(\\d+)Z?$/);\n let nanos = 0;\n if (fractionalMatch) {\n const fractionalPart = fractionalMatch[1];\n // Pad or truncate to 9 digits (nanoseconds)\n const padded = fractionalPart.padEnd(9, \"0\").slice(0, 9);\n nanos = parseInt(padded, 10);\n }\n\n return { seconds, nanos };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ls_api.js","names":[],"sources":["../../src/clients/ls_api.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { RpcOptions } from \"@protobuf-ts/runtime-rpc\";\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport { RestAPI } from \"@milaboratories/pl-client\";\nimport { addRTypeToMetadata, createRTypeRoutingHeader } from \"@milaboratories/pl-client\";\nimport type {\n LsAPI_List_Response,\n LsAPI_ListItem,\n} from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol\";\nimport { LSClient } from \"../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client\";\nimport type { LsApiPaths, LsRestClientType } from \"../proto-rest\";\n\nimport type { ResourceInfo } from \"@milaboratories/pl-tree\";\n\nexport class ClientLs {\n private readonly wire: WireClientProvider<LsRestClientType | LSClient>;\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n private readonly logger: MiLogger,\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wire) => {\n if (wire.type === \"grpc\") {\n return new LSClient(wire.Transport);\n }\n\n return RestAPI.createClient<LsApiPaths>({\n hostAndPort: wire.Config.hostAndPort,\n ssl: wire.Config.ssl,\n dispatcher: wire.Dispatcher,\n middlewares: wire.Middlewares,\n });\n });\n }\n\n close() {}\n\n public async list(\n rInfo: ResourceInfo,\n path: string,\n options?: RpcOptions,\n ): Promise<LsAPI_List_Response> {\n const client = this.wire.get();\n\n if (client instanceof LSClient) {\n return await client.list(\n {\n resourceId: rInfo.id,\n location: path,\n },\n addRTypeToMetadata(rInfo.type, options),\n ).response;\n } else {\n const resp = (\n await client.POST(\"/v1/list\", {\n body: {\n resourceId: rInfo.id.toString(),\n resourceSignature: \"\",\n location: path,\n },\n headers: { ...createRTypeRoutingHeader(rInfo.type) },\n })\n ).data!;\n\n const items: LsAPI_ListItem[] = resp.items.map((item) => ({\n name: item.name,\n size: BigInt(item.size),\n isDir: item.isDir,\n fullName: item.fullName,\n directory: item.directory,\n lastModified: parseTimestamp(item.lastModified),\n version: item.version,\n }));\n\n return {\n items,\n delimiter: resp.delimiter,\n };\n }\n }\n}\n\nfunction parseTimestamp(timestamp: string): { seconds: bigint; nanos: number } {\n // Parse ISO 8601 format: 2025-08-08T11:12:44.145635532Z\n const date = new Date(timestamp);\n const seconds = BigInt(Math.floor(date.getTime() / 1000));\n\n // Extract fractional seconds from the original string\n const fractionalMatch = timestamp.match(/\\.(\\d+)Z?$/);\n let nanos = 0;\n if (fractionalMatch) {\n const fractionalPart = fractionalMatch[1];\n // Pad or truncate to 9 digits (nanoseconds)\n const padded = fractionalPart.padEnd(9, \"0\").slice(0, 9);\n nanos = parseInt(padded, 10);\n }\n\n return { seconds, nanos };\n}\n"],"mappings":";;;AAcA,IAAa,WAAb,MAAsB;CACpB;CAEA,YACE,2BACA,QACA;AADiB,OAAA,SAAA;AAEjB,OAAK,OAAO,0BAA0B,0BAA0B,SAAS;AACvE,OAAI,KAAK,SAAS,OAChB,QAAO,IAAI,SAAS,KAAK,UAAU;AAGrC,UAAO,QAAQ,aAAyB;IACtC,aAAa,KAAK,OAAO;IACzB,KAAK,KAAK,OAAO;IACjB,YAAY,KAAK;IACjB,aAAa,KAAK;IACnB,CAAC;IACF;;CAGJ,QAAQ;CAER,MAAa,KACX,OACA,MACA,SAC8B;EAC9B,MAAM,SAAS,KAAK,KAAK,KAAK;AAE9B,MAAI,kBAAkB,SACpB,QAAO,MAAM,OAAO,KAClB;GACE,YAAY,MAAM;GAClB,UAAU;GACX,EACD,mBAAmB,MAAM,MAAM,QAAQ,CACxC,CAAC;OACG;GACL,MAAM,QACJ,MAAM,OAAO,KAAK,YAAY;IAC5B,MAAM;KACJ,YAAY,MAAM,GAAG,UAAU;KAC/B,mBAAmB;KACnB,UAAU;KACX;IACD,SAAS,EAAE,GAAG,yBAAyB,MAAM,KAAK,EAAE;IACr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