@milaboratories/pl-drivers 1.2.35 → 1.3.1
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/clients/download.d.ts +6 -2
- package/dist/clients/download.d.ts.map +1 -1
- package/dist/clients/helpers.d.ts +2 -2
- package/dist/clients/helpers.d.ts.map +1 -1
- package/dist/drivers/helpers/ls_list_entry.d.ts +8 -13
- package/dist/drivers/helpers/ls_list_entry.d.ts.map +1 -1
- package/dist/drivers/helpers/ls_storage_entry.d.ts +6 -8
- package/dist/drivers/helpers/ls_storage_entry.d.ts.map +1 -1
- package/dist/drivers/ls.d.ts +40 -12
- package/dist/drivers/ls.d.ts.map +1 -1
- package/dist/drivers/types.d.ts +80 -0
- package/dist/drivers/types.d.ts.map +1 -0
- package/dist/drivers/upload.d.ts +18 -26
- package/dist/drivers/upload.d.ts.map +1 -1
- package/dist/helpers/validate.d.ts +2 -0
- package/dist/helpers/validate.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +820 -792
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/clients/download.test.ts +17 -15
- package/src/clients/download.ts +34 -21
- package/src/clients/helpers.ts +13 -43
- package/src/drivers/download_blob.test.ts +4 -4
- package/src/drivers/helpers/ls_list_entry.test.ts +5 -7
- package/src/drivers/helpers/ls_list_entry.ts +31 -36
- package/src/drivers/helpers/ls_storage_entry.ts +18 -62
- package/src/drivers/logs.test.ts +3 -3
- package/src/drivers/ls.test.ts +112 -30
- package/src/drivers/ls.ts +233 -83
- package/src/drivers/types.ts +41 -0
- package/src/drivers/upload.test.ts +43 -82
- package/src/drivers/upload.ts +59 -111
- package/src/helpers/validate.ts +6 -0
- package/src/index.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import * as
|
|
5
|
-
import { addRTypeToMetadata as
|
|
6
|
-
import { ServiceType as
|
|
7
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as
|
|
8
|
-
import { request as
|
|
9
|
-
import { notEmpty as
|
|
10
|
-
import { Readable as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
24
|
-
|
|
1
|
+
var Me = Object.defineProperty;
|
|
2
|
+
var He = (s, e, t) => e in s ? Me(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var d = (s, e, t) => He(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import * as m from "node:fs/promises";
|
|
5
|
+
import { addRTypeToMetadata as k, valErr as je, getField as Ge, isNullResourceId as Ve, bigintToResourceId as Y, stringifyWithResourceId as qe, isNotNullResourceId as Je } from "@milaboratories/pl-client";
|
|
6
|
+
import { ServiceType as D, stackIntercept as y } from "@protobuf-ts/runtime-rpc";
|
|
7
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as ye } from "@protobuf-ts/runtime";
|
|
8
|
+
import { request as be } from "undici";
|
|
9
|
+
import { notEmpty as K, mapGet as ce, mapEntries as Ze, TaskProcessor as ee, CallersCounter as v, asyncPool as te, fileExists as Qe, assertNever as Xe } from "@milaboratories/ts-helpers";
|
|
10
|
+
import { Readable as re, Writable as ne, Transform as Ye } from "node:stream";
|
|
11
|
+
import * as O from "node:fs";
|
|
12
|
+
import * as w from "node:path";
|
|
13
|
+
import Ke from "node:path";
|
|
14
|
+
import { text as et, buffer as Te } from "node:stream/consumers";
|
|
15
|
+
import { Computable as b, ChangeSource as N, PollingComputableHooks as ke } from "@milaboratories/computable";
|
|
16
|
+
import { scheduler as oe } from "node:timers/promises";
|
|
17
|
+
import * as tt from "node:readline/promises";
|
|
18
|
+
import rt from "denque";
|
|
19
|
+
import * as Z from "node:os";
|
|
20
|
+
import { randomUUID as L, createHash as nt } from "node:crypto";
|
|
21
|
+
import { rsSchema as se, treeEntryToResourceInfo as R, isPlTreeEntry as ie, makeResourceSnapshot as Q, isPlTreeEntryAccessor as ot } from "@milaboratories/pl-tree";
|
|
22
|
+
import { z as T } from "zod";
|
|
23
|
+
import * as st from "node:zlib";
|
|
24
|
+
import * as it from "tar-fs";
|
|
25
|
+
import { isImportFileHandleIndex as at } from "@milaboratories/pl-model-common";
|
|
26
|
+
class lt extends g {
|
|
25
27
|
constructor() {
|
|
26
28
|
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
27
29
|
}
|
|
@@ -41,8 +43,8 @@ class rt extends g {
|
|
|
41
43
|
), t;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
new
|
|
45
|
-
class
|
|
46
|
+
new lt();
|
|
47
|
+
class ct extends g {
|
|
46
48
|
constructor() {
|
|
47
49
|
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
48
50
|
}
|
|
@@ -62,8 +64,8 @@ class nt extends g {
|
|
|
62
64
|
), t;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
new
|
|
66
|
-
class
|
|
67
|
+
new ct();
|
|
68
|
+
class dt extends g {
|
|
67
69
|
constructor() {
|
|
68
70
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
69
71
|
{
|
|
@@ -81,8 +83,8 @@ class ot extends g {
|
|
|
81
83
|
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
82
84
|
}
|
|
83
85
|
internalBinaryRead(e, t, n, r) {
|
|
84
|
-
let o = r ?? this.create(),
|
|
85
|
-
for (; e.pos <
|
|
86
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
87
|
+
for (; e.pos < c; ) {
|
|
86
88
|
let [i, l] = e.tag();
|
|
87
89
|
switch (i) {
|
|
88
90
|
case /* uint64 resource_id */
|
|
@@ -117,8 +119,8 @@ class ot extends g {
|
|
|
117
119
|
), t;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
const
|
|
121
|
-
class
|
|
122
|
+
const ht = new dt();
|
|
123
|
+
class ut extends g {
|
|
122
124
|
constructor() {
|
|
123
125
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
124
126
|
{
|
|
@@ -145,8 +147,8 @@ class it extends g {
|
|
|
145
147
|
return t.partsCount = 0n, t.uploadedParts = [], e !== void 0 && f(this, t, e), t;
|
|
146
148
|
}
|
|
147
149
|
internalBinaryRead(e, t, n, r) {
|
|
148
|
-
let o = r ?? this.create(),
|
|
149
|
-
for (; e.pos <
|
|
150
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
151
|
+
for (; e.pos < c; ) {
|
|
150
152
|
let [i, l] = e.tag();
|
|
151
153
|
switch (i) {
|
|
152
154
|
case /* uint64 parts_count */
|
|
@@ -193,8 +195,8 @@ class it extends g {
|
|
|
193
195
|
), t;
|
|
194
196
|
}
|
|
195
197
|
}
|
|
196
|
-
const
|
|
197
|
-
class
|
|
198
|
+
const pt = new ut();
|
|
199
|
+
class gt extends g {
|
|
198
200
|
constructor() {
|
|
199
201
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
200
202
|
}
|
|
@@ -214,8 +216,8 @@ class lt extends g {
|
|
|
214
216
|
), t;
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
|
-
new
|
|
218
|
-
class
|
|
219
|
+
new gt();
|
|
220
|
+
class ft extends g {
|
|
219
221
|
constructor() {
|
|
220
222
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
221
223
|
{
|
|
@@ -245,8 +247,8 @@ class dt extends g {
|
|
|
245
247
|
), t;
|
|
246
248
|
}
|
|
247
249
|
internalBinaryRead(e, t, n, r) {
|
|
248
|
-
let o = r ?? this.create(),
|
|
249
|
-
for (; e.pos <
|
|
250
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
251
|
+
for (; e.pos < c; ) {
|
|
250
252
|
let [i, l] = e.tag();
|
|
251
253
|
switch (i) {
|
|
252
254
|
case /* uint64 resource_id */
|
|
@@ -285,8 +287,8 @@ class dt extends g {
|
|
|
285
287
|
), t;
|
|
286
288
|
}
|
|
287
289
|
}
|
|
288
|
-
const
|
|
289
|
-
class
|
|
290
|
+
const mt = new ft();
|
|
291
|
+
class wt extends g {
|
|
290
292
|
constructor() {
|
|
291
293
|
super(
|
|
292
294
|
"MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
|
|
@@ -313,8 +315,8 @@ class ht extends g {
|
|
|
313
315
|
), t;
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
|
-
const
|
|
317
|
-
class
|
|
318
|
+
const yt = new wt();
|
|
319
|
+
class bt extends g {
|
|
318
320
|
constructor() {
|
|
319
321
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
320
322
|
}
|
|
@@ -334,8 +336,8 @@ class pt extends g {
|
|
|
334
336
|
), t;
|
|
335
337
|
}
|
|
336
338
|
}
|
|
337
|
-
new
|
|
338
|
-
class
|
|
339
|
+
new bt();
|
|
340
|
+
class Tt extends g {
|
|
339
341
|
constructor() {
|
|
340
342
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
341
343
|
{
|
|
@@ -373,8 +375,8 @@ class gt extends g {
|
|
|
373
375
|
), t;
|
|
374
376
|
}
|
|
375
377
|
internalBinaryRead(e, t, n, r) {
|
|
376
|
-
let o = r ?? this.create(),
|
|
377
|
-
for (; e.pos <
|
|
378
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
379
|
+
for (; e.pos < c; ) {
|
|
378
380
|
let [i, l] = e.tag();
|
|
379
381
|
switch (i) {
|
|
380
382
|
case /* uint64 resource_id */
|
|
@@ -417,8 +419,8 @@ class gt extends g {
|
|
|
417
419
|
), t;
|
|
418
420
|
}
|
|
419
421
|
}
|
|
420
|
-
const
|
|
421
|
-
class
|
|
422
|
+
const kt = new Tt();
|
|
423
|
+
class Lt extends g {
|
|
422
424
|
constructor() {
|
|
423
425
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
424
426
|
{
|
|
@@ -448,8 +450,8 @@ class mt extends g {
|
|
|
448
450
|
), t;
|
|
449
451
|
}
|
|
450
452
|
internalBinaryRead(e, t, n, r) {
|
|
451
|
-
let o = r ?? this.create(),
|
|
452
|
-
for (; e.pos <
|
|
453
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
454
|
+
for (; e.pos < c; ) {
|
|
453
455
|
let [i, l] = e.tag();
|
|
454
456
|
switch (i) {
|
|
455
457
|
case /* string Name = 1 [json_name = "Name"];*/
|
|
@@ -488,8 +490,8 @@ class mt extends g {
|
|
|
488
490
|
), t;
|
|
489
491
|
}
|
|
490
492
|
}
|
|
491
|
-
const
|
|
492
|
-
class
|
|
493
|
+
const E = new Lt();
|
|
494
|
+
class Pt extends g {
|
|
493
495
|
constructor() {
|
|
494
496
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
495
497
|
{
|
|
@@ -511,7 +513,7 @@ class wt extends g {
|
|
|
511
513
|
name: "headers",
|
|
512
514
|
kind: "message",
|
|
513
515
|
repeat: 1,
|
|
514
|
-
T: () =>
|
|
516
|
+
T: () => E
|
|
515
517
|
},
|
|
516
518
|
{
|
|
517
519
|
no: 4,
|
|
@@ -540,8 +542,8 @@ class wt extends g {
|
|
|
540
542
|
), t;
|
|
541
543
|
}
|
|
542
544
|
internalBinaryRead(e, t, n, r) {
|
|
543
|
-
let o = r ?? this.create(),
|
|
544
|
-
for (; e.pos <
|
|
545
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
546
|
+
for (; e.pos < c; ) {
|
|
545
547
|
let [i, l] = e.tag();
|
|
546
548
|
switch (i) {
|
|
547
549
|
case /* string upload_url */
|
|
@@ -555,7 +557,7 @@ class wt extends g {
|
|
|
555
557
|
case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
|
|
556
558
|
3:
|
|
557
559
|
o.headers.push(
|
|
558
|
-
|
|
560
|
+
E.internalBinaryRead(
|
|
559
561
|
e,
|
|
560
562
|
e.uint32(),
|
|
561
563
|
n
|
|
@@ -591,7 +593,7 @@ class wt extends g {
|
|
|
591
593
|
internalBinaryWrite(e, t, n) {
|
|
592
594
|
e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
|
|
593
595
|
for (let o = 0; o < e.headers.length; o++)
|
|
594
|
-
|
|
596
|
+
E.internalBinaryWrite(
|
|
595
597
|
e.headers[o],
|
|
596
598
|
t.tag(3, h.LengthDelimited).fork(),
|
|
597
599
|
n
|
|
@@ -605,8 +607,8 @@ class wt extends g {
|
|
|
605
607
|
), t;
|
|
606
608
|
}
|
|
607
609
|
}
|
|
608
|
-
const
|
|
609
|
-
class
|
|
610
|
+
const It = new Pt();
|
|
611
|
+
class Rt extends g {
|
|
610
612
|
constructor() {
|
|
611
613
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
612
614
|
}
|
|
@@ -626,8 +628,8 @@ class bt extends g {
|
|
|
626
628
|
), t;
|
|
627
629
|
}
|
|
628
630
|
}
|
|
629
|
-
new
|
|
630
|
-
class
|
|
631
|
+
new Rt();
|
|
632
|
+
class St extends g {
|
|
631
633
|
constructor() {
|
|
632
634
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
633
635
|
{
|
|
@@ -645,8 +647,8 @@ class Tt extends g {
|
|
|
645
647
|
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
646
648
|
}
|
|
647
649
|
internalBinaryRead(e, t, n, r) {
|
|
648
|
-
let o = r ?? this.create(),
|
|
649
|
-
for (; e.pos <
|
|
650
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
651
|
+
for (; e.pos < c; ) {
|
|
650
652
|
let [i, l] = e.tag();
|
|
651
653
|
switch (i) {
|
|
652
654
|
case /* uint64 resource_id */
|
|
@@ -681,8 +683,8 @@ class Tt extends g {
|
|
|
681
683
|
), t;
|
|
682
684
|
}
|
|
683
685
|
}
|
|
684
|
-
const
|
|
685
|
-
class
|
|
686
|
+
const Nt = new St();
|
|
687
|
+
class Ut extends g {
|
|
686
688
|
constructor() {
|
|
687
689
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
688
690
|
}
|
|
@@ -702,40 +704,40 @@ class Lt extends g {
|
|
|
702
704
|
), t;
|
|
703
705
|
}
|
|
704
706
|
}
|
|
705
|
-
const
|
|
707
|
+
const Bt = new Ut(), W = new D(
|
|
706
708
|
"MiLaboratories.Controller.Shared.Upload",
|
|
707
709
|
[
|
|
708
710
|
{
|
|
709
711
|
name: "Init",
|
|
710
712
|
options: {},
|
|
711
|
-
I:
|
|
712
|
-
O:
|
|
713
|
+
I: ht,
|
|
714
|
+
O: pt
|
|
713
715
|
},
|
|
714
716
|
{
|
|
715
717
|
name: "GetPartURL",
|
|
716
718
|
options: {},
|
|
717
|
-
I:
|
|
718
|
-
O:
|
|
719
|
+
I: kt,
|
|
720
|
+
O: It
|
|
719
721
|
},
|
|
720
722
|
{
|
|
721
723
|
name: "UpdateProgress",
|
|
722
724
|
options: {},
|
|
723
|
-
I:
|
|
724
|
-
O:
|
|
725
|
+
I: mt,
|
|
726
|
+
O: yt
|
|
725
727
|
},
|
|
726
728
|
{
|
|
727
729
|
name: "Finalize",
|
|
728
730
|
options: {},
|
|
729
|
-
I:
|
|
730
|
-
O:
|
|
731
|
+
I: Nt,
|
|
732
|
+
O: Bt
|
|
731
733
|
}
|
|
732
734
|
]
|
|
733
735
|
);
|
|
734
|
-
class
|
|
736
|
+
class Dt {
|
|
735
737
|
constructor(e) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
738
|
+
d(this, "typeName", W.typeName);
|
|
739
|
+
d(this, "methods", W.methods);
|
|
740
|
+
d(this, "options", W.options);
|
|
739
741
|
this._transport = e;
|
|
740
742
|
}
|
|
741
743
|
/**
|
|
@@ -747,7 +749,7 @@ class It {
|
|
|
747
749
|
*/
|
|
748
750
|
init(e, t) {
|
|
749
751
|
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
750
|
-
return
|
|
752
|
+
return y(
|
|
751
753
|
"unary",
|
|
752
754
|
this._transport,
|
|
753
755
|
n,
|
|
@@ -765,7 +767,7 @@ class It {
|
|
|
765
767
|
*/
|
|
766
768
|
getPartURL(e, t) {
|
|
767
769
|
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
768
|
-
return
|
|
770
|
+
return y("unary", this._transport, n, r, e);
|
|
769
771
|
}
|
|
770
772
|
/**
|
|
771
773
|
*
|
|
@@ -776,7 +778,7 @@ class It {
|
|
|
776
778
|
*/
|
|
777
779
|
updateProgress(e, t) {
|
|
778
780
|
const n = this.methods[2], r = this._transport.mergeOptions(t);
|
|
779
|
-
return
|
|
781
|
+
return y("unary", this._transport, n, r, e);
|
|
780
782
|
}
|
|
781
783
|
/**
|
|
782
784
|
*
|
|
@@ -789,32 +791,32 @@ class It {
|
|
|
789
791
|
*/
|
|
790
792
|
finalize(e, t) {
|
|
791
793
|
const n = this.methods[3], r = this._transport.mergeOptions(t);
|
|
792
|
-
return
|
|
794
|
+
return y("unary", this._transport, n, r, e);
|
|
793
795
|
}
|
|
794
796
|
}
|
|
795
|
-
class ke extends Error {
|
|
796
|
-
}
|
|
797
797
|
class Le extends Error {
|
|
798
798
|
}
|
|
799
|
-
class Nt extends Error {
|
|
800
|
-
}
|
|
801
799
|
class Pe extends Error {
|
|
802
800
|
}
|
|
803
|
-
class
|
|
801
|
+
class vt extends Error {
|
|
802
|
+
}
|
|
803
|
+
class Ie extends Error {
|
|
804
|
+
}
|
|
805
|
+
class $t {
|
|
804
806
|
constructor(e, t, n, r) {
|
|
805
|
-
|
|
806
|
-
this.grpcTransport = e, this.httpClient = t, this.logger = r, this.grpcClient = new
|
|
807
|
+
d(this, "grpcClient");
|
|
808
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = r, this.grpcClient = new Dt(this.grpcTransport);
|
|
807
809
|
}
|
|
808
810
|
close() {
|
|
809
811
|
}
|
|
810
812
|
async initUpload({ id: e, type: t }, n) {
|
|
811
813
|
const r = await this.grpcClient.init(
|
|
812
814
|
{ resourceId: e },
|
|
813
|
-
|
|
815
|
+
k(t, n)
|
|
814
816
|
);
|
|
815
817
|
return this.partsToUpload(r.response);
|
|
816
818
|
}
|
|
817
|
-
async partUpload({ id: e, type: t }, n, r, o,
|
|
819
|
+
async partUpload({ id: e, type: t }, n, r, o, c, i) {
|
|
818
820
|
const l = await this.grpcClient.getPartURL(
|
|
819
821
|
{
|
|
820
822
|
resourceId: e,
|
|
@@ -822,51 +824,51 @@ class Rt {
|
|
|
822
824
|
uploadedPartSize: 0n
|
|
823
825
|
// we update progress as a separate call later.
|
|
824
826
|
},
|
|
825
|
-
|
|
827
|
+
k(t, i)
|
|
826
828
|
).response, { chunk: a, mTime: p } = await this.readChunk(
|
|
827
829
|
n,
|
|
828
830
|
l.chunkStart,
|
|
829
831
|
l.chunkEnd
|
|
830
832
|
);
|
|
831
|
-
if (p >
|
|
832
|
-
throw new
|
|
833
|
-
"file was modified, expected mtime: " +
|
|
833
|
+
if (p > c)
|
|
834
|
+
throw new Le(
|
|
835
|
+
"file was modified, expected mtime: " + c + ", got: " + p + "."
|
|
834
836
|
);
|
|
835
|
-
const P = await
|
|
837
|
+
const P = await be(
|
|
836
838
|
l.uploadUrl,
|
|
837
839
|
this.prepareUploadOpts(l, a)
|
|
838
|
-
),
|
|
840
|
+
), le = await P.body.text();
|
|
839
841
|
if (this.logger.info(
|
|
840
|
-
`uploaded chunk ${r} from ${o} of resource: ${e}, response: '${
|
|
842
|
+
`uploaded chunk ${r} from ${o} of resource: ${e}, response: '${le.toString()}', status code: ${P.statusCode}`
|
|
841
843
|
), P.statusCode != 200)
|
|
842
|
-
throw new
|
|
843
|
-
`response is not ok, status code: ${P.statusCode}, body: ${
|
|
844
|
+
throw new vt(
|
|
845
|
+
`response is not ok, status code: ${P.statusCode}, body: ${le}, headers: ${P.headers}, url: ${l.uploadUrl}`
|
|
844
846
|
);
|
|
845
847
|
await this.grpcClient.updateProgress(
|
|
846
848
|
{
|
|
847
849
|
resourceId: e,
|
|
848
850
|
bytesProcessed: l.chunkEnd - l.chunkStart
|
|
849
851
|
},
|
|
850
|
-
|
|
852
|
+
k(t, i)
|
|
851
853
|
);
|
|
852
854
|
}
|
|
853
855
|
async finalizeUpload({ id: e, type: t }, n) {
|
|
854
856
|
return await this.grpcClient.finalize(
|
|
855
857
|
{ resourceId: e },
|
|
856
|
-
|
|
858
|
+
k(t, n)
|
|
857
859
|
);
|
|
858
860
|
}
|
|
859
861
|
async readChunk(e, t, n) {
|
|
860
862
|
let r;
|
|
861
863
|
try {
|
|
862
|
-
r = await
|
|
863
|
-
const o = Number(n - t),
|
|
864
|
+
r = await m.open(e);
|
|
865
|
+
const o = Number(n - t), c = Number(t), i = Buffer.alloc(o), l = await this.readBytesFromPosition(r, i, o, c), a = await m.stat(e);
|
|
864
866
|
return {
|
|
865
867
|
chunk: i.subarray(0, l),
|
|
866
868
|
mTime: BigInt(Math.floor(a.mtimeMs / 1e3))
|
|
867
869
|
};
|
|
868
870
|
} catch (o) {
|
|
869
|
-
throw o.code == "ENOENT" ? new
|
|
871
|
+
throw o.code == "ENOENT" ? new Ie(`there is no file ${e} for uploading`) : o;
|
|
870
872
|
} finally {
|
|
871
873
|
r == null || r.close();
|
|
872
874
|
}
|
|
@@ -876,15 +878,15 @@ class Rt {
|
|
|
876
878
|
async readBytesFromPosition(e, t, n, r) {
|
|
877
879
|
let o = 0;
|
|
878
880
|
for (; o < n; ) {
|
|
879
|
-
const { bytesRead:
|
|
881
|
+
const { bytesRead: c } = await e.read(
|
|
880
882
|
t,
|
|
881
883
|
o,
|
|
882
884
|
n - o,
|
|
883
885
|
r + o
|
|
884
886
|
);
|
|
885
|
-
if (
|
|
886
|
-
throw new
|
|
887
|
-
o +=
|
|
887
|
+
if (c === 0)
|
|
888
|
+
throw new Pe("file ended earlier than expected.");
|
|
889
|
+
o += c;
|
|
888
890
|
}
|
|
889
891
|
return o;
|
|
890
892
|
}
|
|
@@ -906,7 +908,7 @@ class Rt {
|
|
|
906
908
|
};
|
|
907
909
|
}
|
|
908
910
|
}
|
|
909
|
-
class
|
|
911
|
+
class _t extends g {
|
|
910
912
|
constructor() {
|
|
911
913
|
super("google.protobuf.Duration", [
|
|
912
914
|
{
|
|
@@ -946,7 +948,7 @@ class St extends g {
|
|
|
946
948
|
internalJsonRead(e, t, n) {
|
|
947
949
|
if (typeof e != "string")
|
|
948
950
|
throw new Error(
|
|
949
|
-
"Unable to parse Duration from JSON " +
|
|
951
|
+
"Unable to parse Duration from JSON " + ye(e) + ". Expected string."
|
|
950
952
|
);
|
|
951
953
|
let r = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
|
|
952
954
|
if (r === null)
|
|
@@ -954,7 +956,7 @@ class St extends g {
|
|
|
954
956
|
"Unable to parse Duration from JSON string. Invalid format."
|
|
955
957
|
);
|
|
956
958
|
n || (n = this.create());
|
|
957
|
-
let [, o,
|
|
959
|
+
let [, o, c, i] = r, l = I.from(o + c);
|
|
958
960
|
if (l.toNumber() > 315576e6 || l.toNumber() < -315576e6)
|
|
959
961
|
throw new Error(
|
|
960
962
|
"Unable to parse Duration from JSON string. Value out of range."
|
|
@@ -970,8 +972,8 @@ class St extends g {
|
|
|
970
972
|
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
971
973
|
}
|
|
972
974
|
internalBinaryRead(e, t, n, r) {
|
|
973
|
-
let o = r ?? this.create(),
|
|
974
|
-
for (; e.pos <
|
|
975
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
976
|
+
for (; e.pos < c; ) {
|
|
975
977
|
let [i, l] = e.tag();
|
|
976
978
|
switch (i) {
|
|
977
979
|
case /* int64 seconds */
|
|
@@ -1010,8 +1012,8 @@ class St extends g {
|
|
|
1010
1012
|
), t;
|
|
1011
1013
|
}
|
|
1012
1014
|
}
|
|
1013
|
-
const $ = new
|
|
1014
|
-
class
|
|
1015
|
+
const $ = new _t();
|
|
1016
|
+
class Ct extends g {
|
|
1015
1017
|
constructor() {
|
|
1016
1018
|
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
1017
1019
|
}
|
|
@@ -1031,8 +1033,8 @@ class Ut extends g {
|
|
|
1031
1033
|
), t;
|
|
1032
1034
|
}
|
|
1033
1035
|
}
|
|
1034
|
-
new
|
|
1035
|
-
class
|
|
1036
|
+
new Ct();
|
|
1037
|
+
class Ot extends g {
|
|
1036
1038
|
constructor() {
|
|
1037
1039
|
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
1038
1040
|
{
|
|
@@ -1079,8 +1081,8 @@ class Bt extends g {
|
|
|
1079
1081
|
return t.progress = 0, t.bytesProcessed = 0n, t.bytesTotal = 0n, t.done = !1, t.name = "", e !== void 0 && f(this, t, e), t;
|
|
1080
1082
|
}
|
|
1081
1083
|
internalBinaryRead(e, t, n, r) {
|
|
1082
|
-
let o = r ?? this.create(),
|
|
1083
|
-
for (; e.pos <
|
|
1084
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1085
|
+
for (; e.pos < c; ) {
|
|
1084
1086
|
let [i, l] = e.tag();
|
|
1085
1087
|
switch (i) {
|
|
1086
1088
|
case /* float progress */
|
|
@@ -1131,8 +1133,8 @@ class Bt extends g {
|
|
|
1131
1133
|
), t;
|
|
1132
1134
|
}
|
|
1133
1135
|
}
|
|
1134
|
-
const
|
|
1135
|
-
class
|
|
1136
|
+
const S = new Ot();
|
|
1137
|
+
class Ft extends g {
|
|
1136
1138
|
constructor() {
|
|
1137
1139
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1138
1140
|
}
|
|
@@ -1152,8 +1154,8 @@ class vt extends g {
|
|
|
1152
1154
|
), t;
|
|
1153
1155
|
}
|
|
1154
1156
|
}
|
|
1155
|
-
new
|
|
1156
|
-
class
|
|
1157
|
+
new Ft();
|
|
1158
|
+
class Et extends g {
|
|
1157
1159
|
constructor() {
|
|
1158
1160
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1159
1161
|
{
|
|
@@ -1175,8 +1177,8 @@ class Dt extends g {
|
|
|
1175
1177
|
), t;
|
|
1176
1178
|
}
|
|
1177
1179
|
internalBinaryRead(e, t, n, r) {
|
|
1178
|
-
let o = r ?? this.create(),
|
|
1179
|
-
for (; e.pos <
|
|
1180
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1181
|
+
for (; e.pos < c; ) {
|
|
1180
1182
|
let [i, l] = e.tag();
|
|
1181
1183
|
switch (i) {
|
|
1182
1184
|
case /* uint64 resource_id */
|
|
@@ -1211,11 +1213,11 @@ class Dt extends g {
|
|
|
1211
1213
|
), t;
|
|
1212
1214
|
}
|
|
1213
1215
|
}
|
|
1214
|
-
const
|
|
1215
|
-
class
|
|
1216
|
+
const Wt = new Et();
|
|
1217
|
+
class zt extends g {
|
|
1216
1218
|
constructor() {
|
|
1217
1219
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1218
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1220
|
+
{ no: 1, name: "report", kind: "message", T: () => S }
|
|
1219
1221
|
]);
|
|
1220
1222
|
}
|
|
1221
1223
|
create(e) {
|
|
@@ -1227,13 +1229,13 @@ class _t extends g {
|
|
|
1227
1229
|
), t;
|
|
1228
1230
|
}
|
|
1229
1231
|
internalBinaryRead(e, t, n, r) {
|
|
1230
|
-
let o = r ?? this.create(),
|
|
1231
|
-
for (; e.pos <
|
|
1232
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1233
|
+
for (; e.pos < c; ) {
|
|
1232
1234
|
let [i, l] = e.tag();
|
|
1233
1235
|
switch (i) {
|
|
1234
1236
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1235
1237
|
1:
|
|
1236
|
-
o.report =
|
|
1238
|
+
o.report = S.internalBinaryRead(
|
|
1237
1239
|
e,
|
|
1238
1240
|
e.uint32(),
|
|
1239
1241
|
n,
|
|
@@ -1259,7 +1261,7 @@ class _t extends g {
|
|
|
1259
1261
|
return o;
|
|
1260
1262
|
}
|
|
1261
1263
|
internalBinaryWrite(e, t, n) {
|
|
1262
|
-
e.report &&
|
|
1264
|
+
e.report && S.internalBinaryWrite(
|
|
1263
1265
|
e.report,
|
|
1264
1266
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1265
1267
|
n
|
|
@@ -1272,8 +1274,8 @@ class _t extends g {
|
|
|
1272
1274
|
), t;
|
|
1273
1275
|
}
|
|
1274
1276
|
}
|
|
1275
|
-
const
|
|
1276
|
-
class
|
|
1277
|
+
const At = new zt();
|
|
1278
|
+
class xt extends g {
|
|
1277
1279
|
constructor() {
|
|
1278
1280
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1279
1281
|
}
|
|
@@ -1293,8 +1295,8 @@ class Ot extends g {
|
|
|
1293
1295
|
), t;
|
|
1294
1296
|
}
|
|
1295
1297
|
}
|
|
1296
|
-
new
|
|
1297
|
-
class
|
|
1298
|
+
new xt();
|
|
1299
|
+
class Mt extends g {
|
|
1298
1300
|
constructor() {
|
|
1299
1301
|
super(
|
|
1300
1302
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
|
|
@@ -1320,8 +1322,8 @@ class Et extends g {
|
|
|
1320
1322
|
), t;
|
|
1321
1323
|
}
|
|
1322
1324
|
internalBinaryRead(e, t, n, r) {
|
|
1323
|
-
let o = r ?? this.create(),
|
|
1324
|
-
for (; e.pos <
|
|
1325
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1326
|
+
for (; e.pos < c; ) {
|
|
1325
1327
|
let [i, l] = e.tag();
|
|
1326
1328
|
switch (i) {
|
|
1327
1329
|
case /* uint64 resource_id */
|
|
@@ -1369,12 +1371,12 @@ class Et extends g {
|
|
|
1369
1371
|
), t;
|
|
1370
1372
|
}
|
|
1371
1373
|
}
|
|
1372
|
-
const
|
|
1373
|
-
class
|
|
1374
|
+
const Ht = new Mt();
|
|
1375
|
+
class jt extends g {
|
|
1374
1376
|
constructor() {
|
|
1375
1377
|
super(
|
|
1376
1378
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
|
|
1377
|
-
[{ no: 1, name: "report", kind: "message", T: () =>
|
|
1379
|
+
[{ no: 1, name: "report", kind: "message", T: () => S }]
|
|
1378
1380
|
);
|
|
1379
1381
|
}
|
|
1380
1382
|
create(e) {
|
|
@@ -1386,13 +1388,13 @@ class Wt extends g {
|
|
|
1386
1388
|
), t;
|
|
1387
1389
|
}
|
|
1388
1390
|
internalBinaryRead(e, t, n, r) {
|
|
1389
|
-
let o = r ?? this.create(),
|
|
1390
|
-
for (; e.pos <
|
|
1391
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1392
|
+
for (; e.pos < c; ) {
|
|
1391
1393
|
let [i, l] = e.tag();
|
|
1392
1394
|
switch (i) {
|
|
1393
1395
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1394
1396
|
1:
|
|
1395
|
-
o.report =
|
|
1397
|
+
o.report = S.internalBinaryRead(
|
|
1396
1398
|
e,
|
|
1397
1399
|
e.uint32(),
|
|
1398
1400
|
n,
|
|
@@ -1418,7 +1420,7 @@ class Wt extends g {
|
|
|
1418
1420
|
return o;
|
|
1419
1421
|
}
|
|
1420
1422
|
internalBinaryWrite(e, t, n) {
|
|
1421
|
-
e.report &&
|
|
1423
|
+
e.report && S.internalBinaryWrite(
|
|
1422
1424
|
e.report,
|
|
1423
1425
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1424
1426
|
n
|
|
@@ -1431,7 +1433,7 @@ class Wt extends g {
|
|
|
1431
1433
|
), t;
|
|
1432
1434
|
}
|
|
1433
1435
|
}
|
|
1434
|
-
const
|
|
1436
|
+
const Gt = new jt(), z = new D(
|
|
1435
1437
|
"MiLaboratories.Controller.Shared.Progress",
|
|
1436
1438
|
[
|
|
1437
1439
|
{
|
|
@@ -1439,23 +1441,23 @@ const At = new Wt(), A = new v(
|
|
|
1439
1441
|
options: {
|
|
1440
1442
|
"google.api.http": { get: "/resources/{resource_id}/get-progress" }
|
|
1441
1443
|
},
|
|
1442
|
-
I:
|
|
1443
|
-
O:
|
|
1444
|
+
I: Wt,
|
|
1445
|
+
O: At
|
|
1444
1446
|
},
|
|
1445
1447
|
{
|
|
1446
1448
|
name: "RealtimeStatus",
|
|
1447
1449
|
serverStreaming: !0,
|
|
1448
1450
|
options: {},
|
|
1449
|
-
I:
|
|
1450
|
-
O:
|
|
1451
|
+
I: Ht,
|
|
1452
|
+
O: Gt
|
|
1451
1453
|
}
|
|
1452
1454
|
]
|
|
1453
1455
|
);
|
|
1454
|
-
class
|
|
1456
|
+
class Vt {
|
|
1455
1457
|
constructor(e) {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1458
|
+
d(this, "typeName", z.typeName);
|
|
1459
|
+
d(this, "methods", z.methods);
|
|
1460
|
+
d(this, "options", z.options);
|
|
1459
1461
|
this._transport = e;
|
|
1460
1462
|
}
|
|
1461
1463
|
/**
|
|
@@ -1463,20 +1465,20 @@ class zt {
|
|
|
1463
1465
|
*/
|
|
1464
1466
|
getStatus(e, t) {
|
|
1465
1467
|
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
1466
|
-
return
|
|
1468
|
+
return y("unary", this._transport, n, r, e);
|
|
1467
1469
|
}
|
|
1468
1470
|
/**
|
|
1469
1471
|
* @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
|
|
1470
1472
|
*/
|
|
1471
1473
|
realtimeStatus(e, t) {
|
|
1472
1474
|
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
1473
|
-
return
|
|
1475
|
+
return y("serverStreaming", this._transport, n, r, e);
|
|
1474
1476
|
}
|
|
1475
1477
|
}
|
|
1476
|
-
class
|
|
1478
|
+
class qt {
|
|
1477
1479
|
constructor(e, t, n, r) {
|
|
1478
|
-
|
|
1479
|
-
this.grpcTransport = e, this.client = n, this.logger = r, this.grpcClient = new
|
|
1480
|
+
d(this, "grpcClient");
|
|
1481
|
+
this.grpcTransport = e, this.client = n, this.logger = r, this.grpcClient = new Vt(this.grpcTransport);
|
|
1480
1482
|
}
|
|
1481
1483
|
close() {
|
|
1482
1484
|
}
|
|
@@ -1484,8 +1486,8 @@ class xt {
|
|
|
1484
1486
|
async getStatus({ id: e, type: t }, n) {
|
|
1485
1487
|
const r = await this.grpcClient.getStatus(
|
|
1486
1488
|
{ resourceId: e },
|
|
1487
|
-
|
|
1488
|
-
), o =
|
|
1489
|
+
k(t, n)
|
|
1490
|
+
), o = K(r.response.report);
|
|
1489
1491
|
return {
|
|
1490
1492
|
done: o.done,
|
|
1491
1493
|
progress: o.progress,
|
|
@@ -1496,10 +1498,10 @@ class xt {
|
|
|
1496
1498
|
// realtimeStatus returns a async generator that takes statuses from
|
|
1497
1499
|
// GRPC stream every updateIntervalMs milliseconds.
|
|
1498
1500
|
async *realtimeStatus({ id: e, type: t }, n = 100, r) {
|
|
1499
|
-
r =
|
|
1500
|
-
const o = Math.floor(n / 1e3),
|
|
1501
|
+
r = k(t, r);
|
|
1502
|
+
const o = Math.floor(n / 1e3), c = (n - o * 1e3) * 1e6, i = $.create({
|
|
1501
1503
|
seconds: BigInt(o),
|
|
1502
|
-
nanos:
|
|
1504
|
+
nanos: c
|
|
1503
1505
|
});
|
|
1504
1506
|
try {
|
|
1505
1507
|
const { responses: l } = this.grpcClient.realtimeStatus(
|
|
@@ -1515,7 +1517,7 @@ class xt {
|
|
|
1515
1517
|
}
|
|
1516
1518
|
}
|
|
1517
1519
|
}
|
|
1518
|
-
class
|
|
1520
|
+
class Jt extends g {
|
|
1519
1521
|
constructor() {
|
|
1520
1522
|
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1521
1523
|
}
|
|
@@ -1535,8 +1537,8 @@ class Mt extends g {
|
|
|
1535
1537
|
), t;
|
|
1536
1538
|
}
|
|
1537
1539
|
}
|
|
1538
|
-
new
|
|
1539
|
-
class
|
|
1540
|
+
new Jt();
|
|
1541
|
+
class Zt extends g {
|
|
1540
1542
|
constructor() {
|
|
1541
1543
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1542
1544
|
}
|
|
@@ -1556,8 +1558,8 @@ class Ht extends g {
|
|
|
1556
1558
|
), t;
|
|
1557
1559
|
}
|
|
1558
1560
|
}
|
|
1559
|
-
new
|
|
1560
|
-
class
|
|
1561
|
+
new Zt();
|
|
1562
|
+
class Qt extends g {
|
|
1561
1563
|
constructor() {
|
|
1562
1564
|
super(
|
|
1563
1565
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
|
|
@@ -1582,8 +1584,8 @@ class jt extends g {
|
|
|
1582
1584
|
), t;
|
|
1583
1585
|
}
|
|
1584
1586
|
internalBinaryRead(e, t, n, r) {
|
|
1585
|
-
let o = r ?? this.create(),
|
|
1586
|
-
for (; e.pos <
|
|
1587
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1588
|
+
for (; e.pos < c; ) {
|
|
1587
1589
|
let [i, l] = e.tag();
|
|
1588
1590
|
switch (i) {
|
|
1589
1591
|
case /* uint64 resource_id */
|
|
@@ -1618,8 +1620,8 @@ class jt extends g {
|
|
|
1618
1620
|
), t;
|
|
1619
1621
|
}
|
|
1620
1622
|
}
|
|
1621
|
-
const
|
|
1622
|
-
class
|
|
1623
|
+
const Xt = new Qt();
|
|
1624
|
+
class Yt extends g {
|
|
1623
1625
|
constructor() {
|
|
1624
1626
|
super(
|
|
1625
1627
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
|
|
@@ -1652,8 +1654,8 @@ class Vt extends g {
|
|
|
1652
1654
|
), t;
|
|
1653
1655
|
}
|
|
1654
1656
|
internalBinaryRead(e, t, n, r) {
|
|
1655
|
-
let o = r ?? this.create(),
|
|
1656
|
-
for (; e.pos <
|
|
1657
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1658
|
+
for (; e.pos < c; ) {
|
|
1657
1659
|
let [i, l] = e.tag();
|
|
1658
1660
|
switch (i) {
|
|
1659
1661
|
case /* string Name = 1 [json_name = "Name"];*/
|
|
@@ -1692,8 +1694,8 @@ class Vt extends g {
|
|
|
1692
1694
|
), t;
|
|
1693
1695
|
}
|
|
1694
1696
|
}
|
|
1695
|
-
const
|
|
1696
|
-
class
|
|
1697
|
+
const A = new Yt();
|
|
1698
|
+
class Kt extends g {
|
|
1697
1699
|
constructor() {
|
|
1698
1700
|
super(
|
|
1699
1701
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
|
|
@@ -1710,7 +1712,7 @@ class qt extends g {
|
|
|
1710
1712
|
name: "headers",
|
|
1711
1713
|
kind: "message",
|
|
1712
1714
|
repeat: 1,
|
|
1713
|
-
T: () =>
|
|
1715
|
+
T: () => A
|
|
1714
1716
|
}
|
|
1715
1717
|
]
|
|
1716
1718
|
);
|
|
@@ -1724,8 +1726,8 @@ class qt extends g {
|
|
|
1724
1726
|
), t;
|
|
1725
1727
|
}
|
|
1726
1728
|
internalBinaryRead(e, t, n, r) {
|
|
1727
|
-
let o = r ?? this.create(),
|
|
1728
|
-
for (; e.pos <
|
|
1729
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1730
|
+
for (; e.pos < c; ) {
|
|
1729
1731
|
let [i, l] = e.tag();
|
|
1730
1732
|
switch (i) {
|
|
1731
1733
|
case /* string download_url */
|
|
@@ -1735,7 +1737,7 @@ class qt extends g {
|
|
|
1735
1737
|
case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
|
|
1736
1738
|
2:
|
|
1737
1739
|
o.headers.push(
|
|
1738
|
-
|
|
1740
|
+
A.internalBinaryRead(
|
|
1739
1741
|
e,
|
|
1740
1742
|
e.uint32(),
|
|
1741
1743
|
n
|
|
@@ -1763,7 +1765,7 @@ class qt extends g {
|
|
|
1763
1765
|
internalBinaryWrite(e, t, n) {
|
|
1764
1766
|
e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
|
|
1765
1767
|
for (let o = 0; o < e.headers.length; o++)
|
|
1766
|
-
|
|
1768
|
+
A.internalBinaryWrite(
|
|
1767
1769
|
e.headers[o],
|
|
1768
1770
|
t.tag(2, h.LengthDelimited).fork(),
|
|
1769
1771
|
n
|
|
@@ -1776,7 +1778,7 @@ class qt extends g {
|
|
|
1776
1778
|
), t;
|
|
1777
1779
|
}
|
|
1778
1780
|
}
|
|
1779
|
-
const
|
|
1781
|
+
const er = new Kt(), x = new D(
|
|
1780
1782
|
"MiLaboratories.Controller.Shared.Download",
|
|
1781
1783
|
[
|
|
1782
1784
|
{
|
|
@@ -1784,16 +1786,16 @@ const Zt = new qt(), x = new v(
|
|
|
1784
1786
|
options: {
|
|
1785
1787
|
"google.api.http": { get: "/resources/{resource_id}/get-download-url" }
|
|
1786
1788
|
},
|
|
1787
|
-
I:
|
|
1788
|
-
O:
|
|
1789
|
+
I: Xt,
|
|
1790
|
+
O: er
|
|
1789
1791
|
}
|
|
1790
1792
|
]
|
|
1791
1793
|
);
|
|
1792
|
-
class
|
|
1794
|
+
class tr {
|
|
1793
1795
|
constructor(e) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1796
|
+
d(this, "typeName", x.typeName);
|
|
1797
|
+
d(this, "methods", x.methods);
|
|
1798
|
+
d(this, "options", x.options);
|
|
1797
1799
|
this._transport = e;
|
|
1798
1800
|
}
|
|
1799
1801
|
/**
|
|
@@ -1801,24 +1803,24 @@ class Jt {
|
|
|
1801
1803
|
*/
|
|
1802
1804
|
getDownloadURL(e, t) {
|
|
1803
1805
|
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
1804
|
-
return
|
|
1806
|
+
return y("unary", this._transport, n, r, e);
|
|
1805
1807
|
}
|
|
1806
1808
|
}
|
|
1807
|
-
class
|
|
1809
|
+
class ae extends Error {
|
|
1808
1810
|
}
|
|
1809
|
-
class
|
|
1811
|
+
class Re {
|
|
1810
1812
|
constructor(e) {
|
|
1811
1813
|
this.httpClient = e;
|
|
1812
1814
|
}
|
|
1813
1815
|
async downloadRemoteFile(e, t, n) {
|
|
1814
|
-
const { statusCode: r, body: o, headers:
|
|
1816
|
+
const { statusCode: r, body: o, headers: c } = await be(e, {
|
|
1815
1817
|
dispatcher: this.httpClient,
|
|
1816
1818
|
headers: t,
|
|
1817
1819
|
signal: n
|
|
1818
|
-
}), i =
|
|
1820
|
+
}), i = re.toWeb(o);
|
|
1819
1821
|
if (r != 200) {
|
|
1820
|
-
const l = await
|
|
1821
|
-
throw 400 <= r && r < 500 ? new
|
|
1822
|
+
const l = await et(i), a = l.substring(0, Math.min(l.length, 1e3));
|
|
1823
|
+
throw 400 <= r && r < 500 ? new ae(
|
|
1822
1824
|
`Http error: statusCode: ${r} url: ${e.toString()}, beginning of body: ${a}`
|
|
1823
1825
|
) : new Error(
|
|
1824
1826
|
`Http error: statusCode: ${r} url: ${e.toString()}`
|
|
@@ -1826,21 +1828,30 @@ class Ie {
|
|
|
1826
1828
|
}
|
|
1827
1829
|
return {
|
|
1828
1830
|
content: i,
|
|
1829
|
-
size: Number(
|
|
1831
|
+
size: Number(c["content-length"])
|
|
1830
1832
|
};
|
|
1831
1833
|
}
|
|
1832
1834
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
+
function B(s) {
|
|
1836
|
+
if (!Ke.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1837
|
+
return s;
|
|
1838
|
+
}
|
|
1839
|
+
const rr = "storage://";
|
|
1840
|
+
class Se extends Error {
|
|
1835
1841
|
}
|
|
1836
|
-
class
|
|
1842
|
+
class Ne extends Error {
|
|
1837
1843
|
}
|
|
1838
|
-
class
|
|
1844
|
+
class nr {
|
|
1839
1845
|
constructor(e, t, n, r) {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
this
|
|
1846
|
+
d(this, "grpcClient");
|
|
1847
|
+
d(this, "downloadHelper");
|
|
1848
|
+
d(this, "localStorageIdsToRoot");
|
|
1849
|
+
d(this, "isLocal", (e) => e.startsWith(rr));
|
|
1850
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = n;
|
|
1851
|
+
for (const o of r) o.localPath !== "" && B(o.localPath);
|
|
1852
|
+
this.grpcClient = new tr(this.grpcTransport), this.downloadHelper = new Re(t), this.localStorageIdsToRoot = new Map(
|
|
1853
|
+
r.map((o) => [o.storageId, o.localPath])
|
|
1854
|
+
);
|
|
1844
1855
|
}
|
|
1845
1856
|
close() {
|
|
1846
1857
|
}
|
|
@@ -1848,37 +1859,39 @@ class Xt {
|
|
|
1848
1859
|
const o = n ?? {};
|
|
1849
1860
|
return o.abort = r, await this.grpcClient.getDownloadURL(
|
|
1850
1861
|
{ resourceId: e },
|
|
1851
|
-
|
|
1862
|
+
k(t, o)
|
|
1852
1863
|
).response;
|
|
1853
1864
|
}
|
|
1854
1865
|
async downloadBlob(e, t, n) {
|
|
1855
1866
|
const { downloadUrl: r, headers: o } = await this.getUrl(e, t, n);
|
|
1856
1867
|
return this.logger.info(`download from url ${r}`), this.isLocal(r) ? await this.readLocalFile(r) : await this.downloadHelper.downloadRemoteFile(
|
|
1857
1868
|
r,
|
|
1858
|
-
|
|
1869
|
+
sr(o),
|
|
1859
1870
|
n
|
|
1860
1871
|
);
|
|
1861
1872
|
}
|
|
1862
1873
|
async readLocalFile(e) {
|
|
1863
|
-
const t = e.
|
|
1864
|
-
if (t === null || t.length != 3)
|
|
1865
|
-
throw new Re(
|
|
1866
|
-
`url for local filepath ${e} does not match regex ${ie}, parsed: ${t}`
|
|
1867
|
-
);
|
|
1868
|
-
const [n, r, o] = t;
|
|
1869
|
-
if (this.localStorageIdsToRoot[r] == null)
|
|
1870
|
-
throw new Ne(`Unknown storage location: ${r}`);
|
|
1871
|
-
const d = this.localStorageIdsToRoot[r], i = m.join(d, o), a = (await b.stat(i)).size;
|
|
1874
|
+
const t = or(e, this.localStorageIdsToRoot), r = (await m.stat(t)).size;
|
|
1872
1875
|
return {
|
|
1873
|
-
content:
|
|
1874
|
-
size:
|
|
1876
|
+
content: re.toWeb(O.createReadStream(t)),
|
|
1877
|
+
size: r
|
|
1875
1878
|
};
|
|
1876
1879
|
}
|
|
1877
1880
|
}
|
|
1878
|
-
function
|
|
1881
|
+
function or(s, e) {
|
|
1882
|
+
const t = new URL(s);
|
|
1883
|
+
if (t.pathname == "")
|
|
1884
|
+
throw new Ne(`url for local filepath ${s} does not match url scheme`);
|
|
1885
|
+
const n = t.host, r = e.get(n);
|
|
1886
|
+
if (r === void 0)
|
|
1887
|
+
throw new Se(`Unknown storage location: ${n}`);
|
|
1888
|
+
const o = decodeURIComponent(t.pathname.slice(1));
|
|
1889
|
+
return r === "" ? o : w.join(r, o);
|
|
1890
|
+
}
|
|
1891
|
+
function sr(s) {
|
|
1879
1892
|
return Object.fromEntries(s.map(({ name: e, value: t }) => [e, t]));
|
|
1880
1893
|
}
|
|
1881
|
-
class
|
|
1894
|
+
class ir extends g {
|
|
1882
1895
|
constructor() {
|
|
1883
1896
|
super("google.protobuf.Timestamp", [
|
|
1884
1897
|
{
|
|
@@ -1948,7 +1961,7 @@ class Kt extends g {
|
|
|
1948
1961
|
internalJsonRead(e, t, n) {
|
|
1949
1962
|
if (typeof e != "string")
|
|
1950
1963
|
throw new Error(
|
|
1951
|
-
"Unable to parse Timestamp from JSON " +
|
|
1964
|
+
"Unable to parse Timestamp from JSON " + ye(e) + "."
|
|
1952
1965
|
);
|
|
1953
1966
|
let r = e.match(
|
|
1954
1967
|
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
|
|
@@ -1971,8 +1984,8 @@ class Kt extends g {
|
|
|
1971
1984
|
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
1972
1985
|
}
|
|
1973
1986
|
internalBinaryRead(e, t, n, r) {
|
|
1974
|
-
let o = r ?? this.create(),
|
|
1975
|
-
for (; e.pos <
|
|
1987
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1988
|
+
for (; e.pos < c; ) {
|
|
1976
1989
|
let [i, l] = e.tag();
|
|
1977
1990
|
switch (i) {
|
|
1978
1991
|
case /* int64 seconds */
|
|
@@ -2011,8 +2024,8 @@ class Kt extends g {
|
|
|
2011
2024
|
), t;
|
|
2012
2025
|
}
|
|
2013
2026
|
}
|
|
2014
|
-
const M = new
|
|
2015
|
-
class
|
|
2027
|
+
const M = new ir();
|
|
2028
|
+
class ar extends g {
|
|
2016
2029
|
constructor() {
|
|
2017
2030
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
2018
2031
|
}
|
|
@@ -2032,8 +2045,8 @@ class er extends g {
|
|
|
2032
2045
|
), t;
|
|
2033
2046
|
}
|
|
2034
2047
|
}
|
|
2035
|
-
new
|
|
2036
|
-
class
|
|
2048
|
+
new ar();
|
|
2049
|
+
class lr extends g {
|
|
2037
2050
|
constructor() {
|
|
2038
2051
|
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
2039
2052
|
{
|
|
@@ -2087,8 +2100,8 @@ class tr extends g {
|
|
|
2087
2100
|
return t.name = "", t.size = 0n, t.isDir = !1, t.fullName = "", t.directory = "", t.version = "", e !== void 0 && f(this, t, e), t;
|
|
2088
2101
|
}
|
|
2089
2102
|
internalBinaryRead(e, t, n, r) {
|
|
2090
|
-
let o = r ?? this.create(),
|
|
2091
|
-
for (; e.pos <
|
|
2103
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2104
|
+
for (; e.pos < c; ) {
|
|
2092
2105
|
let [i, l] = e.tag();
|
|
2093
2106
|
switch (i) {
|
|
2094
2107
|
case /* string name */
|
|
@@ -2156,8 +2169,8 @@ class tr extends g {
|
|
|
2156
2169
|
), t;
|
|
2157
2170
|
}
|
|
2158
2171
|
}
|
|
2159
|
-
const H = new
|
|
2160
|
-
class
|
|
2172
|
+
const H = new lr();
|
|
2173
|
+
class cr extends g {
|
|
2161
2174
|
constructor() {
|
|
2162
2175
|
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
2163
2176
|
}
|
|
@@ -2177,8 +2190,8 @@ class rr extends g {
|
|
|
2177
2190
|
), t;
|
|
2178
2191
|
}
|
|
2179
2192
|
}
|
|
2180
|
-
new
|
|
2181
|
-
class
|
|
2193
|
+
new cr();
|
|
2194
|
+
class dr extends g {
|
|
2182
2195
|
constructor() {
|
|
2183
2196
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
2184
2197
|
{
|
|
@@ -2203,8 +2216,8 @@ class nr extends g {
|
|
|
2203
2216
|
return t.resourceId = 0n, t.location = "", e !== void 0 && f(this, t, e), t;
|
|
2204
2217
|
}
|
|
2205
2218
|
internalBinaryRead(e, t, n, r) {
|
|
2206
|
-
let o = r ?? this.create(),
|
|
2207
|
-
for (; e.pos <
|
|
2219
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2220
|
+
for (; e.pos < c; ) {
|
|
2208
2221
|
let [i, l] = e.tag();
|
|
2209
2222
|
switch (i) {
|
|
2210
2223
|
case /* uint64 resource_id */
|
|
@@ -2243,8 +2256,8 @@ class nr extends g {
|
|
|
2243
2256
|
), t;
|
|
2244
2257
|
}
|
|
2245
2258
|
}
|
|
2246
|
-
const
|
|
2247
|
-
class
|
|
2259
|
+
const hr = new dr();
|
|
2260
|
+
class ur extends g {
|
|
2248
2261
|
constructor() {
|
|
2249
2262
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2250
2263
|
{
|
|
@@ -2268,8 +2281,8 @@ class sr extends g {
|
|
|
2268
2281
|
return t.items = [], t.delimiter = "", e !== void 0 && f(this, t, e), t;
|
|
2269
2282
|
}
|
|
2270
2283
|
internalBinaryRead(e, t, n, r) {
|
|
2271
|
-
let o = r ?? this.create(),
|
|
2272
|
-
for (; e.pos <
|
|
2284
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2285
|
+
for (; e.pos < c; ) {
|
|
2273
2286
|
let [i, l] = e.tag();
|
|
2274
2287
|
switch (i) {
|
|
2275
2288
|
case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
|
|
@@ -2316,14 +2329,14 @@ class sr extends g {
|
|
|
2316
2329
|
), t;
|
|
2317
2330
|
}
|
|
2318
2331
|
}
|
|
2319
|
-
const
|
|
2320
|
-
{ name: "List", options: {}, I:
|
|
2332
|
+
const pr = new ur(), j = new D("MiLaboratories.Controller.Shared.LS", [
|
|
2333
|
+
{ name: "List", options: {}, I: hr, O: pr }
|
|
2321
2334
|
]);
|
|
2322
|
-
class
|
|
2335
|
+
class gr {
|
|
2323
2336
|
constructor(e) {
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2337
|
+
d(this, "typeName", j.typeName);
|
|
2338
|
+
d(this, "methods", j.methods);
|
|
2339
|
+
d(this, "options", j.options);
|
|
2327
2340
|
this._transport = e;
|
|
2328
2341
|
}
|
|
2329
2342
|
/**
|
|
@@ -2331,7 +2344,7 @@ class ar {
|
|
|
2331
2344
|
*/
|
|
2332
2345
|
list(e, t) {
|
|
2333
2346
|
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
2334
|
-
return
|
|
2347
|
+
return y(
|
|
2335
2348
|
"unary",
|
|
2336
2349
|
this._transport,
|
|
2337
2350
|
n,
|
|
@@ -2340,10 +2353,10 @@ class ar {
|
|
|
2340
2353
|
);
|
|
2341
2354
|
}
|
|
2342
2355
|
}
|
|
2343
|
-
class
|
|
2356
|
+
class fr {
|
|
2344
2357
|
constructor(e, t) {
|
|
2345
|
-
|
|
2346
|
-
this.logger = t, this.grpcClient = new
|
|
2358
|
+
d(this, "grpcClient");
|
|
2359
|
+
this.logger = t, this.grpcClient = new gr(e);
|
|
2347
2360
|
}
|
|
2348
2361
|
close() {
|
|
2349
2362
|
}
|
|
@@ -2353,11 +2366,11 @@ class lr {
|
|
|
2353
2366
|
resourceId: e.id,
|
|
2354
2367
|
location: t
|
|
2355
2368
|
},
|
|
2356
|
-
|
|
2369
|
+
k(e.type, n)
|
|
2357
2370
|
).response;
|
|
2358
2371
|
}
|
|
2359
2372
|
}
|
|
2360
|
-
class
|
|
2373
|
+
class mr extends g {
|
|
2361
2374
|
constructor() {
|
|
2362
2375
|
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2363
2376
|
}
|
|
@@ -2377,8 +2390,8 @@ class dr extends g {
|
|
|
2377
2390
|
), t;
|
|
2378
2391
|
}
|
|
2379
2392
|
}
|
|
2380
|
-
new
|
|
2381
|
-
class
|
|
2393
|
+
new mr();
|
|
2394
|
+
class wr extends g {
|
|
2382
2395
|
constructor() {
|
|
2383
2396
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2384
2397
|
{
|
|
@@ -2421,8 +2434,8 @@ class cr extends g {
|
|
|
2421
2434
|
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2422
2435
|
}
|
|
2423
2436
|
internalBinaryRead(e, t, n, r) {
|
|
2424
|
-
let o = r ?? this.create(),
|
|
2425
|
-
for (; e.pos <
|
|
2437
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2438
|
+
for (; e.pos < c; ) {
|
|
2426
2439
|
let [i, l] = e.tag();
|
|
2427
2440
|
switch (i) {
|
|
2428
2441
|
case /* uint64 resource_id */
|
|
@@ -2469,8 +2482,8 @@ class cr extends g {
|
|
|
2469
2482
|
), t;
|
|
2470
2483
|
}
|
|
2471
2484
|
}
|
|
2472
|
-
const
|
|
2473
|
-
class
|
|
2485
|
+
const yr = new wr();
|
|
2486
|
+
class br extends g {
|
|
2474
2487
|
constructor() {
|
|
2475
2488
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2476
2489
|
{
|
|
@@ -2504,8 +2517,8 @@ class ur extends g {
|
|
|
2504
2517
|
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2505
2518
|
}
|
|
2506
2519
|
internalBinaryRead(e, t, n, r) {
|
|
2507
|
-
let o = r ?? this.create(),
|
|
2508
|
-
for (; e.pos <
|
|
2520
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2521
|
+
for (; e.pos < c; ) {
|
|
2509
2522
|
let [i, l] = e.tag();
|
|
2510
2523
|
switch (i) {
|
|
2511
2524
|
case /* uint64 resource_id */
|
|
@@ -2548,8 +2561,8 @@ class ur extends g {
|
|
|
2548
2561
|
), t;
|
|
2549
2562
|
}
|
|
2550
2563
|
}
|
|
2551
|
-
const
|
|
2552
|
-
class
|
|
2564
|
+
const Tr = new br();
|
|
2565
|
+
class kr extends g {
|
|
2553
2566
|
constructor() {
|
|
2554
2567
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2555
2568
|
{
|
|
@@ -2600,8 +2613,8 @@ class gr extends g {
|
|
|
2600
2613
|
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2601
2614
|
}
|
|
2602
2615
|
internalBinaryRead(e, t, n, r) {
|
|
2603
|
-
let o = r ?? this.create(),
|
|
2604
|
-
for (; e.pos <
|
|
2616
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2617
|
+
for (; e.pos < c; ) {
|
|
2605
2618
|
let [i, l] = e.tag();
|
|
2606
2619
|
switch (i) {
|
|
2607
2620
|
case /* uint64 resource_id */
|
|
@@ -2652,8 +2665,8 @@ class gr extends g {
|
|
|
2652
2665
|
), t;
|
|
2653
2666
|
}
|
|
2654
2667
|
}
|
|
2655
|
-
const
|
|
2656
|
-
class
|
|
2668
|
+
const Lr = new kr();
|
|
2669
|
+
class Pr extends g {
|
|
2657
2670
|
constructor() {
|
|
2658
2671
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2659
2672
|
{
|
|
@@ -2704,8 +2717,8 @@ class mr extends g {
|
|
|
2704
2717
|
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2705
2718
|
}
|
|
2706
2719
|
internalBinaryRead(e, t, n, r) {
|
|
2707
|
-
let o = r ?? this.create(),
|
|
2708
|
-
for (; e.pos <
|
|
2720
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2721
|
+
for (; e.pos < c; ) {
|
|
2709
2722
|
let [i, l] = e.tag();
|
|
2710
2723
|
switch (i) {
|
|
2711
2724
|
case /* uint64 resource_id */
|
|
@@ -2756,8 +2769,8 @@ class mr extends g {
|
|
|
2756
2769
|
), t;
|
|
2757
2770
|
}
|
|
2758
2771
|
}
|
|
2759
|
-
const
|
|
2760
|
-
class
|
|
2772
|
+
const Ir = new Pr();
|
|
2773
|
+
class Rr extends g {
|
|
2761
2774
|
constructor() {
|
|
2762
2775
|
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2763
2776
|
{
|
|
@@ -2808,8 +2821,8 @@ class yr extends g {
|
|
|
2808
2821
|
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
2809
2822
|
}
|
|
2810
2823
|
internalBinaryRead(e, t, n, r) {
|
|
2811
|
-
let o = r ?? this.create(),
|
|
2812
|
-
for (; e.pos <
|
|
2824
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2825
|
+
for (; e.pos < c; ) {
|
|
2813
2826
|
let [i, l] = e.tag();
|
|
2814
2827
|
switch (i) {
|
|
2815
2828
|
case /* uint64 resource_id */
|
|
@@ -2860,8 +2873,8 @@ class yr extends g {
|
|
|
2860
2873
|
), t;
|
|
2861
2874
|
}
|
|
2862
2875
|
}
|
|
2863
|
-
const
|
|
2864
|
-
class
|
|
2876
|
+
const Sr = new Rr();
|
|
2877
|
+
class Nr extends g {
|
|
2865
2878
|
constructor() {
|
|
2866
2879
|
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2867
2880
|
{
|
|
@@ -2894,8 +2907,8 @@ class Tr extends g {
|
|
|
2894
2907
|
return t.data = new Uint8Array(0), t.size = 0n, t.newOffset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2895
2908
|
}
|
|
2896
2909
|
internalBinaryRead(e, t, n, r) {
|
|
2897
|
-
let o = r ?? this.create(),
|
|
2898
|
-
for (; e.pos <
|
|
2910
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2911
|
+
for (; e.pos < c; ) {
|
|
2899
2912
|
let [i, l] = e.tag();
|
|
2900
2913
|
switch (i) {
|
|
2901
2914
|
case /* bytes data */
|
|
@@ -2938,48 +2951,48 @@ class Tr extends g {
|
|
|
2938
2951
|
), t;
|
|
2939
2952
|
}
|
|
2940
2953
|
}
|
|
2941
|
-
const U = new
|
|
2954
|
+
const U = new Nr(), G = new D(
|
|
2942
2955
|
"MiLaboratories.Controller.Shared.Streaming",
|
|
2943
2956
|
[
|
|
2944
2957
|
{
|
|
2945
2958
|
name: "StreamBinary",
|
|
2946
2959
|
serverStreaming: !0,
|
|
2947
2960
|
options: {},
|
|
2948
|
-
I:
|
|
2961
|
+
I: yr,
|
|
2949
2962
|
O: U
|
|
2950
2963
|
},
|
|
2951
2964
|
{
|
|
2952
2965
|
name: "ReadBinary",
|
|
2953
2966
|
options: {},
|
|
2954
|
-
I:
|
|
2967
|
+
I: Tr,
|
|
2955
2968
|
O: U
|
|
2956
2969
|
},
|
|
2957
2970
|
{
|
|
2958
2971
|
name: "StreamText",
|
|
2959
2972
|
serverStreaming: !0,
|
|
2960
2973
|
options: {},
|
|
2961
|
-
I:
|
|
2974
|
+
I: Lr,
|
|
2962
2975
|
O: U
|
|
2963
2976
|
},
|
|
2964
2977
|
{
|
|
2965
2978
|
name: "ReadText",
|
|
2966
2979
|
options: {},
|
|
2967
|
-
I:
|
|
2980
|
+
I: Ir,
|
|
2968
2981
|
O: U
|
|
2969
2982
|
},
|
|
2970
2983
|
{
|
|
2971
2984
|
name: "LastLines",
|
|
2972
2985
|
options: {},
|
|
2973
|
-
I:
|
|
2986
|
+
I: Sr,
|
|
2974
2987
|
O: U
|
|
2975
2988
|
}
|
|
2976
2989
|
]
|
|
2977
2990
|
);
|
|
2978
|
-
class
|
|
2991
|
+
class Ur {
|
|
2979
2992
|
constructor(e) {
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2993
|
+
d(this, "typeName", G.typeName);
|
|
2994
|
+
d(this, "methods", G.methods);
|
|
2995
|
+
d(this, "options", G.options);
|
|
2983
2996
|
this._transport = e;
|
|
2984
2997
|
}
|
|
2985
2998
|
/**
|
|
@@ -2991,7 +3004,7 @@ class kr {
|
|
|
2991
3004
|
*/
|
|
2992
3005
|
streamBinary(e, t) {
|
|
2993
3006
|
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
2994
|
-
return
|
|
3007
|
+
return y(
|
|
2995
3008
|
"serverStreaming",
|
|
2996
3009
|
this._transport,
|
|
2997
3010
|
n,
|
|
@@ -3009,7 +3022,7 @@ class kr {
|
|
|
3009
3022
|
*/
|
|
3010
3023
|
readBinary(e, t) {
|
|
3011
3024
|
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
3012
|
-
return
|
|
3025
|
+
return y(
|
|
3013
3026
|
"unary",
|
|
3014
3027
|
this._transport,
|
|
3015
3028
|
n,
|
|
@@ -3025,7 +3038,7 @@ class kr {
|
|
|
3025
3038
|
*/
|
|
3026
3039
|
streamText(e, t) {
|
|
3027
3040
|
const n = this.methods[2], r = this._transport.mergeOptions(t);
|
|
3028
|
-
return
|
|
3041
|
+
return y(
|
|
3029
3042
|
"serverStreaming",
|
|
3030
3043
|
this._transport,
|
|
3031
3044
|
n,
|
|
@@ -3043,7 +3056,7 @@ class kr {
|
|
|
3043
3056
|
*/
|
|
3044
3057
|
readText(e, t) {
|
|
3045
3058
|
const n = this.methods[3], r = this._transport.mergeOptions(t);
|
|
3046
|
-
return
|
|
3059
|
+
return y(
|
|
3047
3060
|
"unary",
|
|
3048
3061
|
this._transport,
|
|
3049
3062
|
n,
|
|
@@ -3065,7 +3078,7 @@ class kr {
|
|
|
3065
3078
|
*/
|
|
3066
3079
|
lastLines(e, t) {
|
|
3067
3080
|
const n = this.methods[4], r = this._transport.mergeOptions(t);
|
|
3068
|
-
return
|
|
3081
|
+
return y(
|
|
3069
3082
|
"unary",
|
|
3070
3083
|
this._transport,
|
|
3071
3084
|
n,
|
|
@@ -3074,17 +3087,17 @@ class kr {
|
|
|
3074
3087
|
);
|
|
3075
3088
|
}
|
|
3076
3089
|
}
|
|
3077
|
-
class
|
|
3090
|
+
class Br {
|
|
3078
3091
|
constructor(e, t, n) {
|
|
3079
|
-
|
|
3080
|
-
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new
|
|
3092
|
+
d(this, "grpcClient");
|
|
3093
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Ur(this.grpcTransport);
|
|
3081
3094
|
}
|
|
3082
3095
|
close() {
|
|
3083
3096
|
}
|
|
3084
3097
|
/** Reads text back and returns the text,
|
|
3085
3098
|
* the new offset
|
|
3086
3099
|
* and the total size of the (currently existing) file. */
|
|
3087
|
-
async lastLines({ id: e, type: t }, n, r = 0n, o,
|
|
3100
|
+
async lastLines({ id: e, type: t }, n, r = 0n, o, c) {
|
|
3088
3101
|
return (await this.grpcClient.lastLines(
|
|
3089
3102
|
{
|
|
3090
3103
|
resourceId: e,
|
|
@@ -3092,77 +3105,69 @@ class Lr {
|
|
|
3092
3105
|
offset: r,
|
|
3093
3106
|
search: o
|
|
3094
3107
|
},
|
|
3095
|
-
|
|
3108
|
+
k(t, c)
|
|
3096
3109
|
)).response;
|
|
3097
3110
|
}
|
|
3098
3111
|
/** Reads the file forward and returns the text,
|
|
3099
3112
|
* the new offset
|
|
3100
3113
|
* and the total size of the (currently existing) file. */
|
|
3101
|
-
async readText({ id: e, type: t }, n, r = 0n, o,
|
|
3114
|
+
async readText({ id: e, type: t }, n, r = 0n, o, c) {
|
|
3102
3115
|
return (await this.grpcClient.readText(
|
|
3103
3116
|
{
|
|
3104
|
-
resourceId:
|
|
3117
|
+
resourceId: K(e),
|
|
3105
3118
|
readLimit: BigInt(n),
|
|
3106
3119
|
offset: r,
|
|
3107
3120
|
search: o
|
|
3108
3121
|
},
|
|
3109
|
-
|
|
3122
|
+
k(t, c)
|
|
3110
3123
|
)).response;
|
|
3111
3124
|
}
|
|
3112
3125
|
}
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
) : {};
|
|
3116
|
-
function In(s, e, t) {
|
|
3117
|
-
return t === void 0 && (t = Pr), e.getDriver({
|
|
3126
|
+
function Nn(s, e, t) {
|
|
3127
|
+
return e.getDriver({
|
|
3118
3128
|
name: "DownloadBlob",
|
|
3119
|
-
init: (r, o
|
|
3120
|
-
o,
|
|
3121
|
-
d,
|
|
3122
|
-
s,
|
|
3123
|
-
t
|
|
3124
|
-
)
|
|
3129
|
+
init: (n, r, o) => new nr(r, o, s, t)
|
|
3125
3130
|
});
|
|
3126
3131
|
}
|
|
3127
|
-
function
|
|
3132
|
+
function Un(s, e) {
|
|
3128
3133
|
return s.getDriver({
|
|
3129
3134
|
name: "StreamLogs",
|
|
3130
|
-
init: (t, n, r) => new
|
|
3135
|
+
init: (t, n, r) => new Br(n, r, e)
|
|
3131
3136
|
});
|
|
3132
3137
|
}
|
|
3133
|
-
function
|
|
3138
|
+
function Bn(s, e) {
|
|
3134
3139
|
return s.getDriver({
|
|
3135
3140
|
name: "UploadProgress",
|
|
3136
|
-
init: (t, n, r) => new
|
|
3141
|
+
init: (t, n, r) => new qt(n, r, s, e)
|
|
3137
3142
|
});
|
|
3138
3143
|
}
|
|
3139
|
-
function
|
|
3144
|
+
function Dn(s, e) {
|
|
3140
3145
|
return s.getDriver({
|
|
3141
3146
|
name: "UploadBlob",
|
|
3142
|
-
init: (t, n, r) => new
|
|
3147
|
+
init: (t, n, r) => new $t(n, r, s, e)
|
|
3143
3148
|
});
|
|
3144
3149
|
}
|
|
3145
|
-
function
|
|
3150
|
+
function Dr(s, e) {
|
|
3146
3151
|
return s.getDriver({
|
|
3147
3152
|
name: "LsFiles",
|
|
3148
|
-
init: (t, n, r) => new
|
|
3153
|
+
init: (t, n, r) => new fr(n, e)
|
|
3149
3154
|
});
|
|
3150
3155
|
}
|
|
3151
|
-
class
|
|
3156
|
+
class vn {
|
|
3152
3157
|
constructor(e, t) {
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
this.onUpdate = e, this.sleepMs = t, this.updater = new
|
|
3158
|
+
d(this, "updater");
|
|
3159
|
+
d(this, "schedule", () => this.updater.schedule());
|
|
3160
|
+
this.onUpdate = e, this.sleepMs = t, this.updater = new Ue(async () => {
|
|
3156
3161
|
for (; ; ) {
|
|
3157
3162
|
if (await this.onUpdate()) return;
|
|
3158
|
-
await
|
|
3163
|
+
await oe.wait(this.sleepMs);
|
|
3159
3164
|
}
|
|
3160
3165
|
});
|
|
3161
3166
|
}
|
|
3162
3167
|
}
|
|
3163
|
-
class
|
|
3168
|
+
class Ue {
|
|
3164
3169
|
constructor(e) {
|
|
3165
|
-
|
|
3170
|
+
d(this, "updating");
|
|
3166
3171
|
this.onUpdate = e;
|
|
3167
3172
|
}
|
|
3168
3173
|
schedule() {
|
|
@@ -3177,36 +3182,36 @@ class Se {
|
|
|
3177
3182
|
})());
|
|
3178
3183
|
}
|
|
3179
3184
|
}
|
|
3180
|
-
async function
|
|
3185
|
+
async function $n(s, e) {
|
|
3181
3186
|
return s.withReadTx("LogsDriverGetStream", async (t) => {
|
|
3182
|
-
const n = await t.getResourceData(e, !0), r = await
|
|
3187
|
+
const n = await t.getResourceData(e, !0), r = await je(t, Ge(n, "stream"));
|
|
3183
3188
|
if (r.error != "")
|
|
3184
3189
|
throw new Error(`while getting stream: ${r.error}`);
|
|
3185
|
-
if (!
|
|
3190
|
+
if (!Ve(r.valueId))
|
|
3186
3191
|
return await t.getResourceData(r.valueId, !1);
|
|
3187
3192
|
});
|
|
3188
3193
|
}
|
|
3189
|
-
const
|
|
3190
|
-
function
|
|
3191
|
-
const t = s.replace(
|
|
3194
|
+
const Be = "8C7#F1328%9E089B3D22", vr = /(?<stage>.*):\s*(?<progress>[\d.]+%)\s.*(?<eta>ETA:.*)/g;
|
|
3195
|
+
function $r(s) {
|
|
3196
|
+
const t = s.replace(Be, "").match(vr);
|
|
3192
3197
|
if (t == null || t.length != 4)
|
|
3193
3198
|
return;
|
|
3194
|
-
const [n, r, o,
|
|
3199
|
+
const [n, r, o, c] = t;
|
|
3195
3200
|
return {
|
|
3196
3201
|
stage: r,
|
|
3197
3202
|
// For example, 'Building pre-clones from tag groups'
|
|
3198
3203
|
progress: o,
|
|
3199
3204
|
// 35.3%
|
|
3200
|
-
eta:
|
|
3205
|
+
eta: c
|
|
3201
3206
|
// ETA: 00:00:07
|
|
3202
3207
|
};
|
|
3203
3208
|
}
|
|
3204
|
-
async function
|
|
3209
|
+
async function _n(s, e, t) {
|
|
3205
3210
|
const n = await e.lastLines(
|
|
3206
3211
|
s,
|
|
3207
3212
|
1,
|
|
3208
3213
|
0n,
|
|
3209
|
-
|
|
3214
|
+
Be,
|
|
3210
3215
|
t
|
|
3211
3216
|
);
|
|
3212
3217
|
if (n.data == null || n.data.length == 0)
|
|
@@ -3214,13 +3219,13 @@ async function Dn(s, e, t) {
|
|
|
3214
3219
|
const r = n.data.toString().split(/\r?\n/)[0];
|
|
3215
3220
|
if (r == null)
|
|
3216
3221
|
return { found: !1 };
|
|
3217
|
-
const o =
|
|
3222
|
+
const o = $r(r);
|
|
3218
3223
|
return o === void 0 ? { found: !1 } : { found: !0, ...o };
|
|
3219
3224
|
}
|
|
3220
|
-
class
|
|
3225
|
+
class De {
|
|
3221
3226
|
constructor(e) {
|
|
3222
|
-
|
|
3223
|
-
|
|
3227
|
+
d(this, "cache", /* @__PURE__ */ new Map());
|
|
3228
|
+
d(this, "totalSizeBytes", 0);
|
|
3224
3229
|
this.softSizeBytes = e;
|
|
3225
3230
|
}
|
|
3226
3231
|
existsFile(e) {
|
|
@@ -3233,16 +3238,16 @@ class Be {
|
|
|
3233
3238
|
/** Decrements a counter in a cache and if we exceeds
|
|
3234
3239
|
* a soft limit, removes files with zero counters. */
|
|
3235
3240
|
removeFile(e, t) {
|
|
3236
|
-
return
|
|
3241
|
+
return ce(this.cache, e).counter.dec(t), this.toDelete();
|
|
3237
3242
|
}
|
|
3238
3243
|
/** Returns what results should be deleted to comply with the soft limit. */
|
|
3239
3244
|
toDelete() {
|
|
3240
3245
|
if (this.totalSizeBytes <= this.softSizeBytes) return [];
|
|
3241
3246
|
const e = [];
|
|
3242
3247
|
let t = 0;
|
|
3243
|
-
return
|
|
3248
|
+
return Ze(this.cache).filter(([n, r]) => r.counter.isZero()).forEach(([n, r]) => {
|
|
3244
3249
|
if (this.totalSizeBytes - t <= this.softSizeBytes) return;
|
|
3245
|
-
const o =
|
|
3250
|
+
const o = ce(this.cache, n);
|
|
3246
3251
|
t += o.sizeBytes, e.push(o);
|
|
3247
3252
|
}), e;
|
|
3248
3253
|
}
|
|
@@ -3255,13 +3260,13 @@ class Be {
|
|
|
3255
3260
|
this.cache.delete(e.path), this.totalSizeBytes -= e.sizeBytes;
|
|
3256
3261
|
}
|
|
3257
3262
|
}
|
|
3258
|
-
class
|
|
3263
|
+
class Cn {
|
|
3259
3264
|
constructor(e, t) {
|
|
3260
3265
|
this.logsStreamDriver = e, this.downloadDriver = t;
|
|
3261
3266
|
}
|
|
3262
3267
|
getLastLogs(e, t, n) {
|
|
3263
3268
|
if (n === void 0)
|
|
3264
|
-
return
|
|
3269
|
+
return b.make((o) => this.getLastLogs(e, t, o));
|
|
3265
3270
|
const r = q(n, e);
|
|
3266
3271
|
if (r === void 0) {
|
|
3267
3272
|
n.markUnstable("no stream in stream manager");
|
|
@@ -3283,7 +3288,7 @@ class $n {
|
|
|
3283
3288
|
}
|
|
3284
3289
|
getProgressLog(e, t, n) {
|
|
3285
3290
|
if (n === void 0)
|
|
3286
|
-
return
|
|
3291
|
+
return b.make(
|
|
3287
3292
|
(o) => this.getProgressLog(e, t, o)
|
|
3288
3293
|
);
|
|
3289
3294
|
const r = q(n, e);
|
|
@@ -3307,7 +3312,7 @@ class $n {
|
|
|
3307
3312
|
}
|
|
3308
3313
|
getLogHandle(e, t) {
|
|
3309
3314
|
if (t === void 0)
|
|
3310
|
-
return
|
|
3315
|
+
return b.make((r) => this.getLogHandle(e, r));
|
|
3311
3316
|
const n = q(t, e);
|
|
3312
3317
|
if (n === void 0) {
|
|
3313
3318
|
t.markUnstable("no stream in stream manager");
|
|
@@ -3352,57 +3357,57 @@ function q(s, e) {
|
|
|
3352
3357
|
function _(s) {
|
|
3353
3358
|
let e;
|
|
3354
3359
|
if (C(s))
|
|
3355
|
-
e = s.match(De);
|
|
3356
|
-
else if (Rr(s))
|
|
3357
3360
|
e = s.match($e);
|
|
3361
|
+
else if (_r(s))
|
|
3362
|
+
e = s.match(_e);
|
|
3358
3363
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
3359
3364
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
3360
3365
|
const { resourceType: t, resourceVersion: n, resourceId: r } = e.groups;
|
|
3361
3366
|
return {
|
|
3362
|
-
id:
|
|
3367
|
+
id: Y(BigInt(r)),
|
|
3363
3368
|
type: { name: t, version: n }
|
|
3364
3369
|
};
|
|
3365
3370
|
}
|
|
3366
3371
|
function ve(s, e) {
|
|
3367
3372
|
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)}`;
|
|
3368
3373
|
}
|
|
3369
|
-
const
|
|
3374
|
+
const $e = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3370
3375
|
function C(s) {
|
|
3371
|
-
return De.test(s);
|
|
3372
|
-
}
|
|
3373
|
-
const $e = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3374
|
-
function Rr(s) {
|
|
3375
3376
|
return $e.test(s);
|
|
3376
3377
|
}
|
|
3377
|
-
const
|
|
3378
|
+
const _e = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3379
|
+
function _r(s) {
|
|
3380
|
+
return _e.test(s);
|
|
3381
|
+
}
|
|
3382
|
+
const Cr = se({
|
|
3378
3383
|
kv: {
|
|
3379
|
-
"ctl/file/blobInfo":
|
|
3380
|
-
sizeBytes:
|
|
3384
|
+
"ctl/file/blobInfo": T.object({
|
|
3385
|
+
sizeBytes: T.coerce.number()
|
|
3381
3386
|
})
|
|
3382
3387
|
}
|
|
3383
3388
|
});
|
|
3384
|
-
class
|
|
3385
|
-
constructor(e, t, n, r, o,
|
|
3389
|
+
class On {
|
|
3390
|
+
constructor(e, t, n, r, o, c) {
|
|
3386
3391
|
/** Represents a Resource Id to the path of a blob as a map. */
|
|
3387
|
-
|
|
3392
|
+
d(this, "idToDownload", /* @__PURE__ */ new Map());
|
|
3388
3393
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3389
3394
|
* file that should be kept. */
|
|
3390
|
-
|
|
3395
|
+
d(this, "cache");
|
|
3391
3396
|
/** Downloads files and writes them to the local dir. */
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new
|
|
3397
|
+
d(this, "downloadQueue");
|
|
3398
|
+
d(this, "idToOnDemand", /* @__PURE__ */ new Map());
|
|
3399
|
+
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3400
|
+
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3401
|
+
d(this, "saveDir");
|
|
3402
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new De(c.cacheSoftSizeBytes), this.downloadQueue = new ee(
|
|
3398
3403
|
this.logger,
|
|
3399
|
-
|
|
3400
|
-
), this.saveDir =
|
|
3404
|
+
c.nConcurrentDownloads
|
|
3405
|
+
), this.saveDir = w.resolve(r);
|
|
3401
3406
|
}
|
|
3402
3407
|
getDownloadedBlob(e, t) {
|
|
3403
3408
|
if (t === void 0)
|
|
3404
|
-
return
|
|
3405
|
-
const n =
|
|
3409
|
+
return b.make((c) => this.getDownloadedBlob(e, c));
|
|
3410
|
+
const n = R(e, t), r = L();
|
|
3406
3411
|
t.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3407
3412
|
const o = this.getDownloadedBlobNoCtx(
|
|
3408
3413
|
t.watcher,
|
|
@@ -3413,27 +3418,27 @@ class _n {
|
|
|
3413
3418
|
}
|
|
3414
3419
|
getOnDemandBlob(e, t) {
|
|
3415
3420
|
if (t === void 0)
|
|
3416
|
-
return
|
|
3417
|
-
const n =
|
|
3421
|
+
return b.make((c) => this.getOnDemandBlob(e, c));
|
|
3422
|
+
const n = ie(e) ? Q(e, Cr, t) : e, r = L();
|
|
3418
3423
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(n.id, r)), this.getOnDemandBlobNoCtx(t.watcher, n, r);
|
|
3419
3424
|
}
|
|
3420
3425
|
getLocalPath(e) {
|
|
3421
|
-
return
|
|
3426
|
+
return J(e, this.signer);
|
|
3422
3427
|
}
|
|
3423
3428
|
async getContent(e) {
|
|
3424
|
-
if (
|
|
3425
|
-
if (!
|
|
3426
|
-
const t =
|
|
3427
|
-
return await
|
|
3429
|
+
if (zr(e)) return await Fr(this.getLocalPath(e));
|
|
3430
|
+
if (!xr(e)) throw new Error("Malformed remote handle");
|
|
3431
|
+
const t = Mr(e, this.signer), { content: n } = await this.clientDownload.downloadBlob(t);
|
|
3432
|
+
return await Te(n);
|
|
3428
3433
|
}
|
|
3429
3434
|
getDownloadedBlobNoCtx(e, t, n) {
|
|
3430
3435
|
let r = this.idToDownload.get(t.id);
|
|
3431
3436
|
if (r === void 0) {
|
|
3432
|
-
const
|
|
3437
|
+
const c = this.setNewDownloadTask(e, t, n);
|
|
3433
3438
|
this.downloadQueue.push({
|
|
3434
|
-
fn: () => this.downloadBlob(
|
|
3439
|
+
fn: () => this.downloadBlob(c, n),
|
|
3435
3440
|
recoverableErrorPredicate: (i) => !0
|
|
3436
|
-
}), r =
|
|
3441
|
+
}), r = c;
|
|
3437
3442
|
}
|
|
3438
3443
|
r.attach(e, n);
|
|
3439
3444
|
const o = r.getBlob();
|
|
@@ -3443,11 +3448,11 @@ class _n {
|
|
|
3443
3448
|
}
|
|
3444
3449
|
}
|
|
3445
3450
|
setNewDownloadTask(e, t, n) {
|
|
3446
|
-
const r = this.getFilePath(t.id), o = new
|
|
3451
|
+
const r = this.getFilePath(t.id), o = new Wr(
|
|
3447
3452
|
this.clientDownload,
|
|
3448
3453
|
t,
|
|
3449
3454
|
r,
|
|
3450
|
-
|
|
3455
|
+
Ar(r, this.signer)
|
|
3451
3456
|
);
|
|
3452
3457
|
return this.idToDownload.set(t.id, o), o;
|
|
3453
3458
|
}
|
|
@@ -3457,31 +3462,31 @@ class _n {
|
|
|
3457
3462
|
}
|
|
3458
3463
|
getOnDemandBlobNoCtx(e, t, n) {
|
|
3459
3464
|
let r = this.idToOnDemand.get(t.id);
|
|
3460
|
-
return r === void 0 && (r = new
|
|
3465
|
+
return r === void 0 && (r = new Or(
|
|
3461
3466
|
t.kv["ctl/file/blobInfo"].sizeBytes,
|
|
3462
|
-
|
|
3467
|
+
Hr(t, this.signer)
|
|
3463
3468
|
), this.idToOnDemand.set(t.id, r)), r.attach(e, n), r.getHandle();
|
|
3464
3469
|
}
|
|
3465
3470
|
getLastLogs(e, t, n) {
|
|
3466
3471
|
if (n == null)
|
|
3467
|
-
return
|
|
3468
|
-
const r =
|
|
3472
|
+
return b.make((i) => this.getLastLogs(e, t, i));
|
|
3473
|
+
const r = R(e, n), o = L();
|
|
3469
3474
|
n.addOnDestroy(() => this.releaseBlob(r.id, o));
|
|
3470
|
-
const
|
|
3475
|
+
const c = this.getLastLogsNoCtx(
|
|
3471
3476
|
n.watcher,
|
|
3472
3477
|
r,
|
|
3473
3478
|
t,
|
|
3474
3479
|
o
|
|
3475
3480
|
);
|
|
3476
|
-
return
|
|
3481
|
+
return c == null && n.markUnstable("either a file was not downloaded or logs was not read"), c;
|
|
3477
3482
|
}
|
|
3478
3483
|
getLastLogsNoCtx(e, t, n, r) {
|
|
3479
3484
|
const o = this.getDownloadedBlobNoCtx(e, t, r);
|
|
3480
3485
|
if (o == null) return;
|
|
3481
|
-
const
|
|
3486
|
+
const c = J(o.handle, this.signer);
|
|
3482
3487
|
let i = this.idToLastLines.get(t.id);
|
|
3483
3488
|
if (i == null) {
|
|
3484
|
-
const a = new
|
|
3489
|
+
const a = new de(c, n);
|
|
3485
3490
|
this.idToLastLines.set(t.id, a), i = a;
|
|
3486
3491
|
}
|
|
3487
3492
|
const l = i.getOrSchedule(e);
|
|
@@ -3490,28 +3495,28 @@ class _n {
|
|
|
3490
3495
|
}
|
|
3491
3496
|
getProgressLog(e, t, n) {
|
|
3492
3497
|
if (n == null)
|
|
3493
|
-
return
|
|
3498
|
+
return b.make(
|
|
3494
3499
|
(i) => this.getProgressLog(e, t, i)
|
|
3495
3500
|
);
|
|
3496
|
-
const r =
|
|
3501
|
+
const r = R(e, n), o = L();
|
|
3497
3502
|
n.addOnDestroy(() => this.releaseBlob(r.id, o));
|
|
3498
|
-
const
|
|
3503
|
+
const c = this.getProgressLogNoCtx(
|
|
3499
3504
|
n.watcher,
|
|
3500
3505
|
r,
|
|
3501
3506
|
t,
|
|
3502
3507
|
o
|
|
3503
3508
|
);
|
|
3504
|
-
return
|
|
3509
|
+
return c === void 0 && n.markUnstable(
|
|
3505
3510
|
"either a file was not downloaded or a progress log was not read"
|
|
3506
|
-
),
|
|
3511
|
+
), c;
|
|
3507
3512
|
}
|
|
3508
3513
|
getProgressLogNoCtx(e, t, n, r) {
|
|
3509
3514
|
const o = this.getDownloadedBlobNoCtx(e, t, r);
|
|
3510
3515
|
if (o == null) return;
|
|
3511
|
-
const
|
|
3516
|
+
const c = J(o.handle, this.signer);
|
|
3512
3517
|
let i = this.idToProgressLog.get(t.id);
|
|
3513
3518
|
if (i == null) {
|
|
3514
|
-
const a = new
|
|
3519
|
+
const a = new de(c, 1, n);
|
|
3515
3520
|
this.idToProgressLog.set(t.id, a), i = a;
|
|
3516
3521
|
}
|
|
3517
3522
|
const l = i.getOrSchedule(e);
|
|
@@ -3520,8 +3525,8 @@ class _n {
|
|
|
3520
3525
|
}
|
|
3521
3526
|
getLogHandle(e, t) {
|
|
3522
3527
|
if (t == null)
|
|
3523
|
-
return
|
|
3524
|
-
const n =
|
|
3528
|
+
return b.make((r) => this.getLogHandle(e, r));
|
|
3529
|
+
const n = R(e, t);
|
|
3525
3530
|
return this.getLogHandleNoCtx(n);
|
|
3526
3531
|
}
|
|
3527
3532
|
getLogHandleNoCtx(e) {
|
|
@@ -3564,9 +3569,9 @@ class _n {
|
|
|
3564
3569
|
const r = this.cache.removeFile(n.path, t);
|
|
3565
3570
|
await Promise.all(
|
|
3566
3571
|
r.map(async (o) => {
|
|
3567
|
-
await
|
|
3572
|
+
await m.rm(o.path), this.cache.removeCache(o), this.removeTask(
|
|
3568
3573
|
o,
|
|
3569
|
-
`the task ${o.path} was removedfrom cache along with ${r.map((
|
|
3574
|
+
`the task ${o.path} was removedfrom cache along with ${r.map((c) => c.path)}`
|
|
3570
3575
|
);
|
|
3571
3576
|
})
|
|
3572
3577
|
);
|
|
@@ -3587,13 +3592,13 @@ class _n {
|
|
|
3587
3592
|
});
|
|
3588
3593
|
}
|
|
3589
3594
|
getFilePath(e) {
|
|
3590
|
-
return
|
|
3595
|
+
return w.resolve(w.join(this.saveDir, String(BigInt(e))));
|
|
3591
3596
|
}
|
|
3592
3597
|
}
|
|
3593
|
-
class
|
|
3598
|
+
class Or {
|
|
3594
3599
|
constructor(e, t) {
|
|
3595
|
-
|
|
3596
|
-
|
|
3600
|
+
d(this, "change", new N());
|
|
3601
|
+
d(this, "counter", new v());
|
|
3597
3602
|
this.size = e, this.handle = t;
|
|
3598
3603
|
}
|
|
3599
3604
|
getHandle() {
|
|
@@ -3606,13 +3611,13 @@ class Ur {
|
|
|
3606
3611
|
return this.counter.dec(e);
|
|
3607
3612
|
}
|
|
3608
3613
|
}
|
|
3609
|
-
class
|
|
3614
|
+
class de {
|
|
3610
3615
|
constructor(e, t, n) {
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new
|
|
3616
|
+
d(this, "updater");
|
|
3617
|
+
d(this, "log");
|
|
3618
|
+
d(this, "change", new N());
|
|
3619
|
+
d(this, "error");
|
|
3620
|
+
this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new Ue(async () => this.update());
|
|
3616
3621
|
}
|
|
3617
3622
|
getOrSchedule(e) {
|
|
3618
3623
|
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
@@ -3622,7 +3627,7 @@ class ae {
|
|
|
3622
3627
|
}
|
|
3623
3628
|
async update() {
|
|
3624
3629
|
try {
|
|
3625
|
-
const e = await
|
|
3630
|
+
const e = await Er(
|
|
3626
3631
|
this.path,
|
|
3627
3632
|
this.lines,
|
|
3628
3633
|
this.patternToSearch
|
|
@@ -3637,35 +3642,35 @@ class ae {
|
|
|
3637
3642
|
}
|
|
3638
3643
|
}
|
|
3639
3644
|
}
|
|
3640
|
-
async function
|
|
3645
|
+
async function he(s) {
|
|
3641
3646
|
try {
|
|
3642
|
-
return await
|
|
3647
|
+
return await m.access(s), !0;
|
|
3643
3648
|
} catch {
|
|
3644
3649
|
return !1;
|
|
3645
3650
|
}
|
|
3646
3651
|
}
|
|
3647
|
-
async function
|
|
3648
|
-
return await
|
|
3652
|
+
async function Fr(s) {
|
|
3653
|
+
return await Te(re.toWeb(O.createReadStream(s)));
|
|
3649
3654
|
}
|
|
3650
|
-
function
|
|
3651
|
-
const n =
|
|
3652
|
-
return new Promise((o,
|
|
3653
|
-
const i =
|
|
3655
|
+
function Er(s, e, t) {
|
|
3656
|
+
const n = O.createReadStream(s), r = new ne();
|
|
3657
|
+
return new Promise((o, c) => {
|
|
3658
|
+
const i = tt.createInterface(n, r), l = new rt();
|
|
3654
3659
|
i.on("line", function(a) {
|
|
3655
3660
|
t != null && !a.includes(t) || (l.push(a), l.length > e && l.shift());
|
|
3656
|
-
}), i.on("error",
|
|
3657
|
-
o(l.toArray().join(
|
|
3661
|
+
}), i.on("error", c), i.on("close", function() {
|
|
3662
|
+
o(l.toArray().join(Z.EOL) + Z.EOL);
|
|
3658
3663
|
});
|
|
3659
3664
|
});
|
|
3660
3665
|
}
|
|
3661
|
-
let
|
|
3666
|
+
let Wr = class {
|
|
3662
3667
|
constructor(e, t, n, r) {
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3668
|
+
d(this, "counter", new v());
|
|
3669
|
+
d(this, "change", new N());
|
|
3670
|
+
d(this, "signalCtl", new AbortController());
|
|
3671
|
+
d(this, "error");
|
|
3672
|
+
d(this, "done", !1);
|
|
3673
|
+
d(this, "sizeBytes", 0);
|
|
3669
3674
|
this.clientDownload = e, this.rInfo = t, this.path = n, this.handle = r;
|
|
3670
3675
|
}
|
|
3671
3676
|
attach(e, t) {
|
|
@@ -3676,16 +3681,16 @@ let Dr = class {
|
|
|
3676
3681
|
const { content: e, size: t } = await this.clientDownload.downloadBlob(
|
|
3677
3682
|
this.rInfo
|
|
3678
3683
|
);
|
|
3679
|
-
if (await
|
|
3684
|
+
if (await he(w.dirname(this.path)) || await m.mkdir(w.dirname(this.path), { recursive: !0 }), await he(this.path))
|
|
3680
3685
|
await e.cancel("the file already existed");
|
|
3681
3686
|
else {
|
|
3682
|
-
const n =
|
|
3687
|
+
const n = ne.toWeb(O.createWriteStream(this.path));
|
|
3683
3688
|
await e.pipeTo(n);
|
|
3684
3689
|
}
|
|
3685
3690
|
this.setDone(t);
|
|
3686
3691
|
} catch (e) {
|
|
3687
|
-
if (e instanceof
|
|
3688
|
-
this.setError(e), await
|
|
3692
|
+
if (e instanceof ue || e instanceof ae || e instanceof Se || e instanceof Ne || e.code == "ENOENT") {
|
|
3693
|
+
this.setError(e), await m.rm(this.path);
|
|
3689
3694
|
return;
|
|
3690
3695
|
}
|
|
3691
3696
|
throw e;
|
|
@@ -3710,20 +3715,20 @@ let Dr = class {
|
|
|
3710
3715
|
this.done = !0, this.sizeBytes = e, this.change.markChanged();
|
|
3711
3716
|
}
|
|
3712
3717
|
abort(e) {
|
|
3713
|
-
this.signalCtl.abort(new
|
|
3718
|
+
this.signalCtl.abort(new ue(e));
|
|
3714
3719
|
}
|
|
3715
3720
|
setError(e) {
|
|
3716
3721
|
this.error = e, this.change.markChanged();
|
|
3717
3722
|
}
|
|
3718
3723
|
};
|
|
3719
|
-
class
|
|
3724
|
+
class ue extends Error {
|
|
3720
3725
|
}
|
|
3721
|
-
const
|
|
3722
|
-
function
|
|
3723
|
-
return !!s.match(
|
|
3726
|
+
const Ce = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
3727
|
+
function zr(s) {
|
|
3728
|
+
return !!s.match(Ce);
|
|
3724
3729
|
}
|
|
3725
|
-
function
|
|
3726
|
-
const t = s.match(
|
|
3730
|
+
function J(s, e) {
|
|
3731
|
+
const t = s.match(Ce);
|
|
3727
3732
|
if (t === null)
|
|
3728
3733
|
throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
3729
3734
|
const { path: n, signature: r } = t.groups;
|
|
@@ -3733,91 +3738,106 @@ function Z(s, e) {
|
|
|
3733
3738
|
`Signature verification failed for: ${s}`
|
|
3734
3739
|
), n;
|
|
3735
3740
|
}
|
|
3736
|
-
function
|
|
3741
|
+
function Ar(s, e) {
|
|
3737
3742
|
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
3738
3743
|
}
|
|
3739
|
-
const
|
|
3740
|
-
function
|
|
3741
|
-
return !!s.match(
|
|
3744
|
+
const Oe = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
|
|
3745
|
+
function xr(s) {
|
|
3746
|
+
return !!s.match(Oe);
|
|
3742
3747
|
}
|
|
3743
|
-
function
|
|
3744
|
-
const t = s.match(
|
|
3748
|
+
function Mr(s, e) {
|
|
3749
|
+
const t = s.match(Oe);
|
|
3745
3750
|
if (t === null)
|
|
3746
3751
|
throw new Error(
|
|
3747
3752
|
`Remote handle is malformed: ${s}, matches: ${t}`
|
|
3748
3753
|
);
|
|
3749
|
-
const { content: n, resourceType: r, resourceVersion: o, resourceId:
|
|
3754
|
+
const { content: n, resourceType: r, resourceVersion: o, resourceId: c, signature: i } = t.groups;
|
|
3750
3755
|
return e.verify(
|
|
3751
3756
|
n,
|
|
3752
3757
|
i,
|
|
3753
3758
|
`Signature verification failed for ${s}`
|
|
3754
3759
|
), {
|
|
3755
|
-
id:
|
|
3760
|
+
id: Y(BigInt(c)),
|
|
3756
3761
|
type: { name: r, version: o }
|
|
3757
3762
|
};
|
|
3758
3763
|
}
|
|
3759
|
-
function
|
|
3764
|
+
function Hr(s, e) {
|
|
3760
3765
|
const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
|
|
3761
3766
|
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
3762
3767
|
}
|
|
3763
|
-
const
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3768
|
+
const F = T.object({
|
|
3769
|
+
/** Local file path, to take data for upload */
|
|
3770
|
+
localPath: T.string(),
|
|
3771
|
+
/** Path signature, to check this data was generated by us */
|
|
3772
|
+
pathSignature: T.string(),
|
|
3773
|
+
/** File size in bytes */
|
|
3774
|
+
sizeBytes: T.string(),
|
|
3775
|
+
/** Modification time unix timestamp in seconds */
|
|
3776
|
+
modificationTime: T.string()
|
|
3777
|
+
}), Fe = T.object({
|
|
3778
|
+
/** Pl storage id */
|
|
3779
|
+
storageId: T.string(),
|
|
3780
|
+
/** Path inside storage */
|
|
3781
|
+
path: T.string()
|
|
3782
|
+
}), En = T.union([
|
|
3783
|
+
F,
|
|
3784
|
+
Fe
|
|
3785
|
+
]), jr = se({
|
|
3786
|
+
data: F,
|
|
3787
|
+
fields: {
|
|
3788
|
+
blob: !1
|
|
3789
|
+
}
|
|
3790
|
+
}), Gr = se({
|
|
3769
3791
|
fields: {
|
|
3770
|
-
blob: !1,
|
|
3771
|
-
// for BlobUpload
|
|
3772
3792
|
incarnation: !1
|
|
3773
|
-
// for BlobIndex
|
|
3774
3793
|
}
|
|
3775
3794
|
});
|
|
3776
|
-
|
|
3795
|
+
function Vr(s, e) {
|
|
3796
|
+
const t = ie(s) ? e.accessor(s).node() : ot(s) ? s.node() : s;
|
|
3797
|
+
return t.resourceType.name.startsWith("BlobUpload") ? Q(t, jr) : Q(t, Gr);
|
|
3798
|
+
}
|
|
3799
|
+
class Wn {
|
|
3777
3800
|
constructor(e, t, n, r, o = {
|
|
3778
3801
|
nConcurrentPartUploads: 10,
|
|
3779
3802
|
nConcurrentGetProgresses: 10,
|
|
3780
3803
|
pollingInterval: 1e3,
|
|
3781
3804
|
stopPollingDelay: 1e3
|
|
3782
3805
|
}) {
|
|
3783
|
-
|
|
3806
|
+
d(this, "idToProgress", /* @__PURE__ */ new Map());
|
|
3784
3807
|
/** Holds a queue that upload blobs. */
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3808
|
+
d(this, "uploadQueue");
|
|
3809
|
+
d(this, "hooks");
|
|
3810
|
+
d(this, "scheduledOnNextState", []);
|
|
3788
3811
|
/** If true, main loop will continue polling pl state. */
|
|
3789
|
-
|
|
3812
|
+
d(this, "keepRunning", !1);
|
|
3790
3813
|
/** Actual state of main loop. */
|
|
3791
|
-
|
|
3792
|
-
this.logger = e, this.signer = t, this.clientBlob = n, this.clientProgress = r, this.opts = o, this.uploadQueue = new
|
|
3814
|
+
d(this, "currentLoop");
|
|
3815
|
+
this.logger = e, this.signer = t, this.clientBlob = n, this.clientProgress = r, this.opts = o, this.uploadQueue = new ee(this.logger, 1, {
|
|
3793
3816
|
type: "exponentialWithMaxDelayBackoff",
|
|
3794
3817
|
initialDelay: 20,
|
|
3795
3818
|
maxDelay: 15e3,
|
|
3796
3819
|
// 15 seconds
|
|
3797
3820
|
backoffMultiplier: 1.5,
|
|
3798
3821
|
jitter: 0.5
|
|
3799
|
-
}), this.hooks = new
|
|
3822
|
+
}), this.hooks = new ke(
|
|
3800
3823
|
() => this.startUpdating(),
|
|
3801
3824
|
() => this.stopUpdating(),
|
|
3802
3825
|
{ stopDebounce: o.stopPollingDelay },
|
|
3803
|
-
(
|
|
3826
|
+
(c, i) => this.scheduleOnNextState(c, i)
|
|
3804
3827
|
);
|
|
3805
3828
|
}
|
|
3806
3829
|
getProgressId(e, t) {
|
|
3807
|
-
if (t == null)
|
|
3808
|
-
|
|
3809
|
-
const n = be(e) ? Te(e, Ar, t) : e, r = k();
|
|
3830
|
+
if (t == null) return b.make((c) => this.getProgressId(e, c));
|
|
3831
|
+
const n = ie(e) ? Vr(e, t) : e, r = L();
|
|
3810
3832
|
t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(n.id, r));
|
|
3811
3833
|
const o = this.getProgressIdNoCtx(t.watcher, n, r);
|
|
3812
|
-
return
|
|
3813
|
-
`upload/index progress was got, but it's not stable: ${o}`
|
|
3814
|
-
), o;
|
|
3834
|
+
return pe(o) || t.markUnstable(`upload/index progress was got, but it's not stable: ${o}`), o;
|
|
3815
3835
|
}
|
|
3816
3836
|
getProgressIdNoCtx(e, t, n) {
|
|
3817
|
-
const r = t.fields.blob
|
|
3837
|
+
const r = "blob" in t.fields ? t.fields.blob !== void 0 : t.fields.incarnation !== void 0, o = this.idToProgress.get(t.id);
|
|
3818
3838
|
if (o != null)
|
|
3819
3839
|
return o.attach(e, n), o.mustGetProgress(r);
|
|
3820
|
-
const
|
|
3840
|
+
const c = new qr(
|
|
3821
3841
|
this.logger,
|
|
3822
3842
|
this.clientBlob,
|
|
3823
3843
|
this.clientProgress,
|
|
@@ -3825,10 +3845,10 @@ class On {
|
|
|
3825
3845
|
this.signer,
|
|
3826
3846
|
t
|
|
3827
3847
|
);
|
|
3828
|
-
return this.idToProgress.set(t.id,
|
|
3829
|
-
fn: () =>
|
|
3830
|
-
recoverableErrorPredicate: (i) => !
|
|
3831
|
-
}),
|
|
3848
|
+
return this.idToProgress.set(t.id, c), c.attach(e, n), c.progress.isUpload && c.progress.isUploadSignMatch && this.uploadQueue.push({
|
|
3849
|
+
fn: () => c.uploadBlobTask(),
|
|
3850
|
+
recoverableErrorPredicate: (i) => !Ee(i)
|
|
3851
|
+
}), c.mustGetProgress(r);
|
|
3832
3852
|
}
|
|
3833
3853
|
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
3834
3854
|
async release(e, t) {
|
|
@@ -3856,38 +3876,37 @@ class On {
|
|
|
3856
3876
|
const e = this.scheduledOnNextState;
|
|
3857
3877
|
this.scheduledOnNextState = [];
|
|
3858
3878
|
try {
|
|
3859
|
-
await
|
|
3879
|
+
await te(
|
|
3860
3880
|
this.opts.nConcurrentGetProgresses,
|
|
3861
|
-
this.getAllNotDoneProgresses().map(
|
|
3862
|
-
(t) => async () => await t.updateStatus()
|
|
3863
|
-
)
|
|
3881
|
+
this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
|
|
3864
3882
|
), e.forEach((t) => t.resolve());
|
|
3865
3883
|
} catch (t) {
|
|
3866
3884
|
console.error(t), e.forEach((n) => n.reject(t));
|
|
3867
3885
|
}
|
|
3868
3886
|
if (!this.keepRunning) break;
|
|
3869
|
-
await
|
|
3887
|
+
await oe.wait(this.opts.pollingInterval);
|
|
3870
3888
|
}
|
|
3871
3889
|
this.currentLoop = void 0;
|
|
3872
3890
|
}
|
|
3873
3891
|
getAllNotDoneProgresses() {
|
|
3874
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !
|
|
3892
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !pe(t.progress)).map(([e, t]) => t);
|
|
3875
3893
|
}
|
|
3876
3894
|
}
|
|
3877
|
-
class
|
|
3878
|
-
constructor(e, t, n, r, o,
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
this
|
|
3885
|
-
|
|
3895
|
+
class qr {
|
|
3896
|
+
constructor(e, t, n, r, o, c) {
|
|
3897
|
+
d(this, "change", new N());
|
|
3898
|
+
d(this, "counter", new v());
|
|
3899
|
+
d(this, "progress");
|
|
3900
|
+
/** If this is upload progress this field will be defined */
|
|
3901
|
+
d(this, "uploadData");
|
|
3902
|
+
d(this, "uploadingTerminallyFailed");
|
|
3903
|
+
this.logger = e, this.clientBlob = t, this.clientProgress = n, this.nConcurrentPartsUpload = r, this.res = c;
|
|
3904
|
+
const i = c.type.name.startsWith("BlobUpload");
|
|
3886
3905
|
let l;
|
|
3887
|
-
i && (this.
|
|
3906
|
+
i && (this.uploadData = F.parse(c.data), l = Zr(
|
|
3888
3907
|
o,
|
|
3889
|
-
this.
|
|
3890
|
-
this.
|
|
3908
|
+
this.uploadData.localPath,
|
|
3909
|
+
this.uploadData.pathSignature
|
|
3891
3910
|
)), this.progress = {
|
|
3892
3911
|
done: !1,
|
|
3893
3912
|
status: void 0,
|
|
@@ -3900,9 +3919,7 @@ class zr {
|
|
|
3900
3919
|
if (e)
|
|
3901
3920
|
return this.setDone(e), this.progress;
|
|
3902
3921
|
if (this.uploadingTerminallyFailed)
|
|
3903
|
-
throw this.logger.error(
|
|
3904
|
-
`Uploading terminally failed: ${this.progress.lastError}`
|
|
3905
|
-
), new Error(this.progress.lastError);
|
|
3922
|
+
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3906
3923
|
return this.progress;
|
|
3907
3924
|
}
|
|
3908
3925
|
attach(e, t) {
|
|
@@ -3916,30 +3933,28 @@ class zr {
|
|
|
3916
3933
|
try {
|
|
3917
3934
|
await this.uploadBlob();
|
|
3918
3935
|
} catch (e) {
|
|
3919
|
-
if (this.setLastError(e),
|
|
3936
|
+
if (this.setLastError(e), ge(e)) {
|
|
3920
3937
|
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3921
3938
|
return;
|
|
3922
3939
|
}
|
|
3923
|
-
throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(),
|
|
3940
|
+
throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ee(e) && this.terminateWithError(e), e;
|
|
3924
3941
|
}
|
|
3925
3942
|
}
|
|
3926
3943
|
/** Uploads a blob using client. */
|
|
3927
3944
|
async uploadBlob() {
|
|
3928
3945
|
if (this.counter.isZero()) return;
|
|
3929
3946
|
const e = await this.clientBlob.initUpload(this.res);
|
|
3930
|
-
this.logger.info(
|
|
3931
|
-
`start to upload blob ${this.res.id}, parts count: ${e.length}`
|
|
3932
|
-
);
|
|
3947
|
+
this.logger.info(`start to upload blob ${this.res.id}, parts count: ${e.length}`);
|
|
3933
3948
|
const t = (n) => async () => {
|
|
3934
3949
|
this.counter.isZero() || await this.clientBlob.partUpload(
|
|
3935
3950
|
this.res,
|
|
3936
|
-
this.
|
|
3951
|
+
this.uploadData.localPath,
|
|
3937
3952
|
n,
|
|
3938
3953
|
e.length,
|
|
3939
|
-
BigInt(this.
|
|
3954
|
+
BigInt(this.uploadData.modificationTime)
|
|
3940
3955
|
);
|
|
3941
3956
|
};
|
|
3942
|
-
await
|
|
3957
|
+
await te(this.nConcurrentPartsUpload, e.map(t)), !this.counter.isZero() && (await this.clientBlob.finalizeUpload(this.res), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged());
|
|
3943
3958
|
}
|
|
3944
3959
|
terminateWithError(e) {
|
|
3945
3960
|
this.progress.lastError = String(e), this.progress.done = !1, this.uploadingTerminallyFailed = !0;
|
|
@@ -3953,17 +3968,15 @@ class zr {
|
|
|
3953
3968
|
async updateStatus() {
|
|
3954
3969
|
try {
|
|
3955
3970
|
const e = await this.clientProgress.getStatus(this.res), t = this.progress.status;
|
|
3956
|
-
this.progress.status =
|
|
3971
|
+
this.progress.status = Jr(e), this.setDone(e.done), (e.done || e.progress != (t == null ? void 0 : t.progress)) && this.change.markChanged();
|
|
3957
3972
|
} catch (e) {
|
|
3958
3973
|
if (this.setLastError(e), e.name == "RpcError" && e.code == "DEADLINE_EXCEEDED") {
|
|
3959
|
-
this.logger.warn(
|
|
3960
|
-
"deadline exceeded while getting a status of BlobImport"
|
|
3961
|
-
);
|
|
3974
|
+
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
3962
3975
|
return;
|
|
3963
3976
|
}
|
|
3964
|
-
if (
|
|
3977
|
+
if (ge(e)) {
|
|
3965
3978
|
this.logger.warn(
|
|
3966
|
-
`resource was not found while updating a status of BlobImport: ${e}, ${
|
|
3979
|
+
`resource was not found while updating a status of BlobImport: ${e}, ${qe(this.res)}`
|
|
3967
3980
|
), this.change.markChanged(), this.setDone(!0);
|
|
3968
3981
|
return;
|
|
3969
3982
|
}
|
|
@@ -3971,71 +3984,47 @@ class zr {
|
|
|
3971
3984
|
}
|
|
3972
3985
|
}
|
|
3973
3986
|
}
|
|
3974
|
-
function
|
|
3987
|
+
function pe(s) {
|
|
3975
3988
|
return s.done && s.status !== void 0 && s.status !== null && s.status.progress >= 1;
|
|
3976
3989
|
}
|
|
3977
|
-
function
|
|
3978
|
-
if (s.data == null || !("modificationTime" in s.data))
|
|
3979
|
-
throw new Error(
|
|
3980
|
-
"no upload options in BlobUpload resource data: " + B(s.data)
|
|
3981
|
-
);
|
|
3982
|
-
const e = s.data;
|
|
3983
|
-
if (e.modificationTime === void 0)
|
|
3984
|
-
throw new Error(
|
|
3985
|
-
"no modification time in data: " + B(s.data)
|
|
3986
|
-
);
|
|
3987
|
-
if (e.localPath === void 0)
|
|
3988
|
-
throw new Error(
|
|
3989
|
-
"no local path in data: " + B(s.data)
|
|
3990
|
-
);
|
|
3991
|
-
if (e.pathSignature === void 0)
|
|
3992
|
-
throw new Error(
|
|
3993
|
-
"no path signature in data: " + B(s.data)
|
|
3994
|
-
);
|
|
3995
|
-
return {
|
|
3996
|
-
modificationTime: e.modificationTime,
|
|
3997
|
-
localPath: e.localPath,
|
|
3998
|
-
pathSignature: e.pathSignature
|
|
3999
|
-
};
|
|
4000
|
-
}
|
|
4001
|
-
function Mr(s) {
|
|
3990
|
+
function Jr(s) {
|
|
4002
3991
|
return {
|
|
4003
3992
|
progress: s.progress ?? 0,
|
|
4004
3993
|
bytesProcessed: Number(s.bytesProcessed),
|
|
4005
3994
|
bytesTotal: Number(s.bytesTotal)
|
|
4006
3995
|
};
|
|
4007
3996
|
}
|
|
4008
|
-
function
|
|
3997
|
+
function Zr(s, e, t) {
|
|
4009
3998
|
try {
|
|
4010
3999
|
return s.verify(e, t), !0;
|
|
4011
4000
|
} catch {
|
|
4012
4001
|
return !1;
|
|
4013
4002
|
}
|
|
4014
4003
|
}
|
|
4015
|
-
function
|
|
4016
|
-
return s instanceof
|
|
4004
|
+
function Ee(s) {
|
|
4005
|
+
return s instanceof Le || s instanceof Pe || s instanceof Ie;
|
|
4017
4006
|
}
|
|
4018
|
-
function
|
|
4007
|
+
function ge(s) {
|
|
4019
4008
|
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
4020
4009
|
}
|
|
4021
|
-
class
|
|
4010
|
+
class zn {
|
|
4022
4011
|
constructor(e, t = {
|
|
4023
4012
|
nConcurrentGetLogs: 10,
|
|
4024
4013
|
pollingInterval: 1e3,
|
|
4025
4014
|
stopPollingDelay: 1e3
|
|
4026
4015
|
}) {
|
|
4027
4016
|
/** Holds a map of StreamManager Resource Id to all logs of this stream. */
|
|
4028
|
-
|
|
4017
|
+
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
4029
4018
|
/** Holds a map of StreamManager Resource Id to the last log line of this stream. */
|
|
4030
|
-
|
|
4019
|
+
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
4031
4020
|
/** Holds a map of StreamManager Resource Id to log id smart object. */
|
|
4032
|
-
|
|
4033
|
-
|
|
4021
|
+
d(this, "hooks");
|
|
4022
|
+
d(this, "scheduledOnNextState", []);
|
|
4034
4023
|
/** If true, main loop will continue polling pl state. */
|
|
4035
|
-
|
|
4024
|
+
d(this, "keepRunning", !1);
|
|
4036
4025
|
/** Actual state of main loop. */
|
|
4037
|
-
|
|
4038
|
-
this.clientLogs = e, this.opts = t, this.hooks = new
|
|
4026
|
+
d(this, "currentLoop");
|
|
4027
|
+
this.clientLogs = e, this.opts = t, this.hooks = new ke(
|
|
4039
4028
|
() => this.startUpdating(),
|
|
4040
4029
|
() => this.stopUpdating(),
|
|
4041
4030
|
{ stopDebounce: t.stopPollingDelay },
|
|
@@ -4044,33 +4033,33 @@ class En {
|
|
|
4044
4033
|
}
|
|
4045
4034
|
getLastLogs(e, t, n) {
|
|
4046
4035
|
if (n == null)
|
|
4047
|
-
return
|
|
4048
|
-
const r =
|
|
4036
|
+
return b.make((i) => this.getLastLogs(e, t, i));
|
|
4037
|
+
const r = R(e, n), o = L();
|
|
4049
4038
|
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseLastLogs(r.id, o));
|
|
4050
|
-
const
|
|
4039
|
+
const c = this.getLastLogsNoCtx(n.watcher, r, t, o);
|
|
4051
4040
|
return n.markUnstable(
|
|
4052
4041
|
"The logs are from stream, so we consider them unstable. Final values will be got from blobs."
|
|
4053
|
-
),
|
|
4042
|
+
), c;
|
|
4054
4043
|
}
|
|
4055
4044
|
getLastLogsNoCtx(e, t, n, r) {
|
|
4056
4045
|
let o = this.idToLastLines.get(t.id);
|
|
4057
4046
|
if (o == null) {
|
|
4058
|
-
const i = new
|
|
4047
|
+
const i = new fe(this.clientLogs, t, n);
|
|
4059
4048
|
this.idToLastLines.set(t.id, i), o = i;
|
|
4060
4049
|
}
|
|
4061
4050
|
o.attach(e, r);
|
|
4062
|
-
const
|
|
4063
|
-
if (
|
|
4064
|
-
return
|
|
4051
|
+
const c = o.getLog();
|
|
4052
|
+
if (c.error != null) throw c.error;
|
|
4053
|
+
return c.log;
|
|
4065
4054
|
}
|
|
4066
4055
|
getProgressLog(e, t, n) {
|
|
4067
4056
|
if (n == null)
|
|
4068
|
-
return
|
|
4057
|
+
return b.make(
|
|
4069
4058
|
(i) => this.getProgressLog(e, t, i)
|
|
4070
4059
|
);
|
|
4071
|
-
const r =
|
|
4060
|
+
const r = R(e, n), o = L();
|
|
4072
4061
|
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseProgressLog(r.id, o));
|
|
4073
|
-
const
|
|
4062
|
+
const c = this.getProgressLogNoCtx(
|
|
4074
4063
|
n.watcher,
|
|
4075
4064
|
r,
|
|
4076
4065
|
t,
|
|
@@ -4078,12 +4067,12 @@ class En {
|
|
|
4078
4067
|
);
|
|
4079
4068
|
return n.markUnstable(
|
|
4080
4069
|
"The progress log is from the stream, so we consider it unstable. Final value will be got from blobs."
|
|
4081
|
-
),
|
|
4070
|
+
), c;
|
|
4082
4071
|
}
|
|
4083
4072
|
getProgressLogNoCtx(e, t, n, r) {
|
|
4084
4073
|
let o = this.idToProgressLog.get(t.id);
|
|
4085
4074
|
if (o == null) {
|
|
4086
|
-
const i = new
|
|
4075
|
+
const i = new fe(
|
|
4087
4076
|
this.clientLogs,
|
|
4088
4077
|
t,
|
|
4089
4078
|
1,
|
|
@@ -4092,14 +4081,14 @@ class En {
|
|
|
4092
4081
|
this.idToProgressLog.set(t.id, i), o = i;
|
|
4093
4082
|
}
|
|
4094
4083
|
o.attach(e, r);
|
|
4095
|
-
const
|
|
4096
|
-
if (
|
|
4097
|
-
return
|
|
4084
|
+
const c = o.getLog();
|
|
4085
|
+
if (c.error) throw c.error;
|
|
4086
|
+
return c.log;
|
|
4098
4087
|
}
|
|
4099
4088
|
getLogHandle(e, t) {
|
|
4100
4089
|
if (t == null)
|
|
4101
|
-
return
|
|
4102
|
-
const n =
|
|
4090
|
+
return b.make((o) => this.getLogHandle(e, o));
|
|
4091
|
+
const n = R(e, t), r = this.getLogHandleNoCtx(n);
|
|
4103
4092
|
return t.markUnstable(), r;
|
|
4104
4093
|
}
|
|
4105
4094
|
getLogHandleNoCtx(e) {
|
|
@@ -4173,7 +4162,7 @@ class En {
|
|
|
4173
4162
|
const e = this.scheduledOnNextState;
|
|
4174
4163
|
this.scheduledOnNextState = [];
|
|
4175
4164
|
try {
|
|
4176
|
-
await
|
|
4165
|
+
await te(
|
|
4177
4166
|
this.opts.nConcurrentGetLogs,
|
|
4178
4167
|
this.getAllNotDoneLogs().map(
|
|
4179
4168
|
(t) => async () => await t.update()
|
|
@@ -4183,7 +4172,7 @@ class En {
|
|
|
4183
4172
|
console.error(t), e.forEach((n) => n.reject(t));
|
|
4184
4173
|
}
|
|
4185
4174
|
if (!this.keepRunning) break;
|
|
4186
|
-
await
|
|
4175
|
+
await oe.wait(this.opts.pollingInterval);
|
|
4187
4176
|
}
|
|
4188
4177
|
this.currentLoop = void 0;
|
|
4189
4178
|
}
|
|
@@ -4191,13 +4180,13 @@ class En {
|
|
|
4191
4180
|
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).filter(([e, t]) => !t.getLog().done).map(([e, t]) => t);
|
|
4192
4181
|
}
|
|
4193
4182
|
}
|
|
4194
|
-
class
|
|
4183
|
+
class fe {
|
|
4195
4184
|
constructor(e, t, n, r) {
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4185
|
+
d(this, "logs");
|
|
4186
|
+
d(this, "error");
|
|
4187
|
+
d(this, "done", !1);
|
|
4188
|
+
d(this, "change", new N());
|
|
4189
|
+
d(this, "counter", new v());
|
|
4201
4190
|
this.clientLogs = e, this.rInfo = t, this.lines = n, this.patternToSearch = r;
|
|
4202
4191
|
}
|
|
4203
4192
|
getLog() {
|
|
@@ -4232,26 +4221,26 @@ class ue {
|
|
|
4232
4221
|
}
|
|
4233
4222
|
}
|
|
4234
4223
|
}
|
|
4235
|
-
class
|
|
4224
|
+
class An {
|
|
4236
4225
|
constructor(e, t, n, r = {
|
|
4237
4226
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
4238
4227
|
withGunzip: !0,
|
|
4239
4228
|
nConcurrentDownloads: 50
|
|
4240
4229
|
}) {
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4230
|
+
d(this, "downloadHelper");
|
|
4231
|
+
d(this, "urlToDownload", /* @__PURE__ */ new Map());
|
|
4232
|
+
d(this, "downloadQueue");
|
|
4244
4233
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4245
4234
|
* file that should be kept. */
|
|
4246
|
-
|
|
4247
|
-
this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new
|
|
4235
|
+
d(this, "cache");
|
|
4236
|
+
this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new ee(
|
|
4248
4237
|
this.logger,
|
|
4249
4238
|
this.opts.nConcurrentDownloads
|
|
4250
|
-
), this.cache = new
|
|
4239
|
+
), this.cache = new De(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Re(t);
|
|
4251
4240
|
}
|
|
4252
4241
|
getPath(e, t) {
|
|
4253
|
-
if (t === void 0) return
|
|
4254
|
-
const n =
|
|
4242
|
+
if (t === void 0) return b.make((o) => this.getPath(e, o));
|
|
4243
|
+
const n = L();
|
|
4255
4244
|
t.addOnDestroy(() => this.releasePath(e, n));
|
|
4256
4245
|
const r = this.getPathNoCtx(e, t.watcher, n);
|
|
4257
4246
|
return (r == null ? void 0 : r.path) === void 0 && t.markUnstable(
|
|
@@ -4262,11 +4251,11 @@ class Fn {
|
|
|
4262
4251
|
const r = e.toString(), o = this.urlToDownload.get(r);
|
|
4263
4252
|
if (o != null)
|
|
4264
4253
|
return o.attach(t, n), o.getPath();
|
|
4265
|
-
const
|
|
4254
|
+
const c = this.setNewTask(t, e, n);
|
|
4266
4255
|
return this.downloadQueue.push({
|
|
4267
|
-
fn: async () => this.downloadUrl(
|
|
4256
|
+
fn: async () => this.downloadUrl(c, n),
|
|
4268
4257
|
recoverableErrorPredicate: (i) => !0
|
|
4269
|
-
}),
|
|
4258
|
+
}), c.getPath();
|
|
4270
4259
|
}
|
|
4271
4260
|
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4272
4261
|
async downloadUrl(e, t) {
|
|
@@ -4281,10 +4270,10 @@ class Fn {
|
|
|
4281
4270
|
if (this.cache.existsFile(r.path)) {
|
|
4282
4271
|
const o = this.cache.removeFile(r.path, t);
|
|
4283
4272
|
await Promise.all(
|
|
4284
|
-
o.map(async (
|
|
4285
|
-
await
|
|
4286
|
-
|
|
4287
|
-
`the task ${JSON.stringify(
|
|
4273
|
+
o.map(async (c) => {
|
|
4274
|
+
await X(c.path), this.cache.removeCache(c), this.removeTask(
|
|
4275
|
+
c,
|
|
4276
|
+
`the task ${JSON.stringify(c)} was removedfrom cache along with ${JSON.stringify(o)}`
|
|
4288
4277
|
);
|
|
4289
4278
|
})
|
|
4290
4279
|
);
|
|
@@ -4298,7 +4287,7 @@ class Fn {
|
|
|
4298
4287
|
async releaseAll() {
|
|
4299
4288
|
this.downloadQueue.stop(), await Promise.all(
|
|
4300
4289
|
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4301
|
-
await
|
|
4290
|
+
await X(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4302
4291
|
t,
|
|
4303
4292
|
`the task ${t} was released when the driver was closed`
|
|
4304
4293
|
);
|
|
@@ -4306,25 +4295,25 @@ class Fn {
|
|
|
4306
4295
|
);
|
|
4307
4296
|
}
|
|
4308
4297
|
setNewTask(e, t, n) {
|
|
4309
|
-
const r = new
|
|
4298
|
+
const r = new Qr(this.getFilePath(t), t);
|
|
4310
4299
|
return r.attach(e, n), this.urlToDownload.set(t.toString(), r), r;
|
|
4311
4300
|
}
|
|
4312
4301
|
removeTask(e, t) {
|
|
4313
4302
|
e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
|
|
4314
4303
|
}
|
|
4315
4304
|
getFilePath(e) {
|
|
4316
|
-
const t =
|
|
4317
|
-
return
|
|
4305
|
+
const t = nt("sha256").update(e.toString()).digest("hex");
|
|
4306
|
+
return w.join(this.saveDir, t);
|
|
4318
4307
|
}
|
|
4319
4308
|
}
|
|
4320
|
-
class
|
|
4309
|
+
class Qr {
|
|
4321
4310
|
constructor(e, t) {
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4311
|
+
d(this, "counter", new v());
|
|
4312
|
+
d(this, "change", new N());
|
|
4313
|
+
d(this, "signalCtl", new AbortController());
|
|
4314
|
+
d(this, "error");
|
|
4315
|
+
d(this, "done", !1);
|
|
4316
|
+
d(this, "sizeBytes", 0);
|
|
4328
4317
|
this.path = e, this.url = t;
|
|
4329
4318
|
}
|
|
4330
4319
|
attach(e, t) {
|
|
@@ -4339,16 +4328,16 @@ class jr {
|
|
|
4339
4328
|
);
|
|
4340
4329
|
this.setDone(n);
|
|
4341
4330
|
} catch (n) {
|
|
4342
|
-
if (n instanceof
|
|
4343
|
-
this.setError(n), await
|
|
4331
|
+
if (n instanceof me || n instanceof ae) {
|
|
4332
|
+
this.setError(n), await X(this.path);
|
|
4344
4333
|
return;
|
|
4345
4334
|
}
|
|
4346
4335
|
throw n;
|
|
4347
4336
|
}
|
|
4348
4337
|
}
|
|
4349
4338
|
async downloadAndUntar(e, t, n) {
|
|
4350
|
-
if (await
|
|
4351
|
-
return await
|
|
4339
|
+
if (await Qe(this.path))
|
|
4340
|
+
return await We(this.path);
|
|
4352
4341
|
const r = await e.downloadRemoteFile(
|
|
4353
4342
|
this.url.toString(),
|
|
4354
4343
|
{},
|
|
@@ -4356,76 +4345,47 @@ class jr {
|
|
|
4356
4345
|
);
|
|
4357
4346
|
let o = r.content;
|
|
4358
4347
|
if (t) {
|
|
4359
|
-
const i =
|
|
4348
|
+
const i = Ye.toWeb(st.createGunzip());
|
|
4360
4349
|
o = o.pipeThrough(i, { signal: n });
|
|
4361
4350
|
}
|
|
4362
|
-
const
|
|
4363
|
-
return await o.pipeTo(
|
|
4351
|
+
const c = ne.toWeb(it.extract(this.path));
|
|
4352
|
+
return await o.pipeTo(c, { signal: n }), r.size;
|
|
4364
4353
|
}
|
|
4365
4354
|
getPath() {
|
|
4366
|
-
if (this.done) return { path:
|
|
4355
|
+
if (this.done) return { path: K(this.path) };
|
|
4367
4356
|
if (this.error) return { error: this.error };
|
|
4368
4357
|
}
|
|
4369
4358
|
setDone(e) {
|
|
4370
4359
|
this.done = !0, this.sizeBytes = e, this.change.markChanged();
|
|
4371
4360
|
}
|
|
4372
4361
|
abort(e) {
|
|
4373
|
-
this.signalCtl.abort(new
|
|
4362
|
+
this.signalCtl.abort(new me(e));
|
|
4374
4363
|
}
|
|
4375
4364
|
setError(e) {
|
|
4376
4365
|
this.error = String(e), this.change.markChanged();
|
|
4377
4366
|
}
|
|
4378
4367
|
}
|
|
4379
|
-
class
|
|
4368
|
+
class me extends Error {
|
|
4380
4369
|
}
|
|
4381
|
-
async function
|
|
4382
|
-
const e = await
|
|
4370
|
+
async function We(s) {
|
|
4371
|
+
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
4383
4372
|
return (await Promise.all(
|
|
4384
4373
|
e.map(async (n) => {
|
|
4385
|
-
const r =
|
|
4386
|
-
return n.isDirectory() ? await
|
|
4374
|
+
const r = w.join(s, n.name);
|
|
4375
|
+
return n.isDirectory() ? await We(r) : (await m.stat(r)).size;
|
|
4387
4376
|
})
|
|
4388
4377
|
)).reduce((n, r) => n + r, 0);
|
|
4389
4378
|
}
|
|
4390
|
-
async function
|
|
4391
|
-
await
|
|
4379
|
+
async function X(s) {
|
|
4380
|
+
await m.rm(s, { recursive: !0, force: !0 });
|
|
4392
4381
|
}
|
|
4393
|
-
function
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
};
|
|
4399
|
-
}
|
|
4400
|
-
function Vr(s, e) {
|
|
4401
|
-
return s.isDir ? {
|
|
4402
|
-
type: "dir",
|
|
4403
|
-
name: s.name,
|
|
4404
|
-
fullPath: s.fullName
|
|
4405
|
-
} : {
|
|
4406
|
-
type: "file",
|
|
4407
|
-
name: s.name,
|
|
4408
|
-
fullPath: s.fullName,
|
|
4409
|
-
handle: qr({ item: s, ...e })
|
|
4410
|
-
};
|
|
4411
|
-
}
|
|
4412
|
-
function qr(s) {
|
|
4413
|
-
return s.remote ? Zr(s) : Fe(
|
|
4414
|
-
s.item.fullName,
|
|
4415
|
-
s.signer,
|
|
4416
|
-
s.item.size,
|
|
4417
|
-
O(s.item.lastModified).seconds
|
|
4418
|
-
);
|
|
4419
|
-
}
|
|
4420
|
-
function Zr(s) {
|
|
4421
|
-
return `index://index/${encodeURIComponent(
|
|
4422
|
-
JSON.stringify({
|
|
4423
|
-
storageId: s.storageName,
|
|
4424
|
-
path: s.item.fullName
|
|
4425
|
-
})
|
|
4426
|
-
)}`;
|
|
4382
|
+
function we(s, e) {
|
|
4383
|
+
return `index://index/${encodeURIComponent(JSON.stringify({
|
|
4384
|
+
storageId: s,
|
|
4385
|
+
path: e
|
|
4386
|
+
}))}`;
|
|
4427
4387
|
}
|
|
4428
|
-
function
|
|
4388
|
+
function Xr(s, e, t, n) {
|
|
4429
4389
|
const r = {
|
|
4430
4390
|
localPath: s,
|
|
4431
4391
|
pathSignature: e.sign(s),
|
|
@@ -4434,98 +4394,134 @@ function Fe(s, e, t, n) {
|
|
|
4434
4394
|
};
|
|
4435
4395
|
return `upload://upload/${encodeURIComponent(JSON.stringify(r))}`;
|
|
4436
4396
|
}
|
|
4437
|
-
function
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
return;
|
|
4443
|
-
}
|
|
4444
|
-
return {
|
|
4445
|
-
directory: e.directory,
|
|
4446
|
-
isDir: e.dirent.isDirectory(),
|
|
4447
|
-
name: e.dirent.name,
|
|
4448
|
-
fullName: e.fullName,
|
|
4449
|
-
lastModified: {
|
|
4450
|
-
seconds: BigInt(Math.floor(e.stat.mtimeMs / 1e3)),
|
|
4451
|
-
nanos: 0
|
|
4452
|
-
},
|
|
4453
|
-
size: BigInt(e.stat.size)
|
|
4454
|
-
};
|
|
4455
|
-
}
|
|
4456
|
-
function Qr(s, e) {
|
|
4457
|
-
const t = Object.entries(s).map(Yr), n = Object.entries(e).map(rn);
|
|
4458
|
-
return t.concat(n);
|
|
4397
|
+
function Yr(s) {
|
|
4398
|
+
const e = new URL(s);
|
|
4399
|
+
return F.parse(
|
|
4400
|
+
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4401
|
+
);
|
|
4459
4402
|
}
|
|
4460
|
-
function
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
if (Kr(s))
|
|
4464
|
-
return tn(s);
|
|
4465
|
-
Ze(s);
|
|
4403
|
+
function Kr(s) {
|
|
4404
|
+
const e = new URL(s);
|
|
4405
|
+
return Fe.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4466
4406
|
}
|
|
4467
|
-
function
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4407
|
+
function en(s) {
|
|
4408
|
+
if (on(s))
|
|
4409
|
+
return an(s);
|
|
4410
|
+
if (tn(s))
|
|
4411
|
+
return nn(s);
|
|
4412
|
+
Xe(s);
|
|
4473
4413
|
}
|
|
4474
|
-
const
|
|
4475
|
-
function
|
|
4476
|
-
return
|
|
4414
|
+
const ze = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4415
|
+
function tn(s) {
|
|
4416
|
+
return ze.test(s);
|
|
4477
4417
|
}
|
|
4478
|
-
function
|
|
4418
|
+
function rn(s, e) {
|
|
4479
4419
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4480
4420
|
}
|
|
4481
|
-
function
|
|
4482
|
-
const e = s.match(
|
|
4483
|
-
if (e == null)
|
|
4484
|
-
throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4421
|
+
function nn(s) {
|
|
4422
|
+
const e = s.match(ze);
|
|
4423
|
+
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4485
4424
|
const { name: t, path: n } = e.groups;
|
|
4486
4425
|
return {
|
|
4487
|
-
|
|
4426
|
+
rootPath: decodeURIComponent(n),
|
|
4488
4427
|
name: t,
|
|
4489
|
-
|
|
4490
|
-
};
|
|
4491
|
-
}
|
|
4492
|
-
function rn([s, e]) {
|
|
4493
|
-
return {
|
|
4494
|
-
name: s,
|
|
4495
|
-
handle: on(s, e),
|
|
4496
|
-
initialFullPath: ""
|
|
4428
|
+
isRemote: !1
|
|
4497
4429
|
};
|
|
4498
4430
|
}
|
|
4499
4431
|
const Ae = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4500
|
-
function
|
|
4432
|
+
function on(s) {
|
|
4501
4433
|
return Ae.test(s);
|
|
4502
4434
|
}
|
|
4503
|
-
function
|
|
4435
|
+
function sn(s, e) {
|
|
4504
4436
|
return `remote://${s}/${BigInt(e)}`;
|
|
4505
4437
|
}
|
|
4506
|
-
function
|
|
4438
|
+
function an(s) {
|
|
4507
4439
|
const e = s.match(Ae);
|
|
4508
|
-
if (e == null)
|
|
4509
|
-
throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4440
|
+
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4510
4441
|
const { name: t, resourceId: n } = e.groups;
|
|
4511
4442
|
return {
|
|
4512
|
-
id:
|
|
4513
|
-
type:
|
|
4443
|
+
id: Y(BigInt(n)),
|
|
4444
|
+
type: ln(t),
|
|
4514
4445
|
name: t,
|
|
4515
|
-
|
|
4446
|
+
isRemote: !0
|
|
4516
4447
|
};
|
|
4517
4448
|
}
|
|
4518
|
-
function
|
|
4449
|
+
function ln(s) {
|
|
4519
4450
|
return { name: `LS/${s}`, version: "1" };
|
|
4520
4451
|
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4452
|
+
function xn() {
|
|
4453
|
+
const s = Z.homedir();
|
|
4454
|
+
return w.sep === "/" ? [{ name: "local", root: "/", initialPath: s }] : [
|
|
4455
|
+
{
|
|
4456
|
+
name: "local",
|
|
4457
|
+
root: w.parse(s).root,
|
|
4458
|
+
// disk where home directory resides
|
|
4459
|
+
initialPath: s
|
|
4460
|
+
}
|
|
4461
|
+
];
|
|
4462
|
+
}
|
|
4463
|
+
class xe {
|
|
4464
|
+
constructor(e, t, n, r, o, c, i) {
|
|
4465
|
+
this.logger = e, this.lsClient = t, this.storageIdToResourceId = n, this.signer = r, this.virtualStoragesMap = o, this.localProjectionsMap = c, this.openFileDialogCallback = i;
|
|
4466
|
+
}
|
|
4467
|
+
async getLocalFileContent(e, t) {
|
|
4468
|
+
const n = await this.tryResolveLocalFileHandle(e);
|
|
4469
|
+
if (t) throw new Error("Range request not yet supported.");
|
|
4470
|
+
return await m.readFile(n);
|
|
4471
|
+
}
|
|
4472
|
+
async getLocalFileSize(e) {
|
|
4473
|
+
const t = await this.tryResolveLocalFileHandle(e);
|
|
4474
|
+
return (await m.stat(t)).size;
|
|
4475
|
+
}
|
|
4476
|
+
async showOpenMultipleFilesDialog(e) {
|
|
4477
|
+
const t = await this.openFileDialogCallback(!0, e);
|
|
4478
|
+
return t === void 0 ? {} : {
|
|
4479
|
+
files: await Promise.all(t.map((n) => this.getLocalFileHandle(n)))
|
|
4480
|
+
};
|
|
4481
|
+
}
|
|
4482
|
+
async showOpenSingleFileDialog(e) {
|
|
4483
|
+
const t = await this.openFileDialogCallback(!1, e);
|
|
4484
|
+
return t === void 0 ? {} : {
|
|
4485
|
+
file: await this.getLocalFileHandle(t[0])
|
|
4486
|
+
};
|
|
4487
|
+
}
|
|
4488
|
+
/**
|
|
4489
|
+
* Resolves local handle to local file path.
|
|
4490
|
+
*
|
|
4491
|
+
* @param handle handle to be resolved
|
|
4492
|
+
* @private
|
|
4493
|
+
*/
|
|
4494
|
+
async tryResolveLocalFileHandle(e) {
|
|
4495
|
+
if (at(e)) {
|
|
4496
|
+
const t = Kr(e), n = this.localProjectionsMap.get(t.storageId);
|
|
4497
|
+
if (!n)
|
|
4498
|
+
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4499
|
+
return w.join(n.localPath, t.path);
|
|
4500
|
+
} else {
|
|
4501
|
+
const t = Yr(e);
|
|
4502
|
+
this.signer.verify(
|
|
4503
|
+
t.localPath,
|
|
4504
|
+
t.pathSignature,
|
|
4505
|
+
"Failed to validate local file handle signature."
|
|
4506
|
+
);
|
|
4507
|
+
const n = t.localPath, r = await m.stat(n, { bigint: !0 });
|
|
4508
|
+
if (String(r.mtimeMs / 1000n) !== t.modificationTime)
|
|
4509
|
+
throw new Error("File has changed since the handle was created.");
|
|
4510
|
+
return n;
|
|
4511
|
+
}
|
|
4525
4512
|
}
|
|
4526
4513
|
async getLocalFileHandle(e) {
|
|
4527
|
-
|
|
4528
|
-
|
|
4514
|
+
B(e);
|
|
4515
|
+
for (const n of this.localProjectionsMap.values())
|
|
4516
|
+
if (e.startsWith(n.localPath)) {
|
|
4517
|
+
const r = n.localPath === "" ? e : w.relative(n.localPath, e);
|
|
4518
|
+
return we(
|
|
4519
|
+
n.storageId,
|
|
4520
|
+
r
|
|
4521
|
+
);
|
|
4522
|
+
}
|
|
4523
|
+
const t = await m.stat(e, { bigint: !0 });
|
|
4524
|
+
return Xr(
|
|
4529
4525
|
e,
|
|
4530
4526
|
this.signer,
|
|
4531
4527
|
t.size,
|
|
@@ -4534,42 +4530,68 @@ class Wn {
|
|
|
4534
4530
|
);
|
|
4535
4531
|
}
|
|
4536
4532
|
async getStorageList() {
|
|
4537
|
-
return
|
|
4538
|
-
this.
|
|
4539
|
-
|
|
4540
|
-
|
|
4533
|
+
return [
|
|
4534
|
+
...[...this.virtualStoragesMap.values()].map((e) => ({
|
|
4535
|
+
name: e.name,
|
|
4536
|
+
handle: rn(e.name, e.root),
|
|
4537
|
+
initialFullPath: e.initialPath
|
|
4538
|
+
})),
|
|
4539
|
+
...Object.entries(this.storageIdToResourceId).map(([e, t]) => ({
|
|
4540
|
+
name: e,
|
|
4541
|
+
handle: sn(e, t),
|
|
4542
|
+
initialFullPath: ""
|
|
4543
|
+
// we don't have any additional information from where to start browsing remote storages
|
|
4544
|
+
}))
|
|
4545
|
+
];
|
|
4541
4546
|
}
|
|
4542
4547
|
async listFiles(e, t) {
|
|
4543
|
-
const n =
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4548
|
+
const n = en(e);
|
|
4549
|
+
if (n.isRemote)
|
|
4550
|
+
return {
|
|
4551
|
+
entries: (await this.lsClient.list(n, t)).items.map((o) => ({
|
|
4552
|
+
type: o.isDir ? "dir" : "file",
|
|
4553
|
+
name: o.name,
|
|
4554
|
+
fullPath: o.fullName,
|
|
4555
|
+
handle: we(n.name, o.fullName)
|
|
4556
|
+
}))
|
|
4557
|
+
};
|
|
4558
|
+
{
|
|
4559
|
+
w.sep === "/" && t === "" && (t = "/");
|
|
4560
|
+
const r = n.rootPath === "" ? B(t) : w.join(n.rootPath, t), o = [];
|
|
4561
|
+
for await (const c of await m.opendir(r)) {
|
|
4562
|
+
if (!c.isFile() && !c.isDirectory()) continue;
|
|
4563
|
+
const i = w.join(r, c.name);
|
|
4564
|
+
o.push({
|
|
4565
|
+
type: c.isFile() ? "file" : "dir",
|
|
4566
|
+
name: c.name,
|
|
4567
|
+
fullPath: i,
|
|
4568
|
+
handle: await this.getLocalFileHandle(i)
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
return { entries: o };
|
|
4565
4572
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4573
|
+
}
|
|
4574
|
+
static async init(e, t, n, r, o, c) {
|
|
4575
|
+
const i = Dr(t, e);
|
|
4576
|
+
for (const p of r) B(p.root);
|
|
4577
|
+
for (const p of o) p.localPath !== "" && B(p.localPath);
|
|
4578
|
+
const l = new Map(r.map((p) => [p.name, p])), a = new Map(o.map((p) => [p.storageId, p]));
|
|
4579
|
+
if ((/* @__PURE__ */ new Set([...l.keys(), ...a.keys()])).size !== l.size + a.size)
|
|
4580
|
+
throw new Error(
|
|
4581
|
+
"Intersection between local projection storage ids and virtual storages names detected."
|
|
4582
|
+
);
|
|
4583
|
+
return new xe(
|
|
4584
|
+
e,
|
|
4585
|
+
i,
|
|
4586
|
+
await cn(t),
|
|
4587
|
+
n,
|
|
4588
|
+
l,
|
|
4589
|
+
a,
|
|
4590
|
+
c
|
|
4591
|
+
);
|
|
4570
4592
|
}
|
|
4571
4593
|
}
|
|
4572
|
-
async function
|
|
4594
|
+
async function cn(s) {
|
|
4573
4595
|
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4574
4596
|
const t = await e.getResourceByName("LSProvider"), n = await e.getResourceData(t, !0);
|
|
4575
4597
|
return dn(n);
|
|
@@ -4577,46 +4599,52 @@ async function ln(s) {
|
|
|
4577
4599
|
}
|
|
4578
4600
|
function dn(s) {
|
|
4579
4601
|
return Object.fromEntries(
|
|
4580
|
-
s.fields.filter((e) => e.type == "Dynamic" &&
|
|
4602
|
+
s.fields.filter((e) => e.type == "Dynamic" && Je(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4581
4603
|
);
|
|
4582
4604
|
}
|
|
4583
4605
|
export {
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
En as
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
Le as
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4606
|
+
nr as ClientDownload,
|
|
4607
|
+
Br as ClientLogs,
|
|
4608
|
+
fr as ClientLs,
|
|
4609
|
+
qt as ClientProgress,
|
|
4610
|
+
$t as ClientUpload,
|
|
4611
|
+
xn as DefaultVirtualLocalStorages,
|
|
4612
|
+
Wr as Download,
|
|
4613
|
+
On as DownloadDriver,
|
|
4614
|
+
An as DownloadUrlDriver,
|
|
4615
|
+
En as ImportFileHandleData,
|
|
4616
|
+
Fe as ImportFileHandleIndexData,
|
|
4617
|
+
F as ImportFileHandleUploadData,
|
|
4618
|
+
Gr as IndexResourceSnapshot,
|
|
4619
|
+
Cn as LogsDriver,
|
|
4620
|
+
zn as LogsStreamDriver,
|
|
4621
|
+
vn as LongUpdater,
|
|
4622
|
+
xe as LsDriver,
|
|
4623
|
+
Le as MTimeError,
|
|
4624
|
+
vt as NetworkError,
|
|
4625
|
+
Ie as NoFileForUploading,
|
|
4626
|
+
Cr as OnDemandBlobResourceSnapshot,
|
|
4627
|
+
Pe as UnexpectedEOF,
|
|
4628
|
+
Se as UnknownStorageError,
|
|
4629
|
+
Ue as Updater,
|
|
4630
|
+
Wn as UploadDriver,
|
|
4631
|
+
jr as UploadResourceSnapshot,
|
|
4632
|
+
Ne as WrongLocalFileUrl,
|
|
4633
|
+
Nn as createDownloadClient,
|
|
4634
|
+
Un as createLogsClient,
|
|
4635
|
+
Dr as createLsFilesClient,
|
|
4636
|
+
Dn as createUploadBlobClient,
|
|
4637
|
+
Bn as createUploadProgressClient,
|
|
4612
4638
|
ve as dataToHandle,
|
|
4613
|
-
|
|
4639
|
+
$n as getStream,
|
|
4614
4640
|
_ as handleToData,
|
|
4615
|
-
|
|
4616
|
-
xr as importToUploadOpts,
|
|
4641
|
+
sr as headersFromProto,
|
|
4617
4642
|
C as isLiveLogHandle,
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4643
|
+
_r as isReadyLogHandle,
|
|
4644
|
+
$r as lineToProgress,
|
|
4645
|
+
Vr as makeBlobImportSnapshot,
|
|
4646
|
+
_n as mixcrProgressFromLogs,
|
|
4647
|
+
or as parseLocalFileUrl,
|
|
4648
|
+
B as validateAbsolute
|
|
4621
4649
|
};
|
|
4622
4650
|
//# sourceMappingURL=index.mjs.map
|