@milaboratories/pl-drivers 1.5.69 → 1.5.71
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.map +1 -1
- package/dist/clients/download.d.ts +3 -4
- package/dist/clients/download.d.ts.map +1 -1
- package/dist/clients/logs.d.ts +3 -4
- package/dist/clients/logs.d.ts.map +1 -1
- package/dist/clients/ls_api.d.ts +2 -2
- package/dist/clients/ls_api.d.ts.map +1 -1
- package/dist/clients/progress.d.ts +3 -5
- package/dist/clients/progress.d.ts.map +1 -1
- package/dist/clients/upload.d.ts +2 -4
- package/dist/clients/upload.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/clients/constructors.ts +11 -11
- package/src/clients/download.ts +5 -5
- package/src/clients/logs.ts +6 -6
- package/src/clients/ls_api.ts +5 -5
- package/src/clients/progress.ts +6 -6
- package/src/clients/upload.ts +8 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-drivers",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.71",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"undici": "~7.10.0",
|
|
32
32
|
"zod": "~3.23.8",
|
|
33
33
|
"upath": "^2.0.1",
|
|
34
|
+
"@milaboratories/helpers": "^1.6.14",
|
|
34
35
|
"@milaboratories/ts-helpers": "^1.4.0",
|
|
35
|
-
"@milaboratories/helpers": "^1.6.13",
|
|
36
36
|
"@milaboratories/computable": "^2.5.0",
|
|
37
|
-
"@milaboratories/pl-tree": "^1.6.
|
|
38
|
-
"@milaboratories/pl-
|
|
39
|
-
"@milaboratories/pl-
|
|
37
|
+
"@milaboratories/pl-tree": "^1.6.10",
|
|
38
|
+
"@milaboratories/pl-client": "^2.11.1",
|
|
39
|
+
"@milaboratories/pl-model-common": "^1.15.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"eslint": "^9.25.1",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlClient } from '@milaboratories/pl-client';
|
|
1
|
+
import type { GrpcClientProviderFactory, PlClient } from '@milaboratories/pl-client';
|
|
2
2
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
3
3
|
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
4
|
import type { Dispatcher } from 'undici';
|
|
@@ -16,39 +16,39 @@ export function createDownloadClient(
|
|
|
16
16
|
) {
|
|
17
17
|
return client.getDriver({
|
|
18
18
|
name: 'DownloadBlob',
|
|
19
|
-
init: (_: PlClient,
|
|
20
|
-
new ClientDownload(
|
|
19
|
+
init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>
|
|
20
|
+
new ClientDownload(grpcClientProviderFactory, httpDispatcher, logger, localProjections),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function createLogsClient(client: PlClient, logger: MiLogger) {
|
|
25
25
|
return client.getDriver({
|
|
26
26
|
name: 'StreamLogs',
|
|
27
|
-
init: (_: PlClient,
|
|
28
|
-
new ClientLogs(
|
|
27
|
+
init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>
|
|
28
|
+
new ClientLogs(grpcClientProviderFactory, httpDispatcher, logger),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function createUploadProgressClient(client: PlClient, logger: MiLogger) {
|
|
33
33
|
return client.getDriver({
|
|
34
34
|
name: 'UploadProgress',
|
|
35
|
-
init: (_: PlClient,
|
|
36
|
-
new ClientProgress(
|
|
35
|
+
init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>
|
|
36
|
+
new ClientProgress(grpcClientProviderFactory, httpDispatcher, client, logger),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function createUploadBlobClient(client: PlClient, logger: MiLogger) {
|
|
41
41
|
return client.getDriver({
|
|
42
42
|
name: 'UploadBlob',
|
|
43
|
-
init: (_: PlClient,
|
|
44
|
-
new ClientUpload(
|
|
43
|
+
init: (_: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, httpDispatcher: Dispatcher) =>
|
|
44
|
+
new ClientUpload(grpcClientProviderFactory, httpDispatcher, client, logger),
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export function createLsFilesClient(client: PlClient, logger: MiLogger) {
|
|
49
49
|
return client.getDriver({
|
|
50
50
|
name: 'LsFiles',
|
|
51
|
-
init: (_client: PlClient,
|
|
52
|
-
new ClientLs(
|
|
51
|
+
init: (_client: PlClient, grpcClientProviderFactory: GrpcClientProviderFactory, _httpDispatcher: Dispatcher) =>
|
|
52
|
+
new ClientLs(grpcClientProviderFactory, logger),
|
|
53
53
|
});
|
|
54
54
|
}
|
package/src/clients/download.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable n/no-unsupported-features/node-builtins */
|
|
2
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
|
|
2
3
|
import { addRTypeToMetadata } from '@milaboratories/pl-client';
|
|
3
4
|
import type { ResourceInfo } from '@milaboratories/pl-tree';
|
|
4
5
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
5
|
-
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
6
6
|
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as fsp from 'node:fs/promises';
|
|
@@ -20,20 +20,20 @@ import { toHeadersMap } from './helpers';
|
|
|
20
20
|
/** Gets URLs for downloading from pl-core, parses them and reads or downloads
|
|
21
21
|
* files locally and from the web. */
|
|
22
22
|
export class ClientDownload {
|
|
23
|
-
public readonly grpcClient: DownloadClient
|
|
23
|
+
public readonly grpcClient: GrpcClientProvider<DownloadClient>;
|
|
24
24
|
private readonly remoteFileDownloader: RemoteFileDownloader;
|
|
25
25
|
|
|
26
26
|
/** Helps to find a storage root directory by a storage id from URL scheme. */
|
|
27
27
|
private readonly localStorageIdsToRoot: Map<string, string>;
|
|
28
28
|
|
|
29
29
|
constructor(
|
|
30
|
-
|
|
30
|
+
grpcClientProviderFactory: GrpcClientProviderFactory,
|
|
31
31
|
public readonly httpClient: Dispatcher,
|
|
32
32
|
public readonly logger: MiLogger,
|
|
33
33
|
/** Pl storages available locally */
|
|
34
34
|
localProjections: LocalStorageProjection[],
|
|
35
35
|
) {
|
|
36
|
-
this.grpcClient = new DownloadClient(
|
|
36
|
+
this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new DownloadClient(transport));
|
|
37
37
|
this.remoteFileDownloader = new RemoteFileDownloader(httpClient);
|
|
38
38
|
this.localStorageIdsToRoot = newLocalStorageIdsToRoot(localProjections);
|
|
39
39
|
}
|
|
@@ -84,7 +84,7 @@ export class ClientDownload {
|
|
|
84
84
|
const withAbort = options ?? {};
|
|
85
85
|
withAbort.abort = signal;
|
|
86
86
|
|
|
87
|
-
return await this.grpcClient.getDownloadURL(
|
|
87
|
+
return await this.grpcClient.get().getDownloadURL(
|
|
88
88
|
{ resourceId: id },
|
|
89
89
|
addRTypeToMetadata(type, withAbort),
|
|
90
90
|
).response;
|
package/src/clients/logs.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { StreamingClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client';
|
|
2
|
-
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
3
2
|
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
4
3
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
5
4
|
import { notEmpty } from '@milaboratories/ts-helpers';
|
|
6
5
|
import type { Dispatcher } from 'undici';
|
|
6
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
|
|
7
7
|
import { addRTypeToMetadata } from '@milaboratories/pl-client';
|
|
8
8
|
import type { StreamingAPI_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';
|
|
9
9
|
import type { ResourceInfo } from '@milaboratories/pl-tree';
|
|
10
10
|
|
|
11
11
|
export class ClientLogs {
|
|
12
|
-
public readonly grpcClient: StreamingClient
|
|
12
|
+
public readonly grpcClient: GrpcClientProvider<StreamingClient>;
|
|
13
13
|
|
|
14
14
|
constructor(
|
|
15
|
-
|
|
15
|
+
grpcClientProviderFactory: GrpcClientProviderFactory,
|
|
16
16
|
public readonly httpClient: Dispatcher,
|
|
17
17
|
public readonly logger: MiLogger,
|
|
18
18
|
) {
|
|
19
|
-
this.grpcClient = new StreamingClient(
|
|
19
|
+
this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new StreamingClient(transport));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
close() {}
|
|
@@ -32,7 +32,7 @@ export class ClientLogs {
|
|
|
32
32
|
options?: RpcOptions,
|
|
33
33
|
): Promise<StreamingAPI_Response> {
|
|
34
34
|
return (
|
|
35
|
-
await this.grpcClient.lastLines(
|
|
35
|
+
await this.grpcClient.get().lastLines(
|
|
36
36
|
{
|
|
37
37
|
resourceId: rId,
|
|
38
38
|
lineCount: lineCount,
|
|
@@ -55,7 +55,7 @@ export class ClientLogs {
|
|
|
55
55
|
options?: RpcOptions,
|
|
56
56
|
): Promise<StreamingAPI_Response> {
|
|
57
57
|
return (
|
|
58
|
-
await this.grpcClient.readText(
|
|
58
|
+
await this.grpcClient.get().readText(
|
|
59
59
|
{
|
|
60
60
|
resourceId: notEmpty(rId),
|
|
61
61
|
readLimit: BigInt(lineCount),
|
package/src/clients/ls_api.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
2
2
|
import type { LsAPI_List_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol';
|
|
3
3
|
import { LSClient } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client';
|
|
4
|
-
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
5
4
|
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
5
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
|
|
6
6
|
import { addRTypeToMetadata } from '@milaboratories/pl-client';
|
|
7
7
|
import type { ResourceInfo } from '@milaboratories/pl-tree';
|
|
8
8
|
|
|
9
9
|
export class ClientLs {
|
|
10
|
-
private readonly grpcClient: LSClient
|
|
10
|
+
private readonly grpcClient: GrpcClientProvider<LSClient>;
|
|
11
11
|
|
|
12
12
|
constructor(
|
|
13
|
-
|
|
13
|
+
grpcClientProviderFactory: GrpcClientProviderFactory,
|
|
14
14
|
private readonly logger: MiLogger,
|
|
15
15
|
) {
|
|
16
|
-
this.grpcClient = new LSClient(
|
|
16
|
+
this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new LSClient(transport));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
close() {}
|
|
@@ -23,7 +23,7 @@ export class ClientLs {
|
|
|
23
23
|
path: string,
|
|
24
24
|
options?: RpcOptions,
|
|
25
25
|
): Promise<LsAPI_List_Response> {
|
|
26
|
-
return await this.grpcClient.list(
|
|
26
|
+
return await this.grpcClient.get().list(
|
|
27
27
|
{
|
|
28
28
|
resourceId: rInfo.id,
|
|
29
29
|
location: path,
|
package/src/clients/progress.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProgressClient } from '../proto/github.com/milaboratory/pl/controllers/
|
|
|
2
2
|
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
3
3
|
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
4
4
|
import { Duration } from '../proto/google/protobuf/duration';
|
|
5
|
-
import type { PlClient } from '@milaboratories/pl-client';
|
|
5
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory, PlClient } from '@milaboratories/pl-client';
|
|
6
6
|
import { addRTypeToMetadata } from '@milaboratories/pl-client';
|
|
7
7
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
8
8
|
import { notEmpty } from '@milaboratories/ts-helpers';
|
|
@@ -21,22 +21,22 @@ export type ProgressStatus = {
|
|
|
21
21
|
// When blobs are transfered, one can got a status of transfering
|
|
22
22
|
// using this API.
|
|
23
23
|
export class ClientProgress {
|
|
24
|
-
public readonly grpcClient: ProgressClient
|
|
24
|
+
public readonly grpcClient: GrpcClientProvider<ProgressClient>;
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
|
-
|
|
27
|
+
grpcClientProviderFactory: GrpcClientProviderFactory,
|
|
28
28
|
_: Dispatcher,
|
|
29
29
|
public readonly client: PlClient,
|
|
30
30
|
public readonly logger: MiLogger,
|
|
31
31
|
) {
|
|
32
|
-
this.grpcClient = new ProgressClient(
|
|
32
|
+
this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new ProgressClient(transport));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
close() {}
|
|
36
36
|
|
|
37
37
|
/** getStatus gets a progress status by given rId and rType. */
|
|
38
38
|
async getStatus({ id, type }: ResourceInfo, options?: RpcOptions): Promise<ProgressStatus> {
|
|
39
|
-
const status = await this.grpcClient.getStatus(
|
|
39
|
+
const status = await this.grpcClient.get().getStatus(
|
|
40
40
|
{ resourceId: id },
|
|
41
41
|
addRTypeToMetadata(type, options),
|
|
42
42
|
);
|
|
@@ -68,7 +68,7 @@ export class ClientProgress {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
try {
|
|
71
|
-
const { responses } = this.grpcClient.realtimeStatus(
|
|
71
|
+
const { responses } = this.grpcClient.get().realtimeStatus(
|
|
72
72
|
{
|
|
73
73
|
resourceId: id,
|
|
74
74
|
updateInterval: updateInterval,
|
package/src/clients/upload.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { PlClient, ResourceId, ResourceType } from '@milaboratories/pl-client';
|
|
1
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory, PlClient, ResourceId, ResourceType } from '@milaboratories/pl-client';
|
|
2
2
|
import { addRTypeToMetadata } from '@milaboratories/pl-client';
|
|
3
3
|
import type { ResourceInfo } from '@milaboratories/pl-tree';
|
|
4
4
|
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
5
|
-
import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
6
5
|
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
7
6
|
import * as fs from 'node:fs/promises';
|
|
8
7
|
import type { Dispatcher } from 'undici';
|
|
@@ -33,15 +32,15 @@ export class NoFileForUploading extends Error {
|
|
|
33
32
|
* The user should pass here a concrete BlobUpload/<storageId> resource,
|
|
34
33
|
* it can be got from handle field of BlobUpload. */
|
|
35
34
|
export class ClientUpload {
|
|
36
|
-
private readonly grpcClient: UploadClient
|
|
35
|
+
private readonly grpcClient: GrpcClientProvider<UploadClient>;
|
|
37
36
|
|
|
38
37
|
constructor(
|
|
39
|
-
|
|
38
|
+
grpcClientProviderFactory: GrpcClientProviderFactory,
|
|
40
39
|
public readonly httpClient: Dispatcher,
|
|
41
40
|
_: PlClient,
|
|
42
41
|
public readonly logger: MiLogger,
|
|
43
42
|
) {
|
|
44
|
-
this.grpcClient = new UploadClient(
|
|
43
|
+
this.grpcClient = grpcClientProviderFactory.createGrpcClientProvider((transport) => new UploadClient(transport));
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
close() {}
|
|
@@ -126,7 +125,7 @@ export class ClientUpload {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
private async grpcInit(id: ResourceId, type: ResourceType, options?: RpcOptions) {
|
|
129
|
-
return await this.grpcClient.init({ resourceId: id }, addRTypeToMetadata(type, options))
|
|
128
|
+
return await this.grpcClient.get().init({ resourceId: id }, addRTypeToMetadata(type, options))
|
|
130
129
|
.response;
|
|
131
130
|
}
|
|
132
131
|
|
|
@@ -136,7 +135,7 @@ export class ClientUpload {
|
|
|
136
135
|
uploadedPartSize: bigint,
|
|
137
136
|
options?: RpcOptions,
|
|
138
137
|
) {
|
|
139
|
-
return await this.grpcClient.getPartURL(
|
|
138
|
+
return await this.grpcClient.get().getPartURL(
|
|
140
139
|
{ resourceId: id, partNumber, uploadedPartSize },
|
|
141
140
|
addRTypeToMetadata(type, options),
|
|
142
141
|
).response;
|
|
@@ -147,7 +146,7 @@ export class ClientUpload {
|
|
|
147
146
|
bytesProcessed: bigint,
|
|
148
147
|
options?: RpcOptions,
|
|
149
148
|
) {
|
|
150
|
-
await this.grpcClient.updateProgress(
|
|
149
|
+
await this.grpcClient.get().updateProgress(
|
|
151
150
|
{
|
|
152
151
|
resourceId: id,
|
|
153
152
|
bytesProcessed,
|
|
@@ -157,7 +156,7 @@ export class ClientUpload {
|
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
private async grpcFinalize({ id, type }: ResourceInfo, options?: RpcOptions) {
|
|
160
|
-
return await this.grpcClient.finalize({ resourceId: id }, addRTypeToMetadata(type, options))
|
|
159
|
+
return await this.grpcClient.get().finalize({ resourceId: id }, addRTypeToMetadata(type, options))
|
|
161
160
|
.response;
|
|
162
161
|
}
|
|
163
162
|
}
|