@milaboratories/pl-drivers 1.11.45 → 1.11.47
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/README.md +0 -1
- package/dist/clients/constructors.cjs +5 -5
- package/dist/clients/constructors.cjs.map +1 -1
- package/dist/clients/constructors.d.ts +8 -8
- package/dist/clients/constructors.d.ts.map +1 -1
- package/dist/clients/constructors.js +5 -5
- package/dist/clients/constructors.js.map +1 -1
- package/dist/clients/crc32c.cjs.map +1 -1
- package/dist/clients/crc32c.d.ts.map +1 -1
- package/dist/clients/crc32c.js.map +1 -1
- package/dist/clients/download.cjs +12 -13
- package/dist/clients/download.cjs.map +1 -1
- package/dist/clients/download.d.ts +10 -10
- package/dist/clients/download.d.ts.map +1 -1
- package/dist/clients/download.js +12 -13
- package/dist/clients/download.js.map +1 -1
- package/dist/clients/logs.cjs +9 -9
- package/dist/clients/logs.cjs.map +1 -1
- package/dist/clients/logs.d.ts +8 -8
- package/dist/clients/logs.d.ts.map +1 -1
- package/dist/clients/logs.js +9 -9
- package/dist/clients/logs.js.map +1 -1
- package/dist/clients/ls_api.cjs +3 -3
- package/dist/clients/ls_api.cjs.map +1 -1
- package/dist/clients/ls_api.d.ts +5 -5
- package/dist/clients/ls_api.d.ts.map +1 -1
- package/dist/clients/ls_api.js +3 -3
- package/dist/clients/ls_api.js.map +1 -1
- package/dist/clients/progress.cjs +4 -3
- package/dist/clients/progress.cjs.map +1 -1
- package/dist/clients/progress.d.ts +7 -7
- package/dist/clients/progress.d.ts.map +1 -1
- package/dist/clients/progress.js +4 -3
- package/dist/clients/progress.js.map +1 -1
- package/dist/clients/upload.cjs +20 -20
- package/dist/clients/upload.cjs.map +1 -1
- package/dist/clients/upload.d.ts +6 -6
- package/dist/clients/upload.d.ts.map +1 -1
- package/dist/clients/upload.js +20 -20
- package/dist/clients/upload.js.map +1 -1
- package/dist/drivers/download_blob/blob_key.cjs.map +1 -1
- package/dist/drivers/download_blob/blob_key.js.map +1 -1
- package/dist/drivers/download_blob/download_blob.cjs +20 -20
- package/dist/drivers/download_blob/download_blob.cjs.map +1 -1
- package/dist/drivers/download_blob/download_blob.d.ts +9 -9
- package/dist/drivers/download_blob/download_blob.d.ts.map +1 -1
- package/dist/drivers/download_blob/download_blob.js +20 -20
- package/dist/drivers/download_blob/download_blob.js.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.cjs +14 -14
- package/dist/drivers/download_blob/download_blob_task.cjs.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.d.ts +7 -7
- package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.js +14 -14
- package/dist/drivers/download_blob/download_blob_task.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/cache.cjs +4 -4
- package/dist/drivers/download_blob/sparse_cache/cache.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts +3 -3
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/cache.js +4 -4
- package/dist/drivers/download_blob/sparse_cache/cache.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/file.cjs +4 -4
- package/dist/drivers/download_blob/sparse_cache/file.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/file.d.ts.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/file.js +4 -4
- package/dist/drivers/download_blob/sparse_cache/file.js.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs +4 -4
- package/dist/drivers/download_blob/sparse_cache/ranges.cjs.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.d.ts.map +1 -1
- package/dist/drivers/download_blob/sparse_cache/ranges.js +4 -4
- package/dist/drivers/download_blob/sparse_cache/ranges.js.map +1 -1
- package/dist/drivers/download_blob_url/driver.cjs +3 -3
- package/dist/drivers/download_blob_url/driver.cjs.map +1 -1
- package/dist/drivers/download_blob_url/driver.d.ts +9 -9
- package/dist/drivers/download_blob_url/driver.d.ts.map +1 -1
- package/dist/drivers/download_blob_url/driver.js +3 -3
- package/dist/drivers/download_blob_url/driver.js.map +1 -1
- package/dist/drivers/download_blob_url/driver_id.cjs.map +1 -1
- package/dist/drivers/download_blob_url/driver_id.d.ts +2 -2
- package/dist/drivers/download_blob_url/driver_id.js.map +1 -1
- 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 -1
- package/dist/drivers/download_blob_url/snapshot.js.map +1 -1
- package/dist/drivers/download_blob_url/task.cjs +14 -16
- package/dist/drivers/download_blob_url/task.cjs.map +1 -1
- package/dist/drivers/download_blob_url/task.d.ts +7 -7
- package/dist/drivers/download_blob_url/task.d.ts.map +1 -1
- package/dist/drivers/download_blob_url/task.js +14 -16
- package/dist/drivers/download_blob_url/task.js.map +1 -1
- package/dist/drivers/download_url/driver.cjs +4 -4
- package/dist/drivers/download_url/driver.cjs.map +1 -1
- package/dist/drivers/download_url/driver.d.ts +6 -6
- package/dist/drivers/download_url/driver.d.ts.map +1 -1
- package/dist/drivers/download_url/driver.js +4 -4
- package/dist/drivers/download_url/driver.js.map +1 -1
- package/dist/drivers/download_url/task.cjs +2 -2
- package/dist/drivers/download_url/task.cjs.map +1 -1
- package/dist/drivers/download_url/task.d.ts +6 -6
- package/dist/drivers/download_url/task.d.ts.map +1 -1
- package/dist/drivers/download_url/task.js +2 -2
- package/dist/drivers/download_url/task.js.map +1 -1
- package/dist/drivers/helpers/download_local_handle.cjs.map +1 -1
- package/dist/drivers/helpers/download_local_handle.d.ts +2 -2
- package/dist/drivers/helpers/download_local_handle.js.map +1 -1
- package/dist/drivers/helpers/download_remote_handle.cjs.map +1 -1
- package/dist/drivers/helpers/download_remote_handle.d.ts +4 -4
- package/dist/drivers/helpers/download_remote_handle.d.ts.map +1 -1
- package/dist/drivers/helpers/download_remote_handle.js.map +1 -1
- package/dist/drivers/helpers/files_cache.cjs.map +1 -1
- package/dist/drivers/helpers/files_cache.d.ts +1 -1
- package/dist/drivers/helpers/files_cache.js.map +1 -1
- package/dist/drivers/helpers/helpers.cjs +1 -1
- package/dist/drivers/helpers/helpers.cjs.map +1 -1
- package/dist/drivers/helpers/helpers.js +1 -1
- package/dist/drivers/helpers/helpers.js.map +1 -1
- package/dist/drivers/helpers/logs_handle.cjs.map +1 -1
- package/dist/drivers/helpers/logs_handle.d.ts +2 -2
- package/dist/drivers/helpers/logs_handle.d.ts.map +1 -1
- package/dist/drivers/helpers/logs_handle.js.map +1 -1
- package/dist/drivers/helpers/ls_remote_import_handle.cjs.map +1 -1
- package/dist/drivers/helpers/ls_remote_import_handle.d.ts +3 -3
- package/dist/drivers/helpers/ls_remote_import_handle.js.map +1 -1
- package/dist/drivers/helpers/ls_storage_entry.cjs +1 -1
- package/dist/drivers/helpers/ls_storage_entry.cjs.map +1 -1
- package/dist/drivers/helpers/ls_storage_entry.d.ts +2 -2
- package/dist/drivers/helpers/ls_storage_entry.js +1 -1
- package/dist/drivers/helpers/ls_storage_entry.js.map +1 -1
- package/dist/drivers/helpers/read_file.cjs.map +1 -1
- package/dist/drivers/helpers/read_file.d.ts +1 -1
- package/dist/drivers/helpers/read_file.js.map +1 -1
- package/dist/drivers/logs.cjs +6 -6
- package/dist/drivers/logs.cjs.map +1 -1
- package/dist/drivers/logs.d.ts +7 -7
- package/dist/drivers/logs.d.ts.map +1 -1
- package/dist/drivers/logs.js +6 -6
- package/dist/drivers/logs.js.map +1 -1
- package/dist/drivers/logs_stream.cjs +9 -9
- package/dist/drivers/logs_stream.cjs.map +1 -1
- package/dist/drivers/logs_stream.d.ts +7 -7
- package/dist/drivers/logs_stream.d.ts.map +1 -1
- package/dist/drivers/logs_stream.js +9 -9
- package/dist/drivers/logs_stream.js.map +1 -1
- package/dist/drivers/ls.cjs +22 -22
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +6 -6
- package/dist/drivers/ls.d.ts.map +1 -1
- package/dist/drivers/ls.js +22 -22
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/types.cjs +2 -2
- package/dist/drivers/types.cjs.map +1 -1
- package/dist/drivers/types.d.ts +4 -4
- package/dist/drivers/types.d.ts.map +1 -1
- package/dist/drivers/types.js +2 -2
- package/dist/drivers/types.js.map +1 -1
- package/dist/drivers/upload.cjs +6 -6
- package/dist/drivers/upload.cjs.map +1 -1
- package/dist/drivers/upload.d.ts +9 -9
- package/dist/drivers/upload.d.ts.map +1 -1
- package/dist/drivers/upload.js +6 -6
- package/dist/drivers/upload.js.map +1 -1
- package/dist/drivers/upload_task.cjs +17 -17
- package/dist/drivers/upload_task.cjs.map +1 -1
- package/dist/drivers/upload_task.d.ts +9 -9
- package/dist/drivers/upload_task.d.ts.map +1 -1
- package/dist/drivers/upload_task.js +17 -17
- package/dist/drivers/upload_task.js.map +1 -1
- package/dist/drivers/urls/url.cjs +4 -4
- package/dist/drivers/urls/url.cjs.map +1 -1
- package/dist/drivers/urls/url.d.ts +2 -2
- package/dist/drivers/urls/url.js +4 -4
- package/dist/drivers/urls/url.js.map +1 -1
- package/dist/drivers/virtual_storages.cjs +9 -9
- package/dist/drivers/virtual_storages.cjs.map +1 -1
- package/dist/drivers/virtual_storages.d.ts +1 -1
- package/dist/drivers/virtual_storages.js +9 -9
- package/dist/drivers/virtual_storages.js.map +1 -1
- package/dist/helpers/download.cjs +3 -3
- package/dist/helpers/download.cjs.map +1 -1
- package/dist/helpers/download.d.ts +3 -3
- package/dist/helpers/download.d.ts.map +1 -1
- package/dist/helpers/download.js +3 -3
- package/dist/helpers/download.js.map +1 -1
- package/dist/helpers/download_errors.cjs +6 -6
- package/dist/helpers/download_errors.cjs.map +1 -1
- package/dist/helpers/download_errors.d.ts.map +1 -1
- package/dist/helpers/download_errors.js +6 -6
- package/dist/helpers/download_errors.js.map +1 -1
- package/dist/helpers/validate.cjs.map +1 -1
- package/dist/helpers/validate.js.map +1 -1
- package/dist/index.d.ts +21 -21
- package/dist/proto-rest/downloadapi.d.ts.map +1 -1
- package/dist/proto-rest/index.d.ts +6 -6
- package/dist/proto-rest/lsapi.d.ts.map +1 -1
- package/dist/proto-rest/progressapi.d.ts.map +1 -1
- package/dist/proto-rest/streamingapi.d.ts.map +1 -1
- package/dist/proto-rest/uploadapi.d.ts.map +1 -1
- package/package.json +27 -26
- package/src/clients/constructors.ts +19 -16
- package/src/clients/crc32c.ts +257 -65
- package/src/clients/download.test.ts +27 -27
- package/src/clients/download.ts +44 -38
- package/src/clients/logs.ts +56 -52
- package/src/clients/ls_api.ts +33 -30
- package/src/clients/progress.ts +35 -31
- package/src/clients/upload.test.ts +11 -11
- package/src/clients/upload.ts +95 -79
- package/src/drivers/download_blob/blob_key.ts +1 -1
- package/src/drivers/download_blob/download_blob.test.ts +72 -74
- package/src/drivers/download_blob/download_blob.ts +94 -89
- package/src/drivers/download_blob/download_blob_task.ts +33 -36
- package/src/drivers/download_blob/sparse_cache/cache.test.ts +140 -156
- package/src/drivers/download_blob/sparse_cache/cache.ts +23 -15
- package/src/drivers/download_blob/sparse_cache/create_sparse_file_script.js +31 -38
- package/src/drivers/download_blob/sparse_cache/file.ts +7 -11
- package/src/drivers/download_blob/sparse_cache/ranges.test.ts +30 -30
- package/src/drivers/download_blob/sparse_cache/ranges.ts +5 -7
- package/src/drivers/download_blob_url/driver.ts +34 -29
- package/src/drivers/download_blob_url/driver_id.ts +2 -2
- package/src/drivers/download_blob_url/snapshot.ts +13 -3
- package/src/drivers/download_blob_url/task.ts +54 -40
- package/src/drivers/download_url/driver.test.ts +24 -26
- package/src/drivers/download_url/driver.ts +20 -28
- package/src/drivers/download_url/task.ts +22 -24
- package/src/drivers/helpers/download_local_handle.ts +2 -2
- package/src/drivers/helpers/download_remote_handle.ts +14 -11
- package/src/drivers/helpers/files_cache.test.ts +13 -13
- package/src/drivers/helpers/files_cache.ts +2 -2
- package/src/drivers/helpers/helpers.ts +1 -1
- package/src/drivers/helpers/logs_handle.ts +7 -7
- package/src/drivers/helpers/ls_remote_import_handle.ts +3 -3
- package/src/drivers/helpers/ls_storage_entry.ts +5 -5
- package/src/drivers/helpers/read_file.ts +5 -5
- package/src/drivers/helpers/test_helpers.ts +1 -1
- package/src/drivers/logs.test.ts +97 -92
- package/src/drivers/logs.ts +29 -20
- package/src/drivers/logs_stream.ts +30 -39
- package/src/drivers/ls.test.ts +44 -50
- package/src/drivers/ls.ts +42 -41
- package/src/drivers/types.ts +9 -7
- package/src/drivers/upload.test.ts +48 -48
- package/src/drivers/upload.ts +25 -34
- package/src/drivers/upload_task.ts +49 -40
- package/src/drivers/urls/url.test.ts +33 -32
- package/src/drivers/urls/url.ts +12 -8
- package/src/drivers/virtual_storages.ts +14 -14
- package/src/helpers/download.ts +41 -33
- package/src/helpers/download_errors.ts +9 -7
- package/src/helpers/validate.ts +1 -1
- package/src/index.ts +21 -21
- package/src/proto-rest/downloadapi.ts +86 -86
- package/src/proto-rest/index.ts +6 -6
- package/src/proto-rest/lsapi.ts +129 -129
- package/src/proto-rest/progressapi.ts +135 -135
- package/src/proto-rest/streamingapi.ts +430 -430
- package/src/proto-rest/uploadapi.ts +321 -321
- package/src/test_env.ts +1 -1
- package/dist/drivers/download_blob_url/url.d.ts +0 -2
- package/dist/drivers/download_blob_url/url.d.ts.map +0 -1
- package/src/drivers/download_blob_url/url.ts +0 -0
package/README.md
CHANGED
|
@@ -8,31 +8,31 @@ var ls_api = require('./ls_api.cjs');
|
|
|
8
8
|
|
|
9
9
|
function createDownloadClient(logger, client, localProjections) {
|
|
10
10
|
return client.getDriver({
|
|
11
|
-
name:
|
|
11
|
+
name: "DownloadBlob",
|
|
12
12
|
init: (_, wireClientFactory, httpDispatcher) => new download.ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function createLogsClient(client, logger) {
|
|
16
16
|
return client.getDriver({
|
|
17
|
-
name:
|
|
17
|
+
name: "StreamLogs",
|
|
18
18
|
init: (_, wireClientFactory, httpDispatcher) => new logs.ClientLogs(wireClientFactory, httpDispatcher, logger),
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
function createUploadProgressClient(client, logger) {
|
|
22
22
|
return client.getDriver({
|
|
23
|
-
name:
|
|
23
|
+
name: "UploadProgress",
|
|
24
24
|
init: (_, wireClientFactory, httpDispatcher) => new progress.ClientProgress(wireClientFactory, httpDispatcher, client, logger),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
function createUploadBlobClient(client, logger) {
|
|
28
28
|
return client.getDriver({
|
|
29
|
-
name:
|
|
29
|
+
name: "UploadBlob",
|
|
30
30
|
init: (_, wireClientFactory, httpDispatcher) => new upload.ClientUpload(wireClientFactory, httpDispatcher, client, logger),
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function createLsFilesClient(client, logger) {
|
|
34
34
|
return client.getDriver({
|
|
35
|
-
name:
|
|
35
|
+
name: "LsFiles",
|
|
36
36
|
init: (_client, wireClientFactory, _httpDispatcher) => new ls_api.ClientLs(wireClientFactory, logger),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.cjs","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from
|
|
1
|
+
{"version":3,"file":"constructors.cjs","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"names":["ClientDownload","ClientLogs","ClientProgress","ClientUpload","ClientLs"],"mappings":";;;;;;;;SAUgB,oBAAoB,CAClC,MAAgB,EAChB,MAAgB,EAChB,gBAA0C,EAAA;IAE1C,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAIA,uBAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC;AAClF,KAAA,CAAC;AACJ;AAEM,SAAU,gBAAgB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACjE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAIC,eAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,CAAC;AAC5D,KAAA,CAAC;AACJ;AAEM,SAAU,0BAA0B,CAAC,MAAgB,EAAE,MAAgB,EAAA;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAIC,uBAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AACxE,KAAA,CAAC;AACJ;AAEM,SAAU,sBAAsB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACvE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,CAAC,CAAW,EAAE,iBAA4C,EAAE,cAA0B,KAC1F,IAAIC,mBAAY,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;AACtE,KAAA,CAAC;AACJ;AAEM,SAAU,mBAAmB,CAAC,MAAgB,EAAE,MAAgB,EAAA;IACpE,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,IAAI,EAAE,CACJ,OAAiB,EACjB,iBAA4C,EAC5C,eAA2B,KACxB,IAAIC,eAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;AAC7C,KAAA,CAAC;AACJ;;;;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { PlClient } from
|
|
2
|
-
import type { MiLogger } from
|
|
3
|
-
import { ClientDownload } from
|
|
4
|
-
import { ClientLogs } from
|
|
5
|
-
import { ClientProgress } from
|
|
6
|
-
import { ClientUpload } from
|
|
7
|
-
import { ClientLs } from
|
|
8
|
-
import type { LocalStorageProjection } from
|
|
1
|
+
import type { PlClient } from "@milaboratories/pl-client";
|
|
2
|
+
import type { MiLogger } from "@milaboratories/ts-helpers";
|
|
3
|
+
import { ClientDownload } from "./download";
|
|
4
|
+
import { ClientLogs } from "./logs";
|
|
5
|
+
import { ClientProgress } from "./progress";
|
|
6
|
+
import { ClientUpload } from "./upload";
|
|
7
|
+
import { ClientLs } from "./ls_api";
|
|
8
|
+
import type { LocalStorageProjection } from "../drivers/types";
|
|
9
9
|
export declare function createDownloadClient(logger: MiLogger, client: PlClient, localProjections: LocalStorageProjection[]): ClientDownload;
|
|
10
10
|
export declare function createLogsClient(client: PlClient, logger: MiLogger): ClientLogs;
|
|
11
11
|
export declare function createUploadProgressClient(client: PlClient, logger: MiLogger): ClientProgress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.d.ts","sourceRoot":"","sources":["../../src/clients/constructors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,sBAAsB,EAAE,kBAO3C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,cA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
|
6
6
|
|
|
7
7
|
function createDownloadClient(logger, client, localProjections) {
|
|
8
8
|
return client.getDriver({
|
|
9
|
-
name:
|
|
9
|
+
name: "DownloadBlob",
|
|
10
10
|
init: (_, wireClientFactory, httpDispatcher) => new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
function createLogsClient(client, logger) {
|
|
14
14
|
return client.getDriver({
|
|
15
|
-
name:
|
|
15
|
+
name: "StreamLogs",
|
|
16
16
|
init: (_, wireClientFactory, httpDispatcher) => new ClientLogs(wireClientFactory, httpDispatcher, logger),
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function createUploadProgressClient(client, logger) {
|
|
20
20
|
return client.getDriver({
|
|
21
|
-
name:
|
|
21
|
+
name: "UploadProgress",
|
|
22
22
|
init: (_, wireClientFactory, httpDispatcher) => new ClientProgress(wireClientFactory, httpDispatcher, client, logger),
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
function createUploadBlobClient(client, logger) {
|
|
26
26
|
return client.getDriver({
|
|
27
|
-
name:
|
|
27
|
+
name: "UploadBlob",
|
|
28
28
|
init: (_, wireClientFactory, httpDispatcher) => new ClientUpload(wireClientFactory, httpDispatcher, client, logger),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
function createLsFilesClient(client, logger) {
|
|
32
32
|
return client.getDriver({
|
|
33
|
-
name:
|
|
33
|
+
name: "LsFiles",
|
|
34
34
|
init: (_client, wireClientFactory, _httpDispatcher) => new ClientLs(wireClientFactory, logger),
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.js","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from
|
|
1
|
+
{"version":3,"file":"constructors.js","sources":["../../src/clients/constructors.ts"],"sourcesContent":["import type { WireClientProviderFactory, PlClient } from \"@milaboratories/pl-client\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport type { Dispatcher } from \"undici\";\nimport { ClientDownload } from \"./download\";\nimport { ClientLogs } from \"./logs\";\nimport { ClientProgress } from \"./progress\";\nimport { ClientUpload } from \"./upload\";\nimport { ClientLs } from \"./ls_api\";\nimport type { LocalStorageProjection } from \"../drivers/types\";\n\nexport function createDownloadClient(\n logger: MiLogger,\n client: PlClient,\n localProjections: LocalStorageProjection[],\n) {\n return client.getDriver({\n name: \"DownloadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientDownload(wireClientFactory, httpDispatcher, logger, localProjections),\n });\n}\n\nexport function createLogsClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"StreamLogs\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientLogs(wireClientFactory, httpDispatcher, logger),\n });\n}\n\nexport function createUploadProgressClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadProgress\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientProgress(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createUploadBlobClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"UploadBlob\",\n init: (_: PlClient, wireClientFactory: WireClientProviderFactory, httpDispatcher: Dispatcher) =>\n new ClientUpload(wireClientFactory, httpDispatcher, client, logger),\n });\n}\n\nexport function createLsFilesClient(client: PlClient, logger: MiLogger) {\n return client.getDriver({\n name: \"LsFiles\",\n init: (\n _client: PlClient,\n wireClientFactory: WireClientProviderFactory,\n _httpDispatcher: Dispatcher,\n ) => new ClientLs(wireClientFactory, logger),\n });\n}\n"],"names":[],"mappings":";;;;;;SAUgB,oBAAoB,CAClC,MAAgB,EAChB,MAAgB,EAChB,gBAA0C,EAAA;IAE1C,OAAO,MAAM,CAAC,SAAS,CAAC;AACtB,QAAA,IAAI,EAA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;AAC7C,KAAA,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crc32c.cjs","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
|
|
1
|
+
{"version":3,"file":"crc32c.cjs","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"],"names":[],"mappings":";;AAAA;AACA;AACA,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAC7B,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU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G,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;IACtD;IACA,OAAO,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC;AACzB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crc32c.d.ts","sourceRoot":"","sources":["../../src/clients/crc32c.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crc32c.d.ts","sourceRoot":"","sources":["../../src/clients/crc32c.ts"],"names":[],"mappings":"AAqQA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,MAAU,UAS/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crc32c.js","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
|
|
1
|
+
{"version":3,"file":"crc32c.js","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"],"names":[],"mappings":"AAAA;AACA;AACA,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAC7B,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,CACX;SAEe,MAAM,CAAC,GAAoB,EAAE,UAAkB,CAAC,EAAA;IAC9D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACzB,QAAA,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACxB;IACA,IAAI,GAAG,GAAG,CAAC,OAAO,GAAG,CAAC,IAAI,EAAE;AAC5B,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,GAAG,GAAG,SAAS,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;IACtD;IACA,OAAO,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC;AACzB;;;;"}
|
|
@@ -49,7 +49,7 @@ class ClientDownload {
|
|
|
49
49
|
this.httpClient = httpClient;
|
|
50
50
|
this.logger = logger;
|
|
51
51
|
this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {
|
|
52
|
-
if (wireConn.type ===
|
|
52
|
+
if (wireConn.type === "grpc") {
|
|
53
53
|
return new protocol_client.DownloadClient(wireConn.Transport);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
@@ -74,15 +74,14 @@ class ClientDownload {
|
|
|
74
74
|
async withBlobContent(info, options, ops, handler) {
|
|
75
75
|
const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);
|
|
76
76
|
const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));
|
|
77
|
-
this.logger.info(`blob ${plClient.stringifyWithResourceId(info)} download started, `
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
this.logger.info(`blob ${plClient.stringifyWithResourceId(info)} download started, ` +
|
|
78
|
+
`url: ${downloadUrl}, ` +
|
|
79
|
+
`range: ${JSON.stringify(ops.range ?? null)}`);
|
|
80
80
|
const timer = helpers.PerfTimer.start();
|
|
81
81
|
const result = isLocal(downloadUrl)
|
|
82
82
|
? await this.withLocalFileContent(downloadUrl, ops, handler)
|
|
83
83
|
: await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);
|
|
84
|
-
this.logger.info(`blob ${plClient.stringifyWithResourceId(info)} download finished, `
|
|
85
|
-
+ `took: ${timer.elapsed()}`);
|
|
84
|
+
this.logger.info(`blob ${plClient.stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`);
|
|
86
85
|
return result;
|
|
87
86
|
}
|
|
88
87
|
async withLocalFileContent(url, ops, handler) {
|
|
@@ -121,7 +120,7 @@ class ClientDownload {
|
|
|
121
120
|
return await client.getDownloadURL({ resourceId: id, isInternalUse: false }, plClient.addRTypeToMetadata(type, withAbort)).response;
|
|
122
121
|
}
|
|
123
122
|
else {
|
|
124
|
-
return (await client.POST(
|
|
123
|
+
return (await client.POST("/v1/get-download-url", {
|
|
125
124
|
body: {
|
|
126
125
|
resourceId: id.toString(),
|
|
127
126
|
isInternalUse: false,
|
|
@@ -133,7 +132,7 @@ class ClientDownload {
|
|
|
133
132
|
}
|
|
134
133
|
function parseLocalUrl(url) {
|
|
135
134
|
const parsed = new URL(url);
|
|
136
|
-
if (parsed.pathname ==
|
|
135
|
+
if (parsed.pathname == "")
|
|
137
136
|
throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);
|
|
138
137
|
return {
|
|
139
138
|
storageId: parsed.host,
|
|
@@ -144,27 +143,27 @@ function getFullPath(storageId, localStorageIdsToRoot, relativePath) {
|
|
|
144
143
|
const root = localStorageIdsToRoot.get(storageId);
|
|
145
144
|
if (root === undefined)
|
|
146
145
|
throw new UnknownStorageError(`Unknown storage location: ${storageId}`);
|
|
147
|
-
if (root ===
|
|
146
|
+
if (root === "")
|
|
148
147
|
return relativePath;
|
|
149
148
|
return path__namespace.join(root, relativePath);
|
|
150
149
|
}
|
|
151
|
-
const storageProtocol =
|
|
150
|
+
const storageProtocol = "storage://";
|
|
152
151
|
function isLocal(url) {
|
|
153
152
|
return url.startsWith(storageProtocol);
|
|
154
153
|
}
|
|
155
154
|
/** Throws when a local URL have invalid scheme. */
|
|
156
155
|
class WrongLocalFileUrl extends Error {
|
|
157
|
-
name =
|
|
156
|
+
name = "WrongLocalFileUrl";
|
|
158
157
|
}
|
|
159
158
|
/** Happens when a storage for a local file can't be found. */
|
|
160
159
|
class UnknownStorageError extends Error {
|
|
161
|
-
name =
|
|
160
|
+
name = "UnknownStorageError";
|
|
162
161
|
}
|
|
163
162
|
function newLocalStorageIdsToRoot(projections) {
|
|
164
163
|
const idToRoot = new Map();
|
|
165
164
|
for (const lp of projections) {
|
|
166
165
|
// Empty string means no prefix, i.e. any file on this machine can be got from the storage.
|
|
167
|
-
if (lp.localPath !==
|
|
166
|
+
if (lp.localPath !== "") {
|
|
168
167
|
validate.validateAbsolute(lp.localPath);
|
|
169
168
|
}
|
|
170
169
|
idToRoot.set(lp.storageId, lp.localPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.cjs","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId, RestAPI, createRTypeRoutingHeader } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport type { DownloadApiPaths, DownloadRestClientType } from '../proto-rest';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === 'grpc') {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (await client.POST('/v1/get-download-url', {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":["ConcurrencyLimitingExecutor","DownloadClient","RestAPI","RemoteFileDownloader","stringifyWithResourceId","PerfTimer","fsp","fs","Readable","addRTypeToMetadata","createRTypeRoutingHeader","path","validateAbsolute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,IAAI;AACH,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAIA,qCAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B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AC,SAAS,KAAK,EAAE,EAAE;AACvB,YAAAC,yBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC;QAChC;QACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"download.cjs","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\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"],"names":["ConcurrencyLimitingExecutor","DownloadClient","RestAPI","RemoteFileDownloader","stringifyWithResourceId","PerfTimer","fsp","fs","Readable","addRTypeToMetadata","createRTypeRoutingHeader","path","validateAbsolute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,IAAI;AACH,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAIA,qCAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;QAItB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,QAAQ,KAAI;AAC1E,YAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE;AAC5B,gBAAA,OAAO,IAAIC,8BAAc,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC/C;iBAAO;gBACL,OAAOC,gBAAO,CAAC,YAAY,CAAmB;AAC5C,oBAAA,WAAW,EA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iLogger } from
|
|
4
|
-
import type { RpcOptions } from
|
|
5
|
-
import type { Dispatcher } from
|
|
6
|
-
import type { LocalStorageProjection } from
|
|
7
|
-
import { type ContentHandler } from
|
|
8
|
-
import { DownloadClient } from
|
|
9
|
-
import type { DownloadRestClientType } from
|
|
10
|
-
import { type GetContentOptions } from
|
|
1
|
+
import type { WireClientProvider, WireClientProviderFactory } from "@milaboratories/pl-client";
|
|
2
|
+
import type { ResourceInfo } from "@milaboratories/pl-tree";
|
|
3
|
+
import type { MiLogger } from "@milaboratories/ts-helpers";
|
|
4
|
+
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
|
|
5
|
+
import type { Dispatcher } from "undici";
|
|
6
|
+
import type { LocalStorageProjection } from "../drivers/types";
|
|
7
|
+
import { type ContentHandler } from "../helpers/download";
|
|
8
|
+
import { DownloadClient } from "../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client";
|
|
9
|
+
import type { DownloadRestClientType } from "../proto-rest";
|
|
10
|
+
import { type GetContentOptions } from "@milaboratories/pl-model-common";
|
|
11
11
|
/** Gets URLs for downloading from pl-core, parses them and reads or downloads
|
|
12
12
|
* files locally and from the web. */
|
|
13
13
|
export declare class ClientDownload {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/clients/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/clients/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAO/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU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gB,aAAa,CAAC,GAAG,EAAE,MAAM;;;EASxC;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1C,YAAY,EAAE,MAAM,UAQrB;AAOD,mDAAmD;AACnD,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,IAAI,SAAuB;CAC5B;AAED,+DAA+D;AAC/D,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,SAAyB;CAC9B;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,sBAAsB,EAAE,uBAW7E"}
|
package/dist/clients/download.js
CHANGED
|
@@ -26,7 +26,7 @@ class ClientDownload {
|
|
|
26
26
|
this.httpClient = httpClient;
|
|
27
27
|
this.logger = logger;
|
|
28
28
|
this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {
|
|
29
|
-
if (wireConn.type ===
|
|
29
|
+
if (wireConn.type === "grpc") {
|
|
30
30
|
return new DownloadClient(wireConn.Transport);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -51,15 +51,14 @@ class ClientDownload {
|
|
|
51
51
|
async withBlobContent(info, options, ops, handler) {
|
|
52
52
|
const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);
|
|
53
53
|
const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));
|
|
54
|
-
this.logger.info(`blob ${stringifyWithResourceId(info)} download started, `
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
this.logger.info(`blob ${stringifyWithResourceId(info)} download started, ` +
|
|
55
|
+
`url: ${downloadUrl}, ` +
|
|
56
|
+
`range: ${JSON.stringify(ops.range ?? null)}`);
|
|
57
57
|
const timer = PerfTimer.start();
|
|
58
58
|
const result = isLocal(downloadUrl)
|
|
59
59
|
? await this.withLocalFileContent(downloadUrl, ops, handler)
|
|
60
60
|
: await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);
|
|
61
|
-
this.logger.info(`blob ${stringifyWithResourceId(info)} download finished, `
|
|
62
|
-
+ `took: ${timer.elapsed()}`);
|
|
61
|
+
this.logger.info(`blob ${stringifyWithResourceId(info)} download finished, ` + `took: ${timer.elapsed()}`);
|
|
63
62
|
return result;
|
|
64
63
|
}
|
|
65
64
|
async withLocalFileContent(url, ops, handler) {
|
|
@@ -98,7 +97,7 @@ class ClientDownload {
|
|
|
98
97
|
return await client.getDownloadURL({ resourceId: id, isInternalUse: false }, addRTypeToMetadata(type, withAbort)).response;
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
|
-
return (await client.POST(
|
|
100
|
+
return (await client.POST("/v1/get-download-url", {
|
|
102
101
|
body: {
|
|
103
102
|
resourceId: id.toString(),
|
|
104
103
|
isInternalUse: false,
|
|
@@ -110,7 +109,7 @@ class ClientDownload {
|
|
|
110
109
|
}
|
|
111
110
|
function parseLocalUrl(url) {
|
|
112
111
|
const parsed = new URL(url);
|
|
113
|
-
if (parsed.pathname ==
|
|
112
|
+
if (parsed.pathname == "")
|
|
114
113
|
throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);
|
|
115
114
|
return {
|
|
116
115
|
storageId: parsed.host,
|
|
@@ -121,27 +120,27 @@ function getFullPath(storageId, localStorageIdsToRoot, relativePath) {
|
|
|
121
120
|
const root = localStorageIdsToRoot.get(storageId);
|
|
122
121
|
if (root === undefined)
|
|
123
122
|
throw new UnknownStorageError(`Unknown storage location: ${storageId}`);
|
|
124
|
-
if (root ===
|
|
123
|
+
if (root === "")
|
|
125
124
|
return relativePath;
|
|
126
125
|
return path.join(root, relativePath);
|
|
127
126
|
}
|
|
128
|
-
const storageProtocol =
|
|
127
|
+
const storageProtocol = "storage://";
|
|
129
128
|
function isLocal(url) {
|
|
130
129
|
return url.startsWith(storageProtocol);
|
|
131
130
|
}
|
|
132
131
|
/** Throws when a local URL have invalid scheme. */
|
|
133
132
|
class WrongLocalFileUrl extends Error {
|
|
134
|
-
name =
|
|
133
|
+
name = "WrongLocalFileUrl";
|
|
135
134
|
}
|
|
136
135
|
/** Happens when a storage for a local file can't be found. */
|
|
137
136
|
class UnknownStorageError extends Error {
|
|
138
|
-
name =
|
|
137
|
+
name = "UnknownStorageError";
|
|
139
138
|
}
|
|
140
139
|
function newLocalStorageIdsToRoot(projections) {
|
|
141
140
|
const idToRoot = new Map();
|
|
142
141
|
for (const lp of projections) {
|
|
143
142
|
// Empty string means no prefix, i.e. any file on this machine can be got from the storage.
|
|
144
|
-
if (lp.localPath !==
|
|
143
|
+
if (lp.localPath !== "") {
|
|
145
144
|
validateAbsolute(lp.localPath);
|
|
146
145
|
}
|
|
147
146
|
idToRoot.set(lp.storageId, lp.localPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from '@milaboratories/pl-client';\nimport { addRTypeToMetadata, stringifyWithResourceId, RestAPI, createRTypeRoutingHeader } from '@milaboratories/pl-client';\nimport type { ResourceInfo } from '@milaboratories/pl-tree';\nimport { PerfTimer } from '@milaboratories/helpers';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { ConcurrencyLimitingExecutor } from '@milaboratories/ts-helpers';\nimport type { RpcOptions } from '@protobuf-ts/runtime-rpc';\nimport * as fs from 'node:fs';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport type { Dispatcher } from 'undici';\nimport type { LocalStorageProjection } from '../drivers/types';\nimport { type ContentHandler, RemoteFileDownloader } from '../helpers/download';\nimport { validateAbsolute } from '../helpers/validate';\nimport type { DownloadAPI_GetDownloadURL_Response } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol';\nimport { DownloadClient } from '../proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client';\nimport type { DownloadApiPaths, DownloadRestClientType } from '../proto-rest';\nimport { type GetContentOptions } from '@milaboratories/pl-model-common';\n\n/** Gets URLs for downloading from pl-core, parses them and reads or downloads\n * files locally and from the web. */\nexport class ClientDownload {\n public readonly wire: WireClientProvider<DownloadRestClientType | DownloadClient>;\n private readonly remoteFileDownloader: RemoteFileDownloader;\n\n /** Helps to find a storage root directory by a storage id from URL scheme. */\n private readonly localStorageIdsToRoot: Map<string, string>;\n\n /** Concurrency limiter for local file reads - limit to 32 parallel reads */\n private readonly localFileReadLimiter = new ConcurrencyLimitingExecutor(32);\n\n constructor(\n wireClientProviderFactory: WireClientProviderFactory,\n public readonly httpClient: Dispatcher,\n public readonly logger: MiLogger,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n ) {\n this.wire = wireClientProviderFactory.createWireClientProvider((wireConn) => {\n if (wireConn.type === 'grpc') {\n return new DownloadClient(wireConn.Transport);\n } else {\n return RestAPI.createClient<DownloadApiPaths>({\n hostAndPort: wireConn.Config.hostAndPort,\n ssl: wireConn.Config.ssl,\n dispatcher: wireConn.Dispatcher,\n middlewares: wireConn.Middlewares,\n });\n }\n });\n this.remoteFileDownloader = new RemoteFileDownloader(httpClient);\n this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);\n }\n\n close() {}\n\n /**\n * Gets a presign URL and downloads the file.\n * An optional range with 2 numbers from what byte and to what byte to download can be provided.\n * @param fromBytes - from byte including this byte\n * @param toBytes - to byte excluding this byte\n */\n async withBlobContent<T>(\n info: ResourceInfo,\n options: RpcOptions | undefined,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, ops.signal);\n\n const remoteHeaders = Object.fromEntries(headers.map(({ name, value }) => [name, value]));\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download started, `\n + `url: ${downloadUrl}, `\n + `range: ${JSON.stringify(ops.range ?? null)}`,\n );\n\n const timer = PerfTimer.start();\n const result = isLocal(downloadUrl)\n ? await this.withLocalFileContent(downloadUrl, ops, handler)\n : await this.remoteFileDownloader.withContent(downloadUrl, remoteHeaders, ops, handler);\n\n this.logger.info(\n `blob ${stringifyWithResourceId(info)} download finished, `\n + `took: ${timer.elapsed()}`,\n );\n return result;\n }\n\n async withLocalFileContent<T>(\n url: string,\n ops: GetContentOptions,\n handler: ContentHandler<T>,\n ): Promise<T> {\n const { storageId, relativePath } = parseLocalUrl(url);\n const fullPath = getFullPath(storageId, this.localStorageIdsToRoot, relativePath);\n\n return await this.localFileReadLimiter.run(async () => {\n const readOps = {\n start: ops.range?.from,\n end: ops.range?.to !== undefined ? ops.range.to - 1 : undefined,\n signal: ops.signal,\n };\n let stream: fs.ReadStream | undefined;\n let handlerSuccess = false;\n\n try {\n const stat = await fsp.stat(fullPath);\n stream = fs.createReadStream(fullPath, readOps);\n const webStream = Readable.toWeb(stream);\n\n const result = await handler(webStream, stat.size);\n handlerSuccess = true;\n return result;\n } catch (error) {\n // Cleanup on error (including handler errors)\n if (!handlerSuccess && stream && !stream.destroyed) {\n stream.destroy();\n }\n throw error;\n }\n });\n }\n\n private async grpcGetDownloadUrl(\n { id, type }: ResourceInfo,\n options?: RpcOptions,\n signal?: AbortSignal,\n ): Promise<DownloadAPI_GetDownloadURL_Response> {\n const withAbort = options ?? {};\n withAbort.abort = signal;\n\n const client = this.wire.get();\n if (client instanceof DownloadClient) {\n return await client.getDownloadURL(\n { resourceId: id, isInternalUse: false },\n addRTypeToMetadata(type, withAbort),\n ).response;\n } else {\n return (await client.POST('/v1/get-download-url', {\n body: {\n resourceId: id.toString(),\n isInternalUse: false,\n },\n headers: { ...createRTypeRoutingHeader(type) },\n })).data!;\n }\n }\n}\n\nexport function parseLocalUrl(url: string) {\n const parsed = new URL(url);\n if (parsed.pathname == '')\n throw new WrongLocalFileUrl(`url for local filepath ${url} does not match url scheme`);\n\n return {\n storageId: parsed.host,\n relativePath: decodeURIComponent(parsed.pathname.slice(1)),\n };\n}\n\nexport function getFullPath(\n storageId: string,\n localStorageIdsToRoot: Map<string, string>,\n relativePath: string,\n) {\n const root = localStorageIdsToRoot.get(storageId);\n if (root === undefined) throw new UnknownStorageError(`Unknown storage location: ${storageId}`);\n\n if (root === '') return relativePath;\n\n return path.join(root, relativePath);\n}\n\nconst storageProtocol = 'storage://';\nfunction isLocal(url: string) {\n return url.startsWith(storageProtocol);\n}\n\n/** Throws when a local URL have invalid scheme. */\nexport class WrongLocalFileUrl extends Error {\n name = 'WrongLocalFileUrl';\n}\n\n/** Happens when a storage for a local file can't be found. */\nexport class UnknownStorageError extends Error {\n name = 'UnknownStorageError';\n}\n\nexport function newLocalStorageIdsToRoot(projections: LocalStorageProjection[]) {\n const idToRoot: Map<string, string> = new Map();\n for (const lp of projections) {\n // Empty string means no prefix, i.e. any file on this machine can be got from the storage.\n if (lp.localPath !== '') {\n validateAbsolute(lp.localPath);\n }\n idToRoot.set(lp.storageId, lp.localPath);\n }\n\n return idToRoot;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA;AACqC;MACxB,cAAc,CAAA;AAYP,IAAA,UAAA;AACA,IAAA,MAAA;AAZF,IAAA,IAAI;AACH,IAAA,oBAAoB;;AAGpB,IAAA,qBAAqB;;AAGrB,IAAA,oBAAoB,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC;AAE3E,IAAA,WAAA,CACE,yBAAoD,EACpC,UAAsB,EACtB,MAAgB;;IAEhC,gBAA0C,EAAA;QAH1B,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;QAItB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,QAAQ,KAAI;AAC1E,YAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE;AAC5B,gBAAA,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC/C;iBAAO;gBACL,OAAO,OAAO,CAAC,YAAY,CAAmB;AAC5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EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC3D;AACH;SAEgB,WAAW,CACzB,SAAiB,EACjB,qBAA0C,EAC1C,YAAoB,EAAA;IAEpB,MAAM,IAAI,GAAG,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC;IACjD,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,mBAAmB,CAAC,6BAA6B,SAAS,CAAA,CAAE,CAAC;IAE/F,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,OAAO,YAAY;IAEpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;AACtC;AAEA,MAAM,eAAe,GAAG,YAAY;AACpC,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,OAAO,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC;AACxC;AAEA;AACM,MAAO,iBAAkB,SAAQ,KAAK,CAAA;IAC1C,IAAI,GAAG,mBAAmB;AAC3B;AAED;AACM,MAAO,mBAAoB,SAAQ,KAAK,CAAA;IAC5C,IAAI,GAAG,qBAAqB;AAC7B;AAEK,SAAU,wBAAwB,CAAC,WAAqC,EAAA;AAC5E,IAAA,MAAM,QAAQ,GAAwB,IAAI,GAAG,EAAE;AAC/C,IAAA,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE;;AAE5B,QAAA,IAAI,EAAE,CAAC,SAAS,KAAK,EAAE,EAAE;AACvB,YAAA,gBAAgB,CAAC,EAAE,CAAC,SAAS,CAAC;QAChC;QACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAC1C;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;"}
|
|
1
|
+
{"version":3,"file":"download.js","sources":["../../src/clients/download.ts"],"sourcesContent":["/* eslint-disable n/no-unsupported-features/node-builtins */\nimport type { WireClientProvider, WireClientProviderFactory } from \"@milaboratories/pl-client\";\nimport {\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 !==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