@milaboratories/pl-drivers 1.5.11 → 1.5.13

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,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-drivers",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
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",
@@ -28,10 +28,10 @@
28
28
  "undici": "^7.2.3",
29
29
  "zod": "~3.23.8",
30
30
  "@milaboratories/ts-helpers": "^1.1.3",
31
- "@milaboratories/pl-model-common": "^1.10.4",
32
- "@milaboratories/pl-tree": "^1.4.22",
33
31
  "@milaboratories/computable": "^2.3.4",
34
- "@milaboratories/pl-client": "^2.7.3"
32
+ "@milaboratories/pl-client": "^2.7.3",
33
+ "@milaboratories/pl-tree": "^1.4.22",
34
+ "@milaboratories/pl-model-common": "^1.10.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "eslint": "^9.16.0",
@@ -128,7 +128,14 @@ export class DownloadAndUnarchiveTask {
128
128
  await content.pipeTo(f, { signal });
129
129
  this.state!.zipPathCreated = true;
130
130
 
131
- await decompress(this.path + '.zip', fPath);
131
+ // Without this filter it fails with
132
+ // "EISDIR: illegal operation on a directory".
133
+ // The workaround is from
134
+ // https://github.com/kevva/decompress/issues/46#issuecomment-525048104
135
+ await decompress(this.state!.zipPath, fPath, {
136
+ filter: file => !file.path.endsWith('/'),
137
+ });
138
+ this.state!.zipDecompressed = true;
132
139
 
133
140
  await fs.promises.rm(this.state!.zipPath);
134
141
  this.state!.zipPathDeleted = true;
@@ -199,6 +206,7 @@ type DownloadCtx = {
199
206
  tempPath?: string;
200
207
  zipPath?: string;
201
208
  zipPathCreated?: boolean;
209
+ zipDecompressed?: boolean;
202
210
  zipPathDeleted?: boolean;
203
211
  pathCreated?: boolean;
204
212
  };
@@ -97,7 +97,7 @@ test('should get last line with a prefix', async () => {
97
97
  return;
98
98
  }
99
99
 
100
- return logs.getProgressLog(streamManager, 'PREFIX', ctx);
100
+ return logs.getProgressLogWithInfo(streamManager, 'PREFIX', ctx);
101
101
  });
102
102
 
103
103
  expect(await c.getValue()).toBeUndefined();
@@ -113,7 +113,10 @@ test('should get last line with a prefix', async () => {
113
113
 
114
114
  logger.info(`got result: ${JSON.stringify(result)}`);
115
115
  if (result.stable) {
116
- expect(result.value).toStrictEqual('PREFIX4\n');
116
+ expect(result.value).toMatchObject({
117
+ progressLine: 'PREFIX4\n',
118
+ live: false,
119
+ });
117
120
  return;
118
121
  }
119
122
  }
@@ -75,6 +75,49 @@ export class LogsDriver implements sdk.LogsDriver {
75
75
  }
76
76
  }
77
77
 
78
+ /** Same as getProgressLog but also returns a liveliness of the log.
79
+ * The previous getProgressLog couldn't be extended.
80
+ * Returns a last line that has patternToSearch.
81
+ * Notifies when a new line appeared or EOF reached. */
82
+ getProgressLogWithInfo(res: PlTreeEntry, patternToSearch: string): Computable<sdk.ProgressLogWithInfo | undefined>;
83
+ getProgressLogWithInfo(res: PlTreeEntry, patternToSearch: string, ctx: ComputableCtx): sdk.ProgressLogWithInfo | undefined;
84
+ getProgressLogWithInfo(
85
+ res: PlTreeEntry,
86
+ patternToSearch: string,
87
+ ctx?: ComputableCtx,
88
+ ): Computable<sdk.ProgressLogWithInfo | undefined> | sdk.ProgressLogWithInfo | undefined {
89
+ if (ctx === undefined)
90
+ return Computable.make((ctx) => this.getProgressLogWithInfo(res, patternToSearch, ctx));
91
+
92
+ const stream = streamManagerGetStream(ctx, res);
93
+ if (stream === undefined) {
94
+ ctx.markUnstable('no stream in stream manager');
95
+ return undefined;
96
+ }
97
+
98
+ if (isBlob(stream)) {
99
+ const log = this.downloadDriver.getProgressLog(stream, patternToSearch, ctx);
100
+ return {
101
+ progressLine: log,
102
+ live: false,
103
+ }
104
+ }
105
+
106
+ try {
107
+ const log = this.logsStreamDriver.getProgressLog(stream, patternToSearch, ctx);
108
+ return {
109
+ progressLine: log,
110
+ live: true,
111
+ }
112
+ } catch (e: any) {
113
+ if (e.name == 'RpcError' && e.code == 'NOT_FOUND') {
114
+ ctx.markUnstable(`NOT_FOUND in logs stream driver while getting a progress log with info: ${e}`);
115
+ return undefined;
116
+ }
117
+ throw e;
118
+ }
119
+ }
120
+
78
121
  /** Returns an Id of a smart object, that can read logs directly from
79
122
  * the platform. */
80
123
  getLogHandle(res: ResourceInfo | PlTreeEntry): Computable<sdk.AnyLogHandle | undefined>;