@milaboratories/pl-drivers 1.5.15 → 1.5.17

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/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- var rt = Object.defineProperty;
2
- var st = (s, e, t) => e in s ? rt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var d = (s, e, t) => st(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { addRTypeToMetadata as P, bigintToResourceId as he, stringifyWithResourceId as y, resourceIdToString as it, isNotNullResourceId as at } from "@milaboratories/pl-client";
1
+ var st = Object.defineProperty;
2
+ var it = (s, e, t) => e in s ? st(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var d = (s, e, t) => it(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { addRTypeToMetadata as P, bigintToResourceId as he, stringifyWithResourceId as y, resourceIdToString as at, isNotNullResourceId as lt } from "@milaboratories/pl-client";
5
5
  import * as m from "node:fs/promises";
6
6
  import { request as Ne } from "undici";
7
- import { ServiceType as C, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
8
- import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as R, typeofJsonValue as Be, assertNever as lt } from "@protobuf-ts/runtime";
9
- import { notEmpty as H, CallersCounter as S, ensureDirExists as ue, fileExists as pe, createPathAtomically as ge, mapGet as Pe, mapEntries as ct, TaskProcessor as j, asyncPool as fe, assertNever as dt } from "@milaboratories/ts-helpers";
7
+ import { ServiceType as _, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
8
+ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as ct } from "@protobuf-ts/runtime";
9
+ import { notEmpty as H, CallersCounter as v, ensureDirExists as ue, fileExists as pe, createPathAtomically as ge, mapGet as Pe, mapEntries as dt, TaskProcessor as j, asyncPool as fe, assertNever as ht } from "@milaboratories/ts-helpers";
10
10
  import * as me from "node:fs";
11
11
  import ie from "node:fs";
12
12
  import * as b from "node:path";
13
13
  import L from "node:path";
14
- import { Readable as we, Writable as U, Transform as $e } from "node:stream";
15
- import { text as ht, buffer as _e } from "node:stream/consumers";
16
- import { ChangeSource as N, Computable as w, PollingComputableHooks as Ce } from "@milaboratories/computable";
17
- import { rsSchema as G, treeEntryToResourceInfo as I, isPlTreeEntry as F, makeResourceSnapshot as A, isPlTreeEntryAccessor as Fe } from "@milaboratories/pl-tree";
18
- import ut from "denque";
19
- import { randomUUID as D, createHash as pt } from "node:crypto";
20
- import * as De from "node:os";
21
- import gt from "node:os";
22
- import * as ft from "node:readline/promises";
14
+ import { Readable as we, Writable as I, Transform as $e } from "node:stream";
15
+ import { text as ut, buffer as Ce } from "node:stream/consumers";
16
+ import { ChangeSource as N, Computable as w, PollingComputableHooks as _e } from "@milaboratories/computable";
17
+ import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Ee } from "@milaboratories/pl-tree";
18
+ import pt from "denque";
19
+ import { randomUUID as U, createHash as gt } from "node:crypto";
20
+ import * as Ue from "node:os";
21
+ import ft from "node:os";
22
+ import * as mt from "node:readline/promises";
23
23
  import { z as k } from "zod";
24
24
  import * as Oe from "node:zlib";
25
25
  import * as ae from "tar-fs";
26
- import mt from "decompress";
27
- import { scheduler as Ee } from "node:timers/promises";
28
- import wt from "node:assert";
29
- import { isImportFileHandleIndex as yt } from "@milaboratories/pl-model-common";
30
- import bt from "node:util";
31
- import { exec as Tt } from "node:child_process";
32
- class kt extends g {
26
+ import wt from "decompress";
27
+ import { scheduler as Fe } from "node:timers/promises";
28
+ import yt from "node:assert";
29
+ import { isImportFileHandleIndex as bt } from "@milaboratories/pl-model-common";
30
+ import Tt from "node:util";
31
+ import { exec as kt } from "node:child_process";
32
+ class Lt extends g {
33
33
  constructor() {
34
34
  super("MiLaboratories.Controller.Shared.uploadapi", []);
35
35
  }
@@ -49,8 +49,8 @@ class kt extends g {
49
49
  ), t;
50
50
  }
51
51
  }
52
- new kt();
53
- class Lt extends g {
52
+ new Lt();
53
+ class Pt extends g {
54
54
  constructor() {
55
55
  super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
56
56
  }
@@ -70,8 +70,8 @@ class Lt extends g {
70
70
  ), t;
71
71
  }
72
72
  }
73
- new Lt();
74
- class Pt extends g {
73
+ new Pt();
74
+ class Ut extends g {
75
75
  constructor() {
76
76
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
77
77
  {
@@ -125,7 +125,7 @@ class Pt extends g {
125
125
  ), t;
126
126
  }
127
127
  }
128
- const Dt = new Pt();
128
+ const Dt = new Ut();
129
129
  class Rt extends g {
130
130
  constructor() {
131
131
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
@@ -202,7 +202,7 @@ class Rt extends g {
202
202
  }
203
203
  }
204
204
  const It = new Rt();
205
- class Ut extends g {
205
+ class St extends g {
206
206
  constructor() {
207
207
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
208
208
  }
@@ -222,7 +222,7 @@ class Ut extends g {
222
222
  ), t;
223
223
  }
224
224
  }
225
- new Ut();
225
+ new St();
226
226
  class vt extends g {
227
227
  constructor() {
228
228
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
@@ -293,8 +293,8 @@ class vt extends g {
293
293
  ), t;
294
294
  }
295
295
  }
296
- const St = new vt();
297
- class Nt extends g {
296
+ const Nt = new vt();
297
+ class Bt extends g {
298
298
  constructor() {
299
299
  super(
300
300
  "MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
@@ -321,8 +321,8 @@ class Nt extends g {
321
321
  ), t;
322
322
  }
323
323
  }
324
- const Bt = new Nt();
325
- class $t extends g {
324
+ const $t = new Bt();
325
+ class Ct extends g {
326
326
  constructor() {
327
327
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
328
328
  }
@@ -342,7 +342,7 @@ class $t extends g {
342
342
  ), t;
343
343
  }
344
344
  }
345
- new $t();
345
+ new Ct();
346
346
  class _t extends g {
347
347
  constructor() {
348
348
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
@@ -425,8 +425,8 @@ class _t extends g {
425
425
  ), t;
426
426
  }
427
427
  }
428
- const Ct = new _t();
429
- class Ft extends g {
428
+ const Et = new _t();
429
+ class Ot extends g {
430
430
  constructor() {
431
431
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
432
432
  {
@@ -496,8 +496,8 @@ class Ft extends g {
496
496
  ), t;
497
497
  }
498
498
  }
499
- const Z = new Ft();
500
- class Ot extends g {
499
+ const Z = new Ot();
500
+ class Ft extends g {
501
501
  constructor() {
502
502
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
503
503
  {
@@ -613,8 +613,8 @@ class Ot extends g {
613
613
  ), t;
614
614
  }
615
615
  }
616
- const Et = new Ot();
617
- class Wt extends g {
616
+ const Wt = new Ft();
617
+ class zt extends g {
618
618
  constructor() {
619
619
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
620
620
  }
@@ -634,8 +634,8 @@ class Wt extends g {
634
634
  ), t;
635
635
  }
636
636
  }
637
- new Wt();
638
- class zt extends g {
637
+ new zt();
638
+ class xt extends g {
639
639
  constructor() {
640
640
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
641
641
  {
@@ -689,8 +689,8 @@ class zt extends g {
689
689
  ), t;
690
690
  }
691
691
  }
692
- const At = new zt();
693
- class xt extends g {
692
+ const At = new xt();
693
+ class Mt extends g {
694
694
  constructor() {
695
695
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
696
696
  }
@@ -710,7 +710,7 @@ class xt extends g {
710
710
  ), t;
711
711
  }
712
712
  }
713
- const Mt = new xt(), Q = new C(
713
+ const Ht = new Mt(), Q = new _(
714
714
  "MiLaboratories.Controller.Shared.Upload",
715
715
  [
716
716
  {
@@ -722,24 +722,24 @@ const Mt = new xt(), Q = new C(
722
722
  {
723
723
  name: "GetPartURL",
724
724
  options: {},
725
- I: Ct,
726
- O: Et
725
+ I: Et,
726
+ O: Wt
727
727
  },
728
728
  {
729
729
  name: "UpdateProgress",
730
730
  options: {},
731
- I: St,
732
- O: Bt
731
+ I: Nt,
732
+ O: $t
733
733
  },
734
734
  {
735
735
  name: "Finalize",
736
736
  options: {},
737
737
  I: At,
738
- O: Mt
738
+ O: Ht
739
739
  }
740
740
  ]
741
741
  );
742
- class Ht {
742
+ class jt {
743
743
  constructor(e) {
744
744
  d(this, "typeName", Q.typeName);
745
745
  d(this, "methods", Q.methods);
@@ -805,16 +805,16 @@ function We(s) {
805
805
  }
806
806
  class ze extends Error {
807
807
  }
808
- class Ae extends Error {
808
+ class xe extends Error {
809
809
  }
810
- class jt extends Error {
810
+ class Ae extends Error {
811
811
  }
812
- class xe extends Error {
812
+ class Me extends Error {
813
813
  }
814
814
  class Gt {
815
815
  constructor(e, t, o, n) {
816
816
  d(this, "grpcClient");
817
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Ht(this.grpcTransport);
817
+ this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new jt(this.grpcTransport);
818
818
  }
819
819
  close() {
820
820
  }
@@ -842,14 +842,20 @@ class Gt {
842
842
  } = await Ne(i.uploadUrl, {
843
843
  dispatcher: this.httpClient,
844
844
  body: c,
845
+ // We got headers only after we send
846
+ // the whole body (in case of S3 PUT requests it's 5 MB).
847
+ // It might be slow with a slow connection (or with SSH),
848
+ // that's why we got big timeout here.
849
+ headersTimeout: 6e4,
850
+ bodyTimeout: 6e4,
845
851
  headers: We(i.headers),
846
852
  method: i.method.toUpperCase()
847
- }), nt = await l.text();
848
- Zt(p, nt, J, i);
853
+ }), rt = await l.text();
854
+ Zt(p, rt, J, i);
849
855
  } catch (l) {
850
- throw new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
856
+ throw l instanceof Ae ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
851
857
  }
852
- await this.grpcUpdateProgress({ id: e, type: t }, i.chunkEnd - i.chunkStart, a);
858
+ await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), a);
853
859
  }
854
860
  async finalize(e, t) {
855
861
  return await this.grpcFinalize(e, t);
@@ -891,9 +897,9 @@ async function Vt(s, e, t) {
891
897
  const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await qt(o, a, n, r);
892
898
  return a.subarray(0, i);
893
899
  } catch (n) {
894
- throw n.code == "ENOENT" ? new xe(`there is no file ${s} for uploading`) : n;
900
+ throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new Me(`there is no file ${s} for uploading`) : n;
895
901
  } finally {
896
- o == null || o.close();
902
+ await (o == null ? void 0 : o.close());
897
903
  }
898
904
  }
899
905
  async function qt(s, e, t, o) {
@@ -906,7 +912,7 @@ async function qt(s, e, t, o) {
906
912
  o + n
907
913
  );
908
914
  if (r === 0)
909
- throw new Ae("file ended earlier than expected.");
915
+ throw new xe("file ended earlier than expected.");
910
916
  n += r;
911
917
  }
912
918
  return n;
@@ -918,8 +924,8 @@ async function Jt(s, e) {
918
924
  }
919
925
  function Zt(s, e, t, o) {
920
926
  if (s != 200)
921
- throw new jt(
922
- `response is not ok, status code: ${s}, body: ${e}, headers: ${t}, url: ${o.uploadUrl}`
927
+ throw new Ae(
928
+ `response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${o.uploadUrl}`
923
929
  );
924
930
  }
925
931
  class Qt extends g {
@@ -946,7 +952,7 @@ class Qt extends g {
946
952
  * Encode `Duration` to JSON string like "3.000001s".
947
953
  */
948
954
  internalJsonWrite(e, t) {
949
- const o = R.from(e.seconds).toNumber();
955
+ const o = D.from(e.seconds).toNumber();
950
956
  if (o > 315576e6 || o < -315576e6)
951
957
  throw new Error("Duration value out of range.");
952
958
  let n = e.seconds.toString();
@@ -970,7 +976,7 @@ class Qt extends g {
970
976
  "Unable to parse Duration from JSON string. Invalid format."
971
977
  );
972
978
  o || (o = this.create());
973
- const [, r, a, i] = n, c = R.from(r + a);
979
+ const [, r, a, i] = n, c = D.from(r + a);
974
980
  if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
975
981
  throw new Error(
976
982
  "Unable to parse Duration from JSON string. Value out of range."
@@ -1147,7 +1153,7 @@ class Kt extends g {
1147
1153
  ), t;
1148
1154
  }
1149
1155
  }
1150
- const v = new Kt();
1156
+ const S = new Kt();
1151
1157
  class Yt extends g {
1152
1158
  constructor() {
1153
1159
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
@@ -1231,7 +1237,7 @@ const to = new eo();
1231
1237
  class oo extends g {
1232
1238
  constructor() {
1233
1239
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
1234
- { no: 1, name: "report", kind: "message", T: () => v }
1240
+ { no: 1, name: "report", kind: "message", T: () => S }
1235
1241
  ]);
1236
1242
  }
1237
1243
  create(e) {
@@ -1249,7 +1255,7 @@ class oo extends g {
1249
1255
  switch (i) {
1250
1256
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1251
1257
  1:
1252
- r.report = v.internalBinaryRead(
1258
+ r.report = S.internalBinaryRead(
1253
1259
  e,
1254
1260
  e.uint32(),
1255
1261
  o,
@@ -1275,7 +1281,7 @@ class oo extends g {
1275
1281
  return r;
1276
1282
  }
1277
1283
  internalBinaryWrite(e, t, o) {
1278
- e.report && v.internalBinaryWrite(
1284
+ e.report && S.internalBinaryWrite(
1279
1285
  e.report,
1280
1286
  t.tag(1, h.LengthDelimited).fork(),
1281
1287
  o
@@ -1390,7 +1396,7 @@ class ao extends g {
1390
1396
  constructor() {
1391
1397
  super(
1392
1398
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
1393
- [{ no: 1, name: "report", kind: "message", T: () => v }]
1399
+ [{ no: 1, name: "report", kind: "message", T: () => S }]
1394
1400
  );
1395
1401
  }
1396
1402
  create(e) {
@@ -1408,7 +1414,7 @@ class ao extends g {
1408
1414
  switch (i) {
1409
1415
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1410
1416
  1:
1411
- r.report = v.internalBinaryRead(
1417
+ r.report = S.internalBinaryRead(
1412
1418
  e,
1413
1419
  e.uint32(),
1414
1420
  o,
@@ -1434,7 +1440,7 @@ class ao extends g {
1434
1440
  return r;
1435
1441
  }
1436
1442
  internalBinaryWrite(e, t, o) {
1437
- e.report && v.internalBinaryWrite(
1443
+ e.report && S.internalBinaryWrite(
1438
1444
  e.report,
1439
1445
  t.tag(1, h.LengthDelimited).fork(),
1440
1446
  o
@@ -1447,7 +1453,7 @@ class ao extends g {
1447
1453
  ), t;
1448
1454
  }
1449
1455
  }
1450
- const lo = new ao(), X = new C(
1456
+ const lo = new ao(), X = new _(
1451
1457
  "MiLaboratories.Controller.Shared.Progress",
1452
1458
  [
1453
1459
  {
@@ -1527,13 +1533,13 @@ class ho {
1527
1533
  );
1528
1534
  yield* c;
1529
1535
  } catch (c) {
1530
- throw this.logger.warn("Failed to get realtime status" + c), c;
1536
+ throw this.logger.warn("Failed to get realtime status" + String(c)), c;
1531
1537
  }
1532
1538
  }
1533
1539
  }
1534
1540
  class V extends Error {
1535
1541
  }
1536
- class Me {
1542
+ class He {
1537
1543
  constructor(e) {
1538
1544
  this.httpClient = e;
1539
1545
  }
@@ -1551,13 +1557,13 @@ class Me {
1551
1557
  }
1552
1558
  async function uo(s, e, t) {
1553
1559
  if (s != 200) {
1554
- const o = (await ht(e)).substring(0, 1e3);
1560
+ const o = (await ut(e)).substring(0, 1e3);
1555
1561
  throw 400 <= s && s < 500 ? new V(
1556
1562
  `Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${o}`
1557
1563
  ) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
1558
1564
  }
1559
1565
  }
1560
- function _(s) {
1566
+ function C(s) {
1561
1567
  if (!L.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1562
1568
  return s;
1563
1569
  }
@@ -1822,7 +1828,7 @@ class yo extends g {
1822
1828
  ), t;
1823
1829
  }
1824
1830
  }
1825
- const bo = new yo(), Y = new C(
1831
+ const bo = new yo(), Y = new _(
1826
1832
  "MiLaboratories.Controller.Shared.Download",
1827
1833
  [
1828
1834
  {
@@ -1856,13 +1862,13 @@ class ko {
1856
1862
  d(this, "remoteFileDownloader");
1857
1863
  /** Helps to find a storage root directory by a storage id from URL scheme. */
1858
1864
  d(this, "localStorageIdsToRoot");
1859
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new To(this.grpcTransport), this.remoteFileDownloader = new Me(t), this.localStorageIdsToRoot = Io(n);
1865
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new To(this.grpcTransport), this.remoteFileDownloader = new He(t), this.localStorageIdsToRoot = Ro(n);
1860
1866
  }
1861
1867
  close() {
1862
1868
  }
1863
1869
  async downloadBlob(e, t, o) {
1864
1870
  const { downloadUrl: n, headers: r } = await this.grpcGetDownloadUrl(e, t, o);
1865
- return this.logger.info(`download blob from url ${n}`), Ro(n) ? await this.readLocalFile(n) : await this.remoteFileDownloader.download(n, We(r), o);
1871
+ return this.logger.info(`download blob from url ${n}`), Do(n) ? await this.readLocalFile(n) : await this.remoteFileDownloader.download(n, We(r), o);
1866
1872
  }
1867
1873
  async readLocalFile(e) {
1868
1874
  const { storageId: t, relativePath: o } = Lo(e), n = Po(t, this.localStorageIdsToRoot, o);
@@ -1893,21 +1899,21 @@ function Po(s, e, t) {
1893
1899
  if (o === void 0) throw new be(`Unknown storage location: ${s}`);
1894
1900
  return o === "" ? t : b.join(o, t);
1895
1901
  }
1896
- const Do = "storage://";
1897
- function Ro(s) {
1898
- return s.startsWith(Do);
1902
+ const Uo = "storage://";
1903
+ function Do(s) {
1904
+ return s.startsWith(Uo);
1899
1905
  }
1900
1906
  class ye extends Error {
1901
1907
  }
1902
1908
  class be extends Error {
1903
1909
  }
1904
- function Io(s) {
1910
+ function Ro(s) {
1905
1911
  const e = /* @__PURE__ */ new Map();
1906
1912
  for (const t of s)
1907
- t.localPath !== "" && _(t.localPath), e.set(t.storageId, t.localPath);
1913
+ t.localPath !== "" && C(t.localPath), e.set(t.storageId, t.localPath);
1908
1914
  return e;
1909
1915
  }
1910
- class Uo extends g {
1916
+ class Io extends g {
1911
1917
  constructor() {
1912
1918
  super("google.protobuf.Timestamp", [
1913
1919
  {
@@ -1932,14 +1938,14 @@ class Uo extends g {
1932
1938
  */
1933
1939
  now() {
1934
1940
  const e = this.create(), t = Date.now();
1935
- return e.seconds = R.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1941
+ return e.seconds = D.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
1936
1942
  }
1937
1943
  /**
1938
1944
  * Converts a `Timestamp` to a JavaScript Date.
1939
1945
  */
1940
1946
  toDate(e) {
1941
1947
  return new Date(
1942
- R.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1948
+ D.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
1943
1949
  );
1944
1950
  }
1945
1951
  /**
@@ -1947,14 +1953,14 @@ class Uo extends g {
1947
1953
  */
1948
1954
  fromDate(e) {
1949
1955
  const t = this.create(), o = e.getTime();
1950
- return t.seconds = R.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1956
+ return t.seconds = D.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
1951
1957
  }
1952
1958
  /**
1953
1959
  * In JSON format, the `Timestamp` type is encoded as a string
1954
1960
  * in the RFC 3339 format.
1955
1961
  */
1956
1962
  internalJsonWrite(e, t) {
1957
- const o = R.from(e.seconds).toNumber() * 1e3;
1963
+ const o = D.from(e.seconds).toNumber() * 1e3;
1958
1964
  if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
1959
1965
  throw new Error(
1960
1966
  "Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
@@ -1993,7 +1999,7 @@ class Uo extends g {
1993
1999
  throw new globalThis.Error(
1994
2000
  "Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
1995
2001
  );
1996
- return o || (o = this.create()), o.seconds = R.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
2002
+ return o || (o = this.create()), o.seconds = D.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
1997
2003
  }
1998
2004
  create(e) {
1999
2005
  const t = globalThis.Object.create(this.messagePrototype);
@@ -2040,8 +2046,8 @@ class Uo extends g {
2040
2046
  ), t;
2041
2047
  }
2042
2048
  }
2043
- const ee = new Uo();
2044
- class vo extends g {
2049
+ const ee = new Io();
2050
+ class So extends g {
2045
2051
  constructor() {
2046
2052
  super("MiLaboratories.Controller.Shared.LsAPI", []);
2047
2053
  }
@@ -2061,8 +2067,8 @@ class vo extends g {
2061
2067
  ), t;
2062
2068
  }
2063
2069
  }
2064
- new vo();
2065
- class So extends g {
2070
+ new So();
2071
+ class vo extends g {
2066
2072
  constructor() {
2067
2073
  super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
2068
2074
  {
@@ -2185,7 +2191,7 @@ class So extends g {
2185
2191
  ), t;
2186
2192
  }
2187
2193
  }
2188
- const te = new So();
2194
+ const te = new vo();
2189
2195
  class No extends g {
2190
2196
  constructor() {
2191
2197
  super("MiLaboratories.Controller.Shared.LsAPI.List", []);
@@ -2273,7 +2279,7 @@ class Bo extends g {
2273
2279
  }
2274
2280
  }
2275
2281
  const $o = new Bo();
2276
- class _o extends g {
2282
+ class Co extends g {
2277
2283
  constructor() {
2278
2284
  super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
2279
2285
  {
@@ -2345,10 +2351,10 @@ class _o extends g {
2345
2351
  ), t;
2346
2352
  }
2347
2353
  }
2348
- const Co = new _o(), oe = new C("MiLaboratories.Controller.Shared.LS", [
2349
- { name: "List", options: {}, I: $o, O: Co }
2354
+ const _o = new Co(), oe = new _("MiLaboratories.Controller.Shared.LS", [
2355
+ { name: "List", options: {}, I: $o, O: _o }
2350
2356
  ]);
2351
- class Fo {
2357
+ class Eo {
2352
2358
  constructor(e) {
2353
2359
  d(this, "typeName", oe.typeName);
2354
2360
  d(this, "methods", oe.methods);
@@ -2372,7 +2378,7 @@ class Fo {
2372
2378
  class Oo {
2373
2379
  constructor(e, t) {
2374
2380
  d(this, "grpcClient");
2375
- this.logger = t, this.grpcClient = new Fo(e);
2381
+ this.logger = t, this.grpcClient = new Eo(e);
2376
2382
  }
2377
2383
  close() {
2378
2384
  }
@@ -2386,7 +2392,7 @@ class Oo {
2386
2392
  ).response;
2387
2393
  }
2388
2394
  }
2389
- class Eo extends g {
2395
+ class Fo extends g {
2390
2396
  constructor() {
2391
2397
  super("MiLaboratories.Controller.Shared.StreamingAPI", []);
2392
2398
  }
@@ -2406,7 +2412,7 @@ class Eo extends g {
2406
2412
  ), t;
2407
2413
  }
2408
2414
  }
2409
- new Eo();
2415
+ new Fo();
2410
2416
  class Wo extends g {
2411
2417
  constructor() {
2412
2418
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
@@ -2499,7 +2505,7 @@ class Wo extends g {
2499
2505
  }
2500
2506
  }
2501
2507
  const zo = new Wo();
2502
- class Ao extends g {
2508
+ class xo extends g {
2503
2509
  constructor() {
2504
2510
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
2505
2511
  {
@@ -2577,7 +2583,7 @@ class Ao extends g {
2577
2583
  ), t;
2578
2584
  }
2579
2585
  }
2580
- const xo = new Ao();
2586
+ const Ao = new xo();
2581
2587
  class Mo extends g {
2582
2588
  constructor() {
2583
2589
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
@@ -2967,7 +2973,7 @@ class Jo extends g {
2967
2973
  ), t;
2968
2974
  }
2969
2975
  }
2970
- const B = new Jo(), ne = new C(
2976
+ const B = new Jo(), ne = new _(
2971
2977
  "MiLaboratories.Controller.Shared.Streaming",
2972
2978
  [
2973
2979
  {
@@ -2980,7 +2986,7 @@ const B = new Jo(), ne = new C(
2980
2986
  {
2981
2987
  name: "ReadBinary",
2982
2988
  options: {},
2983
- I: xo,
2989
+ I: Ao,
2984
2990
  O: B
2985
2991
  },
2986
2992
  {
@@ -3139,25 +3145,25 @@ class Qo {
3139
3145
  )).response;
3140
3146
  }
3141
3147
  }
3142
- function fr(s, e, t) {
3148
+ function yr(s, e, t) {
3143
3149
  return e.getDriver({
3144
3150
  name: "DownloadBlob",
3145
3151
  init: (o, n, r) => new ko(n, r, s, t)
3146
3152
  });
3147
3153
  }
3148
- function mr(s, e) {
3154
+ function br(s, e) {
3149
3155
  return s.getDriver({
3150
3156
  name: "StreamLogs",
3151
3157
  init: (t, o, n) => new Qo(o, n, e)
3152
3158
  });
3153
3159
  }
3154
- function wr(s, e) {
3160
+ function Tr(s, e) {
3155
3161
  return s.getDriver({
3156
3162
  name: "UploadProgress",
3157
3163
  init: (t, o, n) => new ho(o, n, s, e)
3158
3164
  });
3159
3165
  }
3160
- function yr(s, e) {
3166
+ function kr(s, e) {
3161
3167
  return s.getDriver({
3162
3168
  name: "UploadBlob",
3163
3169
  init: (t, o, n) => new Gt(o, n, s, e)
@@ -3171,7 +3177,7 @@ function Xo(s, e) {
3171
3177
  }
3172
3178
  class Ko {
3173
3179
  constructor(e, t, o, n, r) {
3174
- d(this, "counter", new S());
3180
+ d(this, "counter", new v());
3175
3181
  d(this, "change", new N());
3176
3182
  d(this, "signalCtl", new AbortController());
3177
3183
  d(this, "error");
@@ -3206,12 +3212,12 @@ class Ko {
3206
3212
  return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
3207
3213
  const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
3208
3214
  return await ge(this.logger, this.path, async (o) => {
3209
- const n = U.toWeb(ie.createWriteStream(o, { flags: "wx" }));
3215
+ const n = I.toWeb(ie.createWriteStream(o, { flags: "wx" }));
3210
3216
  await e.pipeTo(n);
3211
3217
  }), t;
3212
3218
  }
3213
3219
  abort(e) {
3214
- this.signalCtl.abort(new He(e));
3220
+ this.signalCtl.abort(new je(e));
3215
3221
  }
3216
3222
  getBlob() {
3217
3223
  return this.done ? this.error ? {
@@ -3236,9 +3242,9 @@ class Ko {
3236
3242
  }
3237
3243
  }
3238
3244
  function Te(s) {
3239
- return s instanceof He || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3245
+ return s instanceof je || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3240
3246
  }
3241
- class He extends Error {
3247
+ class je extends Error {
3242
3248
  }
3243
3249
  class ke {
3244
3250
  constructor(e) {
@@ -3263,7 +3269,7 @@ class ke {
3263
3269
  if (this.totalSizeBytes <= this.softSizeBytes) return [];
3264
3270
  const e = [];
3265
3271
  let t = 0;
3266
- return ct(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3272
+ return dt(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3267
3273
  if (this.totalSizeBytes - t <= this.softSizeBytes) return;
3268
3274
  const r = Pe(this.cache, o);
3269
3275
  t += r.size, e.push(r);
@@ -3278,15 +3284,15 @@ class ke {
3278
3284
  this.cache.delete(e.path), this.totalSizeBytes -= e.size;
3279
3285
  }
3280
3286
  }
3281
- const je = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3287
+ const Ge = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3282
3288
  function Yo(s, e) {
3283
3289
  return `blob+local://download/${s}#${e.sign(s)}`;
3284
3290
  }
3285
3291
  function en(s) {
3286
- return !!s.match(je);
3292
+ return !!s.match(Ge);
3287
3293
  }
3288
3294
  function re(s, e) {
3289
- const t = s.match(je);
3295
+ const t = s.match(Ge);
3290
3296
  if (t === null)
3291
3297
  throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
3292
3298
  const { path: o, signature: n } = t.groups;
@@ -3311,14 +3317,14 @@ const q = k.object({
3311
3317
  sizeBytes: k.string(),
3312
3318
  /** Modification time unix timestamp in seconds */
3313
3319
  modificationTime: k.string()
3314
- }), Ge = k.object({
3320
+ }), Ve = k.object({
3315
3321
  /** Pl storage id */
3316
3322
  storageId: k.string(),
3317
3323
  /** Path inside storage */
3318
3324
  path: k.string()
3319
- }), br = k.union([
3325
+ }), Lr = k.union([
3320
3326
  q,
3321
- Ge
3327
+ Ve
3322
3328
  ]), nn = G({
3323
3329
  data: q,
3324
3330
  fields: {
@@ -3328,16 +3334,16 @@ const q = k.object({
3328
3334
  fields: {
3329
3335
  incarnation: !1
3330
3336
  }
3331
- }), Ve = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3337
+ }), qe = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3332
3338
  function sn(s, e) {
3333
3339
  const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
3334
3340
  return `blob+remote://download/${t}#${e.sign(t)}`;
3335
3341
  }
3336
3342
  function an(s) {
3337
- return !!s.match(Ve);
3343
+ return !!s.match(qe);
3338
3344
  }
3339
3345
  function ln(s, e) {
3340
- const t = s.match(Ve);
3346
+ const t = s.match(qe);
3341
3347
  if (t === null)
3342
3348
  throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
3343
3349
  const { content: o, resourceType: n, resourceVersion: r, resourceId: a, signature: i } = t.groups;
@@ -3346,23 +3352,23 @@ function ln(s, e) {
3346
3352
  type: { name: n, version: r }
3347
3353
  };
3348
3354
  }
3349
- function qe(s, e) {
3355
+ function Je(s, e) {
3350
3356
  return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
3351
3357
  }
3352
- const Je = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3353
- function x(s) {
3354
- return Je.test(s);
3358
+ const Ze = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3359
+ function A(s) {
3360
+ return Ze.test(s);
3355
3361
  }
3356
- const Ze = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3362
+ const Qe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3357
3363
  function cn(s) {
3358
- return Ze.test(s);
3364
+ return Qe.test(s);
3359
3365
  }
3360
3366
  function M(s) {
3361
3367
  let e;
3362
- if (x(s))
3363
- e = s.match(Je);
3364
- else if (cn(s))
3368
+ if (A(s))
3365
3369
  e = s.match(Ze);
3370
+ else if (cn(s))
3371
+ e = s.match(Qe);
3366
3372
  else throw new Error(`Log handle is malformed: ${s}`);
3367
3373
  if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
3368
3374
  const { resourceType: t, resourceVersion: o, resourceId: n } = e.groups;
@@ -3390,7 +3396,7 @@ class dn {
3390
3396
  })());
3391
3397
  }
3392
3398
  }
3393
- class Tr {
3399
+ class Pr {
3394
3400
  constructor(e, t, o, n, r, a) {
3395
3401
  /** Represents a Resource Id to the path of a blob as a map. */
3396
3402
  d(this, "idToDownload", /* @__PURE__ */ new Map());
@@ -3407,7 +3413,7 @@ class Tr {
3407
3413
  }
3408
3414
  getDownloadedBlob(e, t) {
3409
3415
  if (t === void 0) return w.make((a) => this.getDownloadedBlob(e, a));
3410
- const o = I(e, t), n = D();
3416
+ const o = R(e, t), n = U();
3411
3417
  t.addOnDestroy(() => this.releaseBlob(o.id, n));
3412
3418
  const r = this.getDownloadedBlobNoCtx(t.watcher, o, n);
3413
3419
  return r == null && t.markUnstable("download blob is still undefined"), r;
@@ -3446,7 +3452,7 @@ class Tr {
3446
3452
  }
3447
3453
  getOnDemandBlob(e, t) {
3448
3454
  if (t === void 0) return w.make((a) => this.getOnDemandBlob(e, a));
3449
- const o = F(e) ? A(e, tn, t) : e, n = D();
3455
+ const o = E(e) ? x(e, tn, t) : e, n = U();
3450
3456
  return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
3451
3457
  }
3452
3458
  getOnDemandBlobNoCtx(e, t) {
@@ -3465,13 +3471,13 @@ class Tr {
3465
3471
  return await pn(this.getLocalPath(e));
3466
3472
  if (an(e)) {
3467
3473
  const t = ln(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3468
- return await _e(o);
3474
+ return await Ce(o);
3469
3475
  }
3470
3476
  throw new Error("Malformed remote handle");
3471
3477
  }
3472
3478
  getLastLogs(e, t, o) {
3473
3479
  if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
3474
- const n = I(e, o), r = D();
3480
+ const n = R(e, o), r = U();
3475
3481
  o.addOnDestroy(() => this.releaseBlob(n.id, r));
3476
3482
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
3477
3483
  return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
@@ -3483,7 +3489,7 @@ class Tr {
3483
3489
  const { path: a } = re(r.handle, this.signer);
3484
3490
  let i = this.idToLastLines.get(t.id);
3485
3491
  if (i == null) {
3486
- const l = new Re(a, o);
3492
+ const l = new De(a, o);
3487
3493
  this.idToLastLines.set(t.id, l), i = l;
3488
3494
  }
3489
3495
  const c = i.getOrSchedule(e);
@@ -3493,7 +3499,7 @@ class Tr {
3493
3499
  getProgressLog(e, t, o) {
3494
3500
  if (o == null)
3495
3501
  return w.make((i) => this.getProgressLog(e, t, i));
3496
- const n = I(e, o), r = D();
3502
+ const n = R(e, o), r = U();
3497
3503
  o.addOnDestroy(() => this.releaseBlob(n.id, r));
3498
3504
  const a = this.getProgressLogNoCtx(
3499
3505
  o.watcher,
@@ -3510,7 +3516,7 @@ class Tr {
3510
3516
  const { path: a } = re(r.handle, this.signer);
3511
3517
  let i = this.idToProgressLog.get(t.id);
3512
3518
  if (i == null) {
3513
- const l = new Re(a, 1, o);
3519
+ const l = new De(a, 1, o);
3514
3520
  this.idToProgressLog.set(t.id, l), i = l;
3515
3521
  }
3516
3522
  const c = i.getOrSchedule(e);
@@ -3519,11 +3525,11 @@ class Tr {
3519
3525
  }
3520
3526
  getLogHandle(e, t) {
3521
3527
  if (t == null) return w.make((n) => this.getLogHandle(e, n));
3522
- const o = I(e, t);
3528
+ const o = R(e, t);
3523
3529
  return this.getLogHandleNoCtx(o);
3524
3530
  }
3525
3531
  getLogHandleNoCtx(e) {
3526
- return $("getLogHandle", e.type), qe(!1, e);
3532
+ return $("getLogHandle", e.type), Je(!1, e);
3527
3533
  }
3528
3534
  async lastLines(e, t, o, n) {
3529
3535
  const r = await this.clientLogs.lastLines(
@@ -3593,7 +3599,7 @@ class Tr {
3593
3599
  }
3594
3600
  class hn {
3595
3601
  constructor(e, t) {
3596
- d(this, "counter", new S());
3602
+ d(this, "counter", new v());
3597
3603
  this.size = e, this.handle = t;
3598
3604
  }
3599
3605
  getHandle() {
@@ -3606,7 +3612,7 @@ class hn {
3606
3612
  return this.counter.dec(e);
3607
3613
  }
3608
3614
  }
3609
- class Re {
3615
+ class De {
3610
3616
  constructor(e, t, o) {
3611
3617
  d(this, "updater");
3612
3618
  d(this, "log");
@@ -3634,18 +3640,18 @@ class Re {
3634
3640
  }
3635
3641
  }
3636
3642
  function un(s, e, t) {
3637
- const o = me.createReadStream(s), n = new U();
3643
+ const o = me.createReadStream(s), n = new I();
3638
3644
  return new Promise((r, a) => {
3639
- const i = ft.createInterface(o, n), c = new ut();
3645
+ const i = mt.createInterface(o, n), c = new pt();
3640
3646
  i.on("line", function(l) {
3641
3647
  t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
3642
3648
  }), i.on("error", a), i.on("close", function() {
3643
- r(c.toArray().join(De.EOL) + De.EOL);
3649
+ r(c.toArray().join(Ue.EOL) + Ue.EOL);
3644
3650
  });
3645
3651
  });
3646
3652
  }
3647
3653
  async function pn(s) {
3648
- return await _e(we.toWeb(me.createReadStream(s)));
3654
+ return await Ce(we.toWeb(me.createReadStream(s)));
3649
3655
  }
3650
3656
  function $(s, e) {
3651
3657
  if (!e.name.startsWith("Blob/")) {
@@ -3655,8 +3661,8 @@ function $(s, e) {
3655
3661
  }
3656
3662
  const gn = G({});
3657
3663
  function fn(s, e) {
3658
- const t = F(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
3659
- return A(t, gn);
3664
+ const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
3665
+ return x(t, gn);
3660
3666
  }
3661
3667
  function mn(s, e, t) {
3662
3668
  const o = L.relative(e, t);
@@ -3679,7 +3685,7 @@ function bn(s, e) {
3679
3685
  }
3680
3686
  class Tn {
3681
3687
  constructor(e, t, o, n, r, a, i) {
3682
- d(this, "counter", new S());
3688
+ d(this, "counter", new v());
3683
3689
  d(this, "change", new N());
3684
3690
  d(this, "signalCtl", new AbortController());
3685
3691
  d(this, "error");
@@ -3719,7 +3725,7 @@ class Tn {
3719
3725
  /** Does the download part and keeps a state of the process. */
3720
3726
  async downloadAndDecompress(e) {
3721
3727
  if (this.state = {}, this.state.parentDir = L.dirname(this.path), await ue(this.state.parentDir), this.state.fileExisted = await pe(this.path), this.state.fileExisted)
3722
- return await Qe(this.path);
3728
+ return await Xe(this.path);
3723
3729
  const { content: t, size: o } = await this.clientDownload.downloadBlob(
3724
3730
  this.rInfo,
3725
3731
  {},
@@ -3729,23 +3735,23 @@ class Tn {
3729
3735
  switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
3730
3736
  case "tar":
3731
3737
  await m.mkdir(n);
3732
- const r = U.toWeb(ae.extract(n));
3738
+ const r = I.toWeb(ae.extract(n));
3733
3739
  await t.pipeTo(r, { signal: e });
3734
3740
  return;
3735
3741
  case "tgz":
3736
3742
  await m.mkdir(n);
3737
- const a = $e.toWeb(Oe.createGunzip()), i = U.toWeb(ae.extract(n));
3743
+ const a = $e.toWeb(Oe.createGunzip()), i = I.toWeb(ae.extract(n));
3738
3744
  await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
3739
3745
  return;
3740
3746
  case "zip":
3741
3747
  this.state.zipPath = this.path + ".zip";
3742
- const c = U.toWeb(ie.createWriteStream(this.state.zipPath));
3743
- await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await mt(this.state.zipPath, n, {
3748
+ const c = I.toWeb(ie.createWriteStream(this.state.zipPath));
3749
+ await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await wt(this.state.zipPath, n, {
3744
3750
  filter: (l) => !l.path.endsWith("/")
3745
3751
  }), this.state.zipDecompressed = !0, await ie.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3746
3752
  return;
3747
3753
  default:
3748
- lt(this.format);
3754
+ ct(this.format);
3749
3755
  }
3750
3756
  }), this.state.pathCreated = !0, o;
3751
3757
  }
@@ -3760,30 +3766,30 @@ class Tn {
3760
3766
  this.error = String(e);
3761
3767
  }
3762
3768
  abort(e) {
3763
- this.signalCtl.abort(new Xe(e));
3769
+ this.signalCtl.abort(new Ke(e));
3764
3770
  }
3765
3771
  }
3766
- async function Qe(s) {
3772
+ async function Xe(s) {
3767
3773
  const e = await m.readdir(s, { withFileTypes: !0 });
3768
3774
  return (await Promise.all(
3769
3775
  e.map(async (o) => {
3770
3776
  const n = L.join(s, o.name);
3771
- return o.isDirectory() ? await Qe(n) : (await m.stat(n)).size;
3777
+ return o.isDirectory() ? await Xe(n) : (await m.stat(n)).size;
3772
3778
  })
3773
3779
  )).reduce((o, n) => o + n, 0);
3774
3780
  }
3775
3781
  async function le(s) {
3776
3782
  await m.rm(s, { recursive: !0, force: !0 });
3777
3783
  }
3778
- let Xe = class extends Error {
3784
+ let Ke = class extends Error {
3779
3785
  };
3780
3786
  function kn(s) {
3781
- return s instanceof Xe || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3787
+ return s instanceof Ke || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3782
3788
  }
3783
3789
  function O(s, e) {
3784
3790
  return `id:${String(BigInt(s))}-${e}`;
3785
3791
  }
3786
- class Lr {
3792
+ class Dr {
3787
3793
  constructor(e, t, o, n, r = {
3788
3794
  cacheSoftSizeBytes: 50 * 1024 * 1024,
3789
3795
  nConcurrentDownloads: 50
@@ -3821,7 +3827,7 @@ class Lr {
3821
3827
  extractArchiveAndGetURL(e, t, o) {
3822
3828
  if (o === void 0)
3823
3829
  return w.make((i) => this.extractArchiveAndGetURL(e, t, i));
3824
- const n = F(e) ? fn(e, o) : e, r = D();
3830
+ const n = E(e) ? fn(e, o) : e, r = U();
3825
3831
  o.addOnDestroy(() => this.releasePath(n.id, t, r));
3826
3832
  const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
3827
3833
  if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
@@ -3899,7 +3905,11 @@ class Lr {
3899
3905
  class Ln {
3900
3906
  constructor(e, t, o, n, r, a) {
3901
3907
  d(this, "change", new N());
3902
- d(this, "counter", new S());
3908
+ d(this, "counter", new v());
3909
+ d(this, "nMaxUploads");
3910
+ d(this, "nPartsWithThisUploadSpeed", 0);
3911
+ d(this, "nPartsToIncreaseUpload", 10);
3912
+ // how many parts we have to wait to increase concurrency, 50 mb, 10 parts by 5 mb each.
3903
3913
  /** If this is upload progress this field will be defined */
3904
3914
  d(this, "uploadData");
3905
3915
  d(this, "progress");
@@ -3908,65 +3918,68 @@ class Ln {
3908
3918
  /** True if the blob was existed.
3909
3919
  * At this case, the task will show progress == 1.0. */
3910
3920
  d(this, "alreadyExisted", !1);
3911
- this.logger = e, this.clientBlob = t, this.clientProgress = o, this.nConcurrentPartsUpload = n, this.res = a;
3921
+ this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
3912
3922
  const { uploadData: i, progress: c } = Pn(a, r);
3913
3923
  this.uploadData = i, this.progress = c;
3914
3924
  }
3915
3925
  getProgress(e, t) {
3916
3926
  if (this.incCounter(e, t), this.failed)
3917
3927
  throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
3918
- return Dn(this.progress);
3928
+ return Un(this.progress);
3919
3929
  }
3920
3930
  shouldScheduleUpload() {
3921
3931
  return this.progress.isUpload && this.progress.isUploadSignMatch;
3922
3932
  }
3923
3933
  /** Uploads a blob if it's not BlobIndex. */
3924
3934
  async uploadBlobTask() {
3925
- wt(ce(this.res), "the upload operation can be done only for BlobUploads");
3935
+ yt(ce(this.res), "the upload operation can be done only for BlobUploads");
3936
+ const e = 1e4;
3926
3937
  try {
3927
3938
  if (this.isComputableDone()) return;
3928
- const e = await this.clientBlob.initUpload(this.res);
3939
+ const t = await this.clientBlob.initUpload(this.res, { timeout: e });
3929
3940
  this.logger.info(
3930
- `started to upload blob ${this.res.id}, parts overall: ${e.overall}, parts remained: ${e.toUpload.length}`
3941
+ `started to upload blob ${this.res.id}, parts overall: ${t.overall}, parts remained: ${t.toUpload.length}, number of concurrent uploads: ${this.nMaxUploads}`
3931
3942
  );
3932
- const t = (o) => async () => {
3943
+ const o = (n) => async (r) => {
3933
3944
  this.isComputableDone() || (await this.clientBlob.partUpload(
3934
3945
  this.res,
3935
3946
  this.uploadData.localPath,
3936
3947
  BigInt(this.uploadData.modificationTime),
3937
- o
3938
- ), this.logger.info(`uploaded chunk ${o}/${e.overall} of resource: ${this.res.id}`));
3948
+ n,
3949
+ { timeout: e }
3950
+ ), this.logger.info(`uploaded chunk ${n}/${t.overall} of resource: ${this.res.id}`), this.nPartsWithThisUploadSpeed++, this.nPartsWithThisUploadSpeed >= this.nPartsToIncreaseUpload && (this.nPartsWithThisUploadSpeed = 0, this.nMaxUploads = Nn(this.logger, this.nMaxUploads, this.maxNConcurrentPartsUpload), r.setConcurrency(this.nMaxUploads)));
3939
3951
  };
3940
- if (await fe(this.nConcurrentPartsUpload, e.toUpload.map(t)), this.isComputableDone()) return;
3941
- await this.clientBlob.finalize(this.res), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged();
3942
- } catch (e) {
3943
- if (this.setRetriableError(e), Ie(e)) {
3944
- this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
3952
+ if (await fe(this.nMaxUploads, t.toUpload.map(o)), this.isComputableDone()) return;
3953
+ await this.clientBlob.finalize(this.res, { timeout: e }), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged();
3954
+ } catch (t) {
3955
+ if (this.setRetriableError(t), Re(t)) {
3956
+ this.logger.warn(`resource was deleted while uploading a blob: ${t}`), this.change.markChanged(), this.setDone(!0);
3945
3957
  return;
3946
3958
  }
3947
- if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ke(e)) {
3948
- this.setTerminalError(e);
3959
+ if (this.logger.error(`error while uploading a blob: ${t}`), this.change.markChanged(), Ye(t)) {
3960
+ this.setTerminalError(t);
3949
3961
  return;
3950
3962
  }
3951
- throw e;
3963
+ throw vn(t) && (this.nMaxUploads = Bn(this.logger, this.nMaxUploads, 1)), t;
3952
3964
  }
3953
3965
  }
3954
3966
  async updateStatus() {
3967
+ var e;
3955
3968
  try {
3956
- const e = await this.clientProgress.getStatus(this.res), t = this.progress.status, o = vn(this.alreadyExisted, Un(e));
3957
- this.progress.status = o, this.setDone(e.done), (e.done || this.progress.status.progress != (t == null ? void 0 : t.progress)) && this.change.markChanged();
3958
- } catch (e) {
3959
- if (this.setRetriableError(e), e.name == "RpcError" && e.code == "DEADLINE_EXCEEDED") {
3969
+ const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Sn(this.alreadyExisted, In(t));
3970
+ this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
3971
+ } catch (t) {
3972
+ if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
3960
3973
  this.logger.warn("deadline exceeded while getting a status of BlobImport");
3961
3974
  return;
3962
3975
  }
3963
- if (Ie(e)) {
3976
+ if (Re(t)) {
3964
3977
  this.logger.warn(
3965
- `resource was not found while updating a status of BlobImport: ${e}, ${y(this.res)}`
3978
+ `resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
3966
3979
  ), this.change.markChanged(), this.setDone(!0);
3967
3980
  return;
3968
3981
  }
3969
- this.logger.error(`error while updating a status of BlobImport: ${e}`), this.change.markChanged(), this.setTerminalError(e);
3982
+ this.logger.error(`retryable error while updating a status of BlobImport: ${t}`);
3970
3983
  }
3971
3984
  }
3972
3985
  /** Set non-terminal error, that task can be retried. */
@@ -3978,7 +3991,7 @@ class Ln {
3978
3991
  this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
3979
3992
  }
3980
3993
  setDoneIfOutputSet(e) {
3981
- Rn(e) && (this.setDone(!0), this.alreadyExisted = !0);
3994
+ Dn(e) && (this.setDone(!0), this.alreadyExisted = !0);
3982
3995
  }
3983
3996
  setDone(e) {
3984
3997
  this.progress.done = e, e && (this.progress.lastError = void 0);
@@ -3995,7 +4008,7 @@ class Ln {
3995
4008
  }
3996
4009
  function Pn(s, e) {
3997
4010
  let t, o;
3998
- return ce(s) && (o = q.parse(s.data), t = In(e, o.localPath, o.pathSignature)), {
4011
+ return ce(s) && (o = q.parse(s.data), t = Rn(e, o.localPath, o.pathSignature)), {
3999
4012
  uploadData: o,
4000
4013
  progress: {
4001
4014
  done: !1,
@@ -4006,47 +4019,58 @@ function Pn(s, e) {
4006
4019
  }
4007
4020
  };
4008
4021
  }
4009
- function Dn(s) {
4022
+ function Un(s) {
4010
4023
  return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
4011
4024
  }
4012
- function Rn(s) {
4025
+ function Dn(s) {
4013
4026
  return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
4014
4027
  }
4015
4028
  function ce(s) {
4016
4029
  return s.type.name.startsWith("BlobUpload");
4017
4030
  }
4018
- function In(s, e, t) {
4031
+ function Rn(s, e, t) {
4019
4032
  try {
4020
4033
  return s.verify(e, t), !0;
4021
4034
  } catch {
4022
4035
  return !1;
4023
4036
  }
4024
4037
  }
4025
- function Un(s) {
4038
+ function In(s) {
4026
4039
  return {
4027
4040
  progress: s.progress ?? 0,
4028
4041
  bytesProcessed: Number(s.bytesProcessed),
4029
4042
  bytesTotal: Number(s.bytesTotal)
4030
4043
  };
4031
4044
  }
4032
- function vn(s, e) {
4045
+ function Sn(s, e) {
4033
4046
  return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
4034
4047
  progress: 1,
4035
4048
  bytesProcessed: Number(e.bytesTotal),
4036
4049
  bytesTotal: Number(e.bytesTotal)
4037
4050
  } : e;
4038
4051
  }
4039
- function Ie(s) {
4052
+ function Re(s) {
4040
4053
  return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
4041
4054
  }
4042
- function Ke(s) {
4043
- return s instanceof ze || s instanceof Ae || s instanceof xe;
4055
+ function Ye(s) {
4056
+ return s instanceof ze || s instanceof xe || s instanceof Me;
4044
4057
  }
4045
- function Sn(s, e) {
4046
- const t = F(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
4047
- return t.resourceType.name.startsWith("BlobUpload") ? A(t, nn) : A(t, rn);
4058
+ function vn(s) {
4059
+ return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
4048
4060
  }
4049
- class Pr {
4061
+ function Nn(s, e, t) {
4062
+ const o = Math.min(e + 2, t);
4063
+ return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
4064
+ }
4065
+ function Bn(s, e, t) {
4066
+ const o = Math.max(Math.round(e / 2), t);
4067
+ return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
4068
+ }
4069
+ function $n(s, e) {
4070
+ const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
4071
+ return t.resourceType.name.startsWith("BlobUpload") ? x(t, nn) : x(t, rn);
4072
+ }
4073
+ class Rr {
4050
4074
  constructor(e, t, o, n, r = {
4051
4075
  nConcurrentPartUploads: 10,
4052
4076
  nConcurrentGetProgresses: 10,
@@ -4069,7 +4093,7 @@ class Pr {
4069
4093
  // 15 seconds
4070
4094
  backoffMultiplier: 1.5,
4071
4095
  jitter: 0.5
4072
- }), this.hooks = new Ce(
4096
+ }), this.hooks = new _e(
4073
4097
  () => this.startUpdating(),
4074
4098
  () => this.stopUpdating(),
4075
4099
  { stopDebounce: r.stopPollingDelay },
@@ -4078,11 +4102,11 @@ class Pr {
4078
4102
  }
4079
4103
  getProgressId(e, t) {
4080
4104
  if (t == null) return w.make((a) => this.getProgressId(e, a));
4081
- const o = F(e) ? Sn(e, t) : e, n = D();
4105
+ const o = E(e) ? $n(e, t) : e, n = U();
4082
4106
  return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
4083
4107
  }
4084
4108
  getProgressIdNoCtx(e, t, o) {
4085
- Bn("getProgressId", t.type);
4109
+ _n("getProgressId", t.type);
4086
4110
  const n = this.idToProgress.get(t.id);
4087
4111
  if (n != null)
4088
4112
  return n.setDoneIfOutputSet(t), n.getProgress(e, o);
@@ -4096,7 +4120,7 @@ class Pr {
4096
4120
  );
4097
4121
  return this.idToProgress.set(t.id, r), r.shouldScheduleUpload() && this.uploadQueue.push({
4098
4122
  fn: () => r.uploadBlobTask(),
4099
- recoverableErrorPredicate: (a) => !Ke(a)
4123
+ recoverableErrorPredicate: (a) => !Ye(a)
4100
4124
  }), r.setDoneIfOutputSet(t), r.getProgress(e, o);
4101
4125
  }
4102
4126
  /** Decrement counters for the file and remove an uploading if counter == 0. */
@@ -4133,25 +4157,25 @@ class Pr {
4133
4157
  console.error(t), e.forEach((o) => o.reject(t));
4134
4158
  }
4135
4159
  if (!this.keepRunning) break;
4136
- await Ee.wait(this.opts.pollingInterval);
4160
+ await Fe.wait(this.opts.pollingInterval);
4137
4161
  }
4138
4162
  this.currentLoop = void 0;
4139
4163
  }
4140
4164
  getAllNotDoneProgresses() {
4141
- return Array.from(this.idToProgress.entries()).filter(([e, t]) => !Nn(t.progress)).map(([e, t]) => t);
4165
+ return Array.from(this.idToProgress.entries()).filter(([e, t]) => !Cn(t.progress)).map(([e, t]) => t);
4142
4166
  }
4143
4167
  }
4144
- function Nn(s) {
4168
+ function Cn(s) {
4145
4169
  var e;
4146
4170
  return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
4147
4171
  }
4148
- function Bn(s, e) {
4172
+ function _n(s, e) {
4149
4173
  if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
4150
4174
  throw new Le(
4151
4175
  `${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
4152
4176
  );
4153
4177
  }
4154
- class Dr {
4178
+ class Ir {
4155
4179
  constructor(e, t, o = {
4156
4180
  nConcurrentGetLogs: 10,
4157
4181
  pollingInterval: 1e3,
@@ -4168,7 +4192,7 @@ class Dr {
4168
4192
  d(this, "keepRunning", !1);
4169
4193
  /** Actual state of main loop. */
4170
4194
  d(this, "currentLoop");
4171
- this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Ce(
4195
+ this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new _e(
4172
4196
  () => this.startUpdating(),
4173
4197
  () => this.stopUpdating(),
4174
4198
  { stopDebounce: o.stopPollingDelay },
@@ -4177,7 +4201,7 @@ class Dr {
4177
4201
  }
4178
4202
  getLastLogs(e, t, o) {
4179
4203
  if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
4180
- const n = I(e, o), r = D();
4204
+ const n = R(e, o), r = U();
4181
4205
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseLastLogs(n.id, r));
4182
4206
  const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
4183
4207
  return o.markUnstable(
@@ -4188,7 +4212,7 @@ class Dr {
4188
4212
  se("getLastLogs", t.type);
4189
4213
  let r = this.idToLastLines.get(t.id);
4190
4214
  if (r == null) {
4191
- const i = new Ue(this.logger, this.clientLogs, t, o);
4215
+ const i = new Ie(this.logger, this.clientLogs, t, o);
4192
4216
  this.idToLastLines.set(t.id, i), r = i;
4193
4217
  }
4194
4218
  r.attach(e, n);
@@ -4199,7 +4223,7 @@ class Dr {
4199
4223
  getProgressLog(e, t, o) {
4200
4224
  if (o == null)
4201
4225
  return w.make((i) => this.getProgressLog(e, t, i));
4202
- const n = I(e, o), r = D();
4226
+ const n = R(e, o), r = U();
4203
4227
  o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseProgressLog(n.id, r));
4204
4228
  const a = this.getProgressLogNoCtx(o.watcher, n, t, r);
4205
4229
  return o.markUnstable(
@@ -4210,7 +4234,7 @@ class Dr {
4210
4234
  se("getProgressLog", t.type);
4211
4235
  let r = this.idToProgressLog.get(t.id);
4212
4236
  if (r == null) {
4213
- const i = new Ue(this.logger, this.clientLogs, t, 1, o);
4237
+ const i = new Ie(this.logger, this.clientLogs, t, 1, o);
4214
4238
  this.idToProgressLog.set(t.id, i), r = i;
4215
4239
  }
4216
4240
  r.attach(e, n);
@@ -4220,11 +4244,11 @@ class Dr {
4220
4244
  }
4221
4245
  getLogHandle(e, t) {
4222
4246
  if (t == null) return w.make((r) => this.getLogHandle(e, r));
4223
- const o = I(e, t), n = this.getLogHandleNoCtx(o);
4224
- return t.markUnstable(`live_log:${it(o.id)}`), n;
4247
+ const o = R(e, t), n = this.getLogHandleNoCtx(o);
4248
+ return t.markUnstable(`live_log:${at(o.id)}`), n;
4225
4249
  }
4226
4250
  getLogHandleNoCtx(e) {
4227
- return se("getLogHandle", e.type), qe(!0, e);
4251
+ return se("getLogHandle", e.type), Je(!0, e);
4228
4252
  }
4229
4253
  async lastLines(e, t, o, n) {
4230
4254
  return await this.tryWithNotFound(
@@ -4249,7 +4273,7 @@ class Dr {
4249
4273
  );
4250
4274
  }
4251
4275
  async tryWithNotFound(e, t) {
4252
- if (!x(e))
4276
+ if (!A(e))
4253
4277
  throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
4254
4278
  try {
4255
4279
  const o = await t();
@@ -4301,7 +4325,7 @@ class Dr {
4301
4325
  console.error(t), e.forEach((o) => o.reject(t));
4302
4326
  }
4303
4327
  if (!this.keepRunning) break;
4304
- await Ee.wait(this.opts.pollingInterval);
4328
+ await Fe.wait(this.opts.pollingInterval);
4305
4329
  }
4306
4330
  this.currentLoop = void 0;
4307
4331
  }
@@ -4309,12 +4333,12 @@ class Dr {
4309
4333
  return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
4310
4334
  }
4311
4335
  }
4312
- class Ue {
4336
+ class Ie {
4313
4337
  constructor(e, t, o, n, r) {
4314
4338
  d(this, "logs");
4315
4339
  d(this, "error");
4316
4340
  d(this, "change", new N());
4317
- d(this, "counter", new S());
4341
+ d(this, "counter", new v());
4318
4342
  this.logger = e, this.clientLogs = t, this.rInfo = o, this.lines = n, this.patternToSearch = r;
4319
4343
  }
4320
4344
  getLog() {
@@ -4356,7 +4380,7 @@ function se(s, e) {
4356
4380
  `${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
4357
4381
  );
4358
4382
  }
4359
- class Rr {
4383
+ class Sr {
4360
4384
  constructor(e, t, o) {
4361
4385
  this.logger = e, this.logsStreamDriver = t, this.downloadDriver = o;
4362
4386
  }
@@ -4367,7 +4391,7 @@ class Rr {
4367
4391
  o.markUnstable("no stream in stream manager");
4368
4392
  return;
4369
4393
  }
4370
- if (E(n)) return this.downloadDriver.getLastLogs(n, t, o);
4394
+ if (F(n)) return this.downloadDriver.getLastLogs(n, t, o);
4371
4395
  try {
4372
4396
  return this.logsStreamDriver.getLastLogs(n, t, o);
4373
4397
  } catch (r) {
@@ -4386,7 +4410,7 @@ class Rr {
4386
4410
  o.markUnstable("no stream in stream manager");
4387
4411
  return;
4388
4412
  }
4389
- if (E(n)) return this.downloadDriver.getProgressLog(n, t, o);
4413
+ if (F(n)) return this.downloadDriver.getProgressLog(n, t, o);
4390
4414
  try {
4391
4415
  return this.logsStreamDriver.getProgressLog(n, t, o);
4392
4416
  } catch (r) {
@@ -4405,7 +4429,7 @@ class Rr {
4405
4429
  o.markUnstable("no stream in stream manager");
4406
4430
  return;
4407
4431
  }
4408
- if (E(n))
4432
+ if (F(n))
4409
4433
  return {
4410
4434
  progressLine: this.downloadDriver.getProgressLog(n, t, o),
4411
4435
  live: !1
@@ -4430,23 +4454,23 @@ class Rr {
4430
4454
  t.markUnstable("no stream in stream manager");
4431
4455
  return;
4432
4456
  }
4433
- return E(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4457
+ return F(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
4434
4458
  }
4435
4459
  async lastLines(e, t, o, n) {
4436
- return x(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4460
+ return A(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
4437
4461
  }
4438
4462
  async readText(e, t, o, n) {
4439
- return x(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4463
+ return A(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
4440
4464
  }
4441
4465
  }
4442
- function E(s) {
4466
+ function F(s) {
4443
4467
  return !s.type.name.startsWith("StreamWorkdir");
4444
4468
  }
4445
4469
  function W(s, e) {
4446
4470
  var t;
4447
4471
  return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
4448
4472
  }
4449
- class Ir {
4473
+ class vr {
4450
4474
  constructor(e, t, o, n = {
4451
4475
  cacheSoftSizeBytes: 50 * 1024 * 1024,
4452
4476
  withGunzip: !0,
@@ -4458,11 +4482,11 @@ class Ir {
4458
4482
  /** Writes and removes files to a hard drive and holds a counter for every
4459
4483
  * file that should be kept. */
4460
4484
  d(this, "cache");
4461
- this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new ke(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Me(t);
4485
+ this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new ke(this.opts.cacheSoftSizeBytes), this.downloadHelper = new He(t);
4462
4486
  }
4463
4487
  getPath(e, t) {
4464
4488
  if (t === void 0) return w.make((r) => this.getPath(e, r));
4465
- const o = D();
4489
+ const o = U();
4466
4490
  t.addOnDestroy(() => this.releasePath(e, o));
4467
4491
  const n = this.getPathNoCtx(e, t.watcher, o);
4468
4492
  return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
@@ -4517,20 +4541,20 @@ class Ir {
4517
4541
  );
4518
4542
  }
4519
4543
  setNewTask(e, t, o) {
4520
- const n = new $n(this.logger, this.getFilePath(t), t);
4544
+ const n = new En(this.logger, this.getFilePath(t), t);
4521
4545
  return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
4522
4546
  }
4523
4547
  removeTask(e, t) {
4524
4548
  e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
4525
4549
  }
4526
4550
  getFilePath(e) {
4527
- const t = pt("sha256").update(e.toString()).digest("hex");
4551
+ const t = gt("sha256").update(e.toString()).digest("hex");
4528
4552
  return b.join(this.saveDir, t);
4529
4553
  }
4530
4554
  }
4531
- class $n {
4555
+ class En {
4532
4556
  constructor(e, t, o) {
4533
- d(this, "counter", new S());
4557
+ d(this, "counter", new v());
4534
4558
  d(this, "change", new N());
4535
4559
  d(this, "signalCtl", new AbortController());
4536
4560
  d(this, "error");
@@ -4555,7 +4579,7 @@ class $n {
4555
4579
  const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
4556
4580
  this.setDone(o), this.change.markChanged();
4557
4581
  } catch (o) {
4558
- if (o instanceof ve || o instanceof V) {
4582
+ if (o instanceof Se || o instanceof V) {
4559
4583
  this.setError(o), this.change.markChanged(), await de(this.path);
4560
4584
  return;
4561
4585
  }
@@ -4564,7 +4588,7 @@ class $n {
4564
4588
  }
4565
4589
  async downloadAndUntar(e, t, o) {
4566
4590
  if (await ue(b.dirname(this.path)), await pe(this.path))
4567
- return await Ye(this.path);
4591
+ return await et(this.path);
4568
4592
  const n = await e.download(this.url.toString(), {}, o);
4569
4593
  let r = n.content;
4570
4594
  if (t) {
@@ -4573,7 +4597,7 @@ class $n {
4573
4597
  }
4574
4598
  return await ge(this.logger, this.path, async (a) => {
4575
4599
  await m.mkdir(a);
4576
- const i = U.toWeb(ae.extract(a));
4600
+ const i = I.toWeb(ae.extract(a));
4577
4601
  await r.pipeTo(i, { signal: o });
4578
4602
  }), n.size;
4579
4603
  }
@@ -4588,30 +4612,30 @@ class $n {
4588
4612
  this.error = String(e);
4589
4613
  }
4590
4614
  abort(e) {
4591
- this.signalCtl.abort(new ve(e));
4615
+ this.signalCtl.abort(new Se(e));
4592
4616
  }
4593
4617
  }
4594
- class ve extends Error {
4618
+ class Se extends Error {
4595
4619
  }
4596
- async function Ye(s) {
4620
+ async function et(s) {
4597
4621
  const e = await m.readdir(s, { withFileTypes: !0 });
4598
4622
  return (await Promise.all(
4599
4623
  e.map(async (o) => {
4600
4624
  const n = b.join(s, o.name);
4601
- return o.isDirectory() ? await Ye(n) : (await m.stat(n)).size;
4625
+ return o.isDirectory() ? await et(n) : (await m.stat(n)).size;
4602
4626
  })
4603
4627
  )).reduce((o, n) => o + n, 0);
4604
4628
  }
4605
4629
  async function de(s) {
4606
4630
  await m.rm(s, { recursive: !0, force: !0 });
4607
4631
  }
4608
- function Se(s, e) {
4632
+ function ve(s, e) {
4609
4633
  return `index://index/${encodeURIComponent(JSON.stringify({
4610
4634
  storageId: s,
4611
4635
  path: e
4612
4636
  }))}`;
4613
4637
  }
4614
- function _n(s, e, t, o) {
4638
+ function On(s, e, t, o) {
4615
4639
  const n = {
4616
4640
  localPath: s,
4617
4641
  pathSignature: e.sign(s),
@@ -4620,32 +4644,32 @@ function _n(s, e, t, o) {
4620
4644
  };
4621
4645
  return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
4622
4646
  }
4623
- function Cn(s) {
4647
+ function Fn(s) {
4624
4648
  const e = new URL(s);
4625
4649
  return q.parse(
4626
4650
  JSON.parse(decodeURIComponent(e.pathname.substring(1)))
4627
4651
  );
4628
4652
  }
4629
- function Fn(s) {
4653
+ function Wn(s) {
4630
4654
  const e = new URL(s);
4631
- return Ge.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4655
+ return Ve.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4632
4656
  }
4633
- function On(s) {
4634
- if (An(s))
4657
+ function zn(s) {
4658
+ if (Hn(s))
4659
+ return Gn(s);
4660
+ if (xn(s))
4635
4661
  return Mn(s);
4636
- if (En(s))
4637
- return zn(s);
4638
- dt(s);
4662
+ ht(s);
4639
4663
  }
4640
- const et = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4641
- function En(s) {
4642
- return et.test(s);
4664
+ const tt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4665
+ function xn(s) {
4666
+ return tt.test(s);
4643
4667
  }
4644
- function Wn(s, e) {
4668
+ function An(s, e) {
4645
4669
  return `local://${s}/${encodeURIComponent(e)}`;
4646
4670
  }
4647
- function zn(s) {
4648
- const e = s.match(et);
4671
+ function Mn(s) {
4672
+ const e = s.match(tt);
4649
4673
  if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
4650
4674
  const { name: t, path: o } = e.groups;
4651
4675
  return {
@@ -4654,29 +4678,29 @@ function zn(s) {
4654
4678
  isRemote: !1
4655
4679
  };
4656
4680
  }
4657
- const tt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4658
- function An(s) {
4659
- return tt.test(s);
4681
+ const ot = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4682
+ function Hn(s) {
4683
+ return ot.test(s);
4660
4684
  }
4661
- function xn(s, e) {
4685
+ function jn(s, e) {
4662
4686
  return `remote://${s}/${BigInt(e)}`;
4663
4687
  }
4664
- function Mn(s) {
4665
- const e = s.match(tt);
4688
+ function Gn(s) {
4689
+ const e = s.match(ot);
4666
4690
  if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
4667
4691
  const { name: t, resourceId: o } = e.groups;
4668
4692
  return {
4669
4693
  id: he(BigInt(o)),
4670
- type: Hn(t),
4694
+ type: Vn(t),
4671
4695
  name: t,
4672
4696
  isRemote: !0
4673
4697
  };
4674
4698
  }
4675
- function Hn(s) {
4699
+ function Vn(s) {
4676
4700
  return { name: `LS/${s}`, version: "1" };
4677
4701
  }
4678
- async function jn() {
4679
- const s = gt.homedir();
4702
+ async function qn() {
4703
+ const s = ft.homedir();
4680
4704
  if (L.sep == "/")
4681
4705
  return [
4682
4706
  {
@@ -4688,7 +4712,7 @@ async function jn() {
4688
4712
  {
4689
4713
  const t = L.parse(s).root.replaceAll(":\\", "");
4690
4714
  try {
4691
- return (await bt.promisify(Tt)("wmic logicaldisk get name")).stdout.split(`\r
4715
+ return (await Tt.promisify(kt)("wmic logicaldisk get name")).stdout.split(`\r
4692
4716
  `).filter((r) => r.includes(":")).map((r) => r.trim().replaceAll(":", "")).map((r) => {
4693
4717
  const a = r == t;
4694
4718
  return {
@@ -4708,7 +4732,7 @@ async function jn() {
4708
4732
  }
4709
4733
  }
4710
4734
  }
4711
- class ot {
4735
+ class nt {
4712
4736
  constructor(e, t, o, n, r, a, i) {
4713
4737
  this.logger = e, this.lsClient = t, this.storageIdToResourceId = o, this.signer = n, this.virtualStoragesMap = r, this.localProjectionsMap = a, this.openFileDialogCallback = i;
4714
4738
  }
@@ -4740,13 +4764,13 @@ class ot {
4740
4764
  * @private
4741
4765
  */
4742
4766
  async tryResolveLocalFileHandle(e) {
4743
- if (yt(e)) {
4744
- const t = Fn(e), o = this.localProjectionsMap.get(t.storageId);
4767
+ if (bt(e)) {
4768
+ const t = Wn(e), o = this.localProjectionsMap.get(t.storageId);
4745
4769
  if (!o)
4746
4770
  throw new Error(`Storage ${t.storageId} is not mounted locally.`);
4747
4771
  return b.join(o.localPath, t.path);
4748
4772
  } else {
4749
- const t = Cn(e);
4773
+ const t = Fn(e);
4750
4774
  this.signer.verify(
4751
4775
  t.localPath,
4752
4776
  t.pathSignature,
@@ -4759,17 +4783,17 @@ class ot {
4759
4783
  }
4760
4784
  }
4761
4785
  async getLocalFileHandle(e) {
4762
- _(e);
4786
+ C(e);
4763
4787
  for (const o of this.localProjectionsMap.values())
4764
4788
  if (e.startsWith(o.localPath)) {
4765
4789
  const n = o.localPath === "" ? e : b.relative(o.localPath, e);
4766
- return Se(
4790
+ return ve(
4767
4791
  o.storageId,
4768
4792
  n
4769
4793
  );
4770
4794
  }
4771
4795
  const t = await m.stat(e, { bigint: !0 });
4772
- return _n(
4796
+ return On(
4773
4797
  e,
4774
4798
  this.signer,
4775
4799
  t.size,
@@ -4780,12 +4804,12 @@ class ot {
4780
4804
  async getStorageList() {
4781
4805
  const e = [...this.virtualStoragesMap.values()].map((n) => ({
4782
4806
  name: n.name,
4783
- handle: Wn(n.name, n.root),
4807
+ handle: An(n.name, n.root),
4784
4808
  initialFullPath: n.initialPath
4785
4809
  })), o = Object.entries(this.storageIdToResourceId).map(
4786
4810
  ([n, r]) => ({
4787
4811
  name: n,
4788
- handle: xn(n, r),
4812
+ handle: jn(n, r),
4789
4813
  initialFullPath: "",
4790
4814
  // we don't have any additional information from where to start browsing remote storages
4791
4815
  isInitialPathHome: !1
@@ -4794,17 +4818,17 @@ class ot {
4794
4818
  return [...e, ...o];
4795
4819
  }
4796
4820
  async listFiles(e, t) {
4797
- const o = On(e);
4821
+ const o = zn(e);
4798
4822
  if (o.isRemote)
4799
4823
  return {
4800
4824
  entries: (await this.lsClient.list(o, t)).items.map((i) => ({
4801
4825
  type: i.isDir ? "dir" : "file",
4802
4826
  name: i.name,
4803
4827
  fullPath: i.fullName,
4804
- handle: Se(o.name, i.fullName)
4828
+ handle: ve(o.name, i.fullName)
4805
4829
  }))
4806
4830
  };
4807
- b.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && _(t);
4831
+ b.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && C(t);
4808
4832
  const n = b.isAbsolute(t) ? t : b.join(o.rootPath, t), r = [];
4809
4833
  for await (const a of await m.opendir(n)) {
4810
4834
  if (!a.isFile() && !a.isDirectory()) continue;
@@ -4825,18 +4849,18 @@ class ot {
4825
4849
  }
4826
4850
  static async init(e, t, o, n, r, a) {
4827
4851
  const i = Xo(t, e);
4828
- a || (a = await jn());
4829
- for (const p of a) _(p.root);
4830
- for (const p of n) p.localPath !== "" && _(p.localPath);
4852
+ a || (a = await qn());
4853
+ for (const p of a) C(p.root);
4854
+ for (const p of n) p.localPath !== "" && C(p.localPath);
4831
4855
  const c = new Map(a.map((p) => [p.name, p])), l = new Map(n.map((p) => [p.storageId, p]));
4832
4856
  if ((/* @__PURE__ */ new Set([...c.keys(), ...l.keys()])).size !== c.size + l.size)
4833
4857
  throw new Error(
4834
4858
  "Intersection between local projection storage ids and virtual storages names detected."
4835
4859
  );
4836
- return new ot(
4860
+ return new nt(
4837
4861
  e,
4838
4862
  i,
4839
- await Gn(t),
4863
+ await Jn(t),
4840
4864
  o,
4841
4865
  c,
4842
4866
  l,
@@ -4844,15 +4868,15 @@ class ot {
4844
4868
  );
4845
4869
  }
4846
4870
  }
4847
- async function Gn(s) {
4871
+ async function Jn(s) {
4848
4872
  return s.withReadTx("GetAvailableStorageIds", async (e) => {
4849
4873
  const t = await e.getResourceByName("LSProvider"), o = await e.getResourceData(t, !0);
4850
- return Vn(o);
4874
+ return Zn(o);
4851
4875
  });
4852
4876
  }
4853
- function Vn(s) {
4877
+ function Zn(s) {
4854
4878
  return Object.fromEntries(
4855
- s.fields.filter((e) => e.type == "Dynamic" && at(e.value)).map((e) => [e.name.substring(8), e.value])
4879
+ s.fields.filter((e) => e.type == "Dynamic" && lt(e.value)).map((e) => [e.name.substring(8), e.value])
4856
4880
  );
4857
4881
  }
4858
4882
  export {
@@ -4861,40 +4885,40 @@ export {
4861
4885
  Oo as ClientLs,
4862
4886
  ho as ClientProgress,
4863
4887
  Gt as ClientUpload,
4864
- jn as DefaultVirtualLocalStorages,
4865
- Lr as DownloadBlobToURLDriver,
4866
- Tr as DownloadDriver,
4867
- Ir as DownloadUrlDriver,
4888
+ qn as DefaultVirtualLocalStorages,
4889
+ Dr as DownloadBlobToURLDriver,
4890
+ Pr as DownloadDriver,
4891
+ vr as DownloadUrlDriver,
4868
4892
  gn as DownloadableBlobSnapshot,
4869
- br as ImportFileHandleData,
4870
- Ge as ImportFileHandleIndexData,
4893
+ Lr as ImportFileHandleData,
4894
+ Ve as ImportFileHandleIndexData,
4871
4895
  q as ImportFileHandleUploadData,
4872
4896
  rn as IndexResourceSnapshot,
4873
- Rr as LogsDriver,
4874
- Dr as LogsStreamDriver,
4875
- ot as LsDriver,
4897
+ Sr as LogsDriver,
4898
+ Ir as LogsStreamDriver,
4899
+ nt as LsDriver,
4876
4900
  ze as MTimeError,
4877
- jt as NetworkError,
4878
- xe as NoFileForUploading,
4901
+ Ae as NetworkError,
4902
+ Me as NoFileForUploading,
4879
4903
  tn as OnDemandBlobResourceSnapshot,
4880
- Ae as UnexpectedEOF,
4904
+ xe as UnexpectedEOF,
4881
4905
  be as UnknownStorageError,
4882
4906
  dn as Updater,
4883
- Pr as UploadDriver,
4907
+ Rr as UploadDriver,
4884
4908
  nn as UploadResourceSnapshot,
4885
4909
  ye as WrongLocalFileUrl,
4886
4910
  Le as WrongResourceTypeError,
4887
- fr as createDownloadClient,
4888
- mr as createLogsClient,
4911
+ yr as createDownloadClient,
4912
+ br as createLogsClient,
4889
4913
  Xo as createLsFilesClient,
4890
- yr as createUploadBlobClient,
4891
- wr as createUploadProgressClient,
4914
+ kr as createUploadBlobClient,
4915
+ Tr as createUploadProgressClient,
4892
4916
  Po as getFullPath,
4893
4917
  on as getSize,
4894
- Sn as makeBlobImportSnapshot,
4918
+ $n as makeBlobImportSnapshot,
4895
4919
  fn as makeDownloadableBlobSnapshot,
4896
- Io as newLocalStorageIdsToRoot,
4920
+ Ro as newLocalStorageIdsToRoot,
4897
4921
  Lo as parseLocalUrl,
4898
- _ as validateAbsolute
4922
+ C as validateAbsolute
4899
4923
  };
4900
4924
  //# sourceMappingURL=index.mjs.map