@milaboratories/pl-drivers 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/constructors.d.ts +4 -3
- package/dist/clients/constructors.d.ts.map +1 -0
- package/dist/clients/download.d.ts +8 -7
- package/dist/clients/download.d.ts.map +1 -0
- package/dist/clients/logs.d.ts +7 -6
- package/dist/clients/logs.d.ts.map +1 -0
- package/dist/clients/ls_api.d.ts +6 -5
- package/dist/clients/ls_api.d.ts.map +1 -0
- package/dist/clients/progress.d.ts +7 -6
- package/dist/clients/progress.d.ts.map +1 -0
- package/dist/clients/upload.d.ts +7 -6
- package/dist/clients/upload.d.ts.map +1 -0
- package/dist/drivers/download_blob/blob_key.d.ts +2 -1
- package/dist/drivers/download_blob/blob_key.d.ts.map +1 -0
- package/dist/drivers/download_blob/download_blob.d.ts +9 -6
- package/dist/drivers/download_blob/download_blob.d.ts.map +1 -0
- package/dist/drivers/download_blob/download_blob_task.d.ts +8 -5
- package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts +1 -0
- package/dist/drivers/download_blob/sparse_cache/cache.d.ts.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/file.d.ts +2 -1
- package/dist/drivers/download_blob/sparse_cache/file.d.ts.map +1 -0
- package/dist/drivers/download_blob/sparse_cache/ranges.d.ts +4 -3
- package/dist/drivers/download_blob/sparse_cache/ranges.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/driver.d.ts +9 -7
- package/dist/drivers/download_blob_url/driver.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/driver_id.d.ts +3 -2
- package/dist/drivers/download_blob_url/driver_id.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/snapshot.d.ts +4 -3
- package/dist/drivers/download_blob_url/snapshot.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/task.d.ts +8 -5
- package/dist/drivers/download_blob_url/task.d.ts.map +1 -0
- package/dist/drivers/download_blob_url/url.d.ts +1 -0
- package/dist/drivers/download_blob_url/url.d.ts.map +1 -0
- package/dist/drivers/download_url/driver.d.ts +6 -4
- package/dist/drivers/download_url/driver.d.ts.map +1 -0
- package/dist/drivers/download_url/task.d.ts +7 -4
- package/dist/drivers/download_url/task.d.ts.map +1 -0
- package/dist/drivers/helpers/download_local_handle.d.ts +5 -2
- package/dist/drivers/helpers/download_local_handle.d.ts.map +1 -0
- package/dist/drivers/helpers/download_remote_handle.d.ts +6 -3
- package/dist/drivers/helpers/download_remote_handle.d.ts.map +1 -0
- package/dist/drivers/helpers/files_cache.d.ts +2 -1
- package/dist/drivers/helpers/files_cache.d.ts.map +1 -0
- package/dist/drivers/helpers/helpers.d.ts +1 -0
- package/dist/drivers/helpers/helpers.d.ts.map +1 -0
- package/dist/drivers/helpers/logs_handle.d.ts +4 -1
- package/dist/drivers/helpers/logs_handle.d.ts.map +1 -0
- package/dist/drivers/helpers/ls_remote_import_handle.d.ts +3 -2
- package/dist/drivers/helpers/ls_remote_import_handle.d.ts.map +1 -0
- package/dist/drivers/helpers/ls_storage_entry.d.ts +2 -1
- package/dist/drivers/helpers/ls_storage_entry.d.ts.map +1 -0
- package/dist/drivers/helpers/polling_ops.d.ts +1 -0
- package/dist/drivers/helpers/polling_ops.d.ts.map +1 -0
- package/dist/drivers/helpers/read_file.d.ts +2 -1
- package/dist/drivers/helpers/read_file.d.ts.map +1 -0
- package/dist/drivers/helpers/test_helpers.d.ts +1 -0
- package/dist/drivers/helpers/test_helpers.d.ts.map +1 -0
- package/dist/drivers/logs.d.ts +7 -5
- package/dist/drivers/logs.d.ts.map +1 -0
- package/dist/drivers/logs_stream.d.ts +7 -5
- package/dist/drivers/logs_stream.d.ts.map +1 -0
- package/dist/drivers/ls.cjs +15 -6
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +5 -4
- package/dist/drivers/ls.d.ts.map +1 -0
- package/dist/drivers/ls.js +14 -5
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/types.d.ts +5 -4
- package/dist/drivers/types.d.ts.map +1 -0
- package/dist/drivers/upload.d.ts +9 -7
- package/dist/drivers/upload.d.ts.map +1 -0
- package/dist/drivers/upload_task.d.ts +9 -6
- package/dist/drivers/upload_task.d.ts.map +1 -0
- package/dist/drivers/urls/url.d.ts +3 -2
- package/dist/drivers/urls/url.d.ts.map +1 -0
- package/dist/drivers/virtual_storages.d.ts +2 -1
- package/dist/drivers/virtual_storages.d.ts.map +1 -0
- package/dist/helpers/download.d.ts +4 -3
- package/dist/helpers/download.d.ts.map +1 -0
- package/dist/helpers/validate.d.ts +1 -0
- package/dist/helpers/validate.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +8 -2
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +9 -4
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +8 -2
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +9 -4
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +9 -3
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +12 -4
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +9 -3
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +14 -4
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +8 -2
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts +15 -4
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts +8 -2
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +58 -4
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +22 -7
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +12 -4
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +7 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +23 -7
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +8 -2
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -0
- package/dist/proto/google/api/http.d.ts +7 -1
- package/dist/proto/google/api/http.d.ts.map +1 -0
- package/dist/proto/google/protobuf/any.d.ts +11 -1
- package/dist/proto/google/protobuf/any.d.ts.map +1 -0
- package/dist/proto/google/protobuf/descriptor.d.ts +7 -1
- package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -0
- package/dist/proto/google/protobuf/duration.d.ts +10 -1
- package/dist/proto/google/protobuf/duration.d.ts.map +1 -0
- package/dist/proto/google/protobuf/empty.d.ts +7 -1
- package/dist/proto/google/protobuf/empty.d.ts.map +1 -0
- package/dist/proto/google/protobuf/struct.d.ts +10 -1
- package/dist/proto/google/protobuf/struct.d.ts.map +1 -0
- package/dist/proto/google/protobuf/timestamp.d.ts +10 -1
- package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -0
- package/dist/proto/google/protobuf/wrappers.d.ts +10 -1
- package/dist/proto/google/protobuf/wrappers.d.ts.map +1 -0
- package/dist/test_env.d.ts +1 -0
- package/dist/test_env.d.ts.map +1 -0
- package/package.json +11 -11
- package/src/drivers/ls.ts +17 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RangeBytes } from '@milaboratories/pl-model-common';
|
|
1
|
+
import type { RangeBytes } from '@milaboratories/pl-model-common';
|
|
2
2
|
/**
|
|
3
3
|
* Reads file content with concurrency limiting and proper error handling.
|
|
4
4
|
* Ensures file descriptors are properly cleaned up even in error cases.
|
|
5
5
|
*/
|
|
6
6
|
export declare function readFileContent(path: string, range?: RangeBytes): Promise<Uint8Array>;
|
|
7
|
+
//# sourceMappingURL=read_file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_file.d.ts","sourceRoot":"","sources":["../../../src/drivers/helpers/read_file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAOlE;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAmB3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_helpers.d.ts","sourceRoot":"","sources":["../../../src/drivers/helpers/test_helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,KAEzB,CAAC"}
|
package/dist/drivers/logs.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ComputableCtx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DownloadDriver } from './download_blob/download_blob';
|
|
1
|
+
import type { ComputableCtx } from '@milaboratories/computable';
|
|
2
|
+
import { Computable } from '@milaboratories/computable';
|
|
3
|
+
import type { PlTreeEntry, ResourceInfo } from '@milaboratories/pl-tree';
|
|
4
|
+
import type { LogsStreamDriver } from './logs_stream';
|
|
6
5
|
import type * as sdk from '@milaboratories/pl-model-common';
|
|
6
|
+
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
7
|
+
import type { DownloadDriver } from './download_blob/download_blob';
|
|
7
8
|
export declare class LogsDriver implements sdk.LogsDriver {
|
|
8
9
|
private readonly logger;
|
|
9
10
|
private readonly logsStreamDriver;
|
|
@@ -30,3 +31,4 @@ export declare class LogsDriver implements sdk.LogsDriver {
|
|
|
30
31
|
lastLines(handle: sdk.AnyLogHandle, lineCount: number, offsetBytes?: number, searchStr?: string): Promise<sdk.StreamingApiResponse>;
|
|
31
32
|
readText(handle: sdk.AnyLogHandle, lineCount: number, offsetBytes?: number, searchStr?: string): Promise<sdk.StreamingApiResponse>;
|
|
32
33
|
}
|
|
34
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","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MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAClH,sBAAsB,CAAC,GAAG,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,GAAG,CAAC,mBAAmB,GAAG,SAAS;IAsC1H;uBACmB;IACnB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,YAAY,GAAG,SAAS,CAAC;IACvF,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,GAAG,GAAG,CAAC,YAAY,GAAG,SAAS;IAkB1E,SAAS,CACb,MAAM,EAAE,GAAG,CAAC,YAAY,EACxB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAM9B,QAAQ,CACZ,MAAM,EAAE,GAAG,CAAC,YAAY,EACxB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;CAKrC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ComputableCtx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { ComputableCtx } from '@milaboratories/computable';
|
|
2
|
+
import { Computable } from '@milaboratories/computable';
|
|
3
|
+
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
4
|
+
import type { ClientLogs } from '../clients/logs';
|
|
5
|
+
import type { PlTreeEntry, ResourceInfo } from '@milaboratories/pl-tree';
|
|
6
6
|
import type * as sdk from '@milaboratories/pl-model-common';
|
|
7
|
+
import type { PollingOps } from './helpers/polling_ops';
|
|
7
8
|
export type LogsStreamDriverOps = PollingOps & {
|
|
8
9
|
/** Max number of concurrent requests to log streaming backend while calculating computable states */
|
|
9
10
|
nConcurrentGetLogs: number;
|
|
@@ -49,3 +50,4 @@ export declare class LogsStreamDriver implements sdk.LogsDriver {
|
|
|
49
50
|
private mainLoop;
|
|
50
51
|
private getAllLogs;
|
|
51
52
|
}
|
|
53
|
+
//# sourceMappingURL=logs_stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs_stream.d.ts","sourceRoot":"","sources":["../../src/drivers/logs_stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,UAAU,EAEX,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIzE,OAAO,KAAK,KAAK,GAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKxD,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAC7C,qGAAqG;IACrG,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,qBAAa,gBAAiB,YAAW,GAAG,CAAC,UAAU;IAWnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAZvB,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyC;IAEvE,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyC;IAEzE,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;gBAG5B,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,UAAU,EACtB,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OAAO,CAAC,aAAa;IAKrB,2BAA2B;IAC3B,OAAO,CAAC,YAAY;IAIpB,yDAAyD;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,iCAAiC;IACjC,OAAO,CAAC,WAAW,CAAwC;YAE7C,QAAQ;IAyBtB,OAAO,CAAC,UAAU;CAKnB"}
|
package/dist/drivers/ls.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var plClient = require('@milaboratories/pl-client');
|
|
4
4
|
var plModelCommon = require('@milaboratories/pl-model-common');
|
|
5
|
-
var path = require('node:path');
|
|
6
5
|
var fsp = require('node:fs/promises');
|
|
6
|
+
var path = require('node:path');
|
|
7
|
+
var constructors = require('../clients/constructors.cjs');
|
|
8
|
+
var validate = require('../helpers/validate.cjs');
|
|
7
9
|
var ls_remote_import_handle = require('./helpers/ls_remote_import_handle.cjs');
|
|
8
10
|
var ls_storage_entry = require('./helpers/ls_storage_entry.cjs');
|
|
9
|
-
var validate = require('../helpers/validate.cjs');
|
|
10
11
|
var virtual_storages = require('./virtual_storages.cjs');
|
|
11
|
-
var constructors = require('../clients/constructors.cjs');
|
|
12
12
|
|
|
13
13
|
function _interopNamespaceDefault(e) {
|
|
14
14
|
var n = Object.create(null);
|
|
@@ -27,8 +27,8 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
return Object.freeze(n);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
31
30
|
var fsp__namespace = /*#__PURE__*/_interopNamespaceDefault(fsp);
|
|
31
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
32
32
|
|
|
33
33
|
class LsDriver {
|
|
34
34
|
logger;
|
|
@@ -55,8 +55,17 @@ class LsDriver {
|
|
|
55
55
|
}
|
|
56
56
|
async getLocalFileContent(file, range) {
|
|
57
57
|
const localPath = await this.tryResolveLocalFileHandle(file);
|
|
58
|
-
if (range)
|
|
59
|
-
|
|
58
|
+
if (range) {
|
|
59
|
+
const fileHandle = await fsp__namespace.open(localPath, 'r');
|
|
60
|
+
try {
|
|
61
|
+
const buffer = Buffer.alloc(range.length);
|
|
62
|
+
const { bytesRead } = await fileHandle.read(buffer, 0, range.length, range.offset);
|
|
63
|
+
return new Uint8Array(buffer.subarray(0, bytesRead));
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
await fileHandle.close();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
60
69
|
return await fsp__namespace.readFile(localPath);
|
|
61
70
|
}
|
|
62
71
|
async getLocalFileSize(file) {
|
package/dist/drivers/ls.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.cjs","sources":["../../src/drivers/ls.ts"],"sourcesContent":["import type { PlClient, ResourceData, ResourceId } from '@milaboratories/pl-client';\nimport { isNotNullResourceId } from '@milaboratories/pl-client';\nimport type { MiLogger, Signer } from '@milaboratories/ts-helpers';\nimport type * as sdk from '@milaboratories/pl-model-common';\nimport type {\n LocalImportFileHandle,\n LsEntry,\n OpenDialogOps,\n OpenMultipleFilesResponse,\n OpenSingleFileResponse,\n TableRange,\n} from '@milaboratories/pl-model-common';\nimport {\n isImportFileHandleIndex,\n} from '@milaboratories/pl-model-common';\nimport type { ClientLs } from '../clients/ls_api';\nimport * as path from 'node:path';\nimport * as fsp from 'node:fs/promises';\nimport {\n createIndexImportHandle,\n createUploadImportHandle,\n parseIndexHandle,\n parseUploadHandle,\n} from './helpers/ls_remote_import_handle';\nimport {\n createLocalStorageHandle,\n createRemoteStorageHandle,\n parseStorageHandle,\n} from './helpers/ls_storage_entry';\nimport type { LocalStorageProjection, VirtualLocalStorageSpec } from './types';\nimport { validateAbsolute } from '../helpers/validate';\nimport { DefaultVirtualLocalStorages } from './virtual_storages';\nimport { createLsFilesClient } from '../clients/constructors';\n\n/**\n * Extends public and safe SDK's driver API with methods used internally in the middle\n * layer and in tests.\n */\nexport interface InternalLsDriver extends sdk.LsDriver {\n /**\n * Given local path, generates well-structured and signed upload handle.\n * To be used in tests and in implementation of the native file selection UI API.\n * */\n getLocalFileHandle(localPath: string): Promise<sdk.LocalImportFileHandle>;\n\n listRemoteFilesWithAdditionalInfo(storage: sdk.StorageHandle, fullPath: string): Promise<ListRemoteFilesResultWithAdditionalInfo>;\n}\n\nexport type ListRemoteFilesResultWithAdditionalInfo = {\n parent?: string;\n entries: LsEntryWithAdditionalInfo[];\n};\n\nexport type LsEntryWithAdditionalInfo = LsEntry & {\n size: number;\n};\n\nexport type OpenFileDialogCallback = (\n multipleFiles: boolean,\n ops?: OpenDialogOps\n) => Promise<undefined | string[]>;\n\nexport class LsDriver implements InternalLsDriver {\n private constructor(\n private readonly logger: MiLogger,\n private readonly lsClient: ClientLs,\n /** Pl storage id, to resource id. The resource id can be used to make LS GRPC calls to. */\n private readonly storageIdToResourceId: Record<string, ResourceId>,\n private readonly signer: Signer,\n /** Virtual storages by name */\n private readonly virtualStoragesMap: Map<string, VirtualLocalStorageSpec>,\n /** Local projections by storageId */\n private readonly localProjectionsMap: Map<string, LocalStorageProjection>,\n private readonly openFileDialogCallback: OpenFileDialogCallback,\n ) {}\n\n public async getLocalFileContent(\n file: LocalImportFileHandle,\n range?: TableRange,\n ): Promise<Uint8Array> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n if (range) throw new Error('Range request not yet supported.');\n return await fsp.readFile(localPath);\n }\n\n public async getLocalFileSize(file: LocalImportFileHandle): Promise<number> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n const stat = await fsp.stat(localPath);\n return stat.size;\n }\n\n public async showOpenMultipleFilesDialog(\n ops?: OpenDialogOps,\n ): Promise<OpenMultipleFilesResponse> {\n const result = await this.openFileDialogCallback(true, ops);\n if (result === undefined) return {};\n return {\n files: await Promise.all(result.map((localPath) => this.getLocalFileHandle(localPath))),\n };\n }\n\n public async showOpenSingleFileDialog(ops?: OpenDialogOps): Promise<OpenSingleFileResponse> {\n const result = await this.openFileDialogCallback(false, ops);\n if (result === undefined) return {};\n return {\n file: await this.getLocalFileHandle(result[0]),\n };\n }\n\n /**\n * Resolves local handle to local file path.\n *\n * @param handle handle to be resolved\n * @private\n */\n private async tryResolveLocalFileHandle(handle: LocalImportFileHandle): Promise<string> {\n if (isImportFileHandleIndex(handle)) {\n const handleData = parseIndexHandle(handle);\n const localProjection = this.localProjectionsMap.get(handleData.storageId);\n if (!localProjection)\n throw new Error(`Storage ${handleData.storageId} is not mounted locally.`);\n return path.join(localProjection.localPath, handleData.path);\n } else {\n const handleData = parseUploadHandle(handle);\n // checking it is a valid local handle from out machine\n this.signer.verify(\n handleData.localPath,\n handleData.pathSignature,\n 'Failed to validate local file handle signature.',\n );\n\n const localPath = handleData.localPath;\n\n const stat = await fsp.stat(localPath, { bigint: true });\n if (String(stat.mtimeMs / 1000n) !== handleData.modificationTime)\n throw new Error('File has changed since the handle was created.');\n\n return localPath;\n }\n }\n\n public async getLocalFileHandle(\n localPath: string,\n ): Promise<sdk.ImportFileHandle & LocalImportFileHandle> {\n validateAbsolute(localPath);\n\n // Checking if local path is directly reachable by pl, because it is in one of the\n // locally mounted storages\n for (const lp of this.localProjectionsMap.values()) {\n // note: empty lp.localPath will match any address\n if (localPath.startsWith(lp.localPath)) {\n // Just in case:\n // > path.relative(\"/a/b\", \"/a/b/c\");\n // 'c'\n const pathWithinStorage\n = lp.localPath === '' ? localPath : path.relative(lp.localPath, localPath);\n return createIndexImportHandle(\n lp.storageId,\n pathWithinStorage,\n ) as sdk.ImportFileHandleIndex & LocalImportFileHandle;\n }\n }\n\n // we get here if none of the local projections matched the path\n\n const stat = await fsp.stat(localPath, { bigint: true });\n return createUploadImportHandle(\n localPath,\n this.signer,\n stat.size,\n stat.mtimeMs / 1000n, // integer division\n ) as sdk.ImportFileHandleUpload & LocalImportFileHandle;\n }\n\n public async getStorageList(): Promise<sdk.StorageEntry[]> {\n const virtualStorages = [...this.virtualStoragesMap.values()].map((s) => ({\n name: s.name,\n handle: createLocalStorageHandle(s.name, s.root),\n initialFullPath: s.initialPath,\n }));\n\n const otherStorages = Object.entries(this.storageIdToResourceId!).map(\n ([storageId, resourceId]) => ({\n name: storageId,\n handle: createRemoteStorageHandle(storageId, resourceId),\n initialFullPath: '', // we don't have any additional information from where to start browsing remote storages\n isInitialPathHome: false,\n }),\n );\n\n // root must be a storage so we can index any file,\n // but for UI it's enough\n // to have local virtual storage on *nix,\n // and local_disk_${drive} on Windows.\n const noRoot = otherStorages.filter((it) => it.name !== 'root');\n\n return [...virtualStorages, ...noRoot];\n }\n\n public async listFiles(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<sdk.ListFilesResult> {\n const storageData = parseStorageHandle(storageHandle);\n\n if (storageData.isRemote) {\n const response = await this.lsClient.list(storageData, fullPath);\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n })),\n };\n }\n\n if (path.sep === '/' && fullPath === '') fullPath = '/';\n\n if (storageData.rootPath === '') {\n validateAbsolute(fullPath);\n }\n const lsRoot = path.isAbsolute(fullPath) ? fullPath : path.join(storageData.rootPath, fullPath);\n\n const entries: LsEntry[] = [];\n for await (const dirent of await fsp.opendir(lsRoot)) {\n if (!dirent.isFile() && !dirent.isDirectory()) continue;\n\n // We cannot use no dirent.fullPath no dirent.parentPath,\n // since the former is deprecated\n // and the later works differently on different versions.\n const absolutePath = path.join(lsRoot, dirent.name);\n\n entries.push({\n type: dirent.isFile() ? 'file' : 'dir',\n name: dirent.name,\n fullPath: absolutePath,\n handle: await this.getLocalFileHandle(absolutePath),\n });\n }\n\n return { entries };\n }\n\n public async listRemoteFilesWithAdditionalInfo(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<ListRemoteFilesResultWithAdditionalInfo> {\n const storageData = parseStorageHandle(storageHandle);\n if (!storageData.isRemote) {\n throw new Error(`Storage ${storageData.name} is not remote`);\n }\n\n const response = await this.lsClient.list(storageData, fullPath);\n\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n size: Number(e.size),\n })),\n };\n }\n\n public async fileToImportHandle(file: sdk.FileLike): Promise<sdk.ImportFileHandle> {\n throw new Error(\n 'Not implemented. This method must be implemented and intercepted in desktop preload script.',\n );\n }\n\n public static async init(\n logger: MiLogger,\n client: PlClient,\n signer: Signer,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n openFileDialogCallback: OpenFileDialogCallback,\n virtualStorages?: VirtualLocalStorageSpec[],\n ): Promise<LsDriver> {\n const lsClient = createLsFilesClient(client, logger);\n\n if (!virtualStorages) virtualStorages = await DefaultVirtualLocalStorages();\n\n // validating inputs\n for (const vp of virtualStorages) validateAbsolute(vp.root);\n for (const lp of localProjections) if (lp.localPath !== '') validateAbsolute(lp.localPath);\n\n // creating indexed maps for quick access\n const virtualStoragesMap = new Map(virtualStorages.map((s) => [s.name, s]));\n const localProjectionsMap = new Map(localProjections.map((s) => [s.storageId, s]));\n\n // validating there is no intersection\n if (\n new Set([...virtualStoragesMap.keys(), ...localProjectionsMap.keys()]).size\n !== virtualStoragesMap.size + localProjectionsMap.size\n )\n throw new Error(\n 'Intersection between local projection storage ids and virtual storages names detected.',\n );\n\n return new LsDriver(\n logger,\n lsClient,\n await doGetAvailableStorageIds(client),\n signer,\n virtualStoragesMap,\n localProjectionsMap,\n openFileDialogCallback,\n );\n }\n}\n\nasync function doGetAvailableStorageIds(client: PlClient): Promise<Record<string, ResourceId>> {\n return client.withReadTx('GetAvailableStorageIds', async (tx) => {\n const lsProviderId = await tx.getResourceByName('LSProvider');\n const provider = await tx.getResourceData(lsProviderId, true);\n\n return providerToStorageIds(provider);\n });\n}\n\nfunction providerToStorageIds(provider: ResourceData) {\n return Object.fromEntries(\n provider.fields\n .filter((f) => f.type == 'Dynamic' && isNotNullResourceId(f.value))\n .map((f) => [f.name.substring('storage/'.length), f.value as ResourceId]),\n );\n}\n"],"names":["fsp","isImportFileHandleIndex","parseIndexHandle","path","parseUploadHandle","validateAbsolute","createIndexImportHandle","createUploadImportHandle","createLocalStorageHandle","createRemoteStorageHandle","parseStorageHandle","createLsFilesClient","DefaultVirtualLocalStorages","isNotNullResourceId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8Da,QAAQ,CAAA;AAEA,IAAA,MAAA;AACA,IAAA,QAAA;AAEA,IAAA,qBAAA;AACA,IAAA,MAAA;AAEA,IAAA,kBAAA;AAEA,IAAA,mBAAA;AACA,IAAA,sBAAA;IAVnB,WAAA,CACmB,MAAgB,EAChB,QAAkB;;AAElB,IAAA,qBAAiD,EACjD,MAAc;;IAEd,kBAAwD;;AAExD,IAAA,mBAAwD,EACxD,sBAA8C,EAAA;QAT9C,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAER,IAAA,CAAA,qBAAqB,GAArB,qBAAqB;QACrB,IAAA,CAAA,MAAM,GAAN,MAAM;QAEN,IAAA,CAAA,kBAAkB,GAAlB,kBAAkB;QAElB,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,sBAAsB,GAAtB,sBAAsB;IACtC;AAEI,IAAA,MAAM,mBAAmB,CAC9B,IAA2B,EAC3B,KAAkB,EAAA;QAElB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC;AAC5D,QAAA,IAAI,KAAK;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC;AAC9D,QAAA,OAAO,MAAMA,cAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;IACtC;IAEO,MAAM,gBAAgB,CAAC,IAA2B,EAAA;QACvD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC;QAC5D,MAAM,IAA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AC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAmB,CAAC,CAAC,CAC5E;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"ls.cjs","sources":["../../src/drivers/ls.ts"],"sourcesContent":["import type { PlClient, ResourceData, ResourceId } from '@milaboratories/pl-client';\nimport { isNotNullResourceId } from '@milaboratories/pl-client';\nimport type * as sdk from '@milaboratories/pl-model-common';\nimport type {\n LocalImportFileHandle,\n LsEntry,\n OpenDialogOps,\n OpenMultipleFilesResponse,\n OpenSingleFileResponse,\n TableRange,\n} from '@milaboratories/pl-model-common';\nimport {\n isImportFileHandleIndex,\n} from '@milaboratories/pl-model-common';\nimport type { MiLogger, Signer } from '@milaboratories/ts-helpers';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { createLsFilesClient } from '../clients/constructors';\nimport type { ClientLs } from '../clients/ls_api';\nimport { validateAbsolute } from '../helpers/validate';\nimport {\n createIndexImportHandle,\n createUploadImportHandle,\n parseIndexHandle,\n parseUploadHandle,\n} from './helpers/ls_remote_import_handle';\nimport {\n createLocalStorageHandle,\n createRemoteStorageHandle,\n parseStorageHandle,\n} from './helpers/ls_storage_entry';\nimport type { LocalStorageProjection, VirtualLocalStorageSpec } from './types';\nimport { DefaultVirtualLocalStorages } from './virtual_storages';\n\n/**\n * Extends public and safe SDK's driver API with methods used internally in the middle\n * layer and in tests.\n */\nexport interface InternalLsDriver extends sdk.LsDriver {\n /**\n * Given local path, generates well-structured and signed upload handle.\n * To be used in tests and in implementation of the native file selection UI API.\n * */\n getLocalFileHandle(localPath: string): Promise<sdk.LocalImportFileHandle>;\n\n listRemoteFilesWithAdditionalInfo(storage: sdk.StorageHandle, fullPath: string): Promise<ListRemoteFilesResultWithAdditionalInfo>;\n}\n\nexport type ListRemoteFilesResultWithAdditionalInfo = {\n parent?: string;\n entries: LsEntryWithAdditionalInfo[];\n};\n\nexport type LsEntryWithAdditionalInfo = LsEntry & {\n size: number;\n};\n\nexport type OpenFileDialogCallback = (\n multipleFiles: boolean,\n ops?: OpenDialogOps\n) => Promise<undefined | string[]>;\n\nexport class LsDriver implements InternalLsDriver {\n private constructor(\n private readonly logger: MiLogger,\n private readonly lsClient: ClientLs,\n /** Pl storage id, to resource id. The resource id can be used to make LS GRPC calls to. */\n private readonly storageIdToResourceId: Record<string, ResourceId>,\n private readonly signer: Signer,\n /** Virtual storages by name */\n private readonly virtualStoragesMap: Map<string, VirtualLocalStorageSpec>,\n /** Local projections by storageId */\n private readonly localProjectionsMap: Map<string, LocalStorageProjection>,\n private readonly openFileDialogCallback: OpenFileDialogCallback,\n ) {}\n\n public async getLocalFileContent(\n file: LocalImportFileHandle,\n range?: TableRange,\n ): Promise<Uint8Array> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n\n if (range) {\n const fileHandle = await fsp.open(localPath, 'r');\n try {\n const buffer = Buffer.alloc(range.length);\n const { bytesRead } = await fileHandle.read(buffer, 0, range.length, range.offset);\n return new Uint8Array(buffer.subarray(0, bytesRead));\n } finally {\n await fileHandle.close();\n }\n }\n\n return await fsp.readFile(localPath);\n }\n\n public async getLocalFileSize(file: LocalImportFileHandle): Promise<number> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n const stat = await fsp.stat(localPath);\n return stat.size;\n }\n\n public async showOpenMultipleFilesDialog(\n ops?: OpenDialogOps,\n ): Promise<OpenMultipleFilesResponse> {\n const result = await this.openFileDialogCallback(true, ops);\n if (result === undefined) return {};\n return {\n files: await Promise.all(result.map((localPath) => this.getLocalFileHandle(localPath))),\n };\n }\n\n public async showOpenSingleFileDialog(ops?: OpenDialogOps): Promise<OpenSingleFileResponse> {\n const result = await this.openFileDialogCallback(false, ops);\n if (result === undefined) return {};\n return {\n file: await this.getLocalFileHandle(result[0]),\n };\n }\n\n /**\n * Resolves local handle to local file path.\n *\n * @param handle handle to be resolved\n * @private\n */\n private async tryResolveLocalFileHandle(handle: LocalImportFileHandle): Promise<string> {\n if (isImportFileHandleIndex(handle)) {\n const handleData = parseIndexHandle(handle);\n const localProjection = this.localProjectionsMap.get(handleData.storageId);\n if (!localProjection)\n throw new Error(`Storage ${handleData.storageId} is not mounted locally.`);\n return path.join(localProjection.localPath, handleData.path);\n } else {\n const handleData = parseUploadHandle(handle);\n // checking it is a valid local handle from out machine\n this.signer.verify(\n handleData.localPath,\n handleData.pathSignature,\n 'Failed to validate local file handle signature.',\n );\n\n const localPath = handleData.localPath;\n\n const stat = await fsp.stat(localPath, { bigint: true });\n if (String(stat.mtimeMs / 1000n) !== handleData.modificationTime)\n throw new Error('File has changed since the handle was created.');\n\n return localPath;\n }\n }\n\n public async getLocalFileHandle(\n localPath: string,\n ): Promise<sdk.ImportFileHandle & LocalImportFileHandle> {\n validateAbsolute(localPath);\n\n // Checking if local path is directly reachable by pl, because it is in one of the\n // locally mounted storages\n for (const lp of this.localProjectionsMap.values()) {\n // note: empty lp.localPath will match any address\n if (localPath.startsWith(lp.localPath)) {\n // Just in case:\n // > path.relative(\"/a/b\", \"/a/b/c\");\n // 'c'\n const pathWithinStorage\n = lp.localPath === '' ? localPath : path.relative(lp.localPath, localPath);\n return createIndexImportHandle(\n lp.storageId,\n pathWithinStorage,\n ) as sdk.ImportFileHandleIndex & LocalImportFileHandle;\n }\n }\n\n // we get here if none of the local projections matched the path\n\n const stat = await fsp.stat(localPath, { bigint: true });\n return createUploadImportHandle(\n localPath,\n this.signer,\n stat.size,\n stat.mtimeMs / 1000n, // integer division\n ) as sdk.ImportFileHandleUpload & LocalImportFileHandle;\n }\n\n public async getStorageList(): Promise<sdk.StorageEntry[]> {\n const virtualStorages = [...this.virtualStoragesMap.values()].map((s) => ({\n name: s.name,\n handle: createLocalStorageHandle(s.name, s.root),\n initialFullPath: s.initialPath,\n }));\n\n const otherStorages = Object.entries(this.storageIdToResourceId!).map(\n ([storageId, resourceId]) => ({\n name: storageId,\n handle: createRemoteStorageHandle(storageId, resourceId),\n initialFullPath: '', // we don't have any additional information from where to start browsing remote storages\n isInitialPathHome: false,\n }),\n );\n\n // root must be a storage so we can index any file,\n // but for UI it's enough\n // to have local virtual storage on *nix,\n // and local_disk_${drive} on Windows.\n const noRoot = otherStorages.filter((it) => it.name !== 'root');\n\n return [...virtualStorages, ...noRoot];\n }\n\n public async listFiles(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<sdk.ListFilesResult> {\n const storageData = parseStorageHandle(storageHandle);\n\n if (storageData.isRemote) {\n const response = await this.lsClient.list(storageData, fullPath);\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n })),\n };\n }\n\n if (path.sep === '/' && fullPath === '') fullPath = '/';\n\n if (storageData.rootPath === '') {\n validateAbsolute(fullPath);\n }\n const lsRoot = path.isAbsolute(fullPath) ? fullPath : path.join(storageData.rootPath, fullPath);\n\n const entries: LsEntry[] = [];\n for await (const dirent of await fsp.opendir(lsRoot)) {\n if (!dirent.isFile() && !dirent.isDirectory()) continue;\n\n // We cannot use no dirent.fullPath no dirent.parentPath,\n // since the former is deprecated\n // and the later works differently on different versions.\n const absolutePath = path.join(lsRoot, dirent.name);\n\n entries.push({\n type: dirent.isFile() ? 'file' : 'dir',\n name: dirent.name,\n fullPath: absolutePath,\n handle: await this.getLocalFileHandle(absolutePath),\n });\n }\n\n return { entries };\n }\n\n public async listRemoteFilesWithAdditionalInfo(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<ListRemoteFilesResultWithAdditionalInfo> {\n const storageData = parseStorageHandle(storageHandle);\n if (!storageData.isRemote) {\n throw new Error(`Storage ${storageData.name} is not remote`);\n }\n\n const response = await this.lsClient.list(storageData, fullPath);\n\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n size: Number(e.size),\n })),\n };\n }\n\n public async fileToImportHandle(file: sdk.FileLike): Promise<sdk.ImportFileHandle> {\n throw new Error(\n 'Not implemented. This method must be implemented and intercepted in desktop preload script.',\n );\n }\n\n public static async init(\n logger: MiLogger,\n client: PlClient,\n signer: Signer,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n openFileDialogCallback: OpenFileDialogCallback,\n virtualStorages?: VirtualLocalStorageSpec[],\n ): Promise<LsDriver> {\n const lsClient = createLsFilesClient(client, logger);\n\n if (!virtualStorages) virtualStorages = await DefaultVirtualLocalStorages();\n\n // validating inputs\n for (const vp of virtualStorages) validateAbsolute(vp.root);\n for (const lp of localProjections) if (lp.localPath !== '') validateAbsolute(lp.localPath);\n\n // creating indexed maps for quick access\n const virtualStoragesMap = new Map(virtualStorages.map((s) => [s.name, s]));\n const localProjectionsMap = new Map(localProjections.map((s) => [s.storageId, s]));\n\n // validating there is no intersection\n if (\n new Set([...virtualStoragesMap.keys(), ...localProjectionsMap.keys()]).size\n !== virtualStoragesMap.size + localProjectionsMap.size\n )\n throw new Error(\n 'Intersection between local projection storage ids and virtual storages names detected.',\n );\n\n return new LsDriver(\n logger,\n lsClient,\n await doGetAvailableStorageIds(client),\n signer,\n virtualStoragesMap,\n localProjectionsMap,\n openFileDialogCallback,\n );\n }\n}\n\nasync function doGetAvailableStorageIds(client: PlClient): Promise<Record<string, ResourceId>> {\n return client.withReadTx('GetAvailableStorageIds', async (tx) => {\n const lsProviderId = await tx.getResourceByName('LSProvider');\n const provider = await tx.getResourceData(lsProviderId, true);\n\n return providerToStorageIds(provider);\n });\n}\n\nfunction providerToStorageIds(provider: ResourceData) {\n return Object.fromEntries(\n provider.fields\n .filter((f) => f.type == 'Dynamic' && isNotNullResourceId(f.value))\n .map((f) => [f.name.substring('storage/'.length), f.value as ResourceId]),\n );\n}\n"],"names":["fsp","isImportFileHandleIndex","parseIndexHandle","path","parseUploadHandle","validateAbsolute","createIndexImportHandle","createUploadImportHandle","createLocalStorageHandle","createRemote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;AAEA,SAAS,oBAAoB,CAAC,QAAsB,EAAA;AAClD,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,QAAQ,CAAC;AACN,SAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,SAAS,IAAIQ,4BAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;SACjE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAmB,CAAC,CAAC,CAC5E;AACH;;;;"}
|
package/dist/drivers/ls.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PlClient } from '@milaboratories/pl-client';
|
|
2
|
-
import { MiLogger, Signer } from '@milaboratories/ts-helpers';
|
|
3
|
-
import { LocalImportFileHandle, LsEntry, OpenDialogOps, OpenMultipleFilesResponse, OpenSingleFileResponse, TableRange } from '@milaboratories/pl-model-common';
|
|
4
|
-
import { LocalStorageProjection, VirtualLocalStorageSpec } from './types';
|
|
1
|
+
import type { PlClient } from '@milaboratories/pl-client';
|
|
5
2
|
import type * as sdk from '@milaboratories/pl-model-common';
|
|
3
|
+
import type { LocalImportFileHandle, LsEntry, OpenDialogOps, OpenMultipleFilesResponse, OpenSingleFileResponse, TableRange } from '@milaboratories/pl-model-common';
|
|
4
|
+
import type { MiLogger, Signer } from '@milaboratories/ts-helpers';
|
|
5
|
+
import type { LocalStorageProjection, VirtualLocalStorageSpec } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Extends public and safe SDK's driver API with methods used internally in the middle
|
|
8
8
|
* layer and in tests.
|
|
@@ -55,3 +55,4 @@ export declare class LsDriver implements InternalLsDriver {
|
|
|
55
55
|
/** Pl storages available locally */
|
|
56
56
|
localProjections: LocalStorageProjection[], openFileDialogCallback: OpenFileDialogCallback, virtualStorages?: VirtualLocalStorageSpec[]): Promise<LsDriver>;
|
|
57
57
|
}
|
|
58
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oC;IACpC,gBAAgB,EAAE,sBAAsB,EAAE,EAC1C,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,CAAC,EAAE,uBAAuB,EAAE,GAC1C,OAAO,CAAC,QAAQ,CAAC;CAgCrB"}
|
package/dist/drivers/ls.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isNotNullResourceId } from '@milaboratories/pl-client';
|
|
2
2
|
import { isImportFileHandleIndex } from '@milaboratories/pl-model-common';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
3
|
import * as fsp from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { createLsFilesClient } from '../clients/constructors.js';
|
|
6
|
+
import { validateAbsolute } from '../helpers/validate.js';
|
|
5
7
|
import { parseIndexHandle, parseUploadHandle, createIndexImportHandle, createUploadImportHandle } from './helpers/ls_remote_import_handle.js';
|
|
6
8
|
import { createLocalStorageHandle, createRemoteStorageHandle, parseStorageHandle } from './helpers/ls_storage_entry.js';
|
|
7
|
-
import { validateAbsolute } from '../helpers/validate.js';
|
|
8
9
|
import { DefaultVirtualLocalStorages } from './virtual_storages.js';
|
|
9
|
-
import { createLsFilesClient } from '../clients/constructors.js';
|
|
10
10
|
|
|
11
11
|
class LsDriver {
|
|
12
12
|
logger;
|
|
@@ -33,8 +33,17 @@ class LsDriver {
|
|
|
33
33
|
}
|
|
34
34
|
async getLocalFileContent(file, range) {
|
|
35
35
|
const localPath = await this.tryResolveLocalFileHandle(file);
|
|
36
|
-
if (range)
|
|
37
|
-
|
|
36
|
+
if (range) {
|
|
37
|
+
const fileHandle = await fsp.open(localPath, 'r');
|
|
38
|
+
try {
|
|
39
|
+
const buffer = Buffer.alloc(range.length);
|
|
40
|
+
const { bytesRead } = await fileHandle.read(buffer, 0, range.length, range.offset);
|
|
41
|
+
return new Uint8Array(buffer.subarray(0, bytesRead));
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await fileHandle.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
38
47
|
return await fsp.readFile(localPath);
|
|
39
48
|
}
|
|
40
49
|
async getLocalFileSize(file) {
|
package/dist/drivers/ls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.js","sources":["../../src/drivers/ls.ts"],"sourcesContent":["import type { PlClient, ResourceData, ResourceId } from '@milaboratories/pl-client';\nimport { isNotNullResourceId } from '@milaboratories/pl-client';\nimport type { MiLogger, Signer } from '@milaboratories/ts-helpers';\nimport type * as sdk from '@milaboratories/pl-model-common';\nimport type {\n LocalImportFileHandle,\n LsEntry,\n OpenDialogOps,\n OpenMultipleFilesResponse,\n OpenSingleFileResponse,\n TableRange,\n} from '@milaboratories/pl-model-common';\nimport {\n isImportFileHandleIndex,\n} from '@milaboratories/pl-model-common';\nimport type { ClientLs } from '../clients/ls_api';\nimport * as path from 'node:path';\nimport * as fsp from 'node:fs/promises';\nimport {\n createIndexImportHandle,\n createUploadImportHandle,\n parseIndexHandle,\n parseUploadHandle,\n} from './helpers/ls_remote_import_handle';\nimport {\n createLocalStorageHandle,\n createRemoteStorageHandle,\n parseStorageHandle,\n} from './helpers/ls_storage_entry';\nimport type { LocalStorageProjection, VirtualLocalStorageSpec } from './types';\nimport { validateAbsolute } from '../helpers/validate';\nimport { DefaultVirtualLocalStorages } from './virtual_storages';\nimport { createLsFilesClient } from '../clients/constructors';\n\n/**\n * Extends public and safe SDK's driver API with methods used internally in the middle\n * layer and in tests.\n */\nexport interface InternalLsDriver extends sdk.LsDriver {\n /**\n * Given local path, generates well-structured and signed upload handle.\n * To be used in tests and in implementation of the native file selection UI API.\n * */\n getLocalFileHandle(localPath: string): Promise<sdk.LocalImportFileHandle>;\n\n listRemoteFilesWithAdditionalInfo(storage: sdk.StorageHandle, fullPath: string): Promise<ListRemoteFilesResultWithAdditionalInfo>;\n}\n\nexport type ListRemoteFilesResultWithAdditionalInfo = {\n parent?: string;\n entries: LsEntryWithAdditionalInfo[];\n};\n\nexport type LsEntryWithAdditionalInfo = LsEntry & {\n size: number;\n};\n\nexport type OpenFileDialogCallback = (\n multipleFiles: boolean,\n ops?: OpenDialogOps\n) => Promise<undefined | string[]>;\n\nexport class LsDriver implements InternalLsDriver {\n private constructor(\n private readonly logger: MiLogger,\n private readonly lsClient: ClientLs,\n /** Pl storage id, to resource id. The resource id can be used to make LS GRPC calls to. */\n private readonly storageIdToResourceId: Record<string, ResourceId>,\n private readonly signer: Signer,\n /** Virtual storages by name */\n private readonly virtualStoragesMap: Map<string, VirtualLocalStorageSpec>,\n /** Local projections by storageId */\n private readonly localProjectionsMap: Map<string, LocalStorageProjection>,\n private readonly openFileDialogCallback: OpenFileDialogCallback,\n ) {}\n\n public async getLocalFileContent(\n file: LocalImportFileHandle,\n range?: TableRange,\n ): Promise<Uint8Array> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n if (range) throw new Error('Range request not yet supported.');\n return await fsp.readFile(localPath);\n }\n\n public async getLocalFileSize(file: LocalImportFileHandle): Promise<number> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n const stat = await fsp.stat(localPath);\n return stat.size;\n }\n\n public async showOpenMultipleFilesDialog(\n ops?: OpenDialogOps,\n ): Promise<OpenMultipleFilesResponse> {\n const result = await this.openFileDialogCallback(true, ops);\n if (result === undefined) return {};\n return {\n files: await Promise.all(result.map((localPath) => this.getLocalFileHandle(localPath))),\n };\n }\n\n public async showOpenSingleFileDialog(ops?: OpenDialogOps): Promise<OpenSingleFileResponse> {\n const result = await this.openFileDialogCallback(false, ops);\n if (result === undefined) return {};\n return {\n file: await this.getLocalFileHandle(result[0]),\n };\n }\n\n /**\n * Resolves local handle to local file path.\n *\n * @param handle handle to be resolved\n * @private\n */\n private async tryResolveLocalFileHandle(handle: LocalImportFileHandle): Promise<string> {\n if (isImportFileHandleIndex(handle)) {\n const handleData = parseIndexHandle(handle);\n const localProjection = this.localProjectionsMap.get(handleData.storageId);\n if (!localProjection)\n throw new Error(`Storage ${handleData.storageId} is not mounted locally.`);\n return path.join(localProjection.localPath, handleData.path);\n } else {\n const handleData = parseUploadHandle(handle);\n // checking it is a valid local handle from out machine\n this.signer.verify(\n handleData.localPath,\n handleData.pathSignature,\n 'Failed to validate local file handle signature.',\n );\n\n const localPath = handleData.localPath;\n\n const stat = await fsp.stat(localPath, { bigint: true });\n if (String(stat.mtimeMs / 1000n) !== handleData.modificationTime)\n throw new Error('File has changed since the handle was created.');\n\n return localPath;\n }\n }\n\n public async getLocalFileHandle(\n localPath: string,\n ): Promise<sdk.ImportFileHandle & LocalImportFileHandle> {\n validateAbsolute(localPath);\n\n // Checking if local path is directly reachable by pl, because it is in one of the\n // locally mounted storages\n for (const lp of this.localProjectionsMap.values()) {\n // note: empty lp.localPath will match any address\n if (localPath.startsWith(lp.localPath)) {\n // Just in case:\n // > path.relative(\"/a/b\", \"/a/b/c\");\n // 'c'\n const pathWithinStorage\n = lp.localPath === '' ? localPath : path.relative(lp.localPath, localPath);\n return createIndexImportHandle(\n lp.storageId,\n pathWithinStorage,\n ) as sdk.ImportFileHandleIndex & LocalImportFileHandle;\n }\n }\n\n // we get here if none of the local projections matched the path\n\n const stat = await fsp.stat(localPath, { bigint: true });\n return createUploadImportHandle(\n localPath,\n this.signer,\n stat.size,\n stat.mtimeMs / 1000n, // integer division\n ) as sdk.ImportFileHandleUpload & LocalImportFileHandle;\n }\n\n public async getStorageList(): Promise<sdk.StorageEntry[]> {\n const virtualStorages = [...this.virtualStoragesMap.values()].map((s) => ({\n name: s.name,\n handle: createLocalStorageHandle(s.name, s.root),\n initialFullPath: s.initialPath,\n }));\n\n const otherStorages = Object.entries(this.storageIdToResourceId!).map(\n ([storageId, resourceId]) => ({\n name: storageId,\n handle: createRemoteStorageHandle(storageId, resourceId),\n initialFullPath: '', // we don't have any additional information from where to start browsing remote storages\n isInitialPathHome: false,\n }),\n );\n\n // root must be a storage so we can index any file,\n // but for UI it's enough\n // to have local virtual storage on *nix,\n // and local_disk_${drive} on Windows.\n const noRoot = otherStorages.filter((it) => it.name !== 'root');\n\n return [...virtualStorages, ...noRoot];\n }\n\n public async listFiles(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<sdk.ListFilesResult> {\n const storageData = parseStorageHandle(storageHandle);\n\n if (storageData.isRemote) {\n const response = await this.lsClient.list(storageData, fullPath);\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n })),\n };\n }\n\n if (path.sep === '/' && fullPath === '') fullPath = '/';\n\n if (storageData.rootPath === '') {\n validateAbsolute(fullPath);\n }\n const lsRoot = path.isAbsolute(fullPath) ? fullPath : path.join(storageData.rootPath, fullPath);\n\n const entries: LsEntry[] = [];\n for await (const dirent of await fsp.opendir(lsRoot)) {\n if (!dirent.isFile() && !dirent.isDirectory()) continue;\n\n // We cannot use no dirent.fullPath no dirent.parentPath,\n // since the former is deprecated\n // and the later works differently on different versions.\n const absolutePath = path.join(lsRoot, dirent.name);\n\n entries.push({\n type: dirent.isFile() ? 'file' : 'dir',\n name: dirent.name,\n fullPath: absolutePath,\n handle: await this.getLocalFileHandle(absolutePath),\n });\n }\n\n return { entries };\n }\n\n public async listRemoteFilesWithAdditionalInfo(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<ListRemoteFilesResultWithAdditionalInfo> {\n const storageData = parseStorageHandle(storageHandle);\n if (!storageData.isRemote) {\n throw new Error(`Storage ${storageData.name} is not remote`);\n }\n\n const response = await this.lsClient.list(storageData, fullPath);\n\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n size: Number(e.size),\n })),\n };\n }\n\n public async fileToImportHandle(file: sdk.FileLike): Promise<sdk.ImportFileHandle> {\n throw new Error(\n 'Not implemented. This method must be implemented and intercepted in desktop preload script.',\n );\n }\n\n public static async init(\n logger: MiLogger,\n client: PlClient,\n signer: Signer,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n openFileDialogCallback: OpenFileDialogCallback,\n virtualStorages?: VirtualLocalStorageSpec[],\n ): Promise<LsDriver> {\n const lsClient = createLsFilesClient(client, logger);\n\n if (!virtualStorages) virtualStorages = await DefaultVirtualLocalStorages();\n\n // validating inputs\n for (const vp of virtualStorages) validateAbsolute(vp.root);\n for (const lp of localProjections) if (lp.localPath !== '') validateAbsolute(lp.localPath);\n\n // creating indexed maps for quick access\n const virtualStoragesMap = new Map(virtualStorages.map((s) => [s.name, s]));\n const localProjectionsMap = new Map(localProjections.map((s) => [s.storageId, s]));\n\n // validating there is no intersection\n if (\n new Set([...virtualStoragesMap.keys(), ...localProjectionsMap.keys()]).size\n !== virtualStoragesMap.size + localProjectionsMap.size\n )\n throw new Error(\n 'Intersection between local projection storage ids and virtual storages names detected.',\n );\n\n return new LsDriver(\n logger,\n lsClient,\n await doGetAvailableStorageIds(client),\n signer,\n virtualStoragesMap,\n localProjectionsMap,\n openFileDialogCallback,\n );\n }\n}\n\nasync function doGetAvailableStorageIds(client: PlClient): Promise<Record<string, ResourceId>> {\n return client.withReadTx('GetAvailableStorageIds', async (tx) => {\n const lsProviderId = await tx.getResourceByName('LSProvider');\n const provider = await tx.getResourceData(lsProviderId, true);\n\n return providerToStorageIds(provider);\n });\n}\n\nfunction providerToStorageIds(provider: ResourceData) {\n return Object.fromEntries(\n provider.fields\n .filter((f) => f.type == 'Dynamic' && isNotNullResourceId(f.value))\n .map((f) => [f.name.substring('storage/'.length), f.value as ResourceId]),\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;MA8Da,QAAQ,CAAA;AAEA,IAAA,MAAA;AACA,IAAA,QAAA;AAEA,IAAA,qBAAA;AACA,IAAA,MAAA;AAEA,IAAA,kBAAA;AAEA,IAAA,mBAAA;AACA,IAAA,sBAAA;IAVnB,WAAA,CACmB,MAAgB,EAChB,QAAkB;;AAElB,IAAA,qBAAiD,EACj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,MAAM,EACN,QAAQ,EACR,MAAM,wBAAwB,CAAC,MAAM,CAAC,EACtC,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,CACvB;IACH;AACD;AAED,eAAe,wBAAwB,CAAC,MAAgB,EAAA;IACtD,OAAO,MAAM,CAAC,UAAU,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAI;QAC9D,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC;AAE7D,QAAA,OAAO,oBAAoB,CAAC,QAAQ,CAAC;AACvC,IAAA,CAAC,CAAC;AACJ;AAEA,SAAS,oBAAoB,CAAC,QAAsB,EAAA;AAClD,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,QAAQ,CAAC;AACN,SAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,SAAS,IAAI,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;SACjE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAmB,CAAC,CAAC,CAC5E;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"ls.js","sources":["../../src/drivers/ls.ts"],"sourcesContent":["import type { PlClient, ResourceData, ResourceId } from '@milaboratories/pl-client';\nimport { isNotNullResourceId } from '@milaboratories/pl-client';\nimport type * as sdk from '@milaboratories/pl-model-common';\nimport type {\n LocalImportFileHandle,\n LsEntry,\n OpenDialogOps,\n OpenMultipleFilesResponse,\n OpenSingleFileResponse,\n TableRange,\n} from '@milaboratories/pl-model-common';\nimport {\n isImportFileHandleIndex,\n} from '@milaboratories/pl-model-common';\nimport type { MiLogger, Signer } from '@milaboratories/ts-helpers';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { createLsFilesClient } from '../clients/constructors';\nimport type { ClientLs } from '../clients/ls_api';\nimport { validateAbsolute } from '../helpers/validate';\nimport {\n createIndexImportHandle,\n createUploadImportHandle,\n parseIndexHandle,\n parseUploadHandle,\n} from './helpers/ls_remote_import_handle';\nimport {\n createLocalStorageHandle,\n createRemoteStorageHandle,\n parseStorageHandle,\n} from './helpers/ls_storage_entry';\nimport type { LocalStorageProjection, VirtualLocalStorageSpec } from './types';\nimport { DefaultVirtualLocalStorages } from './virtual_storages';\n\n/**\n * Extends public and safe SDK's driver API with methods used internally in the middle\n * layer and in tests.\n */\nexport interface InternalLsDriver extends sdk.LsDriver {\n /**\n * Given local path, generates well-structured and signed upload handle.\n * To be used in tests and in implementation of the native file selection UI API.\n * */\n getLocalFileHandle(localPath: string): Promise<sdk.LocalImportFileHandle>;\n\n listRemoteFilesWithAdditionalInfo(storage: sdk.StorageHandle, fullPath: string): Promise<ListRemoteFilesResultWithAdditionalInfo>;\n}\n\nexport type ListRemoteFilesResultWithAdditionalInfo = {\n parent?: string;\n entries: LsEntryWithAdditionalInfo[];\n};\n\nexport type LsEntryWithAdditionalInfo = LsEntry & {\n size: number;\n};\n\nexport type OpenFileDialogCallback = (\n multipleFiles: boolean,\n ops?: OpenDialogOps\n) => Promise<undefined | string[]>;\n\nexport class LsDriver implements InternalLsDriver {\n private constructor(\n private readonly logger: MiLogger,\n private readonly lsClient: ClientLs,\n /** Pl storage id, to resource id. The resource id can be used to make LS GRPC calls to. */\n private readonly storageIdToResourceId: Record<string, ResourceId>,\n private readonly signer: Signer,\n /** Virtual storages by name */\n private readonly virtualStoragesMap: Map<string, VirtualLocalStorageSpec>,\n /** Local projections by storageId */\n private readonly localProjectionsMap: Map<string, LocalStorageProjection>,\n private readonly openFileDialogCallback: OpenFileDialogCallback,\n ) {}\n\n public async getLocalFileContent(\n file: LocalImportFileHandle,\n range?: TableRange,\n ): Promise<Uint8Array> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n\n if (range) {\n const fileHandle = await fsp.open(localPath, 'r');\n try {\n const buffer = Buffer.alloc(range.length);\n const { bytesRead } = await fileHandle.read(buffer, 0, range.length, range.offset);\n return new Uint8Array(buffer.subarray(0, bytesRead));\n } finally {\n await fileHandle.close();\n }\n }\n\n return await fsp.readFile(localPath);\n }\n\n public async getLocalFileSize(file: LocalImportFileHandle): Promise<number> {\n const localPath = await this.tryResolveLocalFileHandle(file);\n const stat = await fsp.stat(localPath);\n return stat.size;\n }\n\n public async showOpenMultipleFilesDialog(\n ops?: OpenDialogOps,\n ): Promise<OpenMultipleFilesResponse> {\n const result = await this.openFileDialogCallback(true, ops);\n if (result === undefined) return {};\n return {\n files: await Promise.all(result.map((localPath) => this.getLocalFileHandle(localPath))),\n };\n }\n\n public async showOpenSingleFileDialog(ops?: OpenDialogOps): Promise<OpenSingleFileResponse> {\n const result = await this.openFileDialogCallback(false, ops);\n if (result === undefined) return {};\n return {\n file: await this.getLocalFileHandle(result[0]),\n };\n }\n\n /**\n * Resolves local handle to local file path.\n *\n * @param handle handle to be resolved\n * @private\n */\n private async tryResolveLocalFileHandle(handle: LocalImportFileHandle): Promise<string> {\n if (isImportFileHandleIndex(handle)) {\n const handleData = parseIndexHandle(handle);\n const localProjection = this.localProjectionsMap.get(handleData.storageId);\n if (!localProjection)\n throw new Error(`Storage ${handleData.storageId} is not mounted locally.`);\n return path.join(localProjection.localPath, handleData.path);\n } else {\n const handleData = parseUploadHandle(handle);\n // checking it is a valid local handle from out machine\n this.signer.verify(\n handleData.localPath,\n handleData.pathSignature,\n 'Failed to validate local file handle signature.',\n );\n\n const localPath = handleData.localPath;\n\n const stat = await fsp.stat(localPath, { bigint: true });\n if (String(stat.mtimeMs / 1000n) !== handleData.modificationTime)\n throw new Error('File has changed since the handle was created.');\n\n return localPath;\n }\n }\n\n public async getLocalFileHandle(\n localPath: string,\n ): Promise<sdk.ImportFileHandle & LocalImportFileHandle> {\n validateAbsolute(localPath);\n\n // Checking if local path is directly reachable by pl, because it is in one of the\n // locally mounted storages\n for (const lp of this.localProjectionsMap.values()) {\n // note: empty lp.localPath will match any address\n if (localPath.startsWith(lp.localPath)) {\n // Just in case:\n // > path.relative(\"/a/b\", \"/a/b/c\");\n // 'c'\n const pathWithinStorage\n = lp.localPath === '' ? localPath : path.relative(lp.localPath, localPath);\n return createIndexImportHandle(\n lp.storageId,\n pathWithinStorage,\n ) as sdk.ImportFileHandleIndex & LocalImportFileHandle;\n }\n }\n\n // we get here if none of the local projections matched the path\n\n const stat = await fsp.stat(localPath, { bigint: true });\n return createUploadImportHandle(\n localPath,\n this.signer,\n stat.size,\n stat.mtimeMs / 1000n, // integer division\n ) as sdk.ImportFileHandleUpload & LocalImportFileHandle;\n }\n\n public async getStorageList(): Promise<sdk.StorageEntry[]> {\n const virtualStorages = [...this.virtualStoragesMap.values()].map((s) => ({\n name: s.name,\n handle: createLocalStorageHandle(s.name, s.root),\n initialFullPath: s.initialPath,\n }));\n\n const otherStorages = Object.entries(this.storageIdToResourceId!).map(\n ([storageId, resourceId]) => ({\n name: storageId,\n handle: createRemoteStorageHandle(storageId, resourceId),\n initialFullPath: '', // we don't have any additional information from where to start browsing remote storages\n isInitialPathHome: false,\n }),\n );\n\n // root must be a storage so we can index any file,\n // but for UI it's enough\n // to have local virtual storage on *nix,\n // and local_disk_${drive} on Windows.\n const noRoot = otherStorages.filter((it) => it.name !== 'root');\n\n return [...virtualStorages, ...noRoot];\n }\n\n public async listFiles(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<sdk.ListFilesResult> {\n const storageData = parseStorageHandle(storageHandle);\n\n if (storageData.isRemote) {\n const response = await this.lsClient.list(storageData, fullPath);\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n })),\n };\n }\n\n if (path.sep === '/' && fullPath === '') fullPath = '/';\n\n if (storageData.rootPath === '') {\n validateAbsolute(fullPath);\n }\n const lsRoot = path.isAbsolute(fullPath) ? fullPath : path.join(storageData.rootPath, fullPath);\n\n const entries: LsEntry[] = [];\n for await (const dirent of await fsp.opendir(lsRoot)) {\n if (!dirent.isFile() && !dirent.isDirectory()) continue;\n\n // We cannot use no dirent.fullPath no dirent.parentPath,\n // since the former is deprecated\n // and the later works differently on different versions.\n const absolutePath = path.join(lsRoot, dirent.name);\n\n entries.push({\n type: dirent.isFile() ? 'file' : 'dir',\n name: dirent.name,\n fullPath: absolutePath,\n handle: await this.getLocalFileHandle(absolutePath),\n });\n }\n\n return { entries };\n }\n\n public async listRemoteFilesWithAdditionalInfo(\n storageHandle: sdk.StorageHandle,\n fullPath: string,\n ): Promise<ListRemoteFilesResultWithAdditionalInfo> {\n const storageData = parseStorageHandle(storageHandle);\n if (!storageData.isRemote) {\n throw new Error(`Storage ${storageData.name} is not remote`);\n }\n\n const response = await this.lsClient.list(storageData, fullPath);\n\n return {\n entries: response.items.map((e) => ({\n type: e.isDir ? 'dir' : 'file',\n name: e.name,\n fullPath: e.fullName,\n handle: createIndexImportHandle(storageData.name, e.fullName),\n size: Number(e.size),\n })),\n };\n }\n\n public async fileToImportHandle(file: sdk.FileLike): Promise<sdk.ImportFileHandle> {\n throw new Error(\n 'Not implemented. This method must be implemented and intercepted in desktop preload script.',\n );\n }\n\n public static async init(\n logger: MiLogger,\n client: PlClient,\n signer: Signer,\n /** Pl storages available locally */\n localProjections: LocalStorageProjection[],\n openFileDialogCallback: OpenFileDialogCallback,\n virtualStorages?: VirtualLocalStorageSpec[],\n ): Promise<LsDriver> {\n const lsClient = createLsFilesClient(client, logger);\n\n if (!virtualStorages) virtualStorages = await DefaultVirtualLocalStorages();\n\n // validating inputs\n for (const vp of virtualStorages) validateAbsolute(vp.root);\n for (const lp of localProjections) if (lp.localPath !== '') validateAbsolute(lp.localPath);\n\n // creating indexed maps for quick access\n const virtualStoragesMap = new Map(virtualStorages.map((s) => [s.name, s]));\n const localProjectionsMap = new Map(localProjections.map((s) => [s.storageId, s]));\n\n // validating there is no intersection\n if (\n new Set([...virtualStoragesMap.keys(), ...localProjectionsMap.keys()]).size\n !== virtualStoragesMap.size + localProjectionsMap.size\n )\n throw new Error(\n 'Intersection between local projection storage ids and virtual storages names detected.',\n );\n\n return new LsDriver(\n logger,\n lsClient,\n await doGetAvailableStorageIds(client),\n signer,\n virtualStoragesMap,\n localProjectionsMap,\n openFileDialogCallback,\n );\n }\n}\n\nasync function doGetAvailableStorageIds(client: PlClient): Promise<Record<string, ResourceId>> {\n return client.withReadTx('GetAvailableStorageIds', async (tx) => {\n const lsProviderId = await tx.getResourceByName('LSProvider');\n const provider = await tx.getResourceData(lsProviderId, true);\n\n return providerToStorageIds(provider);\n });\n}\n\nfunction providerToStorageIds(provider: ResourceData) {\n return Object.fromEntries(\n provider.fields\n .filter((f) => f.type == 'Dynamic' && isNotNullResourceId(f.value))\n .map((f) => [f.name.substring('storage/'.length), f.value as ResourceId]),\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;MA8Da,QAAQ,CAAA;AAEA,IAAA,MAAA;AACA,IAAA,QAAA;AAEA,IAAA,qBAAA;AACA,IAAA,MAAA;AAEA,IAAA,kBAAA;AAEA,IAAA,mBAAA;AACA,IAAA,sBAAA;IAVnB,WAAA,CACmB,MAAgB,EAChB,QAAkB;;AAElB,IAAA,qBAAiD,EACjD,MAAc;;IAEd,kBAAwD;;AAExD,IAAA,mBAAwD,EACxD,sBAA8C,EAAA;QAT9C,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAER,IAAA,CAAA,qBAAqB,GAArB,qBAAqB;QACrB,IAAA,CAAA,MAAM,GAAN,MAAM;QAEN,IAAA,CAAA,kBAAkB,GAAlB,kBAAkB;QAElB,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,sBAAsB,GAAtB,sBAAsB;IACtC;AAEI,IAAA,MAAM,mBAAmB,CAC9B,IAA2B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H,OAAO,IAAI,QAAQ,CACjB,MAAM,EACN,QAAQ,EACR,MAAM,wBAAwB,CAAC,MAAM,CAAC,EACtC,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,CACvB;IACH;AACD;AAED,eAAe,wBAAwB,CAAC,MAAgB,EAAA;IACtD,OAAO,MAAM,CAAC,UAAU,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAI;QAC9D,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC;AAE7D,QAAA,OAAO,oBAAoB,CAAC,QAAQ,CAAC;AACvC,IAAA,CAAC,CAAC;AACJ;AAEA,SAAS,oBAAoB,CAAC,QAAsB,EAAA;AAClD,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,QAAQ,CAAC;AACN,SAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,SAAS,IAAI,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;SACjE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAmB,CAAC,CAAC,CAC5E;AACH;;;;"}
|
package/dist/drivers/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { InferSnapshot } from '@milaboratories/pl-tree';
|
|
2
|
+
import type { InferSnapshot } from '@milaboratories/pl-tree';
|
|
3
3
|
import { RangeBytes } from '@milaboratories/pl-model-common';
|
|
4
4
|
/** ResourceSnapshot that can be passed to OnDemandBlob */
|
|
5
|
-
export declare const OnDemandBlobResourceSnapshot: import(
|
|
5
|
+
export declare const OnDemandBlobResourceSnapshot: import("@milaboratories/pl-tree").ResourceSnapshotSchema<undefined, undefined, {
|
|
6
6
|
readonly 'ctl/file/blobInfo': z.ZodObject<{
|
|
7
7
|
sizeBytes: z.ZodNumber;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -81,7 +81,7 @@ export declare const ImportFileHandleData: z.ZodUnion<[z.ZodObject<{
|
|
|
81
81
|
export type ImportFileHandleData = z.infer<typeof ImportFileHandleData>;
|
|
82
82
|
/** Options from BlobUpload resource that have to be passed to getProgress. */
|
|
83
83
|
/** ResourceSnapshot that can be passed to GetProgressID */
|
|
84
|
-
export declare const UploadResourceSnapshot: import(
|
|
84
|
+
export declare const UploadResourceSnapshot: import("@milaboratories/pl-tree").ResourceSnapshotSchema<z.ZodObject<{
|
|
85
85
|
/** Local file path, to take data for upload */
|
|
86
86
|
localPath: z.ZodString;
|
|
87
87
|
/** Path signature, to check this data was generated by us */
|
|
@@ -103,7 +103,7 @@ export declare const UploadResourceSnapshot: import('@milaboratories/pl-tree').R
|
|
|
103
103
|
}>, {
|
|
104
104
|
readonly blob: false;
|
|
105
105
|
}, undefined>;
|
|
106
|
-
export declare const IndexResourceSnapshot: import(
|
|
106
|
+
export declare const IndexResourceSnapshot: import("@milaboratories/pl-tree").ResourceSnapshotSchema<undefined, {
|
|
107
107
|
readonly incarnation: false;
|
|
108
108
|
}, undefined>;
|
|
109
109
|
export type UploadResourceSnapshot = InferSnapshot<typeof UploadResourceSnapshot>;
|
|
@@ -130,3 +130,4 @@ export type VirtualLocalStorageSpec = {
|
|
|
130
130
|
/** Used as hint to UI controls to, set as initial path during browsing */
|
|
131
131
|
readonly initialPath: string;
|
|
132
132
|
};
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/drivers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CA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;AAEhF,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,GAAG,qBAAqB,CAAC;AAMpF,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG;IACnC,oBAAoB;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;;SAKK;IACL,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,4FAA4F;AAC5F,MAAM,MAAM,uBAAuB,GAAG;IACpC,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC"}
|
package/dist/drivers/upload.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ComputableCtx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ClientUpload } from '../clients/upload';
|
|
5
|
-
import { PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor } from '@milaboratories/pl-tree';
|
|
6
|
-
import { PollingOps } from './helpers/polling_ops';
|
|
7
|
-
import { ImportResourceSnapshot } from './types';
|
|
1
|
+
import type { ComputableCtx } from '@milaboratories/computable';
|
|
2
|
+
import { Computable } from '@milaboratories/computable';
|
|
3
|
+
import type { MiLogger, Signer } from '@milaboratories/ts-helpers';
|
|
8
4
|
import type * as sdk from '@milaboratories/pl-model-common';
|
|
5
|
+
import type { ClientProgress } from '../clients/progress';
|
|
6
|
+
import type { ClientUpload } from '../clients/upload';
|
|
7
|
+
import type { PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor } from '@milaboratories/pl-tree';
|
|
8
|
+
import type { PollingOps } from './helpers/polling_ops';
|
|
9
|
+
import type { ImportResourceSnapshot } from './types';
|
|
9
10
|
export declare function makeBlobImportSnapshot(entryOrAccessor: PlTreeEntry | PlTreeNodeAccessor | PlTreeEntryAccessor, ctx: ComputableCtx): ImportResourceSnapshot;
|
|
10
11
|
export type UploadDriverOps = PollingOps & {
|
|
11
12
|
/** How much parts of a file can be multipart-uploaded to S3 at once. */
|
|
@@ -50,3 +51,4 @@ export declare class UploadDriver {
|
|
|
50
51
|
private mainLoop;
|
|
51
52
|
private getAllNotDoneProgresses;
|
|
52
53
|
}
|
|
54
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/drivers/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EACL,UAAU,EAEX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,KAAK,KAAK,GAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAKtD,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,WAAW,GAAG,kBAAkB,GAAG,mBAAmB,EACvE,GAAG,EAAE,aAAa,GACjB,sBAAsB,CAUxB;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG;IACzC,wEAAwE;IACxE,sBAAsB,EAAE,MAAM,CAAC;IAC/B;yCACqC;IACrC,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAIF;;;kEAGkE;AAClE,qBAAa,YAAY;IAQrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAXvB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0C;IAEvE,uCAAuC;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAC5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;gBAG5B,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,cAAc,EAAE,cAAc,EAC9B,IAAI,GAAE,eAKtB;IAkBH,4EAA4E;IAC5E,aAAa,CACX,cAAc,EAAE,sBAAsB,GAAG,WAAW,GACnD,UAAU,CAAC,GAAG,CAAC,cAAc,CAAC;IACjC,aAAa,CACX,cAAc,EAAE,sBAAsB,GAAG,WAAW,EACpD,GAAG,EAAE,aAAa,GACjB,GAAG,CAAC,cAAc;IAoBrB,OAAO,CAAC,kBAAkB;IAoC1B,+EAA+E;YACjE,OAAO;IAQrB,iDAAiD;IACpC,UAAU;IAIvB,OAAO,CAAC,oBAAoB,CAA0B;IAEtD,OAAO,CAAC,mBAAmB;IAI3B,2BAA2B;IAC3B,OAAO,CAAC,aAAa;IAKrB,2BAA2B;IAC3B,OAAO,CAAC,YAAY;IAIpB,yDAAyD;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,iCAAiC;IACjC,OAAO,CAAC,WAAW,CAAwC;YAE7C,QAAQ;IAwBtB,OAAO,CAAC,uBAAuB;CAKhC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Watcher } from '@milaboratories/computable';
|
|
2
|
-
import { MiLogger, Signer } from '@milaboratories/ts-helpers';
|
|
3
|
-
import { ClientProgress } from '../clients/progress';
|
|
4
|
-
import { ClientUpload, BadRequestError, MTimeError, NoFileForUploading, UnexpectedEOF } from '../clients/upload';
|
|
5
|
-
import { ImportResourceSnapshot, ImportFileHandleUploadData } from './types';
|
|
6
|
-
import { ResourceInfo } from '@milaboratories/pl-tree';
|
|
1
|
+
import type { Watcher } from '@milaboratories/computable';
|
|
7
2
|
import type * as sdk from '@milaboratories/pl-model-common';
|
|
3
|
+
import type { MiLogger, Signer } from '@milaboratories/ts-helpers';
|
|
4
|
+
import type { ClientProgress } from '../clients/progress';
|
|
5
|
+
import type { ClientUpload } from '../clients/upload';
|
|
6
|
+
import { BadRequestError, MTimeError, NoFileForUploading, UnexpectedEOF } from '../clients/upload';
|
|
7
|
+
import type { ImportResourceSnapshot } from './types';
|
|
8
|
+
import { ImportFileHandleUploadData } from './types';
|
|
9
|
+
import { ResourceInfo } from '@milaboratories/pl-tree';
|
|
8
10
|
/** Holds all info needed to upload a file and a status of uploading
|
|
9
11
|
* and indexing. Also, has a method to update a status of the progress.
|
|
10
12
|
* And holds a change source. */
|
|
@@ -56,3 +58,4 @@ export declare function isUpload(res: ResourceInfo): boolean;
|
|
|
56
58
|
export declare function isSignMatch(signer: Signer, path: string, signature: string): boolean;
|
|
57
59
|
export declare function isResourceWasDeletedError(e: any): boolean;
|
|
58
60
|
export declare function nonRecoverableError(e: any): e is MTimeError | UnexpectedEOF | NoFileForUploading | BadRequestError;
|
|
61
|
+
//# sourceMappingURL=upload_task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload_task.d.ts","sourceRoot":"","sources":["../../src/drivers/upload_task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,KAAK,KAAK,GAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAuB,QAAQ,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAA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E,OAAO,CAAC,gBAAgB;IAMjB,kBAAkB,CAAC,GAAG,EAAE,sBAAsB;IAOrD,OAAO,CAAC,OAAO;IAKR,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAKvC,UAAU,CAAC,QAAQ,EAAE,MAAM;IAIlC,OAAO,CAAC,gBAAgB;CAGzB;AAED,4CAA4C;AAC5C,wBAAsB,UAAU,CAC9B,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,YAAY,EACxB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,0BAA0B,EACtC,QAAQ,EAAE,MAAM,OAAO,EACvB,KAAK,EAAE;IACL,yBAAyB,EAAE,MAAM,CAAC;IAClC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAyCF;AAsBD,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,OAAO,CAEzD;AA+BD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,WAEzC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAOpF;AA2BD,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,GAAG,WAK/C;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,GAAG,0EAKzC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FolderURL, BlockUIURL } from '@milaboratories/pl-model-common';
|
|
2
|
-
import { Signer } from '@milaboratories/ts-helpers';
|
|
1
|
+
import type { FolderURL, BlockUIURL } from '@milaboratories/pl-model-common';
|
|
2
|
+
import type { Signer } from '@milaboratories/ts-helpers';
|
|
3
3
|
/** Creates a new plblob+folder URL. */
|
|
4
4
|
export declare function newFolderURL(signer: Signer, saveDir: string, fPath: string): FolderURL;
|
|
5
5
|
/** Creates a new block-ui URL. */
|
|
@@ -10,3 +10,4 @@ export declare function getPathForFolderURL(signer: Signer, url: FolderURL, root
|
|
|
10
10
|
/** Checks the signature and path injections.
|
|
11
11
|
* @returns the path to the file inside the root directory. */
|
|
12
12
|
export declare function getPathForBlockUIURL(signer: Signer, url: BlockUIURL, rootDir: string): string;
|
|
13
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/drivers/urls/url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAKtF;AAED,kCAAkC;AAClC,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAKxF;AAED;8DAC8D;AAC9D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3F;AAED;8DAC8D;AAC9D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual_storages.d.ts","sourceRoot":"","sources":["../../src/drivers/virtual_storages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC,CA4CtF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dispatcher } from 'undici';
|
|
2
|
-
import { ReadableStream } from 'node:stream/web';
|
|
3
|
-
import { RangeBytes } from '@milaboratories/pl-model-common';
|
|
1
|
+
import type { Dispatcher } from 'undici';
|
|
2
|
+
import type { ReadableStream } from 'node:stream/web';
|
|
3
|
+
import type { RangeBytes } from '@milaboratories/pl-model-common';
|
|
4
4
|
export interface DownloadOps {
|
|
5
5
|
signal?: AbortSignal;
|
|
6
6
|
range?: RangeBytes;
|
|
@@ -15,3 +15,4 @@ export declare class RemoteFileDownloader {
|
|
|
15
15
|
constructor(httpClient: Dispatcher);
|
|
16
16
|
withContent<T>(url: string, reqHeaders: Record<string, string>, ops: DownloadOps, handler: ContentHandler<T>): Promise<T>;
|
|
17
17
|
}
|
|
18
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/helpers/download.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtF,gFAAgF;AAChF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,IAAI,SAAqB;CAC1B;AAED,qBAAa,oBAAoB;aACH,UAAU,EAAE,UAAU;gBAAtB,UAAU,EAAE,UAAU;IAE5C,WAAW,CAAC,CAAC,EACjB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC;CAmCd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/helpers/validate.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAGlD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AAEvC,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { BinaryWriteOptions
|
|
2
|
-
import {
|
|
1
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
4
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
5
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
6
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
7
|
+
import { Any } from "../../../../../google/protobuf/any";
|
|
3
8
|
/**
|
|
4
9
|
* The `Status` type defines a logical error model that is suitable for
|
|
5
10
|
* different programming environments, including REST APIs and RPC APIs. It is
|
|
@@ -45,3 +50,4 @@ declare class Status$Type extends MessageType<Status> {
|
|
|
45
50
|
*/
|
|
46
51
|
export declare const Status: Status$Type;
|
|
47
52
|
export {};
|
|
53
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../../../src/proto/github.com/googleapis/googleapis/google/rpc/status.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AACzD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACnB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,OAAO,EAAE,GAAG,EAAE,CAAC;CAClB;AAED,cAAM,WAAY,SAAQ,WAAW,CAAC,MAAM,CAAC;;IAQzC,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IAS9C,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAyB9G,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAe1G;AACD;;GAEG;AACH,eAAO,MAAM,MAAM,aAAoB,CAAC"}
|