@milaboratories/pl-drivers 1.5.14 → 1.5.16

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/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-drivers",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
+ "engines": {
5
+ "node": ">=20"
6
+ },
4
7
  "description": "Drivers and a low-level clients for log streaming, downloading and uploading files from and to pl",
5
8
  "types": "./dist/index.d.ts",
6
9
  "main": "./dist/index.js",
@@ -27,11 +30,11 @@
27
30
  "tar-fs": "^3.0.8",
28
31
  "undici": "^7.2.3",
29
32
  "zod": "~3.23.8",
30
- "@milaboratories/computable": "^2.3.4",
31
33
  "@milaboratories/ts-helpers": "^1.1.3",
32
- "@milaboratories/pl-client": "^2.7.4",
33
34
  "@milaboratories/pl-tree": "^1.4.23",
34
- "@milaboratories/pl-model-common": "^1.10.5"
35
+ "@milaboratories/computable": "^2.3.4",
36
+ "@milaboratories/pl-model-common": "^1.10.5",
37
+ "@milaboratories/pl-client": "^2.7.4"
35
38
  },
36
39
  "devDependencies": {
37
40
  "eslint": "^9.16.0",
@@ -44,8 +47,8 @@
44
47
  "jest": "^29.7.0",
45
48
  "@jest/globals": "^29.7.0",
46
49
  "ts-jest": "^29.2.5",
47
- "@milaboratories/platforma-build-configs": "1.0.2",
48
- "@milaboratories/eslint-config": "^1.0.1"
50
+ "@milaboratories/eslint-config": "^1.0.1",
51
+ "@milaboratories/platforma-build-configs": "1.0.2"
49
52
  },
50
53
  "scripts": {
51
54
  "type-check": "tsc --noEmit --composite false",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable n/no-unsupported-features/node-builtins */
1
2
  import { addRTypeToMetadata } from '@milaboratories/pl-client';
2
3
  import type { ResourceInfo } from '@milaboratories/pl-tree';
3
4
  import type { MiLogger } from '@milaboratories/ts-helpers';
@@ -78,7 +78,7 @@ export class ClientProgress {
78
78
 
79
79
  yield * responses;
80
80
  } catch (e) {
81
- this.logger.warn('Failed to get realtime status' + e);
81
+ this.logger.warn('Failed to get realtime status' + String(e));
82
82
  throw e;
83
83
  }
84
84
  }
@@ -69,20 +69,24 @@ export class ClientUpload {
69
69
  const chunk = await readFileChunk(path, info.chunkStart, info.chunkEnd);
70
70
  await checkExpectedMTime(path, expectedMTimeUnix);
71
71
 
72
- const {
73
- body: rawBody,
74
- statusCode,
75
- headers,
76
- } = await request(info.uploadUrl, {
77
- dispatcher: this.httpClient,
78
- body: chunk,
79
- headers: toHeadersMap(info.headers),
80
- method: info.method.toUpperCase() as Dispatcher.HttpMethod,
81
- });
82
-
83
- // always read the body for resources to be garbage collected.
84
- const body = await rawBody.text();
85
- checkStatusCodeOk(statusCode, body, headers, info);
72
+ try {
73
+ const {
74
+ body: rawBody,
75
+ statusCode,
76
+ headers,
77
+ } = await request(info.uploadUrl, {
78
+ dispatcher: this.httpClient,
79
+ body: chunk,
80
+ headers: toHeadersMap(info.headers),
81
+ method: info.method.toUpperCase() as Dispatcher.HttpMethod,
82
+ });
83
+
84
+ // always read the body for resources to be garbage collected.
85
+ const body = await rawBody.text();
86
+ checkStatusCodeOk(statusCode, body, headers, info);
87
+ } catch (e: unknown) {
88
+ throw new Error(`partUpload: error ${JSON.stringify(e)} happened while trying to do part upload to the url ${info.uploadUrl}, headers: ${JSON.stringify(info.headers)}`);
89
+ }
86
90
 
87
91
  await this.grpcUpdateProgress({ id, type }, info.chunkEnd - info.chunkStart, options);
88
92
  }
@@ -151,11 +155,11 @@ async function readFileChunk(path: string, chunkStart: bigint, chunkEnd: bigint)
151
155
  const bytesRead = await readBytesFromPosition(f, b, len, pos);
152
156
 
153
157
  return b.subarray(0, bytesRead);
154
- } catch (e: any) {
155
- if (e.code == 'ENOENT') throw new NoFileForUploading(`there is no file ${path} for uploading`);
158
+ } catch (e: unknown) {
159
+ if (e && typeof e === 'object' && ('code' in e) && e.code == 'ENOENT') throw new NoFileForUploading(`there is no file ${path} for uploading`);
156
160
  throw e;
157
161
  } finally {
158
- f?.close();
162
+ await f?.close();
159
163
  }
160
164
  }
161
165
 
@@ -195,7 +199,7 @@ function checkStatusCodeOk(
195
199
  if (statusCode != 200) {
196
200
  throw new NetworkError(
197
201
  `response is not ok, status code: ${statusCode},`
198
- + ` body: ${body}, headers: ${headers}, url: ${info.uploadUrl}`,
202
+ + ` body: ${body}, headers: ${JSON.stringify(headers)}, url: ${info.uploadUrl}`,
199
203
  );
200
204
  }
201
205
  }
@@ -1,3 +1,5 @@
1
+ // @TODO Gleb Zakharov
2
+ /* eslint-disable n/no-unsupported-features/node-builtins */
1
3
  import type { Dispatcher } from 'undici';
2
4
  import { request } from 'undici';
3
5
  import { Readable } from 'node:stream';
@@ -36,7 +38,7 @@ export class RemoteFileDownloader {
36
38
  }
37
39
  }
38
40
 
39
- async function checkStatusCodeOk(statusCode: number, webBody: ReadableStream<any>, url: string) {
41
+ async function checkStatusCodeOk(statusCode: number, webBody: ReadableStream, url: string) {
40
42
  if (statusCode != 200) {
41
43
  const beginning = (await text(webBody)).substring(0, 1000);
42
44