@milaboratories/pl-drivers 1.5.12 → 1.5.14

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.12",
3
+ "version": "1.5.14",
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",
@@ -27,11 +27,11 @@
27
27
  "tar-fs": "^3.0.8",
28
28
  "undici": "^7.2.3",
29
29
  "zod": "~3.23.8",
30
- "@milaboratories/ts-helpers": "^1.1.3",
31
30
  "@milaboratories/computable": "^2.3.4",
32
- "@milaboratories/pl-client": "^2.7.3",
33
- "@milaboratories/pl-tree": "^1.4.22",
34
- "@milaboratories/pl-model-common": "^1.10.4"
31
+ "@milaboratories/ts-helpers": "^1.1.3",
32
+ "@milaboratories/pl-client": "^2.7.4",
33
+ "@milaboratories/pl-tree": "^1.4.23",
34
+ "@milaboratories/pl-model-common": "^1.10.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "eslint": "^9.16.0",
@@ -44,8 +44,8 @@
44
44
  "jest": "^29.7.0",
45
45
  "@jest/globals": "^29.7.0",
46
46
  "ts-jest": "^29.2.5",
47
- "@milaboratories/eslint-config": "^1.0.1",
48
- "@milaboratories/platforma-build-configs": "1.0.2"
47
+ "@milaboratories/platforma-build-configs": "1.0.2",
48
+ "@milaboratories/eslint-config": "^1.0.1"
49
49
  },
50
50
  "scripts": {
51
51
  "type-check": "tsc --noEmit --composite false",
@@ -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>;