@milaboratories/pl-drivers 1.5.9 → 1.5.11

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.
Files changed (118) hide show
  1. package/dist/clients/constructors.d.ts.map +1 -1
  2. package/dist/clients/download.d.ts.map +1 -1
  3. package/dist/clients/logs.d.ts.map +1 -1
  4. package/dist/clients/ls_api.d.ts.map +1 -1
  5. package/dist/clients/progress.d.ts.map +1 -1
  6. package/dist/clients/upload.d.ts.map +1 -1
  7. package/dist/drivers/download_blob.d.ts +2 -2
  8. package/dist/drivers/download_blob.d.ts.map +1 -1
  9. package/dist/drivers/download_blob_task.d.ts +2 -2
  10. package/dist/drivers/download_blob_task.d.ts.map +1 -1
  11. package/dist/drivers/download_blob_url/driver.d.ts +46 -0
  12. package/dist/drivers/download_blob_url/driver.d.ts.map +1 -0
  13. package/dist/drivers/download_blob_url/driver_id.d.ts +6 -0
  14. package/dist/drivers/download_blob_url/driver_id.d.ts.map +1 -0
  15. package/dist/drivers/download_blob_url/snapshot.d.ts +7 -0
  16. package/dist/drivers/download_blob_url/snapshot.d.ts.map +1 -0
  17. package/dist/drivers/download_blob_url/task.d.ts +63 -0
  18. package/dist/drivers/download_blob_url/task.d.ts.map +1 -0
  19. package/dist/drivers/download_blob_url/url.d.ts +6 -0
  20. package/dist/drivers/download_blob_url/url.d.ts.map +1 -0
  21. package/dist/drivers/download_url.d.ts +2 -2
  22. package/dist/drivers/download_url.d.ts.map +1 -1
  23. package/dist/drivers/helpers/download_local_handle.d.ts.map +1 -1
  24. package/dist/drivers/helpers/download_remote_handle.d.ts.map +1 -1
  25. package/dist/drivers/helpers/files_cache.d.ts.map +1 -1
  26. package/dist/drivers/helpers/logs_handle.d.ts +1 -1
  27. package/dist/drivers/helpers/logs_handle.d.ts.map +1 -1
  28. package/dist/drivers/helpers/ls_remote_import_handle.d.ts +1 -1
  29. package/dist/drivers/helpers/ls_remote_import_handle.d.ts.map +1 -1
  30. package/dist/drivers/helpers/ls_storage_entry.d.ts +1 -1
  31. package/dist/drivers/helpers/ls_storage_entry.d.ts.map +1 -1
  32. package/dist/drivers/logs.d.ts +2 -2
  33. package/dist/drivers/logs.d.ts.map +1 -1
  34. package/dist/drivers/logs_stream.d.ts +2 -2
  35. package/dist/drivers/logs_stream.d.ts.map +1 -1
  36. package/dist/drivers/ls.d.ts +1 -1
  37. package/dist/drivers/ls.d.ts.map +1 -1
  38. package/dist/drivers/types.d.ts.map +1 -1
  39. package/dist/drivers/upload.d.ts +1 -1
  40. package/dist/drivers/upload.d.ts.map +1 -1
  41. package/dist/drivers/upload_task.d.ts +1 -1
  42. package/dist/drivers/upload_task.d.ts.map +1 -1
  43. package/dist/drivers/virtual_storages.d.ts.map +1 -1
  44. package/dist/helpers/download.d.ts.map +1 -1
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +2 -2
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.mjs +2310 -2067
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -1
  52. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -1
  53. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -1
  54. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -1
  55. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -1
  56. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -1
  57. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -1
  58. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.d.ts.map +1 -1
  59. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.d.ts.map +1 -1
  60. package/dist/proto/google/api/http.d.ts +28 -28
  61. package/dist/proto/google/api/http.d.ts.map +1 -1
  62. package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -1
  63. package/dist/proto/google/protobuf/duration.d.ts.map +1 -1
  64. package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -1
  65. package/package.json +11 -6
  66. package/src/clients/constructors.ts +11 -11
  67. package/src/clients/download.test.ts +11 -10
  68. package/src/clients/download.ts +15 -14
  69. package/src/clients/logs.ts +13 -12
  70. package/src/clients/ls_api.ts +7 -7
  71. package/src/clients/progress.ts +15 -13
  72. package/src/clients/upload.test.ts +6 -5
  73. package/src/clients/upload.ts +28 -26
  74. package/src/drivers/download_blob.test.ts +21 -20
  75. package/src/drivers/download_blob.ts +47 -42
  76. package/src/drivers/download_blob_task.ts +25 -21
  77. package/src/drivers/download_blob_url/driver.ts +225 -0
  78. package/src/drivers/download_blob_url/driver_id.ts +11 -0
  79. package/src/drivers/download_blob_url/snapshot.ts +20 -0
  80. package/src/drivers/download_blob_url/task.ts +222 -0
  81. package/src/drivers/download_blob_url/url.test.ts +39 -0
  82. package/src/drivers/download_blob_url/url.ts +43 -0
  83. package/src/drivers/download_url.test.ts +3 -3
  84. package/src/drivers/download_url.ts +21 -20
  85. package/src/drivers/helpers/download_local_handle.ts +2 -2
  86. package/src/drivers/helpers/download_remote_handle.ts +8 -8
  87. package/src/drivers/helpers/files_cache.test.ts +7 -6
  88. package/src/drivers/helpers/files_cache.ts +2 -1
  89. package/src/drivers/helpers/helpers.ts +1 -1
  90. package/src/drivers/helpers/logs_handle.ts +7 -7
  91. package/src/drivers/helpers/ls_remote_import_handle.ts +7 -7
  92. package/src/drivers/helpers/ls_storage_entry.ts +6 -5
  93. package/src/drivers/logs.test.ts +23 -22
  94. package/src/drivers/logs.ts +13 -12
  95. package/src/drivers/logs_stream.ts +42 -37
  96. package/src/drivers/ls.test.ts +2 -2
  97. package/src/drivers/ls.ts +38 -35
  98. package/src/drivers/types.ts +12 -11
  99. package/src/drivers/upload.test.ts +19 -17
  100. package/src/drivers/upload.ts +30 -25
  101. package/src/drivers/upload_task.ts +23 -19
  102. package/src/drivers/virtual_storages.ts +6 -6
  103. package/src/helpers/download.ts +8 -8
  104. package/src/index.ts +2 -0
  105. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +4 -4
  106. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +88 -73
  107. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +2 -2
  108. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +71 -56
  109. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +6 -5
  110. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +130 -106
  111. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +14 -10
  112. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +142 -121
  113. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.client.ts +11 -8
  114. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/uploadapi/protocol.ts +216 -174
  115. package/src/proto/google/api/http.ts +95 -86
  116. package/src/proto/google/protobuf/descriptor.ts +674 -593
  117. package/src/proto/google/protobuf/duration.ts +31 -26
  118. package/src/proto/google/protobuf/timestamp.ts +52 -44
@@ -1,5 +1,6 @@
1
- import * as sdk from '@milaboratories/pl-model-common';
2
- import { bigintToResourceId, ResourceId, ResourceType } from '@milaboratories/pl-client';
1
+ import type * as sdk from '@milaboratories/pl-model-common';
2
+ import type { ResourceId, ResourceType } from '@milaboratories/pl-client';
3
+ import { bigintToResourceId } from '@milaboratories/pl-client';
3
4
  import { assertNever } from '@milaboratories/ts-helpers';
4
5
 
5
6
  export type StorageHandleData = RemoteStorageHandleData | LocalStorageHandleData;
@@ -46,7 +47,7 @@ function parseLocalStorageHandle(handle: string): LocalStorageHandleData {
46
47
  return {
47
48
  rootPath: decodeURIComponent(path),
48
49
  name,
49
- isRemote: false
50
+ isRemote: false,
50
51
  };
51
52
  }
52
53
 
@@ -64,7 +65,7 @@ export type RemoteStorageHandleData = {
64
65
  const remoteHandleRegex = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
65
66
 
66
67
  export function isRemoteStorageHandle(
67
- handle: sdk.StorageHandle
68
+ handle: sdk.StorageHandle,
68
69
  ): handle is sdk.StorageHandleRemote {
69
70
  return remoteHandleRegex.test(handle);
70
71
  }
@@ -82,7 +83,7 @@ function parseRemoteStorageHandle(handle: string): RemoteStorageHandleData {
82
83
  id: bigintToResourceId(BigInt(resourceId)),
83
84
  type: storageType(name),
84
85
  name,
85
- isRemote: true
86
+ isRemote: true,
86
87
  };
87
88
  }
88
89
 
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from '@jest/globals';
2
2
  import { Computable } from '@milaboratories/computable';
3
- import {
3
+ import type {
4
4
  AnyFieldRef,
5
5
  FieldId,
6
6
  FieldRef,
@@ -8,10 +8,11 @@ import {
8
8
  PlTransaction,
9
9
  ResourceId,
10
10
  ResourceRef,
11
- ResourceType,
11
+ ResourceType } from '@milaboratories/pl-client';
12
+ import {
12
13
  TestHelpers,
13
14
  jsonToData,
14
- stringifyWithResourceId
15
+ stringifyWithResourceId,
15
16
  } from '@milaboratories/pl-client';
16
17
  import { SynchronizedTreeState } from '@milaboratories/pl-tree';
17
18
  import { ConsoleLoggerAdapter, HmacSha256Signer, notEmpty } from '@milaboratories/ts-helpers';
@@ -30,7 +31,7 @@ test('should get all logs', async () => {
30
31
 
31
32
  const tree = await SynchronizedTreeState.init(client, client.clientRoot, {
32
33
  stopPollingDelay: 10,
33
- pollingInterval: 10
34
+ pollingInterval: 10,
34
35
  });
35
36
  const logsStream = new LogsStreamDriver(logger, createLogsClient(client, logger));
36
37
  const dir = await fsp.mkdtemp(path.join(os.tmpdir(), 'test-logs-1-'));
@@ -40,7 +41,7 @@ test('should get all logs', async () => {
40
41
  createLogsClient(client, logger),
41
42
  dir,
42
43
  new HmacSha256Signer(HmacSha256Signer.generateSecret()),
43
- { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 }
44
+ { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 },
44
45
  );
45
46
  const logs = new LogsDriver(logger, logsStream, download);
46
47
 
@@ -75,7 +76,7 @@ test('should get last line with a prefix', async () => {
75
76
 
76
77
  const tree = await SynchronizedTreeState.init(client, client.clientRoot, {
77
78
  stopPollingDelay: 10,
78
- pollingInterval: 10
79
+ pollingInterval: 10,
79
80
  });
80
81
  const logsStream = new LogsStreamDriver(logger, createLogsClient(client, logger));
81
82
  const dir = await fsp.mkdtemp(path.join(os.tmpdir(), 'test-logs-2-'));
@@ -85,7 +86,7 @@ test('should get last line with a prefix', async () => {
85
86
  createLogsClient(client, logger),
86
87
  dir,
87
88
  new HmacSha256Signer(HmacSha256Signer.generateSecret()),
88
- { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 }
89
+ { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 },
89
90
  );
90
91
  const logs = new LogsDriver(logger, logsStream, download);
91
92
 
@@ -103,7 +104,7 @@ test('should get last line with a prefix', async () => {
103
104
 
104
105
  await createRunCommandWithStdoutStream(client, 'bash', [
105
106
  '-c',
106
- 'echo PREFIX1; echo PREFIX2; echo 3; sleep 0.1; echo PREFIX4'
107
+ 'echo PREFIX1; echo PREFIX2; echo 3; sleep 0.1; echo PREFIX4',
107
108
  ]);
108
109
 
109
110
  while (true) {
@@ -125,7 +126,7 @@ test('should get log smart object and get log lines from that', async () => {
125
126
 
126
127
  const tree = await SynchronizedTreeState.init(client, client.clientRoot, {
127
128
  stopPollingDelay: 10,
128
- pollingInterval: 10
129
+ pollingInterval: 10,
129
130
  });
130
131
  const logsStream = new LogsStreamDriver(logger, createLogsClient(client, logger));
131
132
  const dir = await fsp.mkdtemp(path.join(os.tmpdir(), 'test-logs-3-'));
@@ -135,7 +136,7 @@ test('should get log smart object and get log lines from that', async () => {
135
136
  createLogsClient(client, logger),
136
137
  dir,
137
138
  new HmacSha256Signer(HmacSha256Signer.generateSecret()),
138
- { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 }
139
+ { cacheSoftSizeBytes: 700 * 1024, nConcurrentDownloads: 10 },
139
140
  );
140
141
  const logs = new LogsDriver(logger, logsStream, download);
141
142
 
@@ -181,7 +182,7 @@ test('should get log smart object and get log lines from that', async () => {
181
182
  async function createRunCommandWithStdoutStream(
182
183
  client: PlClient,
183
184
  cmd: string,
184
- args: string[]
185
+ args: string[],
185
186
  ): Promise<ResourceId> {
186
187
  return await client.withWriteTx('CreateRunCommandWithStreaming', async (tx: PlTransaction) => {
187
188
  const wdFId: FieldRef = createWd(tx);
@@ -192,7 +193,7 @@ async function createRunCommandWithStdoutStream(
192
193
 
193
194
  const dynamicId: FieldId = {
194
195
  resourceId: client.clientRoot,
195
- fieldName: 'result'
196
+ fieldName: 'result',
196
197
  };
197
198
  tx.createField(dynamicId, 'Dynamic', streamManagerId);
198
199
 
@@ -211,18 +212,18 @@ function createRunCommand(
211
212
  tx: PlTransaction,
212
213
  wdFId: FieldRef,
213
214
  cmd: string,
214
- args: string[]
215
+ args: string[],
215
216
  ): FieldRef {
216
217
  const refsId = tx.createStruct({ name: 'RunCommandRefs', version: '1' });
217
218
  tx.lock(refsId);
218
219
  const cmdData = {
219
220
  type: 'string',
220
- value: cmd
221
+ value: cmd,
221
222
  };
222
223
  const argsData = args.map((arg) => {
223
224
  return {
224
225
  type: 'string',
225
- value: arg
226
+ value: arg,
226
227
  };
227
228
  });
228
229
  const optsData = {
@@ -230,7 +231,7 @@ function createRunCommand(
230
231
  errorLines: 200,
231
232
  redirectStdout: 'logs.txt',
232
233
  redirectStderr: 'logs.txt',
233
- envs: []
234
+ envs: [],
234
235
  };
235
236
 
236
237
  const runCmdId = tx.createEphemeral({ name: 'RunCommand/executor', version: '1' });
@@ -257,9 +258,9 @@ function createWdSave(tx: PlTransaction, workdirOut: FieldRef): FieldRef {
257
258
  {
258
259
  blobKey: 'logs.txt',
259
260
  type: 'file',
260
- filePath: 'logs.txt'
261
- }
262
- ])
261
+ filePath: 'logs.txt',
262
+ },
263
+ ]),
263
264
  );
264
265
  tx.setField({ resourceId: wdSave, fieldName: 'workdirIn' }, workdirOut);
265
266
  tx.setField({ resourceId: wdSave, fieldName: 'rules' }, wdSaveRules);
@@ -271,7 +272,7 @@ function createDownloadableBlobFromStdout(tx: PlTransaction, blobsOut: FieldRef)
271
272
  const blobOut = tx.getFutureFieldValue(blobsOut, 'logs.txt', 'Input');
272
273
  const blobDownloadId = tx.createStruct({
273
274
  name: 'BlobDownload',
274
- version: '2'
275
+ version: '2',
275
276
  });
276
277
  tx.setField({ resourceId: blobDownloadId, fieldName: 'blob' }, blobOut);
277
278
 
@@ -281,7 +282,7 @@ function createDownloadableBlobFromStdout(tx: PlTransaction, blobsOut: FieldRef)
281
282
  function createStreamManager(
282
283
  tx: PlTransaction,
283
284
  wdFId: FieldRef,
284
- downloadableFId: AnyFieldRef
285
+ downloadableFId: AnyFieldRef,
285
286
  ): ResourceRef {
286
287
  const streamId = tx.createEphemeral({ name: 'CreateStream', version: '2' });
287
288
  tx.setField({ resourceId: streamId, fieldName: 'workdir' }, wdFId);
@@ -291,7 +292,7 @@ function createStreamManager(
291
292
 
292
293
  const streamManagerId = tx.createEphemeral({
293
294
  name: 'StreamManager',
294
- version: '2'
295
+ version: '2',
295
296
  });
296
297
  tx.setField({ resourceId: streamManagerId, fieldName: 'downloadable' }, downloadableFId);
297
298
  tx.setField({ resourceId: streamManagerId, fieldName: 'stream' }, streamFId);
@@ -1,16 +1,17 @@
1
- import { Computable, ComputableCtx } from '@milaboratories/computable';
2
- import { PlTreeEntry, ResourceInfo } from '@milaboratories/pl-tree';
3
- import { LogsStreamDriver } from './logs_stream';
4
- import * as sdk from '@milaboratories/pl-model-common';
5
- import { MiLogger } from '@milaboratories/ts-helpers';
6
- import { DownloadDriver } from './download_blob';
1
+ import type { ComputableCtx } from '@milaboratories/computable';
2
+ import { Computable } from '@milaboratories/computable';
3
+ import type { PlTreeEntry, ResourceInfo } from '@milaboratories/pl-tree';
4
+ import type { LogsStreamDriver } from './logs_stream';
5
+ import type * as sdk from '@milaboratories/pl-model-common';
6
+ import type { MiLogger } from '@milaboratories/ts-helpers';
7
+ import type { DownloadDriver } from './download_blob';
7
8
  import { isLiveLogHandle } from './helpers/logs_handle';
8
9
 
9
10
  export class LogsDriver implements sdk.LogsDriver {
10
11
  constructor(
11
12
  private readonly logger: MiLogger,
12
13
  private readonly logsStreamDriver: LogsStreamDriver,
13
- private readonly downloadDriver: DownloadDriver
14
+ private readonly downloadDriver: DownloadDriver,
14
15
  ) {}
15
16
 
16
17
  /** Returns all logs and schedules a job that reads remain logs.
@@ -20,7 +21,7 @@ export class LogsDriver implements sdk.LogsDriver {
20
21
  getLastLogs(
21
22
  res: PlTreeEntry,
22
23
  lines: number,
23
- ctx?: ComputableCtx
24
+ ctx?: ComputableCtx,
24
25
  ): Computable<string | undefined> | string | undefined {
25
26
  if (ctx === undefined) return Computable.make((ctx) => this.getLastLogs(res, lines, ctx));
26
27
 
@@ -50,7 +51,7 @@ export class LogsDriver implements sdk.LogsDriver {
50
51
  getProgressLog(
51
52
  res: PlTreeEntry,
52
53
  patternToSearch: string,
53
- ctx?: ComputableCtx
54
+ ctx?: ComputableCtx,
54
55
  ): Computable<string | undefined> | string | undefined {
55
56
  if (ctx === undefined)
56
57
  return Computable.make((ctx) => this.getProgressLog(res, patternToSearch, ctx));
@@ -80,7 +81,7 @@ export class LogsDriver implements sdk.LogsDriver {
80
81
  getLogHandle(res: PlTreeEntry, ctx: ComputableCtx): sdk.AnyLogHandle | undefined;
81
82
  getLogHandle(
82
83
  res: PlTreeEntry,
83
- ctx?: ComputableCtx
84
+ ctx?: ComputableCtx,
84
85
  ): Computable<sdk.AnyLogHandle | undefined> | sdk.AnyLogHandle | undefined {
85
86
  if (ctx === undefined) return Computable.make((ctx) => this.getLogHandle(res, ctx));
86
87
 
@@ -99,7 +100,7 @@ export class LogsDriver implements sdk.LogsDriver {
99
100
  handle: sdk.AnyLogHandle,
100
101
  lineCount: number,
101
102
  offsetBytes?: number,
102
- searchStr?: string
103
+ searchStr?: string,
103
104
  ): Promise<sdk.StreamingApiResponse> {
104
105
  if (isLiveLogHandle(handle))
105
106
  return await this.logsStreamDriver.lastLines(handle, lineCount, offsetBytes, searchStr);
@@ -110,7 +111,7 @@ export class LogsDriver implements sdk.LogsDriver {
110
111
  handle: sdk.AnyLogHandle,
111
112
  lineCount: number,
112
113
  offsetBytes?: number,
113
- searchStr?: string
114
+ searchStr?: string,
114
115
  ): Promise<sdk.StreamingApiResponse> {
115
116
  if (isLiveLogHandle(handle))
116
117
  return await this.logsStreamDriver.readText(handle, lineCount, offsetBytes, searchStr);
@@ -1,25 +1,30 @@
1
+ import type {
2
+ ComputableCtx,
3
+ Watcher,
4
+ } from '@milaboratories/computable';
1
5
  import {
2
6
  ChangeSource,
3
7
  Computable,
4
- ComputableCtx,
5
8
  PollingComputableHooks,
6
- Watcher
7
9
  } from '@milaboratories/computable';
8
- import {
10
+ import type {
9
11
  ResourceId,
12
+ ResourceType } from '@milaboratories/pl-client';
13
+ import {
10
14
  resourceIdToString,
11
- ResourceType,
12
- stringifyWithResourceId
15
+ stringifyWithResourceId,
13
16
  } from '@milaboratories/pl-client';
14
- import { asyncPool, CallersCounter, MiLogger } from '@milaboratories/ts-helpers';
15
- import { ClientLogs } from '../clients/logs';
17
+ import type { MiLogger } from '@milaboratories/ts-helpers';
18
+ import { asyncPool, CallersCounter } from '@milaboratories/ts-helpers';
19
+ import type { ClientLogs } from '../clients/logs';
16
20
  import { randomUUID } from 'node:crypto';
17
- import { PlTreeEntry, ResourceInfo, treeEntryToResourceInfo } from '@milaboratories/pl-tree';
21
+ import type { PlTreeEntry, ResourceInfo } from '@milaboratories/pl-tree';
22
+ import { treeEntryToResourceInfo } from '@milaboratories/pl-tree';
18
23
  import { scheduler } from 'node:timers/promises';
19
- import { StreamingAPI_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';
20
- import * as sdk from '@milaboratories/pl-model-common';
21
- import { PollingOps } from './helpers/polling_ops';
22
- import { RpcError } from '@protobuf-ts/runtime-rpc';
24
+ import type { StreamingAPI_Response } from '../proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol';
25
+ import type * as sdk from '@milaboratories/pl-model-common';
26
+ import type { PollingOps } from './helpers/polling_ops';
27
+ import type { RpcError } from '@protobuf-ts/runtime-rpc';
23
28
  import { getResourceInfoFromLogHandle, isLiveLogHandle, newLogHandle } from './helpers/logs_handle';
24
29
  import { WrongResourceTypeError } from './helpers/helpers';
25
30
 
@@ -44,14 +49,14 @@ export class LogsStreamDriver implements sdk.LogsDriver {
44
49
  private readonly opts: LogsStreamDriverOps = {
45
50
  nConcurrentGetLogs: 10,
46
51
  pollingInterval: 1000,
47
- stopPollingDelay: 1000
48
- }
52
+ stopPollingDelay: 1000,
53
+ },
49
54
  ) {
50
55
  this.hooks = new PollingComputableHooks(
51
56
  () => this.startUpdating(),
52
57
  () => this.stopUpdating(),
53
58
  { stopDebounce: opts.stopPollingDelay },
54
- (resolve, reject) => this.scheduleOnNextState(resolve, reject)
59
+ (resolve, reject) => this.scheduleOnNextState(resolve, reject),
55
60
  );
56
61
  }
57
62
 
@@ -64,7 +69,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
64
69
  getLastLogs(
65
70
  res: ResourceInfo | PlTreeEntry,
66
71
  lines: number,
67
- ctx?: ComputableCtx
72
+ ctx?: ComputableCtx,
68
73
  ): Computable<string | undefined> | string | undefined {
69
74
  if (ctx == undefined) return Computable.make((ctx) => this.getLastLogs(res, lines, ctx));
70
75
 
@@ -75,7 +80,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
75
80
 
76
81
  const result = this.getLastLogsNoCtx(ctx.watcher, r, lines, callerId);
77
82
  ctx.markUnstable(
78
- 'The logs are from stream, so we consider them unstable. Final values will be got from blobs.'
83
+ 'The logs are from stream, so we consider them unstable. Final values will be got from blobs.',
79
84
  );
80
85
 
81
86
  return result;
@@ -85,7 +90,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
85
90
  w: Watcher,
86
91
  rInfo: ResourceInfo,
87
92
  lines: number,
88
- callerId: string
93
+ callerId: string,
89
94
  ): string | undefined {
90
95
  validateResourceType('getLastLogs', rInfo.type);
91
96
 
@@ -119,7 +124,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
119
124
  getProgressLog(
120
125
  res: ResourceInfo | PlTreeEntry,
121
126
  patternToSearch: string,
122
- ctx?: ComputableCtx
127
+ ctx?: ComputableCtx,
123
128
  ): Computable<string | undefined> | string | undefined {
124
129
  if (ctx == undefined)
125
130
  return Computable.make((ctx) => this.getProgressLog(res, patternToSearch, ctx));
@@ -131,7 +136,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
131
136
 
132
137
  const result = this.getProgressLogNoCtx(ctx.watcher, r, patternToSearch, callerId);
133
138
  ctx.markUnstable(
134
- 'The progress log is from the stream, so we consider it unstable. Final value will be got from blobs.'
139
+ 'The progress log is from the stream, so we consider it unstable. Final value will be got from blobs.',
135
140
  );
136
141
 
137
142
  return result;
@@ -141,7 +146,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
141
146
  w: Watcher,
142
147
  rInfo: ResourceInfo,
143
148
  patternToSearch: string,
144
- callerId: string
149
+ callerId: string,
145
150
  ): string | undefined {
146
151
  validateResourceType('getProgressLog', rInfo.type);
147
152
 
@@ -165,7 +170,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
165
170
  getLogHandle(res: ResourceInfo | PlTreeEntry, ctx: ComputableCtx): sdk.AnyLogHandle;
166
171
  getLogHandle(
167
172
  res: ResourceInfo | PlTreeEntry,
168
- ctx?: ComputableCtx
173
+ ctx?: ComputableCtx,
169
174
  ): Computable<sdk.AnyLogHandle> | sdk.AnyLogHandle {
170
175
  if (ctx == undefined) return Computable.make((ctx) => this.getLogHandle(res, ctx));
171
176
 
@@ -190,15 +195,15 @@ export class LogsStreamDriver implements sdk.LogsDriver {
190
195
  handle: sdk.AnyLogHandle,
191
196
  lineCount: number,
192
197
  offsetBytes?: number,
193
- searchStr?: string | undefined
198
+ searchStr?: string | undefined,
194
199
  ) {
195
200
  return await this.tryWithNotFound(handle, () =>
196
201
  this.clientLogs.lastLines(
197
202
  getResourceInfoFromLogHandle(handle),
198
203
  lineCount,
199
204
  BigInt(offsetBytes ?? 0),
200
- searchStr
201
- )
205
+ searchStr,
206
+ ),
202
207
  );
203
208
  }
204
209
 
@@ -206,21 +211,21 @@ export class LogsStreamDriver implements sdk.LogsDriver {
206
211
  handle: sdk.AnyLogHandle,
207
212
  lineCount: number,
208
213
  offsetBytes?: number,
209
- searchStr?: string | undefined
214
+ searchStr?: string | undefined,
210
215
  ) {
211
216
  return await this.tryWithNotFound(handle, () =>
212
217
  this.clientLogs.readText(
213
218
  getResourceInfoFromLogHandle(handle),
214
219
  lineCount,
215
220
  BigInt(offsetBytes ?? 0),
216
- searchStr
217
- )
221
+ searchStr,
222
+ ),
218
223
  );
219
224
  }
220
225
 
221
226
  private async tryWithNotFound(
222
227
  handle: sdk.AnyLogHandle,
223
- method: () => Promise<StreamingAPI_Response>
228
+ method: () => Promise<StreamingAPI_Response>,
224
229
  ): Promise<sdk.StreamingApiResponse> {
225
230
  if (!isLiveLogHandle(handle))
226
231
  throw new Error(`Not live log handle was passed to live log driver, handle: ${handle}`);
@@ -232,7 +237,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
232
237
  shouldUpdateHandle: false,
233
238
  data: resp.data,
234
239
  size: Number(resp.size),
235
- newOffset: Number(resp.newOffset)
240
+ newOffset: Number(resp.newOffset),
236
241
  };
237
242
  } catch (e: any) {
238
243
  if (e.name == 'RpcError' && e.code == 'NOT_FOUND') {
@@ -286,7 +291,7 @@ export class LogsStreamDriver implements sdk.LogsDriver {
286
291
  const logs = this.getAllLogs();
287
292
  await asyncPool(
288
293
  this.opts.nConcurrentGetLogs,
289
- logs.map((getter) => async () => await getter.update())
294
+ logs.map((getter) => async () => await getter.update()),
290
295
  );
291
296
 
292
297
  toNotify.forEach((n) => n.resolve());
@@ -322,7 +327,7 @@ class LogGetter {
322
327
  private readonly clientLogs: ClientLogs,
323
328
  private readonly rInfo: ResourceInfo,
324
329
  private readonly lines: number,
325
- private readonly patternToSearch?: string
330
+ private readonly patternToSearch?: string,
326
331
  ) {}
327
332
 
328
333
  getLog(): {
@@ -331,7 +336,7 @@ class LogGetter {
331
336
  } {
332
337
  return {
333
338
  log: this.logs,
334
- error: this.error
339
+ error: this.error,
335
340
  };
336
341
  }
337
342
 
@@ -350,7 +355,7 @@ class LogGetter {
350
355
  this.rInfo,
351
356
  this.lines,
352
357
  0n,
353
- this.patternToSearch
358
+ this.patternToSearch,
354
359
  );
355
360
 
356
361
  const newLogs = resp.data.toString();
@@ -371,7 +376,7 @@ class LogGetter {
371
376
  }
372
377
 
373
378
  this.logger.error(
374
- `Stream log lines for ${stringifyWithResourceId(this.rInfo.id)} failed, reason: ${e}`
379
+ `Stream log lines for ${stringifyWithResourceId(this.rInfo.id)} failed, reason: ${e}`,
375
380
  );
376
381
  throw e;
377
382
  }
@@ -386,8 +391,8 @@ type ScheduledRefresh = {
386
391
  function validateResourceType(methodName: string, rType: ResourceType) {
387
392
  if (!rType.name.startsWith('StreamWorkdir')) {
388
393
  throw new WrongResourceTypeError(
389
- `${methodName}: wrong resource type: ${rType.name}, ` +
390
- `expected: a resource of type 'StreamWorkdir'.`
394
+ `${methodName}: wrong resource type: ${rType.name}, `
395
+ + `expected: a resource of type 'StreamWorkdir'.`,
391
396
  );
392
397
  }
393
398
  }
@@ -91,7 +91,7 @@ test('should ok when list files from local storage in ls driver and correctly ap
91
91
  client,
92
92
  signer,
93
93
  [{ storageId: 'test_storage', localPath: path.join(assetsPath, 'ls_dir_structure_test') }],
94
- async () => [dialogRet]
94
+ async () => [dialogRet],
95
95
  );
96
96
 
97
97
  const storages = await driver.getStorageList();
@@ -128,7 +128,7 @@ test('should ok when get file using local dialog, and read its content', async (
128
128
  const logger = new ConsoleLoggerAdapter();
129
129
  await TestHelpers.withTempRoot(async (client) => {
130
130
  const driver = await LsDriver.init(logger, client, signer, [], async () => [
131
- path.join(assetsPath, 'answer_to_the_ultimate_question.txt')
131
+ path.join(assetsPath, 'answer_to_the_ultimate_question.txt'),
132
132
  ]);
133
133
 
134
134
  const result = await driver.showOpenSingleFileDialog();