@milaboratories/pl-drivers 1.2.21 → 1.2.23

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.
@@ -1,5 +1,6 @@
1
- import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions } from '@protobuf-ts/runtime-rpc';
1
+ import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions, MethodInfo } from '@protobuf-ts/runtime-rpc';
2
2
  import { DownloadAPI_GetDownloadURL_Response, DownloadAPI_GetDownloadURL_Request } from './protocol';
3
+ import { JsonValue } from '@protobuf-ts/runtime';
3
4
  /**
4
5
  *
5
6
  * Download provides access to any data, that can be downloaded via network.
@@ -23,9 +24,9 @@ export interface IDownloadClient {
23
24
  export declare class DownloadClient implements IDownloadClient, ServiceInfo {
24
25
  private readonly _transport;
25
26
  typeName: string;
26
- methods: import('@protobuf-ts/runtime-rpc').MethodInfo<any, any>[];
27
+ methods: MethodInfo<any, any>[];
27
28
  options: {
28
- [extensionName: string]: import('@protobuf-ts/runtime').JsonValue;
29
+ [extensionName: string]: JsonValue;
29
30
  };
30
31
  constructor(_transport: RpcTransport);
31
32
  /**
@@ -1,5 +1,6 @@
1
- import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions } from '@protobuf-ts/runtime-rpc';
1
+ import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions, MethodInfo } from '@protobuf-ts/runtime-rpc';
2
2
  import { LsAPI_List_Response, LsAPI_List_Request } from './protocol';
3
+ import { JsonValue } from '@protobuf-ts/runtime';
3
4
  /**
4
5
  *
5
6
  * LS provides access to lists of blobs (files, S3 objects and so on) is some storage.
@@ -29,9 +30,9 @@ export interface ILSClient {
29
30
  export declare class LSClient implements ILSClient, ServiceInfo {
30
31
  private readonly _transport;
31
32
  typeName: string;
32
- methods: import('@protobuf-ts/runtime-rpc').MethodInfo<any, any>[];
33
+ methods: MethodInfo<any, any>[];
33
34
  options: {
34
- [extensionName: string]: import('@protobuf-ts/runtime').JsonValue;
35
+ [extensionName: string]: JsonValue;
35
36
  };
36
37
  constructor(_transport: RpcTransport);
37
38
  /**
@@ -1,5 +1,6 @@
1
- import { RpcTransport, ServiceInfo, ServerStreamingCall, UnaryCall, RpcOptions } from '@protobuf-ts/runtime-rpc';
1
+ import { RpcTransport, ServiceInfo, ServerStreamingCall, UnaryCall, RpcOptions, MethodInfo } from '@protobuf-ts/runtime-rpc';
2
2
  import { ProgressAPI_RealtimeStatus_Response, ProgressAPI_RealtimeStatus_Request, ProgressAPI_GetStatus_Response, ProgressAPI_GetStatus_Request } from './protocol';
3
+ import { JsonValue } from '@protobuf-ts/runtime';
3
4
  /**
4
5
  *
5
6
  * Progress provides access to progress of any long-running process associated with resource.
@@ -27,9 +28,9 @@ export interface IProgressClient {
27
28
  export declare class ProgressClient implements IProgressClient, ServiceInfo {
28
29
  private readonly _transport;
29
30
  typeName: string;
30
- methods: import('@protobuf-ts/runtime-rpc').MethodInfo<any, any>[];
31
+ methods: MethodInfo<any, any>[];
31
32
  options: {
32
- [extensionName: string]: import('@protobuf-ts/runtime').JsonValue;
33
+ [extensionName: string]: JsonValue;
33
34
  };
34
35
  constructor(_transport: RpcTransport);
35
36
  /**
@@ -1,5 +1,6 @@
1
- import { RpcTransport, ServiceInfo, UnaryCall, ServerStreamingCall, RpcOptions } from '@protobuf-ts/runtime-rpc';
1
+ import { RpcTransport, ServiceInfo, UnaryCall, ServerStreamingCall, RpcOptions, MethodInfo } from '@protobuf-ts/runtime-rpc';
2
2
  import { StreamingAPI_LastLines, StreamingAPI_ReadText, StreamingAPI_StreamText, StreamingAPI_ReadBinary, StreamingAPI_Response, StreamingAPI_StreamBinary } from './protocol';
3
+ import { JsonValue } from '@protobuf-ts/runtime';
3
4
  /**
4
5
  *
5
6
  * Streaming provides access to online data stream from item in storage. Whenever item is appended with data,
@@ -67,9 +68,9 @@ export interface IStreamingClient {
67
68
  export declare class StreamingClient implements IStreamingClient, ServiceInfo {
68
69
  private readonly _transport;
69
70
  typeName: string;
70
- methods: import('@protobuf-ts/runtime-rpc').MethodInfo<any, any>[];
71
+ methods: MethodInfo<any, any>[];
71
72
  options: {
72
- [extensionName: string]: import('@protobuf-ts/runtime').JsonValue;
73
+ [extensionName: string]: JsonValue;
73
74
  };
74
75
  constructor(_transport: RpcTransport);
75
76
  /**
@@ -1,5 +1,6 @@
1
- import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions } from '@protobuf-ts/runtime-rpc';
1
+ import { RpcTransport, ServiceInfo, UnaryCall, RpcOptions, MethodInfo } from '@protobuf-ts/runtime-rpc';
2
2
  import { uploadapi_Finalize_Response, uploadapi_Finalize_Request, uploadapi_UpdateProgress_Response, uploadapi_UpdateProgress_Request, uploadapi_GetPartURL_Response, uploadapi_GetPartURL_Request, uploadapi_Init_Response, uploadapi_Init_Request } from './protocol';
3
+ import { JsonValue } from '@protobuf-ts/runtime';
3
4
  /**
4
5
  *
5
6
  * Upload provides access to data upload feature, allowing clients to uplad data to Platforma.
@@ -54,9 +55,9 @@ export interface IUploadClient {
54
55
  export declare class UploadClient implements IUploadClient, ServiceInfo {
55
56
  private readonly _transport;
56
57
  typeName: string;
57
- methods: import('@protobuf-ts/runtime-rpc').MethodInfo<any, any>[];
58
+ methods: MethodInfo<any, any>[];
58
59
  options: {
59
- [extensionName: string]: import('@protobuf-ts/runtime').JsonValue;
60
+ [extensionName: string]: JsonValue;
60
61
  };
61
62
  constructor(_transport: RpcTransport);
62
63
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-drivers",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Drivers and a low-level clients for log streaming, downloading and uploading files from and to pl",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -26,10 +26,10 @@
26
26
  "tar-fs": "^3.0.6",
27
27
  "undici": "^6.19.8",
28
28
  "zod": "^3.23.8",
29
- "@milaboratories/computable": "^2.1.6",
30
- "@milaboratories/ts-helpers": "^1.0.26",
31
- "@milaboratories/pl-client": "^2.4.14",
32
- "@milaboratories/pl-tree": "^1.3.11",
29
+ "@milaboratories/ts-helpers": "^1.0.27",
30
+ "@milaboratories/computable": "^2.1.7",
31
+ "@milaboratories/pl-client": "^2.4.16",
32
+ "@milaboratories/pl-tree": "^1.3.13",
33
33
  "@milaboratories/pl-model-common": "^1.3.13"
34
34
  },
35
35
  "devDependencies": {
@@ -39,6 +39,7 @@
39
39
  "@types/jest": "^29.5.13",
40
40
  "@types/tar-fs": "^2.0.4",
41
41
  "jest": "^29.7.0",
42
+ "@jest/globals": "^29.7.0",
42
43
  "ts-jest": "^29.2.5",
43
44
  "@milaboratories/platforma-build-configs": "1.0.1"
44
45
  },
@@ -81,7 +81,7 @@ export class ClientUpload {
81
81
  this.prepareUploadOpts(info, chunk)
82
82
  );
83
83
 
84
- const body = await (await resp.body.blob()).text();
84
+ const body = await resp.body.text();
85
85
  this.logger.info(
86
86
  `uploaded chunk ${partNumber} from ${partsOverall} of resource: ${id},` +
87
87
  ` response: '${body.toString()}', ` +
@@ -473,7 +473,7 @@ export class DownloadDriver implements BlobDriver {
473
473
  this.removeTask(
474
474
  task,
475
475
  `the task ${task.path} was removed` +
476
- `from cache along with ${toDelete.map((d) => d.path)}`
476
+ `from cache along with ${toDelete.map((d) => d.path)}`
477
477
  );
478
478
  })
479
479
  );
@@ -667,7 +667,9 @@ export class Download {
667
667
  // check in case we already have a file by this resource id
668
668
  // in the directory. It can happen when we forgot to call removeAll
669
669
  // in the previous launch.
670
- if (!(await fileOrDirExists(this.path))) {
670
+ if (await fileOrDirExists(this.path)) {
671
+ content.cancel(`the file already existed`); // we don't need the blob
672
+ } else {
671
673
  const fileToWrite = Writable.toWeb(fs.createWriteStream(this.path));
672
674
  await content.pipeTo(fileToWrite);
673
675
  }
@@ -7,6 +7,7 @@ import * as fs from 'node:fs';
7
7
  import * as fsp from 'node:fs/promises';
8
8
  import * as path from 'node:path';
9
9
  import { DownloadUrlDriver } from './download_url';
10
+ import {test, expect} from '@jest/globals';
10
11
 
11
12
  test('should download a tar archive and extracts its content and then deleted', async () => {
12
13
  await TestHelpers.withTempRoot(async (client) => {
@@ -39,7 +40,7 @@ test('should download a tar archive and extracts its content and then deleted',
39
40
  });
40
41
  });
41
42
 
42
- test('should show a error when 403 status code', async () => {
43
+ test('should show a error when 404 status code', async () => {
43
44
  try {
44
45
  await TestHelpers.withTempRoot(async (client) => {
45
46
  const logger = new ConsoleLoggerAdapter();
@@ -23,6 +23,7 @@ import {
23
23
  createUploadProgressClient
24
24
  } from '../clients/helpers';
25
25
  import { Writable, Readable } from 'node:stream';
26
+ import { test, expect } from '@jest/globals';
26
27
 
27
28
  test('upload a blob', async () => {
28
29
  await withTest(async ({ client, uploader, signer }: TestArg) => {
@@ -243,7 +244,7 @@ test('index a blob', async () => {
243
244
  await withTest(async ({ client, uploader }: TestArg) => {
244
245
  const uploadId = await createBlobIndex(
245
246
  client,
246
- 'another_answer_to_the_ultimate_question.txt',
247
+ './another_answer_to_the_ultimate_question.txt',
247
248
  'library'
248
249
  );
249
250
  const handleRes = await getHandleField(client, uploadId);
@@ -382,6 +382,8 @@ class ProgressUpdater {
382
382
 
383
383
  private setDone(done: boolean) {
384
384
  this.progress.done = done;
385
+ if (done)
386
+ this.progress.lastError = undefined;
385
387
  }
386
388
 
387
389
  async updateStatus() {
@@ -25,12 +25,14 @@ export class DownloadHelper {
25
25
  });
26
26
 
27
27
  if (400 <= statusCode && statusCode < 500) {
28
+ body.on('error', (_) => {}).destroy();
28
29
  throw new NetworkError400(
29
30
  `Http error: statusCode: ${statusCode} url: ${url.toString()}`
30
31
  );
31
32
  }
32
33
  if (statusCode != 200) {
33
- throw Error(
34
+ body.on('error', (_) => {}).destroy();
35
+ throw new Error(
34
36
  `Http error: statusCode: ${statusCode} url: ${url.toString()}`
35
37
  );
36
38
  }