@milaboratories/pl-drivers 1.2.16 → 1.2.18
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/progress.d.ts +1 -1
- package/dist/index.js +1 -4626
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4627 -0
- package/dist/{index.cjs.map → index.mjs.map} +1 -1
- package/package.json +14 -11
- package/src/clients/upload.test.ts +2 -2
- package/src/drivers/download_blob.test.ts +4 -4
- package/dist/index.cjs +0 -2
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4627 @@
|
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var xe = (s, e, t) => e in s ? ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var d = (s, e, t) => xe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import * as w from "node:fs/promises";
|
|
5
|
+
import { addRTypeToMetadata as T, valErr as Me, getField as He, isNullResourceId as je, bigintToResourceId as Q, stringifyWithResourceId as B, isNotNullResourceId as Ge } from "@milaboratories/pl-client";
|
|
6
|
+
import { ServiceType as v, 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 ge } from "@protobuf-ts/runtime";
|
|
8
|
+
import { request as fe } from "undici";
|
|
9
|
+
import { notEmpty as O, mapGet as oe, mapEntries as Ve, TaskProcessor as X, CallersCounter as D, asyncPool as Y, assertNever as qe } from "@milaboratories/ts-helpers";
|
|
10
|
+
import { Readable as K, Writable as ee, Transform as Ze } from "node:stream";
|
|
11
|
+
import * as E from "node:fs";
|
|
12
|
+
import * as m from "node:path";
|
|
13
|
+
import { Computable as b, ChangeSource as S, PollingComputableHooks as me } from "@milaboratories/computable";
|
|
14
|
+
import { scheduler as te } from "node:timers/promises";
|
|
15
|
+
import * as Je from "node:readline/promises";
|
|
16
|
+
import Qe from "denque";
|
|
17
|
+
import * as se from "node:os";
|
|
18
|
+
import { randomUUID as k, createHash as Xe } from "node:crypto";
|
|
19
|
+
import { buffer as we } from "node:stream/consumers";
|
|
20
|
+
import { rsSchema as ye, treeEntryToResourceInfo as N, isPlTreeEntry as be, makeResourceSnapshot as Te } from "@milaboratories/pl-tree";
|
|
21
|
+
import { z as L } from "zod";
|
|
22
|
+
import * as Ye from "node:zlib";
|
|
23
|
+
import * as Ke from "tar-fs";
|
|
24
|
+
class et extends g {
|
|
25
|
+
constructor() {
|
|
26
|
+
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
27
|
+
}
|
|
28
|
+
create(e) {
|
|
29
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
30
|
+
return e !== void 0 && f(this, t, e), t;
|
|
31
|
+
}
|
|
32
|
+
internalBinaryRead(e, t, n, r) {
|
|
33
|
+
return r ?? this.create();
|
|
34
|
+
}
|
|
35
|
+
internalBinaryWrite(e, t, n) {
|
|
36
|
+
let r = n.writeUnknownFields;
|
|
37
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
38
|
+
this.typeName,
|
|
39
|
+
e,
|
|
40
|
+
t
|
|
41
|
+
), t;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
new et();
|
|
45
|
+
class tt extends g {
|
|
46
|
+
constructor() {
|
|
47
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
48
|
+
}
|
|
49
|
+
create(e) {
|
|
50
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
51
|
+
return e !== void 0 && f(this, t, e), t;
|
|
52
|
+
}
|
|
53
|
+
internalBinaryRead(e, t, n, r) {
|
|
54
|
+
return r ?? this.create();
|
|
55
|
+
}
|
|
56
|
+
internalBinaryWrite(e, t, n) {
|
|
57
|
+
let r = n.writeUnknownFields;
|
|
58
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
59
|
+
this.typeName,
|
|
60
|
+
e,
|
|
61
|
+
t
|
|
62
|
+
), t;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
new tt();
|
|
66
|
+
class rt extends g {
|
|
67
|
+
constructor() {
|
|
68
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
69
|
+
{
|
|
70
|
+
no: 1,
|
|
71
|
+
name: "resource_id",
|
|
72
|
+
kind: "scalar",
|
|
73
|
+
T: 4,
|
|
74
|
+
L: 0
|
|
75
|
+
/*LongType.BIGINT*/
|
|
76
|
+
}
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
create(e) {
|
|
80
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
81
|
+
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
82
|
+
}
|
|
83
|
+
internalBinaryRead(e, t, n, r) {
|
|
84
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
85
|
+
for (; e.pos < c; ) {
|
|
86
|
+
let [i, l] = e.tag();
|
|
87
|
+
switch (i) {
|
|
88
|
+
case /* uint64 resource_id */
|
|
89
|
+
1:
|
|
90
|
+
o.resourceId = e.uint64().toBigInt();
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
let a = n.readUnknownField;
|
|
94
|
+
if (a === "throw")
|
|
95
|
+
throw new globalThis.Error(
|
|
96
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
97
|
+
);
|
|
98
|
+
let p = e.skip(l);
|
|
99
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
100
|
+
this.typeName,
|
|
101
|
+
o,
|
|
102
|
+
i,
|
|
103
|
+
l,
|
|
104
|
+
p
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return o;
|
|
109
|
+
}
|
|
110
|
+
internalBinaryWrite(e, t, n) {
|
|
111
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId);
|
|
112
|
+
let r = n.writeUnknownFields;
|
|
113
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
114
|
+
this.typeName,
|
|
115
|
+
e,
|
|
116
|
+
t
|
|
117
|
+
), t;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const nt = new rt();
|
|
121
|
+
class ot extends g {
|
|
122
|
+
constructor() {
|
|
123
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
124
|
+
{
|
|
125
|
+
no: 1,
|
|
126
|
+
name: "parts_count",
|
|
127
|
+
kind: "scalar",
|
|
128
|
+
T: 4,
|
|
129
|
+
L: 0
|
|
130
|
+
/*LongType.BIGINT*/
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
no: 2,
|
|
134
|
+
name: "uploaded_parts",
|
|
135
|
+
kind: "scalar",
|
|
136
|
+
repeat: 1,
|
|
137
|
+
T: 4,
|
|
138
|
+
L: 0
|
|
139
|
+
/*LongType.BIGINT*/
|
|
140
|
+
}
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
create(e) {
|
|
144
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
145
|
+
return t.partsCount = 0n, t.uploadedParts = [], e !== void 0 && f(this, t, e), t;
|
|
146
|
+
}
|
|
147
|
+
internalBinaryRead(e, t, n, r) {
|
|
148
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
149
|
+
for (; e.pos < c; ) {
|
|
150
|
+
let [i, l] = e.tag();
|
|
151
|
+
switch (i) {
|
|
152
|
+
case /* uint64 parts_count */
|
|
153
|
+
1:
|
|
154
|
+
o.partsCount = e.uint64().toBigInt();
|
|
155
|
+
break;
|
|
156
|
+
case /* repeated uint64 uploaded_parts */
|
|
157
|
+
2:
|
|
158
|
+
if (l === h.LengthDelimited)
|
|
159
|
+
for (let P = e.int32() + e.pos; e.pos < P; )
|
|
160
|
+
o.uploadedParts.push(e.uint64().toBigInt());
|
|
161
|
+
else o.uploadedParts.push(e.uint64().toBigInt());
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
let a = n.readUnknownField;
|
|
165
|
+
if (a === "throw")
|
|
166
|
+
throw new globalThis.Error(
|
|
167
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
168
|
+
);
|
|
169
|
+
let p = e.skip(l);
|
|
170
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
171
|
+
this.typeName,
|
|
172
|
+
o,
|
|
173
|
+
i,
|
|
174
|
+
l,
|
|
175
|
+
p
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return o;
|
|
180
|
+
}
|
|
181
|
+
internalBinaryWrite(e, t, n) {
|
|
182
|
+
if (e.partsCount !== 0n && t.tag(1, h.Varint).uint64(e.partsCount), e.uploadedParts.length) {
|
|
183
|
+
t.tag(2, h.LengthDelimited).fork();
|
|
184
|
+
for (let o = 0; o < e.uploadedParts.length; o++)
|
|
185
|
+
t.uint64(e.uploadedParts[o]);
|
|
186
|
+
t.join();
|
|
187
|
+
}
|
|
188
|
+
let r = n.writeUnknownFields;
|
|
189
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
190
|
+
this.typeName,
|
|
191
|
+
e,
|
|
192
|
+
t
|
|
193
|
+
), t;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const st = new ot();
|
|
197
|
+
class it extends g {
|
|
198
|
+
constructor() {
|
|
199
|
+
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
200
|
+
}
|
|
201
|
+
create(e) {
|
|
202
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
203
|
+
return e !== void 0 && f(this, t, e), t;
|
|
204
|
+
}
|
|
205
|
+
internalBinaryRead(e, t, n, r) {
|
|
206
|
+
return r ?? this.create();
|
|
207
|
+
}
|
|
208
|
+
internalBinaryWrite(e, t, n) {
|
|
209
|
+
let r = n.writeUnknownFields;
|
|
210
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
211
|
+
this.typeName,
|
|
212
|
+
e,
|
|
213
|
+
t
|
|
214
|
+
), t;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
new it();
|
|
218
|
+
class at extends g {
|
|
219
|
+
constructor() {
|
|
220
|
+
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
221
|
+
{
|
|
222
|
+
no: 1,
|
|
223
|
+
name: "resource_id",
|
|
224
|
+
kind: "scalar",
|
|
225
|
+
T: 4,
|
|
226
|
+
L: 0
|
|
227
|
+
/*LongType.BIGINT*/
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
no: 2,
|
|
231
|
+
name: "bytes_processed",
|
|
232
|
+
kind: "scalar",
|
|
233
|
+
T: 3,
|
|
234
|
+
L: 0
|
|
235
|
+
/*LongType.BIGINT*/
|
|
236
|
+
}
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
create(e) {
|
|
240
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
241
|
+
return t.resourceId = 0n, t.bytesProcessed = 0n, e !== void 0 && f(
|
|
242
|
+
this,
|
|
243
|
+
t,
|
|
244
|
+
e
|
|
245
|
+
), t;
|
|
246
|
+
}
|
|
247
|
+
internalBinaryRead(e, t, n, r) {
|
|
248
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
249
|
+
for (; e.pos < c; ) {
|
|
250
|
+
let [i, l] = e.tag();
|
|
251
|
+
switch (i) {
|
|
252
|
+
case /* uint64 resource_id */
|
|
253
|
+
1:
|
|
254
|
+
o.resourceId = e.uint64().toBigInt();
|
|
255
|
+
break;
|
|
256
|
+
case /* int64 bytes_processed */
|
|
257
|
+
2:
|
|
258
|
+
o.bytesProcessed = e.int64().toBigInt();
|
|
259
|
+
break;
|
|
260
|
+
default:
|
|
261
|
+
let a = n.readUnknownField;
|
|
262
|
+
if (a === "throw")
|
|
263
|
+
throw new globalThis.Error(
|
|
264
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
265
|
+
);
|
|
266
|
+
let p = e.skip(l);
|
|
267
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
268
|
+
this.typeName,
|
|
269
|
+
o,
|
|
270
|
+
i,
|
|
271
|
+
l,
|
|
272
|
+
p
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return o;
|
|
277
|
+
}
|
|
278
|
+
internalBinaryWrite(e, t, n) {
|
|
279
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.bytesProcessed !== 0n && t.tag(2, h.Varint).int64(e.bytesProcessed);
|
|
280
|
+
let r = n.writeUnknownFields;
|
|
281
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
282
|
+
this.typeName,
|
|
283
|
+
e,
|
|
284
|
+
t
|
|
285
|
+
), t;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const lt = new at();
|
|
289
|
+
class ct extends g {
|
|
290
|
+
constructor() {
|
|
291
|
+
super(
|
|
292
|
+
"MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
|
|
293
|
+
[]
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
create(e) {
|
|
297
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
298
|
+
return e !== void 0 && f(
|
|
299
|
+
this,
|
|
300
|
+
t,
|
|
301
|
+
e
|
|
302
|
+
), t;
|
|
303
|
+
}
|
|
304
|
+
internalBinaryRead(e, t, n, r) {
|
|
305
|
+
return r ?? this.create();
|
|
306
|
+
}
|
|
307
|
+
internalBinaryWrite(e, t, n) {
|
|
308
|
+
let r = n.writeUnknownFields;
|
|
309
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
310
|
+
this.typeName,
|
|
311
|
+
e,
|
|
312
|
+
t
|
|
313
|
+
), t;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const dt = new ct();
|
|
317
|
+
class ht extends g {
|
|
318
|
+
constructor() {
|
|
319
|
+
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
320
|
+
}
|
|
321
|
+
create(e) {
|
|
322
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
323
|
+
return e !== void 0 && f(this, t, e), t;
|
|
324
|
+
}
|
|
325
|
+
internalBinaryRead(e, t, n, r) {
|
|
326
|
+
return r ?? this.create();
|
|
327
|
+
}
|
|
328
|
+
internalBinaryWrite(e, t, n) {
|
|
329
|
+
let r = n.writeUnknownFields;
|
|
330
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
331
|
+
this.typeName,
|
|
332
|
+
e,
|
|
333
|
+
t
|
|
334
|
+
), t;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
new ht();
|
|
338
|
+
class ut extends g {
|
|
339
|
+
constructor() {
|
|
340
|
+
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
341
|
+
{
|
|
342
|
+
no: 1,
|
|
343
|
+
name: "resource_id",
|
|
344
|
+
kind: "scalar",
|
|
345
|
+
T: 4,
|
|
346
|
+
L: 0
|
|
347
|
+
/*LongType.BIGINT*/
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
no: 2,
|
|
351
|
+
name: "part_number",
|
|
352
|
+
kind: "scalar",
|
|
353
|
+
T: 4,
|
|
354
|
+
L: 0
|
|
355
|
+
/*LongType.BIGINT*/
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
no: 3,
|
|
359
|
+
name: "uploaded_part_size",
|
|
360
|
+
kind: "scalar",
|
|
361
|
+
T: 4,
|
|
362
|
+
L: 0
|
|
363
|
+
/*LongType.BIGINT*/
|
|
364
|
+
}
|
|
365
|
+
]);
|
|
366
|
+
}
|
|
367
|
+
create(e) {
|
|
368
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
369
|
+
return t.resourceId = 0n, t.partNumber = 0n, t.uploadedPartSize = 0n, e !== void 0 && f(
|
|
370
|
+
this,
|
|
371
|
+
t,
|
|
372
|
+
e
|
|
373
|
+
), t;
|
|
374
|
+
}
|
|
375
|
+
internalBinaryRead(e, t, n, r) {
|
|
376
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
377
|
+
for (; e.pos < c; ) {
|
|
378
|
+
let [i, l] = e.tag();
|
|
379
|
+
switch (i) {
|
|
380
|
+
case /* uint64 resource_id */
|
|
381
|
+
1:
|
|
382
|
+
o.resourceId = e.uint64().toBigInt();
|
|
383
|
+
break;
|
|
384
|
+
case /* uint64 part_number */
|
|
385
|
+
2:
|
|
386
|
+
o.partNumber = e.uint64().toBigInt();
|
|
387
|
+
break;
|
|
388
|
+
case /* uint64 uploaded_part_size */
|
|
389
|
+
3:
|
|
390
|
+
o.uploadedPartSize = e.uint64().toBigInt();
|
|
391
|
+
break;
|
|
392
|
+
default:
|
|
393
|
+
let a = n.readUnknownField;
|
|
394
|
+
if (a === "throw")
|
|
395
|
+
throw new globalThis.Error(
|
|
396
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
397
|
+
);
|
|
398
|
+
let p = e.skip(l);
|
|
399
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
400
|
+
this.typeName,
|
|
401
|
+
o,
|
|
402
|
+
i,
|
|
403
|
+
l,
|
|
404
|
+
p
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return o;
|
|
409
|
+
}
|
|
410
|
+
internalBinaryWrite(e, t, n) {
|
|
411
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.partNumber !== 0n && t.tag(2, h.Varint).uint64(e.partNumber), e.uploadedPartSize !== 0n && t.tag(3, h.Varint).uint64(e.uploadedPartSize);
|
|
412
|
+
let r = n.writeUnknownFields;
|
|
413
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
414
|
+
this.typeName,
|
|
415
|
+
e,
|
|
416
|
+
t
|
|
417
|
+
), t;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const pt = new ut();
|
|
421
|
+
class gt extends g {
|
|
422
|
+
constructor() {
|
|
423
|
+
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
424
|
+
{
|
|
425
|
+
no: 1,
|
|
426
|
+
name: "Name",
|
|
427
|
+
kind: "scalar",
|
|
428
|
+
jsonName: "Name",
|
|
429
|
+
T: 9
|
|
430
|
+
/*ScalarType.STRING*/
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
no: 2,
|
|
434
|
+
name: "Value",
|
|
435
|
+
kind: "scalar",
|
|
436
|
+
jsonName: "Value",
|
|
437
|
+
T: 9
|
|
438
|
+
/*ScalarType.STRING*/
|
|
439
|
+
}
|
|
440
|
+
]);
|
|
441
|
+
}
|
|
442
|
+
create(e) {
|
|
443
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
444
|
+
return t.name = "", t.value = "", e !== void 0 && f(
|
|
445
|
+
this,
|
|
446
|
+
t,
|
|
447
|
+
e
|
|
448
|
+
), t;
|
|
449
|
+
}
|
|
450
|
+
internalBinaryRead(e, t, n, r) {
|
|
451
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
452
|
+
for (; e.pos < c; ) {
|
|
453
|
+
let [i, l] = e.tag();
|
|
454
|
+
switch (i) {
|
|
455
|
+
case /* string Name = 1 [json_name = "Name"];*/
|
|
456
|
+
1:
|
|
457
|
+
o.name = e.string();
|
|
458
|
+
break;
|
|
459
|
+
case /* string Value = 2 [json_name = "Value"];*/
|
|
460
|
+
2:
|
|
461
|
+
o.value = e.string();
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
let a = n.readUnknownField;
|
|
465
|
+
if (a === "throw")
|
|
466
|
+
throw new globalThis.Error(
|
|
467
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
468
|
+
);
|
|
469
|
+
let p = e.skip(l);
|
|
470
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
471
|
+
this.typeName,
|
|
472
|
+
o,
|
|
473
|
+
i,
|
|
474
|
+
l,
|
|
475
|
+
p
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return o;
|
|
480
|
+
}
|
|
481
|
+
internalBinaryWrite(e, t, n) {
|
|
482
|
+
e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.value !== "" && t.tag(2, h.LengthDelimited).string(e.value);
|
|
483
|
+
let r = n.writeUnknownFields;
|
|
484
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
485
|
+
this.typeName,
|
|
486
|
+
e,
|
|
487
|
+
t
|
|
488
|
+
), t;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const F = new gt();
|
|
492
|
+
class ft extends g {
|
|
493
|
+
constructor() {
|
|
494
|
+
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
495
|
+
{
|
|
496
|
+
no: 1,
|
|
497
|
+
name: "upload_url",
|
|
498
|
+
kind: "scalar",
|
|
499
|
+
T: 9
|
|
500
|
+
/*ScalarType.STRING*/
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
no: 2,
|
|
504
|
+
name: "method",
|
|
505
|
+
kind: "scalar",
|
|
506
|
+
T: 9
|
|
507
|
+
/*ScalarType.STRING*/
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
no: 3,
|
|
511
|
+
name: "headers",
|
|
512
|
+
kind: "message",
|
|
513
|
+
repeat: 1,
|
|
514
|
+
T: () => F
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
no: 4,
|
|
518
|
+
name: "chunk_start",
|
|
519
|
+
kind: "scalar",
|
|
520
|
+
T: 4,
|
|
521
|
+
L: 0
|
|
522
|
+
/*LongType.BIGINT*/
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
no: 5,
|
|
526
|
+
name: "chunk_end",
|
|
527
|
+
kind: "scalar",
|
|
528
|
+
T: 4,
|
|
529
|
+
L: 0
|
|
530
|
+
/*LongType.BIGINT*/
|
|
531
|
+
}
|
|
532
|
+
]);
|
|
533
|
+
}
|
|
534
|
+
create(e) {
|
|
535
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
536
|
+
return t.uploadUrl = "", t.method = "", t.headers = [], t.chunkStart = 0n, t.chunkEnd = 0n, e !== void 0 && f(
|
|
537
|
+
this,
|
|
538
|
+
t,
|
|
539
|
+
e
|
|
540
|
+
), t;
|
|
541
|
+
}
|
|
542
|
+
internalBinaryRead(e, t, n, r) {
|
|
543
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
544
|
+
for (; e.pos < c; ) {
|
|
545
|
+
let [i, l] = e.tag();
|
|
546
|
+
switch (i) {
|
|
547
|
+
case /* string upload_url */
|
|
548
|
+
1:
|
|
549
|
+
o.uploadUrl = e.string();
|
|
550
|
+
break;
|
|
551
|
+
case /* string method */
|
|
552
|
+
2:
|
|
553
|
+
o.method = e.string();
|
|
554
|
+
break;
|
|
555
|
+
case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
|
|
556
|
+
3:
|
|
557
|
+
o.headers.push(
|
|
558
|
+
F.internalBinaryRead(
|
|
559
|
+
e,
|
|
560
|
+
e.uint32(),
|
|
561
|
+
n
|
|
562
|
+
)
|
|
563
|
+
);
|
|
564
|
+
break;
|
|
565
|
+
case /* uint64 chunk_start */
|
|
566
|
+
4:
|
|
567
|
+
o.chunkStart = e.uint64().toBigInt();
|
|
568
|
+
break;
|
|
569
|
+
case /* uint64 chunk_end */
|
|
570
|
+
5:
|
|
571
|
+
o.chunkEnd = e.uint64().toBigInt();
|
|
572
|
+
break;
|
|
573
|
+
default:
|
|
574
|
+
let a = n.readUnknownField;
|
|
575
|
+
if (a === "throw")
|
|
576
|
+
throw new globalThis.Error(
|
|
577
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
578
|
+
);
|
|
579
|
+
let p = e.skip(l);
|
|
580
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
581
|
+
this.typeName,
|
|
582
|
+
o,
|
|
583
|
+
i,
|
|
584
|
+
l,
|
|
585
|
+
p
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return o;
|
|
590
|
+
}
|
|
591
|
+
internalBinaryWrite(e, t, n) {
|
|
592
|
+
e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
|
|
593
|
+
for (let o = 0; o < e.headers.length; o++)
|
|
594
|
+
F.internalBinaryWrite(
|
|
595
|
+
e.headers[o],
|
|
596
|
+
t.tag(3, h.LengthDelimited).fork(),
|
|
597
|
+
n
|
|
598
|
+
).join();
|
|
599
|
+
e.chunkStart !== 0n && t.tag(4, h.Varint).uint64(e.chunkStart), e.chunkEnd !== 0n && t.tag(5, h.Varint).uint64(e.chunkEnd);
|
|
600
|
+
let r = n.writeUnknownFields;
|
|
601
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
602
|
+
this.typeName,
|
|
603
|
+
e,
|
|
604
|
+
t
|
|
605
|
+
), t;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const mt = new ft();
|
|
609
|
+
class wt extends g {
|
|
610
|
+
constructor() {
|
|
611
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
612
|
+
}
|
|
613
|
+
create(e) {
|
|
614
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
615
|
+
return e !== void 0 && f(this, t, e), t;
|
|
616
|
+
}
|
|
617
|
+
internalBinaryRead(e, t, n, r) {
|
|
618
|
+
return r ?? this.create();
|
|
619
|
+
}
|
|
620
|
+
internalBinaryWrite(e, t, n) {
|
|
621
|
+
let r = n.writeUnknownFields;
|
|
622
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
623
|
+
this.typeName,
|
|
624
|
+
e,
|
|
625
|
+
t
|
|
626
|
+
), t;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
new wt();
|
|
630
|
+
class yt extends g {
|
|
631
|
+
constructor() {
|
|
632
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
633
|
+
{
|
|
634
|
+
no: 1,
|
|
635
|
+
name: "resource_id",
|
|
636
|
+
kind: "scalar",
|
|
637
|
+
T: 4,
|
|
638
|
+
L: 0
|
|
639
|
+
/*LongType.BIGINT*/
|
|
640
|
+
}
|
|
641
|
+
]);
|
|
642
|
+
}
|
|
643
|
+
create(e) {
|
|
644
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
645
|
+
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
646
|
+
}
|
|
647
|
+
internalBinaryRead(e, t, n, r) {
|
|
648
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
649
|
+
for (; e.pos < c; ) {
|
|
650
|
+
let [i, l] = e.tag();
|
|
651
|
+
switch (i) {
|
|
652
|
+
case /* uint64 resource_id */
|
|
653
|
+
1:
|
|
654
|
+
o.resourceId = e.uint64().toBigInt();
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
let a = n.readUnknownField;
|
|
658
|
+
if (a === "throw")
|
|
659
|
+
throw new globalThis.Error(
|
|
660
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
661
|
+
);
|
|
662
|
+
let p = e.skip(l);
|
|
663
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
664
|
+
this.typeName,
|
|
665
|
+
o,
|
|
666
|
+
i,
|
|
667
|
+
l,
|
|
668
|
+
p
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return o;
|
|
673
|
+
}
|
|
674
|
+
internalBinaryWrite(e, t, n) {
|
|
675
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId);
|
|
676
|
+
let r = n.writeUnknownFields;
|
|
677
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
678
|
+
this.typeName,
|
|
679
|
+
e,
|
|
680
|
+
t
|
|
681
|
+
), t;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const bt = new yt();
|
|
685
|
+
class Tt extends g {
|
|
686
|
+
constructor() {
|
|
687
|
+
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
688
|
+
}
|
|
689
|
+
create(e) {
|
|
690
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
691
|
+
return e !== void 0 && f(this, t, e), t;
|
|
692
|
+
}
|
|
693
|
+
internalBinaryRead(e, t, n, r) {
|
|
694
|
+
return r ?? this.create();
|
|
695
|
+
}
|
|
696
|
+
internalBinaryWrite(e, t, n) {
|
|
697
|
+
let r = n.writeUnknownFields;
|
|
698
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
699
|
+
this.typeName,
|
|
700
|
+
e,
|
|
701
|
+
t
|
|
702
|
+
), t;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const kt = new Tt(), W = new v(
|
|
706
|
+
"MiLaboratories.Controller.Shared.Upload",
|
|
707
|
+
[
|
|
708
|
+
{
|
|
709
|
+
name: "Init",
|
|
710
|
+
options: {},
|
|
711
|
+
I: nt,
|
|
712
|
+
O: st
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: "GetPartURL",
|
|
716
|
+
options: {},
|
|
717
|
+
I: pt,
|
|
718
|
+
O: mt
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
name: "UpdateProgress",
|
|
722
|
+
options: {},
|
|
723
|
+
I: lt,
|
|
724
|
+
O: dt
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
name: "Finalize",
|
|
728
|
+
options: {},
|
|
729
|
+
I: bt,
|
|
730
|
+
O: kt
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
);
|
|
734
|
+
class Lt {
|
|
735
|
+
constructor(e) {
|
|
736
|
+
d(this, "typeName", W.typeName);
|
|
737
|
+
d(this, "methods", W.methods);
|
|
738
|
+
d(this, "options", W.options);
|
|
739
|
+
this._transport = e;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
*
|
|
743
|
+
* Init upload, making controller to do all required preparation steps.
|
|
744
|
+
*
|
|
745
|
+
*
|
|
746
|
+
* @generated from protobuf rpc: Init(MiLaboratories.Controller.Shared.uploadapi.Init.Request) returns (MiLaboratories.Controller.Shared.uploadapi.Init.Response);
|
|
747
|
+
*/
|
|
748
|
+
init(e, t) {
|
|
749
|
+
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
750
|
+
return y(
|
|
751
|
+
"unary",
|
|
752
|
+
this._transport,
|
|
753
|
+
n,
|
|
754
|
+
r,
|
|
755
|
+
e
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
*
|
|
760
|
+
* GetPartURL provides URL for uploading chunk of the data.
|
|
761
|
+
* Clients are expected to put their data directly to the given location.
|
|
762
|
+
*
|
|
763
|
+
*
|
|
764
|
+
* @generated from protobuf rpc: GetPartURL(MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request) returns (MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response);
|
|
765
|
+
*/
|
|
766
|
+
getPartURL(e, t) {
|
|
767
|
+
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
768
|
+
return y("unary", this._transport, n, r, e);
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
*
|
|
772
|
+
* UpdateProgress of the upload, so other clients can see how it is going.
|
|
773
|
+
*
|
|
774
|
+
*
|
|
775
|
+
* @generated from protobuf rpc: UpdateProgress(MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request) returns (MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response);
|
|
776
|
+
*/
|
|
777
|
+
updateProgress(e, t) {
|
|
778
|
+
const n = this.methods[2], r = this._transport.mergeOptions(t);
|
|
779
|
+
return y("unary", this._transport, n, r, e);
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
*
|
|
783
|
+
* Finalize informs Controller that the upload process is done.
|
|
784
|
+
* Returns an error, if the total size of all uploaded chunks is not equal to
|
|
785
|
+
* size of the upload given in Init.
|
|
786
|
+
*
|
|
787
|
+
*
|
|
788
|
+
* @generated from protobuf rpc: Finalize(MiLaboratories.Controller.Shared.uploadapi.Finalize.Request) returns (MiLaboratories.Controller.Shared.uploadapi.Finalize.Response);
|
|
789
|
+
*/
|
|
790
|
+
finalize(e, t) {
|
|
791
|
+
const n = this.methods[3], r = this._transport.mergeOptions(t);
|
|
792
|
+
return y("unary", this._transport, n, r, e);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
class ke extends Error {
|
|
796
|
+
}
|
|
797
|
+
class Le extends Error {
|
|
798
|
+
}
|
|
799
|
+
class Pt extends Error {
|
|
800
|
+
}
|
|
801
|
+
class Pe extends Error {
|
|
802
|
+
}
|
|
803
|
+
class It {
|
|
804
|
+
constructor(e, t, n, r) {
|
|
805
|
+
d(this, "grpcClient");
|
|
806
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = r, this.grpcClient = new Lt(this.grpcTransport);
|
|
807
|
+
}
|
|
808
|
+
close() {
|
|
809
|
+
}
|
|
810
|
+
async initUpload({ id: e, type: t }, n) {
|
|
811
|
+
const r = await this.grpcClient.init(
|
|
812
|
+
{ resourceId: e },
|
|
813
|
+
T(t, n)
|
|
814
|
+
);
|
|
815
|
+
return this.partsToUpload(r.response);
|
|
816
|
+
}
|
|
817
|
+
async partUpload({ id: e, type: t }, n, r, o, c, i) {
|
|
818
|
+
const l = await this.grpcClient.getPartURL(
|
|
819
|
+
{
|
|
820
|
+
resourceId: e,
|
|
821
|
+
partNumber: r,
|
|
822
|
+
uploadedPartSize: 0n
|
|
823
|
+
// we update progress as a separate call later.
|
|
824
|
+
},
|
|
825
|
+
T(t, i)
|
|
826
|
+
).response, { chunk: a, mTime: p } = await this.readChunk(
|
|
827
|
+
n,
|
|
828
|
+
l.chunkStart,
|
|
829
|
+
l.chunkEnd
|
|
830
|
+
);
|
|
831
|
+
if (p > c)
|
|
832
|
+
throw new ke(
|
|
833
|
+
"file was modified, expected mtime: " + c + ", got: " + p + "."
|
|
834
|
+
);
|
|
835
|
+
const P = await fe(
|
|
836
|
+
l.uploadUrl,
|
|
837
|
+
this.prepareUploadOpts(l, a)
|
|
838
|
+
), ne = await (await P.body.blob()).text();
|
|
839
|
+
if (this.logger.info(
|
|
840
|
+
`uploaded chunk ${r} from ${o} of resource: ${e}, response: '${ne.toString()}', status code: ${P.statusCode}`
|
|
841
|
+
), P.statusCode != 200)
|
|
842
|
+
throw new Pt(
|
|
843
|
+
`response is not ok, status code: ${P.statusCode}, body: ${ne}, headers: ${P.headers}, url: ${l.uploadUrl}`
|
|
844
|
+
);
|
|
845
|
+
await this.grpcClient.updateProgress(
|
|
846
|
+
{
|
|
847
|
+
resourceId: e,
|
|
848
|
+
bytesProcessed: l.chunkEnd - l.chunkStart
|
|
849
|
+
},
|
|
850
|
+
T(t, i)
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
async finalizeUpload({ id: e, type: t }, n) {
|
|
854
|
+
return await this.grpcClient.finalize(
|
|
855
|
+
{ resourceId: e },
|
|
856
|
+
T(t, n)
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
async readChunk(e, t, n) {
|
|
860
|
+
let r;
|
|
861
|
+
try {
|
|
862
|
+
r = await w.open(e);
|
|
863
|
+
const o = Number(n - t), c = Number(t), i = Buffer.alloc(o), l = await this.readBytesFromPosition(r, i, o, c), a = await w.stat(e);
|
|
864
|
+
return {
|
|
865
|
+
chunk: i.subarray(0, l),
|
|
866
|
+
mTime: BigInt(Math.floor(a.mtimeMs / 1e3))
|
|
867
|
+
};
|
|
868
|
+
} catch (o) {
|
|
869
|
+
throw o.code == "ENOENT" ? new Pe(`there is no file ${e} for uploading`) : o;
|
|
870
|
+
} finally {
|
|
871
|
+
r == null || r.close();
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
/** Read len bytes from a given position. The reason the method exists
|
|
875
|
+
is that FileHandle.read can read less bytes than it's needed. */
|
|
876
|
+
async readBytesFromPosition(e, t, n, r) {
|
|
877
|
+
let o = 0;
|
|
878
|
+
for (; o < n; ) {
|
|
879
|
+
const { bytesRead: c } = await e.read(
|
|
880
|
+
t,
|
|
881
|
+
o,
|
|
882
|
+
n - o,
|
|
883
|
+
r + o
|
|
884
|
+
);
|
|
885
|
+
if (c === 0)
|
|
886
|
+
throw new Le("file ended earlier than expected.");
|
|
887
|
+
o += c;
|
|
888
|
+
}
|
|
889
|
+
return o;
|
|
890
|
+
}
|
|
891
|
+
/** Calculates parts that need to be uploaded from the parts that were
|
|
892
|
+
* already uploaded. */
|
|
893
|
+
partsToUpload(e) {
|
|
894
|
+
const t = [], n = new Set(e.uploadedParts);
|
|
895
|
+
for (let r = 1n; r <= e.partsCount; r++)
|
|
896
|
+
n.has(r) || t.push(r);
|
|
897
|
+
return t;
|
|
898
|
+
}
|
|
899
|
+
prepareUploadOpts(e, t) {
|
|
900
|
+
const n = e.headers.map(({ name: r, value: o }) => [r, o]);
|
|
901
|
+
return {
|
|
902
|
+
dispatcher: this.httpClient,
|
|
903
|
+
body: t,
|
|
904
|
+
headers: Object.fromEntries(n),
|
|
905
|
+
method: e.method.toUpperCase()
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
class Nt extends g {
|
|
910
|
+
constructor() {
|
|
911
|
+
super("google.protobuf.Duration", [
|
|
912
|
+
{
|
|
913
|
+
no: 1,
|
|
914
|
+
name: "seconds",
|
|
915
|
+
kind: "scalar",
|
|
916
|
+
T: 3,
|
|
917
|
+
L: 0
|
|
918
|
+
/*LongType.BIGINT*/
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
no: 2,
|
|
922
|
+
name: "nanos",
|
|
923
|
+
kind: "scalar",
|
|
924
|
+
T: 5
|
|
925
|
+
/*ScalarType.INT32*/
|
|
926
|
+
}
|
|
927
|
+
]);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Encode `Duration` to JSON string like "3.000001s".
|
|
931
|
+
*/
|
|
932
|
+
internalJsonWrite(e, t) {
|
|
933
|
+
let n = I.from(e.seconds).toNumber();
|
|
934
|
+
if (n > 315576e6 || n < -315576e6)
|
|
935
|
+
throw new Error("Duration value out of range.");
|
|
936
|
+
let r = e.seconds.toString();
|
|
937
|
+
if (n === 0 && e.nanos < 0 && (r = "-" + r), e.nanos !== 0) {
|
|
938
|
+
let o = Math.abs(e.nanos).toString();
|
|
939
|
+
o = "0".repeat(9 - o.length) + o, o.substring(3) === "000000" ? o = o.substring(0, 3) : o.substring(6) === "000" && (o = o.substring(0, 6)), r += "." + o;
|
|
940
|
+
}
|
|
941
|
+
return r + "s";
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Decode `Duration` from JSON string like "3.000001s"
|
|
945
|
+
*/
|
|
946
|
+
internalJsonRead(e, t, n) {
|
|
947
|
+
if (typeof e != "string")
|
|
948
|
+
throw new Error(
|
|
949
|
+
"Unable to parse Duration from JSON " + ge(e) + ". Expected string."
|
|
950
|
+
);
|
|
951
|
+
let r = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
|
|
952
|
+
if (r === null)
|
|
953
|
+
throw new Error(
|
|
954
|
+
"Unable to parse Duration from JSON string. Invalid format."
|
|
955
|
+
);
|
|
956
|
+
n || (n = this.create());
|
|
957
|
+
let [, o, c, i] = r, l = I.from(o + c);
|
|
958
|
+
if (l.toNumber() > 315576e6 || l.toNumber() < -315576e6)
|
|
959
|
+
throw new Error(
|
|
960
|
+
"Unable to parse Duration from JSON string. Value out of range."
|
|
961
|
+
);
|
|
962
|
+
if (n.seconds = l.toBigInt(), typeof i == "string") {
|
|
963
|
+
let a = o + i + "0".repeat(9 - i.length);
|
|
964
|
+
n.nanos = parseInt(a);
|
|
965
|
+
}
|
|
966
|
+
return n;
|
|
967
|
+
}
|
|
968
|
+
create(e) {
|
|
969
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
970
|
+
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
971
|
+
}
|
|
972
|
+
internalBinaryRead(e, t, n, r) {
|
|
973
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
974
|
+
for (; e.pos < c; ) {
|
|
975
|
+
let [i, l] = e.tag();
|
|
976
|
+
switch (i) {
|
|
977
|
+
case /* int64 seconds */
|
|
978
|
+
1:
|
|
979
|
+
o.seconds = e.int64().toBigInt();
|
|
980
|
+
break;
|
|
981
|
+
case /* int32 nanos */
|
|
982
|
+
2:
|
|
983
|
+
o.nanos = e.int32();
|
|
984
|
+
break;
|
|
985
|
+
default:
|
|
986
|
+
let a = n.readUnknownField;
|
|
987
|
+
if (a === "throw")
|
|
988
|
+
throw new globalThis.Error(
|
|
989
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
990
|
+
);
|
|
991
|
+
let p = e.skip(l);
|
|
992
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
993
|
+
this.typeName,
|
|
994
|
+
o,
|
|
995
|
+
i,
|
|
996
|
+
l,
|
|
997
|
+
p
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return o;
|
|
1002
|
+
}
|
|
1003
|
+
internalBinaryWrite(e, t, n) {
|
|
1004
|
+
e.seconds !== 0n && t.tag(1, h.Varint).int64(e.seconds), e.nanos !== 0 && t.tag(2, h.Varint).int32(e.nanos);
|
|
1005
|
+
let r = n.writeUnknownFields;
|
|
1006
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1007
|
+
this.typeName,
|
|
1008
|
+
e,
|
|
1009
|
+
t
|
|
1010
|
+
), t;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
const _ = new Nt();
|
|
1014
|
+
class Rt extends g {
|
|
1015
|
+
constructor() {
|
|
1016
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
1017
|
+
}
|
|
1018
|
+
create(e) {
|
|
1019
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1020
|
+
return e !== void 0 && f(this, t, e), t;
|
|
1021
|
+
}
|
|
1022
|
+
internalBinaryRead(e, t, n, r) {
|
|
1023
|
+
return r ?? this.create();
|
|
1024
|
+
}
|
|
1025
|
+
internalBinaryWrite(e, t, n) {
|
|
1026
|
+
let r = n.writeUnknownFields;
|
|
1027
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1028
|
+
this.typeName,
|
|
1029
|
+
e,
|
|
1030
|
+
t
|
|
1031
|
+
), t;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
new Rt();
|
|
1035
|
+
class St extends g {
|
|
1036
|
+
constructor() {
|
|
1037
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
1038
|
+
{
|
|
1039
|
+
no: 1,
|
|
1040
|
+
name: "progress",
|
|
1041
|
+
kind: "scalar",
|
|
1042
|
+
T: 2
|
|
1043
|
+
/*ScalarType.FLOAT*/
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
no: 2,
|
|
1047
|
+
name: "bytes_processed",
|
|
1048
|
+
kind: "scalar",
|
|
1049
|
+
T: 4,
|
|
1050
|
+
L: 0
|
|
1051
|
+
/*LongType.BIGINT*/
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
no: 3,
|
|
1055
|
+
name: "bytes_total",
|
|
1056
|
+
kind: "scalar",
|
|
1057
|
+
T: 4,
|
|
1058
|
+
L: 0
|
|
1059
|
+
/*LongType.BIGINT*/
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
no: 4,
|
|
1063
|
+
name: "done",
|
|
1064
|
+
kind: "scalar",
|
|
1065
|
+
T: 8
|
|
1066
|
+
/*ScalarType.BOOL*/
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
no: 5,
|
|
1070
|
+
name: "name",
|
|
1071
|
+
kind: "scalar",
|
|
1072
|
+
T: 9
|
|
1073
|
+
/*ScalarType.STRING*/
|
|
1074
|
+
}
|
|
1075
|
+
]);
|
|
1076
|
+
}
|
|
1077
|
+
create(e) {
|
|
1078
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1079
|
+
return t.progress = 0, t.bytesProcessed = 0n, t.bytesTotal = 0n, t.done = !1, t.name = "", e !== void 0 && f(this, t, e), t;
|
|
1080
|
+
}
|
|
1081
|
+
internalBinaryRead(e, t, n, r) {
|
|
1082
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1083
|
+
for (; e.pos < c; ) {
|
|
1084
|
+
let [i, l] = e.tag();
|
|
1085
|
+
switch (i) {
|
|
1086
|
+
case /* float progress */
|
|
1087
|
+
1:
|
|
1088
|
+
o.progress = e.float();
|
|
1089
|
+
break;
|
|
1090
|
+
case /* uint64 bytes_processed */
|
|
1091
|
+
2:
|
|
1092
|
+
o.bytesProcessed = e.uint64().toBigInt();
|
|
1093
|
+
break;
|
|
1094
|
+
case /* uint64 bytes_total */
|
|
1095
|
+
3:
|
|
1096
|
+
o.bytesTotal = e.uint64().toBigInt();
|
|
1097
|
+
break;
|
|
1098
|
+
case /* bool done */
|
|
1099
|
+
4:
|
|
1100
|
+
o.done = e.bool();
|
|
1101
|
+
break;
|
|
1102
|
+
case /* string name */
|
|
1103
|
+
5:
|
|
1104
|
+
o.name = e.string();
|
|
1105
|
+
break;
|
|
1106
|
+
default:
|
|
1107
|
+
let a = n.readUnknownField;
|
|
1108
|
+
if (a === "throw")
|
|
1109
|
+
throw new globalThis.Error(
|
|
1110
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1111
|
+
);
|
|
1112
|
+
let p = e.skip(l);
|
|
1113
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1114
|
+
this.typeName,
|
|
1115
|
+
o,
|
|
1116
|
+
i,
|
|
1117
|
+
l,
|
|
1118
|
+
p
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return o;
|
|
1123
|
+
}
|
|
1124
|
+
internalBinaryWrite(e, t, n) {
|
|
1125
|
+
e.progress !== 0 && t.tag(1, h.Bit32).float(e.progress), e.bytesProcessed !== 0n && t.tag(2, h.Varint).uint64(e.bytesProcessed), e.bytesTotal !== 0n && t.tag(3, h.Varint).uint64(e.bytesTotal), e.done !== !1 && t.tag(4, h.Varint).bool(e.done), e.name !== "" && t.tag(5, h.LengthDelimited).string(e.name);
|
|
1126
|
+
let r = n.writeUnknownFields;
|
|
1127
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1128
|
+
this.typeName,
|
|
1129
|
+
e,
|
|
1130
|
+
t
|
|
1131
|
+
), t;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
const R = new St();
|
|
1135
|
+
class Ut extends g {
|
|
1136
|
+
constructor() {
|
|
1137
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1138
|
+
}
|
|
1139
|
+
create(e) {
|
|
1140
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1141
|
+
return e !== void 0 && f(this, t, e), t;
|
|
1142
|
+
}
|
|
1143
|
+
internalBinaryRead(e, t, n, r) {
|
|
1144
|
+
return r ?? this.create();
|
|
1145
|
+
}
|
|
1146
|
+
internalBinaryWrite(e, t, n) {
|
|
1147
|
+
let r = n.writeUnknownFields;
|
|
1148
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1149
|
+
this.typeName,
|
|
1150
|
+
e,
|
|
1151
|
+
t
|
|
1152
|
+
), t;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
new Ut();
|
|
1156
|
+
class Bt extends g {
|
|
1157
|
+
constructor() {
|
|
1158
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1159
|
+
{
|
|
1160
|
+
no: 1,
|
|
1161
|
+
name: "resource_id",
|
|
1162
|
+
kind: "scalar",
|
|
1163
|
+
T: 4,
|
|
1164
|
+
L: 0
|
|
1165
|
+
/*LongType.BIGINT*/
|
|
1166
|
+
}
|
|
1167
|
+
]);
|
|
1168
|
+
}
|
|
1169
|
+
create(e) {
|
|
1170
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1171
|
+
return t.resourceId = 0n, e !== void 0 && f(
|
|
1172
|
+
this,
|
|
1173
|
+
t,
|
|
1174
|
+
e
|
|
1175
|
+
), t;
|
|
1176
|
+
}
|
|
1177
|
+
internalBinaryRead(e, t, n, r) {
|
|
1178
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1179
|
+
for (; e.pos < c; ) {
|
|
1180
|
+
let [i, l] = e.tag();
|
|
1181
|
+
switch (i) {
|
|
1182
|
+
case /* uint64 resource_id */
|
|
1183
|
+
1:
|
|
1184
|
+
o.resourceId = e.uint64().toBigInt();
|
|
1185
|
+
break;
|
|
1186
|
+
default:
|
|
1187
|
+
let a = n.readUnknownField;
|
|
1188
|
+
if (a === "throw")
|
|
1189
|
+
throw new globalThis.Error(
|
|
1190
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1191
|
+
);
|
|
1192
|
+
let p = e.skip(l);
|
|
1193
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1194
|
+
this.typeName,
|
|
1195
|
+
o,
|
|
1196
|
+
i,
|
|
1197
|
+
l,
|
|
1198
|
+
p
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
return o;
|
|
1203
|
+
}
|
|
1204
|
+
internalBinaryWrite(e, t, n) {
|
|
1205
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId);
|
|
1206
|
+
let r = n.writeUnknownFields;
|
|
1207
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1208
|
+
this.typeName,
|
|
1209
|
+
e,
|
|
1210
|
+
t
|
|
1211
|
+
), t;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
const vt = new Bt();
|
|
1215
|
+
class Dt extends g {
|
|
1216
|
+
constructor() {
|
|
1217
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1218
|
+
{ no: 1, name: "report", kind: "message", T: () => R }
|
|
1219
|
+
]);
|
|
1220
|
+
}
|
|
1221
|
+
create(e) {
|
|
1222
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1223
|
+
return e !== void 0 && f(
|
|
1224
|
+
this,
|
|
1225
|
+
t,
|
|
1226
|
+
e
|
|
1227
|
+
), t;
|
|
1228
|
+
}
|
|
1229
|
+
internalBinaryRead(e, t, n, r) {
|
|
1230
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1231
|
+
for (; e.pos < c; ) {
|
|
1232
|
+
let [i, l] = e.tag();
|
|
1233
|
+
switch (i) {
|
|
1234
|
+
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1235
|
+
1:
|
|
1236
|
+
o.report = R.internalBinaryRead(
|
|
1237
|
+
e,
|
|
1238
|
+
e.uint32(),
|
|
1239
|
+
n,
|
|
1240
|
+
o.report
|
|
1241
|
+
);
|
|
1242
|
+
break;
|
|
1243
|
+
default:
|
|
1244
|
+
let a = n.readUnknownField;
|
|
1245
|
+
if (a === "throw")
|
|
1246
|
+
throw new globalThis.Error(
|
|
1247
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1248
|
+
);
|
|
1249
|
+
let p = e.skip(l);
|
|
1250
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1251
|
+
this.typeName,
|
|
1252
|
+
o,
|
|
1253
|
+
i,
|
|
1254
|
+
l,
|
|
1255
|
+
p
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return o;
|
|
1260
|
+
}
|
|
1261
|
+
internalBinaryWrite(e, t, n) {
|
|
1262
|
+
e.report && R.internalBinaryWrite(
|
|
1263
|
+
e.report,
|
|
1264
|
+
t.tag(1, h.LengthDelimited).fork(),
|
|
1265
|
+
n
|
|
1266
|
+
).join();
|
|
1267
|
+
let r = n.writeUnknownFields;
|
|
1268
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1269
|
+
this.typeName,
|
|
1270
|
+
e,
|
|
1271
|
+
t
|
|
1272
|
+
), t;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
const _t = new Dt();
|
|
1276
|
+
class $t extends g {
|
|
1277
|
+
constructor() {
|
|
1278
|
+
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1279
|
+
}
|
|
1280
|
+
create(e) {
|
|
1281
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1282
|
+
return e !== void 0 && f(this, t, e), t;
|
|
1283
|
+
}
|
|
1284
|
+
internalBinaryRead(e, t, n, r) {
|
|
1285
|
+
return r ?? this.create();
|
|
1286
|
+
}
|
|
1287
|
+
internalBinaryWrite(e, t, n) {
|
|
1288
|
+
let r = n.writeUnknownFields;
|
|
1289
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1290
|
+
this.typeName,
|
|
1291
|
+
e,
|
|
1292
|
+
t
|
|
1293
|
+
), t;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
new $t();
|
|
1297
|
+
class Ct extends g {
|
|
1298
|
+
constructor() {
|
|
1299
|
+
super(
|
|
1300
|
+
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
|
|
1301
|
+
[
|
|
1302
|
+
{
|
|
1303
|
+
no: 1,
|
|
1304
|
+
name: "resource_id",
|
|
1305
|
+
kind: "scalar",
|
|
1306
|
+
T: 4,
|
|
1307
|
+
L: 0
|
|
1308
|
+
/*LongType.BIGINT*/
|
|
1309
|
+
},
|
|
1310
|
+
{ no: 2, name: "update_interval", kind: "message", T: () => _ }
|
|
1311
|
+
]
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
create(e) {
|
|
1315
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1316
|
+
return t.resourceId = 0n, e !== void 0 && f(
|
|
1317
|
+
this,
|
|
1318
|
+
t,
|
|
1319
|
+
e
|
|
1320
|
+
), t;
|
|
1321
|
+
}
|
|
1322
|
+
internalBinaryRead(e, t, n, r) {
|
|
1323
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1324
|
+
for (; e.pos < c; ) {
|
|
1325
|
+
let [i, l] = e.tag();
|
|
1326
|
+
switch (i) {
|
|
1327
|
+
case /* uint64 resource_id */
|
|
1328
|
+
1:
|
|
1329
|
+
o.resourceId = e.uint64().toBigInt();
|
|
1330
|
+
break;
|
|
1331
|
+
case /* google.protobuf.Duration update_interval */
|
|
1332
|
+
2:
|
|
1333
|
+
o.updateInterval = _.internalBinaryRead(
|
|
1334
|
+
e,
|
|
1335
|
+
e.uint32(),
|
|
1336
|
+
n,
|
|
1337
|
+
o.updateInterval
|
|
1338
|
+
);
|
|
1339
|
+
break;
|
|
1340
|
+
default:
|
|
1341
|
+
let a = n.readUnknownField;
|
|
1342
|
+
if (a === "throw")
|
|
1343
|
+
throw new globalThis.Error(
|
|
1344
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1345
|
+
);
|
|
1346
|
+
let p = e.skip(l);
|
|
1347
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1348
|
+
this.typeName,
|
|
1349
|
+
o,
|
|
1350
|
+
i,
|
|
1351
|
+
l,
|
|
1352
|
+
p
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return o;
|
|
1357
|
+
}
|
|
1358
|
+
internalBinaryWrite(e, t, n) {
|
|
1359
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && _.internalBinaryWrite(
|
|
1360
|
+
e.updateInterval,
|
|
1361
|
+
t.tag(2, h.LengthDelimited).fork(),
|
|
1362
|
+
n
|
|
1363
|
+
).join();
|
|
1364
|
+
let r = n.writeUnknownFields;
|
|
1365
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1366
|
+
this.typeName,
|
|
1367
|
+
e,
|
|
1368
|
+
t
|
|
1369
|
+
), t;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
const Ot = new Ct();
|
|
1373
|
+
class Et extends g {
|
|
1374
|
+
constructor() {
|
|
1375
|
+
super(
|
|
1376
|
+
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
|
|
1377
|
+
[{ no: 1, name: "report", kind: "message", T: () => R }]
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
create(e) {
|
|
1381
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1382
|
+
return e !== void 0 && f(
|
|
1383
|
+
this,
|
|
1384
|
+
t,
|
|
1385
|
+
e
|
|
1386
|
+
), t;
|
|
1387
|
+
}
|
|
1388
|
+
internalBinaryRead(e, t, n, r) {
|
|
1389
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1390
|
+
for (; e.pos < c; ) {
|
|
1391
|
+
let [i, l] = e.tag();
|
|
1392
|
+
switch (i) {
|
|
1393
|
+
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1394
|
+
1:
|
|
1395
|
+
o.report = R.internalBinaryRead(
|
|
1396
|
+
e,
|
|
1397
|
+
e.uint32(),
|
|
1398
|
+
n,
|
|
1399
|
+
o.report
|
|
1400
|
+
);
|
|
1401
|
+
break;
|
|
1402
|
+
default:
|
|
1403
|
+
let a = n.readUnknownField;
|
|
1404
|
+
if (a === "throw")
|
|
1405
|
+
throw new globalThis.Error(
|
|
1406
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1407
|
+
);
|
|
1408
|
+
let p = e.skip(l);
|
|
1409
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1410
|
+
this.typeName,
|
|
1411
|
+
o,
|
|
1412
|
+
i,
|
|
1413
|
+
l,
|
|
1414
|
+
p
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
return o;
|
|
1419
|
+
}
|
|
1420
|
+
internalBinaryWrite(e, t, n) {
|
|
1421
|
+
e.report && R.internalBinaryWrite(
|
|
1422
|
+
e.report,
|
|
1423
|
+
t.tag(1, h.LengthDelimited).fork(),
|
|
1424
|
+
n
|
|
1425
|
+
).join();
|
|
1426
|
+
let r = n.writeUnknownFields;
|
|
1427
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1428
|
+
this.typeName,
|
|
1429
|
+
e,
|
|
1430
|
+
t
|
|
1431
|
+
), t;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
const Ft = new Et(), A = new v(
|
|
1435
|
+
"MiLaboratories.Controller.Shared.Progress",
|
|
1436
|
+
[
|
|
1437
|
+
{
|
|
1438
|
+
name: "GetStatus",
|
|
1439
|
+
options: {
|
|
1440
|
+
"google.api.http": { get: "/resources/{resource_id}/get-progress" }
|
|
1441
|
+
},
|
|
1442
|
+
I: vt,
|
|
1443
|
+
O: _t
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
name: "RealtimeStatus",
|
|
1447
|
+
serverStreaming: !0,
|
|
1448
|
+
options: {},
|
|
1449
|
+
I: Ot,
|
|
1450
|
+
O: Ft
|
|
1451
|
+
}
|
|
1452
|
+
]
|
|
1453
|
+
);
|
|
1454
|
+
class Wt {
|
|
1455
|
+
constructor(e) {
|
|
1456
|
+
d(this, "typeName", A.typeName);
|
|
1457
|
+
d(this, "methods", A.methods);
|
|
1458
|
+
d(this, "options", A.options);
|
|
1459
|
+
this._transport = e;
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* @generated from protobuf rpc: GetStatus(MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request) returns (MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response);
|
|
1463
|
+
*/
|
|
1464
|
+
getStatus(e, t) {
|
|
1465
|
+
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
1466
|
+
return y("unary", this._transport, n, r, e);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
|
|
1470
|
+
*/
|
|
1471
|
+
realtimeStatus(e, t) {
|
|
1472
|
+
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
1473
|
+
return y("serverStreaming", this._transport, n, r, e);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
class At {
|
|
1477
|
+
constructor(e, t, n, r) {
|
|
1478
|
+
d(this, "grpcClient");
|
|
1479
|
+
this.grpcTransport = e, this.client = n, this.logger = r, this.grpcClient = new Wt(this.grpcTransport);
|
|
1480
|
+
}
|
|
1481
|
+
close() {
|
|
1482
|
+
}
|
|
1483
|
+
/** getStatus gets a progress status by given rId and rType. */
|
|
1484
|
+
async getStatus({ id: e, type: t }, n) {
|
|
1485
|
+
const r = await this.grpcClient.getStatus(
|
|
1486
|
+
{ resourceId: e },
|
|
1487
|
+
T(t, n)
|
|
1488
|
+
), o = O(r.response.report);
|
|
1489
|
+
return {
|
|
1490
|
+
done: o.done,
|
|
1491
|
+
progress: o.progress,
|
|
1492
|
+
bytesProcessed: String(o.bytesProcessed),
|
|
1493
|
+
bytesTotal: String(o.bytesTotal)
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
// realtimeStatus returns a async generator that takes statuses from
|
|
1497
|
+
// GRPC stream every updateIntervalMs milliseconds.
|
|
1498
|
+
async *realtimeStatus({ id: e, type: t }, n = 100, r) {
|
|
1499
|
+
r = T(t, r);
|
|
1500
|
+
const o = Math.floor(n / 1e3), c = (n - o * 1e3) * 1e6, i = _.create({
|
|
1501
|
+
seconds: BigInt(o),
|
|
1502
|
+
nanos: c
|
|
1503
|
+
});
|
|
1504
|
+
try {
|
|
1505
|
+
const { responses: l } = this.grpcClient.realtimeStatus(
|
|
1506
|
+
{
|
|
1507
|
+
resourceId: e,
|
|
1508
|
+
updateInterval: i
|
|
1509
|
+
},
|
|
1510
|
+
r
|
|
1511
|
+
);
|
|
1512
|
+
yield* l;
|
|
1513
|
+
} catch (l) {
|
|
1514
|
+
throw this.logger.warn("Failed to get realtime status" + l), l;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
class zt extends g {
|
|
1519
|
+
constructor() {
|
|
1520
|
+
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1521
|
+
}
|
|
1522
|
+
create(e) {
|
|
1523
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1524
|
+
return e !== void 0 && f(this, t, e), t;
|
|
1525
|
+
}
|
|
1526
|
+
internalBinaryRead(e, t, n, r) {
|
|
1527
|
+
return r ?? this.create();
|
|
1528
|
+
}
|
|
1529
|
+
internalBinaryWrite(e, t, n) {
|
|
1530
|
+
let r = n.writeUnknownFields;
|
|
1531
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1532
|
+
this.typeName,
|
|
1533
|
+
e,
|
|
1534
|
+
t
|
|
1535
|
+
), t;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
new zt();
|
|
1539
|
+
class xt extends g {
|
|
1540
|
+
constructor() {
|
|
1541
|
+
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1542
|
+
}
|
|
1543
|
+
create(e) {
|
|
1544
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1545
|
+
return e !== void 0 && f(this, t, e), t;
|
|
1546
|
+
}
|
|
1547
|
+
internalBinaryRead(e, t, n, r) {
|
|
1548
|
+
return r ?? this.create();
|
|
1549
|
+
}
|
|
1550
|
+
internalBinaryWrite(e, t, n) {
|
|
1551
|
+
let r = n.writeUnknownFields;
|
|
1552
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1553
|
+
this.typeName,
|
|
1554
|
+
e,
|
|
1555
|
+
t
|
|
1556
|
+
), t;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
new xt();
|
|
1560
|
+
class Mt extends g {
|
|
1561
|
+
constructor() {
|
|
1562
|
+
super(
|
|
1563
|
+
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
|
|
1564
|
+
[
|
|
1565
|
+
{
|
|
1566
|
+
no: 1,
|
|
1567
|
+
name: "resource_id",
|
|
1568
|
+
kind: "scalar",
|
|
1569
|
+
T: 4,
|
|
1570
|
+
L: 0
|
|
1571
|
+
/*LongType.BIGINT*/
|
|
1572
|
+
}
|
|
1573
|
+
]
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
create(e) {
|
|
1577
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1578
|
+
return t.resourceId = 0n, e !== void 0 && f(
|
|
1579
|
+
this,
|
|
1580
|
+
t,
|
|
1581
|
+
e
|
|
1582
|
+
), t;
|
|
1583
|
+
}
|
|
1584
|
+
internalBinaryRead(e, t, n, r) {
|
|
1585
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1586
|
+
for (; e.pos < c; ) {
|
|
1587
|
+
let [i, l] = e.tag();
|
|
1588
|
+
switch (i) {
|
|
1589
|
+
case /* uint64 resource_id */
|
|
1590
|
+
1:
|
|
1591
|
+
o.resourceId = e.uint64().toBigInt();
|
|
1592
|
+
break;
|
|
1593
|
+
default:
|
|
1594
|
+
let a = n.readUnknownField;
|
|
1595
|
+
if (a === "throw")
|
|
1596
|
+
throw new globalThis.Error(
|
|
1597
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1598
|
+
);
|
|
1599
|
+
let p = e.skip(l);
|
|
1600
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1601
|
+
this.typeName,
|
|
1602
|
+
o,
|
|
1603
|
+
i,
|
|
1604
|
+
l,
|
|
1605
|
+
p
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
return o;
|
|
1610
|
+
}
|
|
1611
|
+
internalBinaryWrite(e, t, n) {
|
|
1612
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId);
|
|
1613
|
+
let r = n.writeUnknownFields;
|
|
1614
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1615
|
+
this.typeName,
|
|
1616
|
+
e,
|
|
1617
|
+
t
|
|
1618
|
+
), t;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
const Ht = new Mt();
|
|
1622
|
+
class jt extends g {
|
|
1623
|
+
constructor() {
|
|
1624
|
+
super(
|
|
1625
|
+
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
|
|
1626
|
+
[
|
|
1627
|
+
{
|
|
1628
|
+
no: 1,
|
|
1629
|
+
name: "Name",
|
|
1630
|
+
kind: "scalar",
|
|
1631
|
+
jsonName: "Name",
|
|
1632
|
+
T: 9
|
|
1633
|
+
/*ScalarType.STRING*/
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
no: 2,
|
|
1637
|
+
name: "Value",
|
|
1638
|
+
kind: "scalar",
|
|
1639
|
+
jsonName: "Value",
|
|
1640
|
+
T: 9
|
|
1641
|
+
/*ScalarType.STRING*/
|
|
1642
|
+
}
|
|
1643
|
+
]
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1646
|
+
create(e) {
|
|
1647
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1648
|
+
return t.name = "", t.value = "", e !== void 0 && f(
|
|
1649
|
+
this,
|
|
1650
|
+
t,
|
|
1651
|
+
e
|
|
1652
|
+
), t;
|
|
1653
|
+
}
|
|
1654
|
+
internalBinaryRead(e, t, n, r) {
|
|
1655
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1656
|
+
for (; e.pos < c; ) {
|
|
1657
|
+
let [i, l] = e.tag();
|
|
1658
|
+
switch (i) {
|
|
1659
|
+
case /* string Name = 1 [json_name = "Name"];*/
|
|
1660
|
+
1:
|
|
1661
|
+
o.name = e.string();
|
|
1662
|
+
break;
|
|
1663
|
+
case /* string Value = 2 [json_name = "Value"];*/
|
|
1664
|
+
2:
|
|
1665
|
+
o.value = e.string();
|
|
1666
|
+
break;
|
|
1667
|
+
default:
|
|
1668
|
+
let a = n.readUnknownField;
|
|
1669
|
+
if (a === "throw")
|
|
1670
|
+
throw new globalThis.Error(
|
|
1671
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1672
|
+
);
|
|
1673
|
+
let p = e.skip(l);
|
|
1674
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1675
|
+
this.typeName,
|
|
1676
|
+
o,
|
|
1677
|
+
i,
|
|
1678
|
+
l,
|
|
1679
|
+
p
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
return o;
|
|
1684
|
+
}
|
|
1685
|
+
internalBinaryWrite(e, t, n) {
|
|
1686
|
+
e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.value !== "" && t.tag(2, h.LengthDelimited).string(e.value);
|
|
1687
|
+
let r = n.writeUnknownFields;
|
|
1688
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1689
|
+
this.typeName,
|
|
1690
|
+
e,
|
|
1691
|
+
t
|
|
1692
|
+
), t;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
const z = new jt();
|
|
1696
|
+
class Gt extends g {
|
|
1697
|
+
constructor() {
|
|
1698
|
+
super(
|
|
1699
|
+
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
|
|
1700
|
+
[
|
|
1701
|
+
{
|
|
1702
|
+
no: 1,
|
|
1703
|
+
name: "download_url",
|
|
1704
|
+
kind: "scalar",
|
|
1705
|
+
T: 9
|
|
1706
|
+
/*ScalarType.STRING*/
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
no: 2,
|
|
1710
|
+
name: "headers",
|
|
1711
|
+
kind: "message",
|
|
1712
|
+
repeat: 1,
|
|
1713
|
+
T: () => z
|
|
1714
|
+
}
|
|
1715
|
+
]
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
create(e) {
|
|
1719
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1720
|
+
return t.downloadUrl = "", t.headers = [], e !== void 0 && f(
|
|
1721
|
+
this,
|
|
1722
|
+
t,
|
|
1723
|
+
e
|
|
1724
|
+
), t;
|
|
1725
|
+
}
|
|
1726
|
+
internalBinaryRead(e, t, n, r) {
|
|
1727
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1728
|
+
for (; e.pos < c; ) {
|
|
1729
|
+
let [i, l] = e.tag();
|
|
1730
|
+
switch (i) {
|
|
1731
|
+
case /* string download_url */
|
|
1732
|
+
1:
|
|
1733
|
+
o.downloadUrl = e.string();
|
|
1734
|
+
break;
|
|
1735
|
+
case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
|
|
1736
|
+
2:
|
|
1737
|
+
o.headers.push(
|
|
1738
|
+
z.internalBinaryRead(
|
|
1739
|
+
e,
|
|
1740
|
+
e.uint32(),
|
|
1741
|
+
n
|
|
1742
|
+
)
|
|
1743
|
+
);
|
|
1744
|
+
break;
|
|
1745
|
+
default:
|
|
1746
|
+
let a = n.readUnknownField;
|
|
1747
|
+
if (a === "throw")
|
|
1748
|
+
throw new globalThis.Error(
|
|
1749
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1750
|
+
);
|
|
1751
|
+
let p = e.skip(l);
|
|
1752
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1753
|
+
this.typeName,
|
|
1754
|
+
o,
|
|
1755
|
+
i,
|
|
1756
|
+
l,
|
|
1757
|
+
p
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return o;
|
|
1762
|
+
}
|
|
1763
|
+
internalBinaryWrite(e, t, n) {
|
|
1764
|
+
e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
|
|
1765
|
+
for (let o = 0; o < e.headers.length; o++)
|
|
1766
|
+
z.internalBinaryWrite(
|
|
1767
|
+
e.headers[o],
|
|
1768
|
+
t.tag(2, h.LengthDelimited).fork(),
|
|
1769
|
+
n
|
|
1770
|
+
).join();
|
|
1771
|
+
let r = n.writeUnknownFields;
|
|
1772
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
1773
|
+
this.typeName,
|
|
1774
|
+
e,
|
|
1775
|
+
t
|
|
1776
|
+
), t;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
const Vt = new Gt(), x = new v(
|
|
1780
|
+
"MiLaboratories.Controller.Shared.Download",
|
|
1781
|
+
[
|
|
1782
|
+
{
|
|
1783
|
+
name: "GetDownloadURL",
|
|
1784
|
+
options: {
|
|
1785
|
+
"google.api.http": { get: "/resources/{resource_id}/get-download-url" }
|
|
1786
|
+
},
|
|
1787
|
+
I: Ht,
|
|
1788
|
+
O: Vt
|
|
1789
|
+
}
|
|
1790
|
+
]
|
|
1791
|
+
);
|
|
1792
|
+
class qt {
|
|
1793
|
+
constructor(e) {
|
|
1794
|
+
d(this, "typeName", x.typeName);
|
|
1795
|
+
d(this, "methods", x.methods);
|
|
1796
|
+
d(this, "options", x.options);
|
|
1797
|
+
this._transport = e;
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* @generated from protobuf rpc: GetDownloadURL(MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request) returns (MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response);
|
|
1801
|
+
*/
|
|
1802
|
+
getDownloadURL(e, t) {
|
|
1803
|
+
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
1804
|
+
return y("unary", this._transport, n, r, e);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
class re extends Error {
|
|
1808
|
+
}
|
|
1809
|
+
class Ie {
|
|
1810
|
+
constructor(e) {
|
|
1811
|
+
this.httpClient = e;
|
|
1812
|
+
}
|
|
1813
|
+
async downloadRemoteFile(e, t, n) {
|
|
1814
|
+
const { statusCode: r, body: o, headers: c } = await fe(e, {
|
|
1815
|
+
dispatcher: this.httpClient,
|
|
1816
|
+
headers: t,
|
|
1817
|
+
signal: n
|
|
1818
|
+
});
|
|
1819
|
+
if (400 <= r && r < 500)
|
|
1820
|
+
throw new re(
|
|
1821
|
+
`Http error: statusCode: ${r} url: ${e.toString()}`
|
|
1822
|
+
);
|
|
1823
|
+
if (r != 200)
|
|
1824
|
+
throw Error(
|
|
1825
|
+
`Http error: statusCode: ${r} url: ${e.toString()}`
|
|
1826
|
+
);
|
|
1827
|
+
return {
|
|
1828
|
+
content: K.toWeb(o),
|
|
1829
|
+
size: Number(c["content-length"])
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
const Zt = "storage://", ie = /storage:\/\/(?<storageId>.*?)\/(?<localPath>.*)/;
|
|
1834
|
+
class Ne extends Error {
|
|
1835
|
+
}
|
|
1836
|
+
class Re extends Error {
|
|
1837
|
+
}
|
|
1838
|
+
class Jt {
|
|
1839
|
+
constructor(e, t, n, r) {
|
|
1840
|
+
d(this, "grpcClient");
|
|
1841
|
+
d(this, "downloadHelper");
|
|
1842
|
+
d(this, "isLocal", (e) => e.startsWith(Zt));
|
|
1843
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.localStorageIdsToRoot = r, this.grpcClient = new qt(this.grpcTransport), this.downloadHelper = new Ie(t);
|
|
1844
|
+
}
|
|
1845
|
+
close() {
|
|
1846
|
+
}
|
|
1847
|
+
async getUrl({ id: e, type: t }, n, r) {
|
|
1848
|
+
const o = n ?? {};
|
|
1849
|
+
return o.abort = r, await this.grpcClient.getDownloadURL(
|
|
1850
|
+
{ resourceId: e },
|
|
1851
|
+
T(t, o)
|
|
1852
|
+
).response;
|
|
1853
|
+
}
|
|
1854
|
+
async downloadBlob(e, t, n) {
|
|
1855
|
+
const { downloadUrl: r, headers: o } = await this.getUrl(e, t, n);
|
|
1856
|
+
return this.logger.info(`download from url ${r}`), this.isLocal(r) ? await this.readLocalFile(r) : await this.downloadHelper.downloadRemoteFile(
|
|
1857
|
+
r,
|
|
1858
|
+
Qt(o),
|
|
1859
|
+
n
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
async readLocalFile(e) {
|
|
1863
|
+
const t = e.match(ie);
|
|
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 c = this.localStorageIdsToRoot[r], i = m.join(c, o), a = (await w.stat(i)).size;
|
|
1872
|
+
return {
|
|
1873
|
+
content: K.toWeb(E.createReadStream(i)),
|
|
1874
|
+
size: a
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
function Qt(s) {
|
|
1879
|
+
return Object.fromEntries(s.map(({ name: e, value: t }) => [e, t]));
|
|
1880
|
+
}
|
|
1881
|
+
class Xt extends g {
|
|
1882
|
+
constructor() {
|
|
1883
|
+
super("google.protobuf.Timestamp", [
|
|
1884
|
+
{
|
|
1885
|
+
no: 1,
|
|
1886
|
+
name: "seconds",
|
|
1887
|
+
kind: "scalar",
|
|
1888
|
+
T: 3,
|
|
1889
|
+
L: 0
|
|
1890
|
+
/*LongType.BIGINT*/
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
no: 2,
|
|
1894
|
+
name: "nanos",
|
|
1895
|
+
kind: "scalar",
|
|
1896
|
+
T: 5
|
|
1897
|
+
/*ScalarType.INT32*/
|
|
1898
|
+
}
|
|
1899
|
+
]);
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Creates a new `Timestamp` for the current time.
|
|
1903
|
+
*/
|
|
1904
|
+
now() {
|
|
1905
|
+
const e = this.create(), t = Date.now();
|
|
1906
|
+
return e.seconds = I.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Converts a `Timestamp` to a JavaScript Date.
|
|
1910
|
+
*/
|
|
1911
|
+
toDate(e) {
|
|
1912
|
+
return new Date(
|
|
1913
|
+
I.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Converts a JavaScript Date to a `Timestamp`.
|
|
1918
|
+
*/
|
|
1919
|
+
fromDate(e) {
|
|
1920
|
+
const t = this.create(), n = e.getTime();
|
|
1921
|
+
return t.seconds = I.from(Math.floor(n / 1e3)).toBigInt(), t.nanos = n % 1e3 * 1e6, t;
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1925
|
+
* in the RFC 3339 format.
|
|
1926
|
+
*/
|
|
1927
|
+
internalJsonWrite(e, t) {
|
|
1928
|
+
let n = I.from(e.seconds).toNumber() * 1e3;
|
|
1929
|
+
if (n < Date.parse("0001-01-01T00:00:00Z") || n > Date.parse("9999-12-31T23:59:59Z"))
|
|
1930
|
+
throw new Error(
|
|
1931
|
+
"Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
1932
|
+
);
|
|
1933
|
+
if (e.nanos < 0)
|
|
1934
|
+
throw new Error(
|
|
1935
|
+
"Unable to encode invalid Timestamp to JSON. Nanos must not be negative."
|
|
1936
|
+
);
|
|
1937
|
+
let r = "Z";
|
|
1938
|
+
if (e.nanos > 0) {
|
|
1939
|
+
let o = (e.nanos + 1e9).toString().substring(1);
|
|
1940
|
+
o.substring(3) === "000000" ? r = "." + o.substring(0, 3) + "Z" : o.substring(6) === "000" ? r = "." + o.substring(0, 6) + "Z" : r = "." + o + "Z";
|
|
1941
|
+
}
|
|
1942
|
+
return new Date(n).toISOString().replace(".000Z", r);
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1946
|
+
* in the RFC 3339 format.
|
|
1947
|
+
*/
|
|
1948
|
+
internalJsonRead(e, t, n) {
|
|
1949
|
+
if (typeof e != "string")
|
|
1950
|
+
throw new Error(
|
|
1951
|
+
"Unable to parse Timestamp from JSON " + ge(e) + "."
|
|
1952
|
+
);
|
|
1953
|
+
let r = e.match(
|
|
1954
|
+
/^([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]))$/
|
|
1955
|
+
);
|
|
1956
|
+
if (!r)
|
|
1957
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
|
1958
|
+
let o = Date.parse(
|
|
1959
|
+
r[1] + "-" + r[2] + "-" + r[3] + "T" + r[4] + ":" + r[5] + ":" + r[6] + (r[8] ? r[8] : "Z")
|
|
1960
|
+
);
|
|
1961
|
+
if (Number.isNaN(o))
|
|
1962
|
+
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
|
1963
|
+
if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
|
|
1964
|
+
throw new globalThis.Error(
|
|
1965
|
+
"Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
1966
|
+
);
|
|
1967
|
+
return n || (n = this.create()), n.seconds = I.from(o / 1e3).toBigInt(), n.nanos = 0, r[7] && (n.nanos = parseInt("1" + r[7] + "0".repeat(9 - r[7].length)) - 1e9), n;
|
|
1968
|
+
}
|
|
1969
|
+
create(e) {
|
|
1970
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
1971
|
+
return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
|
|
1972
|
+
}
|
|
1973
|
+
internalBinaryRead(e, t, n, r) {
|
|
1974
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
1975
|
+
for (; e.pos < c; ) {
|
|
1976
|
+
let [i, l] = e.tag();
|
|
1977
|
+
switch (i) {
|
|
1978
|
+
case /* int64 seconds */
|
|
1979
|
+
1:
|
|
1980
|
+
o.seconds = e.int64().toBigInt();
|
|
1981
|
+
break;
|
|
1982
|
+
case /* int32 nanos */
|
|
1983
|
+
2:
|
|
1984
|
+
o.nanos = e.int32();
|
|
1985
|
+
break;
|
|
1986
|
+
default:
|
|
1987
|
+
let a = n.readUnknownField;
|
|
1988
|
+
if (a === "throw")
|
|
1989
|
+
throw new globalThis.Error(
|
|
1990
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
1991
|
+
);
|
|
1992
|
+
let p = e.skip(l);
|
|
1993
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
1994
|
+
this.typeName,
|
|
1995
|
+
o,
|
|
1996
|
+
i,
|
|
1997
|
+
l,
|
|
1998
|
+
p
|
|
1999
|
+
);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
return o;
|
|
2003
|
+
}
|
|
2004
|
+
internalBinaryWrite(e, t, n) {
|
|
2005
|
+
e.seconds !== 0n && t.tag(1, h.Varint).int64(e.seconds), e.nanos !== 0 && t.tag(2, h.Varint).int32(e.nanos);
|
|
2006
|
+
let r = n.writeUnknownFields;
|
|
2007
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2008
|
+
this.typeName,
|
|
2009
|
+
e,
|
|
2010
|
+
t
|
|
2011
|
+
), t;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
const M = new Xt();
|
|
2015
|
+
class Yt extends g {
|
|
2016
|
+
constructor() {
|
|
2017
|
+
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
2018
|
+
}
|
|
2019
|
+
create(e) {
|
|
2020
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2021
|
+
return e !== void 0 && f(this, t, e), t;
|
|
2022
|
+
}
|
|
2023
|
+
internalBinaryRead(e, t, n, r) {
|
|
2024
|
+
return r ?? this.create();
|
|
2025
|
+
}
|
|
2026
|
+
internalBinaryWrite(e, t, n) {
|
|
2027
|
+
let r = n.writeUnknownFields;
|
|
2028
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2029
|
+
this.typeName,
|
|
2030
|
+
e,
|
|
2031
|
+
t
|
|
2032
|
+
), t;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
new Yt();
|
|
2036
|
+
class Kt extends g {
|
|
2037
|
+
constructor() {
|
|
2038
|
+
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
2039
|
+
{
|
|
2040
|
+
no: 1,
|
|
2041
|
+
name: "name",
|
|
2042
|
+
kind: "scalar",
|
|
2043
|
+
T: 9
|
|
2044
|
+
/*ScalarType.STRING*/
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
no: 2,
|
|
2048
|
+
name: "size",
|
|
2049
|
+
kind: "scalar",
|
|
2050
|
+
T: 4,
|
|
2051
|
+
L: 0
|
|
2052
|
+
/*LongType.BIGINT*/
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
no: 3,
|
|
2056
|
+
name: "is_dir",
|
|
2057
|
+
kind: "scalar",
|
|
2058
|
+
T: 8
|
|
2059
|
+
/*ScalarType.BOOL*/
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
no: 10,
|
|
2063
|
+
name: "full_name",
|
|
2064
|
+
kind: "scalar",
|
|
2065
|
+
T: 9
|
|
2066
|
+
/*ScalarType.STRING*/
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
no: 11,
|
|
2070
|
+
name: "directory",
|
|
2071
|
+
kind: "scalar",
|
|
2072
|
+
T: 9
|
|
2073
|
+
/*ScalarType.STRING*/
|
|
2074
|
+
},
|
|
2075
|
+
{ no: 12, name: "last_modified", kind: "message", T: () => M },
|
|
2076
|
+
{
|
|
2077
|
+
no: 13,
|
|
2078
|
+
name: "version",
|
|
2079
|
+
kind: "scalar",
|
|
2080
|
+
T: 9
|
|
2081
|
+
/*ScalarType.STRING*/
|
|
2082
|
+
}
|
|
2083
|
+
]);
|
|
2084
|
+
}
|
|
2085
|
+
create(e) {
|
|
2086
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2087
|
+
return t.name = "", t.size = 0n, t.isDir = !1, t.fullName = "", t.directory = "", t.version = "", e !== void 0 && f(this, t, e), t;
|
|
2088
|
+
}
|
|
2089
|
+
internalBinaryRead(e, t, n, r) {
|
|
2090
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2091
|
+
for (; e.pos < c; ) {
|
|
2092
|
+
let [i, l] = e.tag();
|
|
2093
|
+
switch (i) {
|
|
2094
|
+
case /* string name */
|
|
2095
|
+
1:
|
|
2096
|
+
o.name = e.string();
|
|
2097
|
+
break;
|
|
2098
|
+
case /* uint64 size */
|
|
2099
|
+
2:
|
|
2100
|
+
o.size = e.uint64().toBigInt();
|
|
2101
|
+
break;
|
|
2102
|
+
case /* bool is_dir */
|
|
2103
|
+
3:
|
|
2104
|
+
o.isDir = e.bool();
|
|
2105
|
+
break;
|
|
2106
|
+
case /* string full_name */
|
|
2107
|
+
10:
|
|
2108
|
+
o.fullName = e.string();
|
|
2109
|
+
break;
|
|
2110
|
+
case /* string directory */
|
|
2111
|
+
11:
|
|
2112
|
+
o.directory = e.string();
|
|
2113
|
+
break;
|
|
2114
|
+
case /* google.protobuf.Timestamp last_modified */
|
|
2115
|
+
12:
|
|
2116
|
+
o.lastModified = M.internalBinaryRead(
|
|
2117
|
+
e,
|
|
2118
|
+
e.uint32(),
|
|
2119
|
+
n,
|
|
2120
|
+
o.lastModified
|
|
2121
|
+
);
|
|
2122
|
+
break;
|
|
2123
|
+
case /* string version */
|
|
2124
|
+
13:
|
|
2125
|
+
o.version = e.string();
|
|
2126
|
+
break;
|
|
2127
|
+
default:
|
|
2128
|
+
let a = n.readUnknownField;
|
|
2129
|
+
if (a === "throw")
|
|
2130
|
+
throw new globalThis.Error(
|
|
2131
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2132
|
+
);
|
|
2133
|
+
let p = e.skip(l);
|
|
2134
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2135
|
+
this.typeName,
|
|
2136
|
+
o,
|
|
2137
|
+
i,
|
|
2138
|
+
l,
|
|
2139
|
+
p
|
|
2140
|
+
);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
return o;
|
|
2144
|
+
}
|
|
2145
|
+
internalBinaryWrite(e, t, n) {
|
|
2146
|
+
e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && M.internalBinaryWrite(
|
|
2147
|
+
e.lastModified,
|
|
2148
|
+
t.tag(12, h.LengthDelimited).fork(),
|
|
2149
|
+
n
|
|
2150
|
+
).join(), e.version !== "" && t.tag(13, h.LengthDelimited).string(e.version);
|
|
2151
|
+
let r = n.writeUnknownFields;
|
|
2152
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2153
|
+
this.typeName,
|
|
2154
|
+
e,
|
|
2155
|
+
t
|
|
2156
|
+
), t;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
const H = new Kt();
|
|
2160
|
+
class er extends g {
|
|
2161
|
+
constructor() {
|
|
2162
|
+
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
2163
|
+
}
|
|
2164
|
+
create(e) {
|
|
2165
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2166
|
+
return e !== void 0 && f(this, t, e), t;
|
|
2167
|
+
}
|
|
2168
|
+
internalBinaryRead(e, t, n, r) {
|
|
2169
|
+
return r ?? this.create();
|
|
2170
|
+
}
|
|
2171
|
+
internalBinaryWrite(e, t, n) {
|
|
2172
|
+
let r = n.writeUnknownFields;
|
|
2173
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2174
|
+
this.typeName,
|
|
2175
|
+
e,
|
|
2176
|
+
t
|
|
2177
|
+
), t;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
new er();
|
|
2181
|
+
class tr extends g {
|
|
2182
|
+
constructor() {
|
|
2183
|
+
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
2184
|
+
{
|
|
2185
|
+
no: 1,
|
|
2186
|
+
name: "resource_id",
|
|
2187
|
+
kind: "scalar",
|
|
2188
|
+
T: 4,
|
|
2189
|
+
L: 0
|
|
2190
|
+
/*LongType.BIGINT*/
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
no: 2,
|
|
2194
|
+
name: "location",
|
|
2195
|
+
kind: "scalar",
|
|
2196
|
+
T: 9
|
|
2197
|
+
/*ScalarType.STRING*/
|
|
2198
|
+
}
|
|
2199
|
+
]);
|
|
2200
|
+
}
|
|
2201
|
+
create(e) {
|
|
2202
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2203
|
+
return t.resourceId = 0n, t.location = "", e !== void 0 && f(this, t, e), t;
|
|
2204
|
+
}
|
|
2205
|
+
internalBinaryRead(e, t, n, r) {
|
|
2206
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2207
|
+
for (; e.pos < c; ) {
|
|
2208
|
+
let [i, l] = e.tag();
|
|
2209
|
+
switch (i) {
|
|
2210
|
+
case /* uint64 resource_id */
|
|
2211
|
+
1:
|
|
2212
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2213
|
+
break;
|
|
2214
|
+
case /* string location */
|
|
2215
|
+
2:
|
|
2216
|
+
o.location = e.string();
|
|
2217
|
+
break;
|
|
2218
|
+
default:
|
|
2219
|
+
let a = n.readUnknownField;
|
|
2220
|
+
if (a === "throw")
|
|
2221
|
+
throw new globalThis.Error(
|
|
2222
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2223
|
+
);
|
|
2224
|
+
let p = e.skip(l);
|
|
2225
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2226
|
+
this.typeName,
|
|
2227
|
+
o,
|
|
2228
|
+
i,
|
|
2229
|
+
l,
|
|
2230
|
+
p
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
return o;
|
|
2235
|
+
}
|
|
2236
|
+
internalBinaryWrite(e, t, n) {
|
|
2237
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.location !== "" && t.tag(2, h.LengthDelimited).string(e.location);
|
|
2238
|
+
let r = n.writeUnknownFields;
|
|
2239
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2240
|
+
this.typeName,
|
|
2241
|
+
e,
|
|
2242
|
+
t
|
|
2243
|
+
), t;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
const rr = new tr();
|
|
2247
|
+
class nr extends g {
|
|
2248
|
+
constructor() {
|
|
2249
|
+
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2250
|
+
{
|
|
2251
|
+
no: 1,
|
|
2252
|
+
name: "items",
|
|
2253
|
+
kind: "message",
|
|
2254
|
+
repeat: 1,
|
|
2255
|
+
T: () => H
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
no: 2,
|
|
2259
|
+
name: "delimiter",
|
|
2260
|
+
kind: "scalar",
|
|
2261
|
+
T: 9
|
|
2262
|
+
/*ScalarType.STRING*/
|
|
2263
|
+
}
|
|
2264
|
+
]);
|
|
2265
|
+
}
|
|
2266
|
+
create(e) {
|
|
2267
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2268
|
+
return t.items = [], t.delimiter = "", e !== void 0 && f(this, t, e), t;
|
|
2269
|
+
}
|
|
2270
|
+
internalBinaryRead(e, t, n, r) {
|
|
2271
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2272
|
+
for (; e.pos < c; ) {
|
|
2273
|
+
let [i, l] = e.tag();
|
|
2274
|
+
switch (i) {
|
|
2275
|
+
case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
|
|
2276
|
+
1:
|
|
2277
|
+
o.items.push(
|
|
2278
|
+
H.internalBinaryRead(e, e.uint32(), n)
|
|
2279
|
+
);
|
|
2280
|
+
break;
|
|
2281
|
+
case /* string delimiter */
|
|
2282
|
+
2:
|
|
2283
|
+
o.delimiter = e.string();
|
|
2284
|
+
break;
|
|
2285
|
+
default:
|
|
2286
|
+
let a = n.readUnknownField;
|
|
2287
|
+
if (a === "throw")
|
|
2288
|
+
throw new globalThis.Error(
|
|
2289
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2290
|
+
);
|
|
2291
|
+
let p = e.skip(l);
|
|
2292
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2293
|
+
this.typeName,
|
|
2294
|
+
o,
|
|
2295
|
+
i,
|
|
2296
|
+
l,
|
|
2297
|
+
p
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
return o;
|
|
2302
|
+
}
|
|
2303
|
+
internalBinaryWrite(e, t, n) {
|
|
2304
|
+
for (let o = 0; o < e.items.length; o++)
|
|
2305
|
+
H.internalBinaryWrite(
|
|
2306
|
+
e.items[o],
|
|
2307
|
+
t.tag(1, h.LengthDelimited).fork(),
|
|
2308
|
+
n
|
|
2309
|
+
).join();
|
|
2310
|
+
e.delimiter !== "" && t.tag(2, h.LengthDelimited).string(e.delimiter);
|
|
2311
|
+
let r = n.writeUnknownFields;
|
|
2312
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2313
|
+
this.typeName,
|
|
2314
|
+
e,
|
|
2315
|
+
t
|
|
2316
|
+
), t;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
const or = new nr(), j = new v("MiLaboratories.Controller.Shared.LS", [
|
|
2320
|
+
{ name: "List", options: {}, I: rr, O: or }
|
|
2321
|
+
]);
|
|
2322
|
+
class sr {
|
|
2323
|
+
constructor(e) {
|
|
2324
|
+
d(this, "typeName", j.typeName);
|
|
2325
|
+
d(this, "methods", j.methods);
|
|
2326
|
+
d(this, "options", j.options);
|
|
2327
|
+
this._transport = e;
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* @generated from protobuf rpc: List(MiLaboratories.Controller.Shared.LsAPI.List.Request) returns (MiLaboratories.Controller.Shared.LsAPI.List.Response);
|
|
2331
|
+
*/
|
|
2332
|
+
list(e, t) {
|
|
2333
|
+
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
2334
|
+
return y(
|
|
2335
|
+
"unary",
|
|
2336
|
+
this._transport,
|
|
2337
|
+
n,
|
|
2338
|
+
r,
|
|
2339
|
+
e
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
class ir {
|
|
2344
|
+
constructor(e, t) {
|
|
2345
|
+
d(this, "grpcClient");
|
|
2346
|
+
this.logger = t, this.grpcClient = new sr(e);
|
|
2347
|
+
}
|
|
2348
|
+
close() {
|
|
2349
|
+
}
|
|
2350
|
+
async list(e, t, n) {
|
|
2351
|
+
return await this.grpcClient.list(
|
|
2352
|
+
{
|
|
2353
|
+
resourceId: e.id,
|
|
2354
|
+
location: t
|
|
2355
|
+
},
|
|
2356
|
+
T(e.type, n)
|
|
2357
|
+
).response;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
class ar extends g {
|
|
2361
|
+
constructor() {
|
|
2362
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2363
|
+
}
|
|
2364
|
+
create(e) {
|
|
2365
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2366
|
+
return e !== void 0 && f(this, t, e), t;
|
|
2367
|
+
}
|
|
2368
|
+
internalBinaryRead(e, t, n, r) {
|
|
2369
|
+
return r ?? this.create();
|
|
2370
|
+
}
|
|
2371
|
+
internalBinaryWrite(e, t, n) {
|
|
2372
|
+
let r = n.writeUnknownFields;
|
|
2373
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2374
|
+
this.typeName,
|
|
2375
|
+
e,
|
|
2376
|
+
t
|
|
2377
|
+
), t;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
new ar();
|
|
2381
|
+
class lr extends g {
|
|
2382
|
+
constructor() {
|
|
2383
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2384
|
+
{
|
|
2385
|
+
no: 1,
|
|
2386
|
+
name: "resource_id",
|
|
2387
|
+
kind: "scalar",
|
|
2388
|
+
T: 4,
|
|
2389
|
+
L: 0
|
|
2390
|
+
/*LongType.BIGINT*/
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
no: 2,
|
|
2394
|
+
name: "offset",
|
|
2395
|
+
kind: "scalar",
|
|
2396
|
+
T: 3,
|
|
2397
|
+
L: 0
|
|
2398
|
+
/*LongType.BIGINT*/
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
no: 11,
|
|
2402
|
+
name: "chunk_size",
|
|
2403
|
+
kind: "scalar",
|
|
2404
|
+
opt: !0,
|
|
2405
|
+
T: 13
|
|
2406
|
+
/*ScalarType.UINT32*/
|
|
2407
|
+
},
|
|
2408
|
+
{
|
|
2409
|
+
no: 20,
|
|
2410
|
+
name: "read_limit",
|
|
2411
|
+
kind: "scalar",
|
|
2412
|
+
opt: !0,
|
|
2413
|
+
T: 3,
|
|
2414
|
+
L: 0
|
|
2415
|
+
/*LongType.BIGINT*/
|
|
2416
|
+
}
|
|
2417
|
+
]);
|
|
2418
|
+
}
|
|
2419
|
+
create(e) {
|
|
2420
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2421
|
+
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2422
|
+
}
|
|
2423
|
+
internalBinaryRead(e, t, n, r) {
|
|
2424
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2425
|
+
for (; e.pos < c; ) {
|
|
2426
|
+
let [i, l] = e.tag();
|
|
2427
|
+
switch (i) {
|
|
2428
|
+
case /* uint64 resource_id */
|
|
2429
|
+
1:
|
|
2430
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2431
|
+
break;
|
|
2432
|
+
case /* int64 offset */
|
|
2433
|
+
2:
|
|
2434
|
+
o.offset = e.int64().toBigInt();
|
|
2435
|
+
break;
|
|
2436
|
+
case /* optional uint32 chunk_size */
|
|
2437
|
+
11:
|
|
2438
|
+
o.chunkSize = e.uint32();
|
|
2439
|
+
break;
|
|
2440
|
+
case /* optional int64 read_limit */
|
|
2441
|
+
20:
|
|
2442
|
+
o.readLimit = e.int64().toBigInt();
|
|
2443
|
+
break;
|
|
2444
|
+
default:
|
|
2445
|
+
let a = n.readUnknownField;
|
|
2446
|
+
if (a === "throw")
|
|
2447
|
+
throw new globalThis.Error(
|
|
2448
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2449
|
+
);
|
|
2450
|
+
let p = e.skip(l);
|
|
2451
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2452
|
+
this.typeName,
|
|
2453
|
+
o,
|
|
2454
|
+
i,
|
|
2455
|
+
l,
|
|
2456
|
+
p
|
|
2457
|
+
);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
return o;
|
|
2461
|
+
}
|
|
2462
|
+
internalBinaryWrite(e, t, n) {
|
|
2463
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, h.Varint).int64(e.offset), e.chunkSize !== void 0 && t.tag(11, h.Varint).uint32(e.chunkSize), e.readLimit !== void 0 && t.tag(20, h.Varint).int64(e.readLimit);
|
|
2464
|
+
let r = n.writeUnknownFields;
|
|
2465
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2466
|
+
this.typeName,
|
|
2467
|
+
e,
|
|
2468
|
+
t
|
|
2469
|
+
), t;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
const cr = new lr();
|
|
2473
|
+
class dr extends g {
|
|
2474
|
+
constructor() {
|
|
2475
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2476
|
+
{
|
|
2477
|
+
no: 1,
|
|
2478
|
+
name: "resource_id",
|
|
2479
|
+
kind: "scalar",
|
|
2480
|
+
T: 4,
|
|
2481
|
+
L: 0
|
|
2482
|
+
/*LongType.BIGINT*/
|
|
2483
|
+
},
|
|
2484
|
+
{
|
|
2485
|
+
no: 2,
|
|
2486
|
+
name: "offset",
|
|
2487
|
+
kind: "scalar",
|
|
2488
|
+
T: 3,
|
|
2489
|
+
L: 0
|
|
2490
|
+
/*LongType.BIGINT*/
|
|
2491
|
+
},
|
|
2492
|
+
{
|
|
2493
|
+
no: 11,
|
|
2494
|
+
name: "chunk_size",
|
|
2495
|
+
kind: "scalar",
|
|
2496
|
+
opt: !0,
|
|
2497
|
+
T: 13
|
|
2498
|
+
/*ScalarType.UINT32*/
|
|
2499
|
+
}
|
|
2500
|
+
]);
|
|
2501
|
+
}
|
|
2502
|
+
create(e) {
|
|
2503
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2504
|
+
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2505
|
+
}
|
|
2506
|
+
internalBinaryRead(e, t, n, r) {
|
|
2507
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2508
|
+
for (; e.pos < c; ) {
|
|
2509
|
+
let [i, l] = e.tag();
|
|
2510
|
+
switch (i) {
|
|
2511
|
+
case /* uint64 resource_id */
|
|
2512
|
+
1:
|
|
2513
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2514
|
+
break;
|
|
2515
|
+
case /* int64 offset */
|
|
2516
|
+
2:
|
|
2517
|
+
o.offset = e.int64().toBigInt();
|
|
2518
|
+
break;
|
|
2519
|
+
case /* optional uint32 chunk_size */
|
|
2520
|
+
11:
|
|
2521
|
+
o.chunkSize = e.uint32();
|
|
2522
|
+
break;
|
|
2523
|
+
default:
|
|
2524
|
+
let a = n.readUnknownField;
|
|
2525
|
+
if (a === "throw")
|
|
2526
|
+
throw new globalThis.Error(
|
|
2527
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2528
|
+
);
|
|
2529
|
+
let p = e.skip(l);
|
|
2530
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2531
|
+
this.typeName,
|
|
2532
|
+
o,
|
|
2533
|
+
i,
|
|
2534
|
+
l,
|
|
2535
|
+
p
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
return o;
|
|
2540
|
+
}
|
|
2541
|
+
internalBinaryWrite(e, t, n) {
|
|
2542
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, h.Varint).int64(e.offset), e.chunkSize !== void 0 && t.tag(11, h.Varint).uint32(e.chunkSize);
|
|
2543
|
+
let r = n.writeUnknownFields;
|
|
2544
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2545
|
+
this.typeName,
|
|
2546
|
+
e,
|
|
2547
|
+
t
|
|
2548
|
+
), t;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
const hr = new dr();
|
|
2552
|
+
class ur extends g {
|
|
2553
|
+
constructor() {
|
|
2554
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2555
|
+
{
|
|
2556
|
+
no: 1,
|
|
2557
|
+
name: "resource_id",
|
|
2558
|
+
kind: "scalar",
|
|
2559
|
+
T: 4,
|
|
2560
|
+
L: 0
|
|
2561
|
+
/*LongType.BIGINT*/
|
|
2562
|
+
},
|
|
2563
|
+
{
|
|
2564
|
+
no: 2,
|
|
2565
|
+
name: "offset",
|
|
2566
|
+
kind: "scalar",
|
|
2567
|
+
T: 3,
|
|
2568
|
+
L: 0
|
|
2569
|
+
/*LongType.BIGINT*/
|
|
2570
|
+
},
|
|
2571
|
+
{
|
|
2572
|
+
no: 20,
|
|
2573
|
+
name: "read_limit",
|
|
2574
|
+
kind: "scalar",
|
|
2575
|
+
opt: !0,
|
|
2576
|
+
T: 3,
|
|
2577
|
+
L: 0
|
|
2578
|
+
/*LongType.BIGINT*/
|
|
2579
|
+
},
|
|
2580
|
+
{
|
|
2581
|
+
no: 21,
|
|
2582
|
+
name: "search",
|
|
2583
|
+
kind: "scalar",
|
|
2584
|
+
opt: !0,
|
|
2585
|
+
T: 9
|
|
2586
|
+
/*ScalarType.STRING*/
|
|
2587
|
+
},
|
|
2588
|
+
{
|
|
2589
|
+
no: 22,
|
|
2590
|
+
name: "search_re",
|
|
2591
|
+
kind: "scalar",
|
|
2592
|
+
opt: !0,
|
|
2593
|
+
T: 9
|
|
2594
|
+
/*ScalarType.STRING*/
|
|
2595
|
+
}
|
|
2596
|
+
]);
|
|
2597
|
+
}
|
|
2598
|
+
create(e) {
|
|
2599
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2600
|
+
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2601
|
+
}
|
|
2602
|
+
internalBinaryRead(e, t, n, r) {
|
|
2603
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2604
|
+
for (; e.pos < c; ) {
|
|
2605
|
+
let [i, l] = e.tag();
|
|
2606
|
+
switch (i) {
|
|
2607
|
+
case /* uint64 resource_id */
|
|
2608
|
+
1:
|
|
2609
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2610
|
+
break;
|
|
2611
|
+
case /* int64 offset */
|
|
2612
|
+
2:
|
|
2613
|
+
o.offset = e.int64().toBigInt();
|
|
2614
|
+
break;
|
|
2615
|
+
case /* optional int64 read_limit */
|
|
2616
|
+
20:
|
|
2617
|
+
o.readLimit = e.int64().toBigInt();
|
|
2618
|
+
break;
|
|
2619
|
+
case /* optional string search */
|
|
2620
|
+
21:
|
|
2621
|
+
o.search = e.string();
|
|
2622
|
+
break;
|
|
2623
|
+
case /* optional string search_re */
|
|
2624
|
+
22:
|
|
2625
|
+
o.searchRe = e.string();
|
|
2626
|
+
break;
|
|
2627
|
+
default:
|
|
2628
|
+
let a = n.readUnknownField;
|
|
2629
|
+
if (a === "throw")
|
|
2630
|
+
throw new globalThis.Error(
|
|
2631
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2632
|
+
);
|
|
2633
|
+
let p = e.skip(l);
|
|
2634
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2635
|
+
this.typeName,
|
|
2636
|
+
o,
|
|
2637
|
+
i,
|
|
2638
|
+
l,
|
|
2639
|
+
p
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
return o;
|
|
2644
|
+
}
|
|
2645
|
+
internalBinaryWrite(e, t, n) {
|
|
2646
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, h.Varint).int64(e.offset), e.readLimit !== void 0 && t.tag(20, h.Varint).int64(e.readLimit), e.search !== void 0 && t.tag(21, h.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, h.LengthDelimited).string(e.searchRe);
|
|
2647
|
+
let r = n.writeUnknownFields;
|
|
2648
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2649
|
+
this.typeName,
|
|
2650
|
+
e,
|
|
2651
|
+
t
|
|
2652
|
+
), t;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
const pr = new ur();
|
|
2656
|
+
class gr extends g {
|
|
2657
|
+
constructor() {
|
|
2658
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2659
|
+
{
|
|
2660
|
+
no: 1,
|
|
2661
|
+
name: "resource_id",
|
|
2662
|
+
kind: "scalar",
|
|
2663
|
+
T: 4,
|
|
2664
|
+
L: 0
|
|
2665
|
+
/*LongType.BIGINT*/
|
|
2666
|
+
},
|
|
2667
|
+
{
|
|
2668
|
+
no: 2,
|
|
2669
|
+
name: "offset",
|
|
2670
|
+
kind: "scalar",
|
|
2671
|
+
T: 3,
|
|
2672
|
+
L: 0
|
|
2673
|
+
/*LongType.BIGINT*/
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
no: 20,
|
|
2677
|
+
name: "read_limit",
|
|
2678
|
+
kind: "scalar",
|
|
2679
|
+
opt: !0,
|
|
2680
|
+
T: 3,
|
|
2681
|
+
L: 0
|
|
2682
|
+
/*LongType.BIGINT*/
|
|
2683
|
+
},
|
|
2684
|
+
{
|
|
2685
|
+
no: 21,
|
|
2686
|
+
name: "search",
|
|
2687
|
+
kind: "scalar",
|
|
2688
|
+
opt: !0,
|
|
2689
|
+
T: 9
|
|
2690
|
+
/*ScalarType.STRING*/
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
no: 22,
|
|
2694
|
+
name: "search_re",
|
|
2695
|
+
kind: "scalar",
|
|
2696
|
+
opt: !0,
|
|
2697
|
+
T: 9
|
|
2698
|
+
/*ScalarType.STRING*/
|
|
2699
|
+
}
|
|
2700
|
+
]);
|
|
2701
|
+
}
|
|
2702
|
+
create(e) {
|
|
2703
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2704
|
+
return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2705
|
+
}
|
|
2706
|
+
internalBinaryRead(e, t, n, r) {
|
|
2707
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2708
|
+
for (; e.pos < c; ) {
|
|
2709
|
+
let [i, l] = e.tag();
|
|
2710
|
+
switch (i) {
|
|
2711
|
+
case /* uint64 resource_id */
|
|
2712
|
+
1:
|
|
2713
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2714
|
+
break;
|
|
2715
|
+
case /* int64 offset */
|
|
2716
|
+
2:
|
|
2717
|
+
o.offset = e.int64().toBigInt();
|
|
2718
|
+
break;
|
|
2719
|
+
case /* optional int64 read_limit */
|
|
2720
|
+
20:
|
|
2721
|
+
o.readLimit = e.int64().toBigInt();
|
|
2722
|
+
break;
|
|
2723
|
+
case /* optional string search */
|
|
2724
|
+
21:
|
|
2725
|
+
o.search = e.string();
|
|
2726
|
+
break;
|
|
2727
|
+
case /* optional string search_re */
|
|
2728
|
+
22:
|
|
2729
|
+
o.searchRe = e.string();
|
|
2730
|
+
break;
|
|
2731
|
+
default:
|
|
2732
|
+
let a = n.readUnknownField;
|
|
2733
|
+
if (a === "throw")
|
|
2734
|
+
throw new globalThis.Error(
|
|
2735
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2736
|
+
);
|
|
2737
|
+
let p = e.skip(l);
|
|
2738
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2739
|
+
this.typeName,
|
|
2740
|
+
o,
|
|
2741
|
+
i,
|
|
2742
|
+
l,
|
|
2743
|
+
p
|
|
2744
|
+
);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
return o;
|
|
2748
|
+
}
|
|
2749
|
+
internalBinaryWrite(e, t, n) {
|
|
2750
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.offset !== 0n && t.tag(2, h.Varint).int64(e.offset), e.readLimit !== void 0 && t.tag(20, h.Varint).int64(e.readLimit), e.search !== void 0 && t.tag(21, h.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, h.LengthDelimited).string(e.searchRe);
|
|
2751
|
+
let r = n.writeUnknownFields;
|
|
2752
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2753
|
+
this.typeName,
|
|
2754
|
+
e,
|
|
2755
|
+
t
|
|
2756
|
+
), t;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
const fr = new gr();
|
|
2760
|
+
class mr extends g {
|
|
2761
|
+
constructor() {
|
|
2762
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2763
|
+
{
|
|
2764
|
+
no: 1,
|
|
2765
|
+
name: "resource_id",
|
|
2766
|
+
kind: "scalar",
|
|
2767
|
+
T: 4,
|
|
2768
|
+
L: 0
|
|
2769
|
+
/*LongType.BIGINT*/
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
no: 2,
|
|
2773
|
+
name: "offset",
|
|
2774
|
+
kind: "scalar",
|
|
2775
|
+
opt: !0,
|
|
2776
|
+
T: 3,
|
|
2777
|
+
L: 0
|
|
2778
|
+
/*LongType.BIGINT*/
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
no: 3,
|
|
2782
|
+
name: "line_count",
|
|
2783
|
+
kind: "scalar",
|
|
2784
|
+
opt: !0,
|
|
2785
|
+
T: 5
|
|
2786
|
+
/*ScalarType.INT32*/
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
no: 21,
|
|
2790
|
+
name: "search",
|
|
2791
|
+
kind: "scalar",
|
|
2792
|
+
opt: !0,
|
|
2793
|
+
T: 9
|
|
2794
|
+
/*ScalarType.STRING*/
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
no: 22,
|
|
2798
|
+
name: "search_re",
|
|
2799
|
+
kind: "scalar",
|
|
2800
|
+
opt: !0,
|
|
2801
|
+
T: 9
|
|
2802
|
+
/*ScalarType.STRING*/
|
|
2803
|
+
}
|
|
2804
|
+
]);
|
|
2805
|
+
}
|
|
2806
|
+
create(e) {
|
|
2807
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2808
|
+
return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
|
|
2809
|
+
}
|
|
2810
|
+
internalBinaryRead(e, t, n, r) {
|
|
2811
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2812
|
+
for (; e.pos < c; ) {
|
|
2813
|
+
let [i, l] = e.tag();
|
|
2814
|
+
switch (i) {
|
|
2815
|
+
case /* uint64 resource_id */
|
|
2816
|
+
1:
|
|
2817
|
+
o.resourceId = e.uint64().toBigInt();
|
|
2818
|
+
break;
|
|
2819
|
+
case /* optional int64 offset */
|
|
2820
|
+
2:
|
|
2821
|
+
o.offset = e.int64().toBigInt();
|
|
2822
|
+
break;
|
|
2823
|
+
case /* optional int32 line_count */
|
|
2824
|
+
3:
|
|
2825
|
+
o.lineCount = e.int32();
|
|
2826
|
+
break;
|
|
2827
|
+
case /* optional string search */
|
|
2828
|
+
21:
|
|
2829
|
+
o.search = e.string();
|
|
2830
|
+
break;
|
|
2831
|
+
case /* optional string search_re */
|
|
2832
|
+
22:
|
|
2833
|
+
o.searchRe = e.string();
|
|
2834
|
+
break;
|
|
2835
|
+
default:
|
|
2836
|
+
let a = n.readUnknownField;
|
|
2837
|
+
if (a === "throw")
|
|
2838
|
+
throw new globalThis.Error(
|
|
2839
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2840
|
+
);
|
|
2841
|
+
let p = e.skip(l);
|
|
2842
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2843
|
+
this.typeName,
|
|
2844
|
+
o,
|
|
2845
|
+
i,
|
|
2846
|
+
l,
|
|
2847
|
+
p
|
|
2848
|
+
);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
return o;
|
|
2852
|
+
}
|
|
2853
|
+
internalBinaryWrite(e, t, n) {
|
|
2854
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.offset !== void 0 && t.tag(2, h.Varint).int64(e.offset), e.lineCount !== void 0 && t.tag(3, h.Varint).int32(e.lineCount), e.search !== void 0 && t.tag(21, h.LengthDelimited).string(e.search), e.searchRe !== void 0 && t.tag(22, h.LengthDelimited).string(e.searchRe);
|
|
2855
|
+
let r = n.writeUnknownFields;
|
|
2856
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2857
|
+
this.typeName,
|
|
2858
|
+
e,
|
|
2859
|
+
t
|
|
2860
|
+
), t;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
const wr = new mr();
|
|
2864
|
+
class yr extends g {
|
|
2865
|
+
constructor() {
|
|
2866
|
+
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2867
|
+
{
|
|
2868
|
+
no: 1,
|
|
2869
|
+
name: "data",
|
|
2870
|
+
kind: "scalar",
|
|
2871
|
+
T: 12
|
|
2872
|
+
/*ScalarType.BYTES*/
|
|
2873
|
+
},
|
|
2874
|
+
{
|
|
2875
|
+
no: 2,
|
|
2876
|
+
name: "size",
|
|
2877
|
+
kind: "scalar",
|
|
2878
|
+
T: 4,
|
|
2879
|
+
L: 0
|
|
2880
|
+
/*LongType.BIGINT*/
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
no: 3,
|
|
2884
|
+
name: "new_offset",
|
|
2885
|
+
kind: "scalar",
|
|
2886
|
+
T: 4,
|
|
2887
|
+
L: 0
|
|
2888
|
+
/*LongType.BIGINT*/
|
|
2889
|
+
}
|
|
2890
|
+
]);
|
|
2891
|
+
}
|
|
2892
|
+
create(e) {
|
|
2893
|
+
const t = globalThis.Object.create(this.messagePrototype);
|
|
2894
|
+
return t.data = new Uint8Array(0), t.size = 0n, t.newOffset = 0n, e !== void 0 && f(this, t, e), t;
|
|
2895
|
+
}
|
|
2896
|
+
internalBinaryRead(e, t, n, r) {
|
|
2897
|
+
let o = r ?? this.create(), c = e.pos + t;
|
|
2898
|
+
for (; e.pos < c; ) {
|
|
2899
|
+
let [i, l] = e.tag();
|
|
2900
|
+
switch (i) {
|
|
2901
|
+
case /* bytes data */
|
|
2902
|
+
1:
|
|
2903
|
+
o.data = e.bytes();
|
|
2904
|
+
break;
|
|
2905
|
+
case /* uint64 size */
|
|
2906
|
+
2:
|
|
2907
|
+
o.size = e.uint64().toBigInt();
|
|
2908
|
+
break;
|
|
2909
|
+
case /* uint64 new_offset */
|
|
2910
|
+
3:
|
|
2911
|
+
o.newOffset = e.uint64().toBigInt();
|
|
2912
|
+
break;
|
|
2913
|
+
default:
|
|
2914
|
+
let a = n.readUnknownField;
|
|
2915
|
+
if (a === "throw")
|
|
2916
|
+
throw new globalThis.Error(
|
|
2917
|
+
`Unknown field ${i} (wire type ${l}) for ${this.typeName}`
|
|
2918
|
+
);
|
|
2919
|
+
let p = e.skip(l);
|
|
2920
|
+
a !== !1 && (a === !0 ? u.onRead : a)(
|
|
2921
|
+
this.typeName,
|
|
2922
|
+
o,
|
|
2923
|
+
i,
|
|
2924
|
+
l,
|
|
2925
|
+
p
|
|
2926
|
+
);
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
return o;
|
|
2930
|
+
}
|
|
2931
|
+
internalBinaryWrite(e, t, n) {
|
|
2932
|
+
e.data.length && t.tag(1, h.LengthDelimited).bytes(e.data), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.newOffset !== 0n && t.tag(3, h.Varint).uint64(e.newOffset);
|
|
2933
|
+
let r = n.writeUnknownFields;
|
|
2934
|
+
return r !== !1 && (r == !0 ? u.onWrite : r)(
|
|
2935
|
+
this.typeName,
|
|
2936
|
+
e,
|
|
2937
|
+
t
|
|
2938
|
+
), t;
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
const U = new yr(), G = new v(
|
|
2942
|
+
"MiLaboratories.Controller.Shared.Streaming",
|
|
2943
|
+
[
|
|
2944
|
+
{
|
|
2945
|
+
name: "StreamBinary",
|
|
2946
|
+
serverStreaming: !0,
|
|
2947
|
+
options: {},
|
|
2948
|
+
I: cr,
|
|
2949
|
+
O: U
|
|
2950
|
+
},
|
|
2951
|
+
{
|
|
2952
|
+
name: "ReadBinary",
|
|
2953
|
+
options: {},
|
|
2954
|
+
I: hr,
|
|
2955
|
+
O: U
|
|
2956
|
+
},
|
|
2957
|
+
{
|
|
2958
|
+
name: "StreamText",
|
|
2959
|
+
serverStreaming: !0,
|
|
2960
|
+
options: {},
|
|
2961
|
+
I: pr,
|
|
2962
|
+
O: U
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
name: "ReadText",
|
|
2966
|
+
options: {},
|
|
2967
|
+
I: fr,
|
|
2968
|
+
O: U
|
|
2969
|
+
},
|
|
2970
|
+
{
|
|
2971
|
+
name: "LastLines",
|
|
2972
|
+
options: {},
|
|
2973
|
+
I: wr,
|
|
2974
|
+
O: U
|
|
2975
|
+
}
|
|
2976
|
+
]
|
|
2977
|
+
);
|
|
2978
|
+
class br {
|
|
2979
|
+
constructor(e) {
|
|
2980
|
+
d(this, "typeName", G.typeName);
|
|
2981
|
+
d(this, "methods", G.methods);
|
|
2982
|
+
d(this, "options", G.options);
|
|
2983
|
+
this._transport = e;
|
|
2984
|
+
}
|
|
2985
|
+
/**
|
|
2986
|
+
* StreamBinary provides stream of binary file. Each response message keeps
|
|
2987
|
+
* one single chunk of binary data from data source. See StreamingAPI.Binary message
|
|
2988
|
+
* for more info on available options.
|
|
2989
|
+
*
|
|
2990
|
+
* @generated from protobuf rpc: StreamBinary(MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary) returns (stream MiLaboratories.Controller.Shared.StreamingAPI.Response);
|
|
2991
|
+
*/
|
|
2992
|
+
streamBinary(e, t) {
|
|
2993
|
+
const n = this.methods[0], r = this._transport.mergeOptions(t);
|
|
2994
|
+
return y(
|
|
2995
|
+
"serverStreaming",
|
|
2996
|
+
this._transport,
|
|
2997
|
+
n,
|
|
2998
|
+
r,
|
|
2999
|
+
e
|
|
3000
|
+
);
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
3004
|
+
* The difference to StreamBinary is that the client receives single response for each
|
|
3005
|
+
* call and has to send new calls to the server to get fresh data from remote item.
|
|
3006
|
+
* Each response (each chunk from server) keeps not more than 3.9MiB of data.
|
|
3007
|
+
*
|
|
3008
|
+
* @generated from protobuf rpc: ReadBinary(MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary) returns (MiLaboratories.Controller.Shared.StreamingAPI.Response);
|
|
3009
|
+
*/
|
|
3010
|
+
readBinary(e, t) {
|
|
3011
|
+
const n = this.methods[1], r = this._transport.mergeOptions(t);
|
|
3012
|
+
return y(
|
|
3013
|
+
"unary",
|
|
3014
|
+
this._transport,
|
|
3015
|
+
n,
|
|
3016
|
+
r,
|
|
3017
|
+
e
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* StreamText provides stream of textual file, splitting the data by newline symbol.
|
|
3022
|
+
* Each response message keeps one single line of text from data source.
|
|
3023
|
+
*
|
|
3024
|
+
* @generated from protobuf rpc: StreamText(MiLaboratories.Controller.Shared.StreamingAPI.StreamText) returns (stream MiLaboratories.Controller.Shared.StreamingAPI.Response);
|
|
3025
|
+
*/
|
|
3026
|
+
streamText(e, t) {
|
|
3027
|
+
const n = this.methods[2], r = this._transport.mergeOptions(t);
|
|
3028
|
+
return y(
|
|
3029
|
+
"serverStreaming",
|
|
3030
|
+
this._transport,
|
|
3031
|
+
n,
|
|
3032
|
+
r,
|
|
3033
|
+
e
|
|
3034
|
+
);
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
3038
|
+
* The difference to StreamBinary is that the client receives single response for each
|
|
3039
|
+
* call and has to send new calls to the server to get fresh data from remote item.
|
|
3040
|
+
* Each response (each chunk from server) keeps not more than 3.9MiB of data.
|
|
3041
|
+
*
|
|
3042
|
+
* @generated from protobuf rpc: ReadText(MiLaboratories.Controller.Shared.StreamingAPI.ReadText) returns (MiLaboratories.Controller.Shared.StreamingAPI.Response);
|
|
3043
|
+
*/
|
|
3044
|
+
readText(e, t) {
|
|
3045
|
+
const n = this.methods[3], r = this._transport.mergeOptions(t);
|
|
3046
|
+
return y(
|
|
3047
|
+
"unary",
|
|
3048
|
+
this._transport,
|
|
3049
|
+
n,
|
|
3050
|
+
r,
|
|
3051
|
+
e
|
|
3052
|
+
);
|
|
3053
|
+
}
|
|
3054
|
+
/**
|
|
3055
|
+
* LastLines provides single message with the last lines from data source.
|
|
3056
|
+
* When search pattern is specified, the last lines matching the given pattern are returned.
|
|
3057
|
+
* The lines are returned in reversed order, as server reads data source from the end.
|
|
3058
|
+
* Consider it as equivalent to 'tac <file> | grep <search> | head -n <line_count>'
|
|
3059
|
+
* The <new_offset> returned in the response points to the _beginning_ of the last
|
|
3060
|
+
* line found, so client can continue reading the file backwards in subsequent calls.
|
|
3061
|
+
* This means, that use of this <new_offset> in ReadText() will return you the same line
|
|
3062
|
+
* returned last in LastLines() data.
|
|
3063
|
+
*
|
|
3064
|
+
* @generated from protobuf rpc: LastLines(MiLaboratories.Controller.Shared.StreamingAPI.LastLines) returns (MiLaboratories.Controller.Shared.StreamingAPI.Response);
|
|
3065
|
+
*/
|
|
3066
|
+
lastLines(e, t) {
|
|
3067
|
+
const n = this.methods[4], r = this._transport.mergeOptions(t);
|
|
3068
|
+
return y(
|
|
3069
|
+
"unary",
|
|
3070
|
+
this._transport,
|
|
3071
|
+
n,
|
|
3072
|
+
r,
|
|
3073
|
+
e
|
|
3074
|
+
);
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
class Tr {
|
|
3078
|
+
constructor(e, t, n) {
|
|
3079
|
+
d(this, "grpcClient");
|
|
3080
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new br(this.grpcTransport);
|
|
3081
|
+
}
|
|
3082
|
+
close() {
|
|
3083
|
+
}
|
|
3084
|
+
/** Reads text back and returns the text,
|
|
3085
|
+
* the new offset
|
|
3086
|
+
* and the total size of the (currently existing) file. */
|
|
3087
|
+
async lastLines({ id: e, type: t }, n, r = 0n, o, c) {
|
|
3088
|
+
return (await this.grpcClient.lastLines(
|
|
3089
|
+
{
|
|
3090
|
+
resourceId: e,
|
|
3091
|
+
lineCount: n,
|
|
3092
|
+
offset: r,
|
|
3093
|
+
search: o
|
|
3094
|
+
},
|
|
3095
|
+
T(t, c)
|
|
3096
|
+
)).response;
|
|
3097
|
+
}
|
|
3098
|
+
/** Reads the file forward and returns the text,
|
|
3099
|
+
* the new offset
|
|
3100
|
+
* and the total size of the (currently existing) file. */
|
|
3101
|
+
async readText({ id: e, type: t }, n, r = 0n, o, c) {
|
|
3102
|
+
return (await this.grpcClient.readText(
|
|
3103
|
+
{
|
|
3104
|
+
resourceId: O(e),
|
|
3105
|
+
readLimit: BigInt(n),
|
|
3106
|
+
offset: r,
|
|
3107
|
+
search: o
|
|
3108
|
+
},
|
|
3109
|
+
T(t, c)
|
|
3110
|
+
)).response;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
const kr = process.env.PL_STORAGE_TO_PATH ? Object.fromEntries(
|
|
3114
|
+
process.env.PL_STORAGE_TO_PATH.split(";").map((s) => s.split(":"))
|
|
3115
|
+
) : {};
|
|
3116
|
+
function Pn(s, e, t) {
|
|
3117
|
+
return t === void 0 && (t = kr), e.getDriver({
|
|
3118
|
+
name: "DownloadBlob",
|
|
3119
|
+
init: (r, o, c) => new Jt(
|
|
3120
|
+
o,
|
|
3121
|
+
c,
|
|
3122
|
+
s,
|
|
3123
|
+
t
|
|
3124
|
+
)
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
function In(s, e) {
|
|
3128
|
+
return s.getDriver({
|
|
3129
|
+
name: "StreamLogs",
|
|
3130
|
+
init: (t, n, r) => new Tr(n, r, e)
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
function Nn(s, e) {
|
|
3134
|
+
return s.getDriver({
|
|
3135
|
+
name: "UploadProgress",
|
|
3136
|
+
init: (t, n, r) => new At(n, r, s, e)
|
|
3137
|
+
});
|
|
3138
|
+
}
|
|
3139
|
+
function Rn(s, e) {
|
|
3140
|
+
return s.getDriver({
|
|
3141
|
+
name: "UploadBlob",
|
|
3142
|
+
init: (t, n, r) => new It(n, r, s, e)
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
function Sn(s, e) {
|
|
3146
|
+
return s.getDriver({
|
|
3147
|
+
name: "LsFiles",
|
|
3148
|
+
init: (t, n, r) => new ir(n, e)
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
class Un {
|
|
3152
|
+
constructor(e, t) {
|
|
3153
|
+
d(this, "updater");
|
|
3154
|
+
d(this, "schedule", () => this.updater.schedule());
|
|
3155
|
+
this.onUpdate = e, this.sleepMs = t, this.updater = new Se(async () => {
|
|
3156
|
+
for (; ; ) {
|
|
3157
|
+
if (await this.onUpdate()) return;
|
|
3158
|
+
await te.wait(this.sleepMs);
|
|
3159
|
+
}
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
class Se {
|
|
3164
|
+
constructor(e) {
|
|
3165
|
+
d(this, "updating");
|
|
3166
|
+
this.onUpdate = e;
|
|
3167
|
+
}
|
|
3168
|
+
schedule() {
|
|
3169
|
+
this.updating == null && (this.updating = (async () => {
|
|
3170
|
+
try {
|
|
3171
|
+
await this.onUpdate();
|
|
3172
|
+
} catch (e) {
|
|
3173
|
+
console.log(`error while updating in Updater: ${e}`);
|
|
3174
|
+
} finally {
|
|
3175
|
+
this.updating = void 0;
|
|
3176
|
+
}
|
|
3177
|
+
})());
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
async function Bn(s, e) {
|
|
3181
|
+
return s.withReadTx("LogsDriverGetStream", async (t) => {
|
|
3182
|
+
const n = await t.getResourceData(e, !0), r = await Me(t, He(n, "stream"));
|
|
3183
|
+
if (r.error != "")
|
|
3184
|
+
throw new Error(`while getting stream: ${r.error}`);
|
|
3185
|
+
if (!je(r.valueId))
|
|
3186
|
+
return await t.getResourceData(r.valueId, !1);
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
const Ue = "8C7#F1328%9E089B3D22", Lr = /(?<stage>.*):\s*(?<progress>[\d.]+%)\s.*(?<eta>ETA:.*)/g;
|
|
3190
|
+
function Pr(s) {
|
|
3191
|
+
const t = s.replace(Ue, "").match(Lr);
|
|
3192
|
+
if (t == null || t.length != 4)
|
|
3193
|
+
return;
|
|
3194
|
+
const [n, r, o, c] = t;
|
|
3195
|
+
return {
|
|
3196
|
+
stage: r,
|
|
3197
|
+
// For example, 'Building pre-clones from tag groups'
|
|
3198
|
+
progress: o,
|
|
3199
|
+
// 35.3%
|
|
3200
|
+
eta: c
|
|
3201
|
+
// ETA: 00:00:07
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
async function vn(s, e, t) {
|
|
3205
|
+
const n = await e.lastLines(
|
|
3206
|
+
s,
|
|
3207
|
+
1,
|
|
3208
|
+
0n,
|
|
3209
|
+
Ue,
|
|
3210
|
+
t
|
|
3211
|
+
);
|
|
3212
|
+
if (n.data == null || n.data.length == 0)
|
|
3213
|
+
return { found: !1 };
|
|
3214
|
+
const r = n.data.toString().split(/\r?\n/)[0];
|
|
3215
|
+
if (r == null)
|
|
3216
|
+
return { found: !1 };
|
|
3217
|
+
const o = Pr(r);
|
|
3218
|
+
return o === void 0 ? { found: !1 } : { found: !0, ...o };
|
|
3219
|
+
}
|
|
3220
|
+
class Be {
|
|
3221
|
+
constructor(e) {
|
|
3222
|
+
d(this, "cache", /* @__PURE__ */ new Map());
|
|
3223
|
+
d(this, "totalSizeBytes", 0);
|
|
3224
|
+
this.softSizeBytes = e;
|
|
3225
|
+
}
|
|
3226
|
+
existsFile(e) {
|
|
3227
|
+
return this.cache.get(e) != null;
|
|
3228
|
+
}
|
|
3229
|
+
getFile(e, t) {
|
|
3230
|
+
const n = this.cache.get(e);
|
|
3231
|
+
return n != null && n.counter.inc(t), n;
|
|
3232
|
+
}
|
|
3233
|
+
/** Decrements a counter in a cache and if we exceeds
|
|
3234
|
+
* a soft limit, removes files with zero counters. */
|
|
3235
|
+
removeFile(e, t) {
|
|
3236
|
+
return oe(this.cache, e).counter.dec(t), this.toDelete();
|
|
3237
|
+
}
|
|
3238
|
+
/** Returns what results should be deleted to comply with the soft limit. */
|
|
3239
|
+
toDelete() {
|
|
3240
|
+
if (this.totalSizeBytes <= this.softSizeBytes) return [];
|
|
3241
|
+
const e = [];
|
|
3242
|
+
let t = 0;
|
|
3243
|
+
return Ve(this.cache).filter(([n, r]) => r.counter.isZero()).forEach(([n, r]) => {
|
|
3244
|
+
if (this.totalSizeBytes - t <= this.softSizeBytes) return;
|
|
3245
|
+
const o = oe(this.cache, n);
|
|
3246
|
+
t += o.sizeBytes, e.push(o);
|
|
3247
|
+
}), e;
|
|
3248
|
+
}
|
|
3249
|
+
addCache(e, t) {
|
|
3250
|
+
const n = this.cache.get(e.path) == null;
|
|
3251
|
+
if (this.cache.set(e.path, e), e.counter.inc(t), e.sizeBytes < 0) throw new Error(`empty sizeBytes: ${e}`);
|
|
3252
|
+
n && (this.totalSizeBytes += e.sizeBytes);
|
|
3253
|
+
}
|
|
3254
|
+
removeCache(e) {
|
|
3255
|
+
this.cache.delete(e.path), this.totalSizeBytes -= e.sizeBytes;
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
class Dn {
|
|
3259
|
+
constructor(e, t) {
|
|
3260
|
+
this.logsStreamDriver = e, this.downloadDriver = t;
|
|
3261
|
+
}
|
|
3262
|
+
getLastLogs(e, t, n) {
|
|
3263
|
+
if (n === void 0)
|
|
3264
|
+
return b.make((o) => this.getLastLogs(e, t, o));
|
|
3265
|
+
const r = q(n, e);
|
|
3266
|
+
if (r === void 0) {
|
|
3267
|
+
n.markUnstable("no stream in stream manager");
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
if (V(r))
|
|
3271
|
+
return this.downloadDriver.getLastLogs(r, t, n);
|
|
3272
|
+
try {
|
|
3273
|
+
return this.logsStreamDriver.getLastLogs(r, t, n);
|
|
3274
|
+
} catch (o) {
|
|
3275
|
+
if (o.name == "RpcError" && o.code == "NOT_FOUND") {
|
|
3276
|
+
n.markUnstable(
|
|
3277
|
+
`NOT_FOUND in logs stream driver while getting last logs: ${o}`
|
|
3278
|
+
);
|
|
3279
|
+
return;
|
|
3280
|
+
}
|
|
3281
|
+
throw o;
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
getProgressLog(e, t, n) {
|
|
3285
|
+
if (n === void 0)
|
|
3286
|
+
return b.make(
|
|
3287
|
+
(o) => this.getProgressLog(e, t, o)
|
|
3288
|
+
);
|
|
3289
|
+
const r = q(n, e);
|
|
3290
|
+
if (r === void 0) {
|
|
3291
|
+
n.markUnstable("no stream in stream manager");
|
|
3292
|
+
return;
|
|
3293
|
+
}
|
|
3294
|
+
if (V(r))
|
|
3295
|
+
return this.downloadDriver.getProgressLog(r, t, n);
|
|
3296
|
+
try {
|
|
3297
|
+
return this.logsStreamDriver.getProgressLog(r, t, n);
|
|
3298
|
+
} catch (o) {
|
|
3299
|
+
if (o.name == "RpcError" && o.code == "NOT_FOUND") {
|
|
3300
|
+
n.markUnstable(
|
|
3301
|
+
`NOT_FOUND in logs stream driver while getting a progress log: ${o}`
|
|
3302
|
+
);
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
throw o;
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
getLogHandle(e, t) {
|
|
3309
|
+
if (t === void 0)
|
|
3310
|
+
return b.make((r) => this.getLogHandle(e, r));
|
|
3311
|
+
const n = q(t, e);
|
|
3312
|
+
if (n === void 0) {
|
|
3313
|
+
t.markUnstable("no stream in stream manager");
|
|
3314
|
+
return;
|
|
3315
|
+
}
|
|
3316
|
+
return V(n) ? this.downloadDriver.getLogHandle(n, t) : this.logsStreamDriver.getLogHandle(n, t);
|
|
3317
|
+
}
|
|
3318
|
+
async lastLines(e, t, n, r) {
|
|
3319
|
+
return C(e) ? await this.logsStreamDriver.lastLines(
|
|
3320
|
+
e,
|
|
3321
|
+
t,
|
|
3322
|
+
n,
|
|
3323
|
+
r
|
|
3324
|
+
) : await this.downloadDriver.lastLines(
|
|
3325
|
+
e,
|
|
3326
|
+
t,
|
|
3327
|
+
n,
|
|
3328
|
+
r
|
|
3329
|
+
);
|
|
3330
|
+
}
|
|
3331
|
+
async readText(e, t, n, r) {
|
|
3332
|
+
return C(e) ? await this.logsStreamDriver.readText(
|
|
3333
|
+
e,
|
|
3334
|
+
t,
|
|
3335
|
+
n,
|
|
3336
|
+
r
|
|
3337
|
+
) : await this.downloadDriver.readText(
|
|
3338
|
+
e,
|
|
3339
|
+
t,
|
|
3340
|
+
n,
|
|
3341
|
+
r
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
function V(s) {
|
|
3346
|
+
return !s.type.name.startsWith("StreamWorkdir");
|
|
3347
|
+
}
|
|
3348
|
+
function q(s, e) {
|
|
3349
|
+
var t;
|
|
3350
|
+
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
3351
|
+
}
|
|
3352
|
+
function $(s) {
|
|
3353
|
+
let e;
|
|
3354
|
+
if (C(s))
|
|
3355
|
+
e = s.match(De);
|
|
3356
|
+
else if (Ir(s))
|
|
3357
|
+
e = s.match(_e);
|
|
3358
|
+
else throw new Error(`Log handle is malformed: ${s}`);
|
|
3359
|
+
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
3360
|
+
const { resourceType: t, resourceVersion: n, resourceId: r } = e.groups;
|
|
3361
|
+
return {
|
|
3362
|
+
id: Q(BigInt(r)),
|
|
3363
|
+
type: { name: t, version: n }
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
function ve(s, e) {
|
|
3367
|
+
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
|
+
}
|
|
3369
|
+
const De = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3370
|
+
function C(s) {
|
|
3371
|
+
return De.test(s);
|
|
3372
|
+
}
|
|
3373
|
+
const _e = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3374
|
+
function Ir(s) {
|
|
3375
|
+
return _e.test(s);
|
|
3376
|
+
}
|
|
3377
|
+
const Nr = ye({
|
|
3378
|
+
kv: {
|
|
3379
|
+
"ctl/file/blobInfo": L.object({
|
|
3380
|
+
sizeBytes: L.coerce.number()
|
|
3381
|
+
})
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3384
|
+
class _n {
|
|
3385
|
+
constructor(e, t, n, r, o, c) {
|
|
3386
|
+
/** Represents a Resource Id to the path of a blob as a map. */
|
|
3387
|
+
d(this, "idToDownload", /* @__PURE__ */ new Map());
|
|
3388
|
+
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3389
|
+
* file that should be kept. */
|
|
3390
|
+
d(this, "cache");
|
|
3391
|
+
/** Downloads files and writes them to the local dir. */
|
|
3392
|
+
d(this, "downloadQueue");
|
|
3393
|
+
d(this, "idToOnDemand", /* @__PURE__ */ new Map());
|
|
3394
|
+
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3395
|
+
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3396
|
+
d(this, "saveDir");
|
|
3397
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new Be(c.cacheSoftSizeBytes), this.downloadQueue = new X(
|
|
3398
|
+
this.logger,
|
|
3399
|
+
c.nConcurrentDownloads
|
|
3400
|
+
), this.saveDir = m.resolve(r);
|
|
3401
|
+
}
|
|
3402
|
+
getDownloadedBlob(e, t) {
|
|
3403
|
+
if (t === void 0)
|
|
3404
|
+
return b.make((c) => this.getDownloadedBlob(e, c));
|
|
3405
|
+
const n = N(e, t), r = k();
|
|
3406
|
+
t.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3407
|
+
const o = this.getDownloadedBlobNoCtx(
|
|
3408
|
+
t.watcher,
|
|
3409
|
+
n,
|
|
3410
|
+
r
|
|
3411
|
+
);
|
|
3412
|
+
return o == null && t.markUnstable("download blob is still undefined"), o;
|
|
3413
|
+
}
|
|
3414
|
+
getOnDemandBlob(e, t) {
|
|
3415
|
+
if (t === void 0)
|
|
3416
|
+
return b.make((c) => this.getOnDemandBlob(e, c));
|
|
3417
|
+
const n = be(e) ? Te(e, Nr, t) : e, r = k();
|
|
3418
|
+
return t.addOnDestroy(() => this.releaseOnDemandBlob(n.id, r)), this.getOnDemandBlobNoCtx(t.watcher, n, r);
|
|
3419
|
+
}
|
|
3420
|
+
getLocalPath(e) {
|
|
3421
|
+
return Z(e, this.signer);
|
|
3422
|
+
}
|
|
3423
|
+
async getContent(e) {
|
|
3424
|
+
if (vr(e)) return await Sr(this.getLocalPath(e));
|
|
3425
|
+
if (!_r(e)) throw new Error("Malformed remote handle");
|
|
3426
|
+
const t = $r(e, this.signer), { content: n } = await this.clientDownload.downloadBlob(t);
|
|
3427
|
+
return await we(n);
|
|
3428
|
+
}
|
|
3429
|
+
getDownloadedBlobNoCtx(e, t, n) {
|
|
3430
|
+
let r = this.idToDownload.get(t.id);
|
|
3431
|
+
if (r === void 0) {
|
|
3432
|
+
const c = this.setNewDownloadTask(e, t, n);
|
|
3433
|
+
this.downloadQueue.push({
|
|
3434
|
+
fn: () => this.downloadBlob(c, n),
|
|
3435
|
+
recoverableErrorPredicate: (i) => !0
|
|
3436
|
+
}), r = c;
|
|
3437
|
+
}
|
|
3438
|
+
r.attach(e, n);
|
|
3439
|
+
const o = r.getBlob();
|
|
3440
|
+
if (o !== void 0) {
|
|
3441
|
+
if (o.ok) return o.value;
|
|
3442
|
+
throw o.error;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
setNewDownloadTask(e, t, n) {
|
|
3446
|
+
const r = this.getFilePath(t.id), o = new Br(
|
|
3447
|
+
this.clientDownload,
|
|
3448
|
+
t,
|
|
3449
|
+
r,
|
|
3450
|
+
Dr(r, this.signer)
|
|
3451
|
+
);
|
|
3452
|
+
return this.idToDownload.set(t.id, o), o;
|
|
3453
|
+
}
|
|
3454
|
+
async downloadBlob(e, t) {
|
|
3455
|
+
var n;
|
|
3456
|
+
await e.download(), (n = e.getBlob()) != null && n.ok && this.cache.addCache(e, t);
|
|
3457
|
+
}
|
|
3458
|
+
getOnDemandBlobNoCtx(e, t, n) {
|
|
3459
|
+
let r = this.idToOnDemand.get(t.id);
|
|
3460
|
+
return r === void 0 && (r = new Rr(
|
|
3461
|
+
t.kv["ctl/file/blobInfo"].sizeBytes,
|
|
3462
|
+
Cr(t, this.signer)
|
|
3463
|
+
), this.idToOnDemand.set(t.id, r)), r.attach(e, n), r.getHandle();
|
|
3464
|
+
}
|
|
3465
|
+
getLastLogs(e, t, n) {
|
|
3466
|
+
if (n == null)
|
|
3467
|
+
return b.make((i) => this.getLastLogs(e, t, i));
|
|
3468
|
+
const r = N(e, n), o = k();
|
|
3469
|
+
n.addOnDestroy(() => this.releaseBlob(r.id, o));
|
|
3470
|
+
const c = this.getLastLogsNoCtx(
|
|
3471
|
+
n.watcher,
|
|
3472
|
+
r,
|
|
3473
|
+
t,
|
|
3474
|
+
o
|
|
3475
|
+
);
|
|
3476
|
+
return c == null && n.markUnstable("either a file was not downloaded or logs was not read"), c;
|
|
3477
|
+
}
|
|
3478
|
+
getLastLogsNoCtx(e, t, n, r) {
|
|
3479
|
+
const o = this.getDownloadedBlobNoCtx(e, t, r);
|
|
3480
|
+
if (o == null) return;
|
|
3481
|
+
const c = Z(o.handle, this.signer);
|
|
3482
|
+
let i = this.idToLastLines.get(t.id);
|
|
3483
|
+
if (i == null) {
|
|
3484
|
+
const a = new ae(c, n);
|
|
3485
|
+
this.idToLastLines.set(t.id, a), i = a;
|
|
3486
|
+
}
|
|
3487
|
+
const l = i.getOrSchedule(e);
|
|
3488
|
+
if (l.error) throw l.error;
|
|
3489
|
+
return l.log;
|
|
3490
|
+
}
|
|
3491
|
+
getProgressLog(e, t, n) {
|
|
3492
|
+
if (n == null)
|
|
3493
|
+
return b.make(
|
|
3494
|
+
(i) => this.getProgressLog(e, t, i)
|
|
3495
|
+
);
|
|
3496
|
+
const r = N(e, n), o = k();
|
|
3497
|
+
n.addOnDestroy(() => this.releaseBlob(r.id, o));
|
|
3498
|
+
const c = this.getProgressLogNoCtx(
|
|
3499
|
+
n.watcher,
|
|
3500
|
+
r,
|
|
3501
|
+
t,
|
|
3502
|
+
o
|
|
3503
|
+
);
|
|
3504
|
+
return c === void 0 && n.markUnstable(
|
|
3505
|
+
"either a file was not downloaded or a progress log was not read"
|
|
3506
|
+
), c;
|
|
3507
|
+
}
|
|
3508
|
+
getProgressLogNoCtx(e, t, n, r) {
|
|
3509
|
+
const o = this.getDownloadedBlobNoCtx(e, t, r);
|
|
3510
|
+
if (o == null) return;
|
|
3511
|
+
const c = Z(o.handle, this.signer);
|
|
3512
|
+
let i = this.idToProgressLog.get(t.id);
|
|
3513
|
+
if (i == null) {
|
|
3514
|
+
const a = new ae(c, 1, n);
|
|
3515
|
+
this.idToProgressLog.set(t.id, a), i = a;
|
|
3516
|
+
}
|
|
3517
|
+
const l = i.getOrSchedule(e);
|
|
3518
|
+
if (l.error) throw l.error;
|
|
3519
|
+
return l.log;
|
|
3520
|
+
}
|
|
3521
|
+
getLogHandle(e, t) {
|
|
3522
|
+
if (t == null)
|
|
3523
|
+
return b.make((r) => this.getLogHandle(e, r));
|
|
3524
|
+
const n = N(e, t);
|
|
3525
|
+
return this.getLogHandleNoCtx(n);
|
|
3526
|
+
}
|
|
3527
|
+
getLogHandleNoCtx(e) {
|
|
3528
|
+
return ve(!1, e);
|
|
3529
|
+
}
|
|
3530
|
+
async lastLines(e, t, n, r) {
|
|
3531
|
+
const o = await this.clientLogs.lastLines(
|
|
3532
|
+
$(e),
|
|
3533
|
+
t,
|
|
3534
|
+
BigInt(n ?? 0),
|
|
3535
|
+
r
|
|
3536
|
+
);
|
|
3537
|
+
return {
|
|
3538
|
+
live: !1,
|
|
3539
|
+
shouldUpdateHandle: !1,
|
|
3540
|
+
data: o.data,
|
|
3541
|
+
size: Number(o.size),
|
|
3542
|
+
newOffset: Number(o.newOffset)
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
async readText(e, t, n, r) {
|
|
3546
|
+
const o = await this.clientLogs.readText(
|
|
3547
|
+
$(e),
|
|
3548
|
+
t,
|
|
3549
|
+
BigInt(n ?? 0),
|
|
3550
|
+
r
|
|
3551
|
+
);
|
|
3552
|
+
return {
|
|
3553
|
+
live: !1,
|
|
3554
|
+
shouldUpdateHandle: !1,
|
|
3555
|
+
data: o.data,
|
|
3556
|
+
size: Number(o.size),
|
|
3557
|
+
newOffset: Number(o.newOffset)
|
|
3558
|
+
};
|
|
3559
|
+
}
|
|
3560
|
+
async releaseBlob(e, t) {
|
|
3561
|
+
const n = this.idToDownload.get(e);
|
|
3562
|
+
if (n != null)
|
|
3563
|
+
if (this.cache.existsFile(n.path)) {
|
|
3564
|
+
const r = this.cache.removeFile(n.path, t);
|
|
3565
|
+
await Promise.all(
|
|
3566
|
+
r.map(async (o) => {
|
|
3567
|
+
await w.rm(o.path), this.cache.removeCache(o), this.removeTask(
|
|
3568
|
+
o,
|
|
3569
|
+
`the task ${o.path} was removedfrom cache along with ${r.map((c) => c.path)}`
|
|
3570
|
+
);
|
|
3571
|
+
})
|
|
3572
|
+
);
|
|
3573
|
+
} else
|
|
3574
|
+
n.counter.dec(t) && this.removeTask(n, `the task ${n.path} was removed from cache`);
|
|
3575
|
+
}
|
|
3576
|
+
removeTask(e, t) {
|
|
3577
|
+
e.abort(t), e.change.markChanged(), this.idToDownload.delete(e.rInfo.id), this.idToLastLines.delete(e.rInfo.id), this.idToProgressLog.delete(e.rInfo.id);
|
|
3578
|
+
}
|
|
3579
|
+
async releaseOnDemandBlob(e, t) {
|
|
3580
|
+
var r;
|
|
3581
|
+
(((r = this.idToOnDemand.get(e)) == null ? void 0 : r.release(t)) ?? !1) && this.idToOnDemand.delete(e);
|
|
3582
|
+
}
|
|
3583
|
+
/** Removes all files from a hard drive. */
|
|
3584
|
+
async releaseAll() {
|
|
3585
|
+
this.downloadQueue.stop(), this.idToDownload.forEach((e, t) => {
|
|
3586
|
+
this.idToDownload.delete(t), e.change.markChanged();
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
getFilePath(e) {
|
|
3590
|
+
return m.resolve(m.join(this.saveDir, String(BigInt(e))));
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
class Rr {
|
|
3594
|
+
constructor(e, t) {
|
|
3595
|
+
d(this, "change", new S());
|
|
3596
|
+
d(this, "counter", new D());
|
|
3597
|
+
this.size = e, this.handle = t;
|
|
3598
|
+
}
|
|
3599
|
+
getHandle() {
|
|
3600
|
+
return { handle: this.handle, size: this.size };
|
|
3601
|
+
}
|
|
3602
|
+
attach(e, t) {
|
|
3603
|
+
this.counter.inc(t), this.change.attachWatcher(e);
|
|
3604
|
+
}
|
|
3605
|
+
release(e) {
|
|
3606
|
+
return this.counter.dec(e);
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
class ae {
|
|
3610
|
+
constructor(e, t, n) {
|
|
3611
|
+
d(this, "updater");
|
|
3612
|
+
d(this, "log");
|
|
3613
|
+
d(this, "change", new S());
|
|
3614
|
+
d(this, "error");
|
|
3615
|
+
this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new Se(async () => this.update());
|
|
3616
|
+
}
|
|
3617
|
+
getOrSchedule(e) {
|
|
3618
|
+
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
3619
|
+
log: this.log,
|
|
3620
|
+
error: this.error
|
|
3621
|
+
};
|
|
3622
|
+
}
|
|
3623
|
+
async update() {
|
|
3624
|
+
try {
|
|
3625
|
+
const e = await Ur(
|
|
3626
|
+
this.path,
|
|
3627
|
+
this.lines,
|
|
3628
|
+
this.patternToSearch
|
|
3629
|
+
);
|
|
3630
|
+
this.log != e && this.change.markChanged(), this.log = e;
|
|
3631
|
+
} catch (e) {
|
|
3632
|
+
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
3633
|
+
this.log = "", this.error = e, this.change.markChanged();
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
throw e;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
async function le(s) {
|
|
3641
|
+
try {
|
|
3642
|
+
return await w.access(s), !0;
|
|
3643
|
+
} catch {
|
|
3644
|
+
return !1;
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
async function Sr(s) {
|
|
3648
|
+
return await we(K.toWeb(E.createReadStream(s)));
|
|
3649
|
+
}
|
|
3650
|
+
function Ur(s, e, t) {
|
|
3651
|
+
const n = E.createReadStream(s), r = new ee();
|
|
3652
|
+
return new Promise((o, c) => {
|
|
3653
|
+
const i = Je.createInterface(n, r), l = new Qe();
|
|
3654
|
+
i.on("line", function(a) {
|
|
3655
|
+
t != null && !a.includes(t) || (l.push(a), l.length > e && l.shift());
|
|
3656
|
+
}), i.on("error", c), i.on("close", function() {
|
|
3657
|
+
o(l.toArray().join(se.EOL) + se.EOL);
|
|
3658
|
+
});
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
let Br = class {
|
|
3662
|
+
constructor(e, t, n, r) {
|
|
3663
|
+
d(this, "counter", new D());
|
|
3664
|
+
d(this, "change", new S());
|
|
3665
|
+
d(this, "signalCtl", new AbortController());
|
|
3666
|
+
d(this, "error");
|
|
3667
|
+
d(this, "done", !1);
|
|
3668
|
+
d(this, "sizeBytes", 0);
|
|
3669
|
+
this.clientDownload = e, this.rInfo = t, this.path = n, this.handle = r;
|
|
3670
|
+
}
|
|
3671
|
+
attach(e, t) {
|
|
3672
|
+
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
3673
|
+
}
|
|
3674
|
+
async download() {
|
|
3675
|
+
try {
|
|
3676
|
+
const { content: e, size: t } = await this.clientDownload.downloadBlob(
|
|
3677
|
+
this.rInfo
|
|
3678
|
+
);
|
|
3679
|
+
if (await le(m.dirname(this.path)) || w.mkdir(m.dirname(this.path), { recursive: !0 }), !await le(this.path)) {
|
|
3680
|
+
const n = ee.toWeb(E.createWriteStream(this.path));
|
|
3681
|
+
await e.pipeTo(n);
|
|
3682
|
+
}
|
|
3683
|
+
this.setDone(t);
|
|
3684
|
+
} catch (e) {
|
|
3685
|
+
if (e instanceof ce || e instanceof re || e instanceof Ne || e instanceof Re || e.code == "ENOENT") {
|
|
3686
|
+
this.setError(e), await w.rm(this.path);
|
|
3687
|
+
return;
|
|
3688
|
+
}
|
|
3689
|
+
throw e;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
getBlob() {
|
|
3693
|
+
if (this.done)
|
|
3694
|
+
return {
|
|
3695
|
+
ok: !0,
|
|
3696
|
+
value: {
|
|
3697
|
+
handle: this.handle,
|
|
3698
|
+
size: this.sizeBytes
|
|
3699
|
+
}
|
|
3700
|
+
};
|
|
3701
|
+
if (this.error)
|
|
3702
|
+
return {
|
|
3703
|
+
ok: !1,
|
|
3704
|
+
error: this.error
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
setDone(e) {
|
|
3708
|
+
this.done = !0, this.sizeBytes = e, this.change.markChanged();
|
|
3709
|
+
}
|
|
3710
|
+
abort(e) {
|
|
3711
|
+
this.signalCtl.abort(new ce(e));
|
|
3712
|
+
}
|
|
3713
|
+
setError(e) {
|
|
3714
|
+
this.error = e, this.change.markChanged();
|
|
3715
|
+
}
|
|
3716
|
+
};
|
|
3717
|
+
class ce extends Error {
|
|
3718
|
+
}
|
|
3719
|
+
const $e = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
3720
|
+
function vr(s) {
|
|
3721
|
+
return !!s.match($e);
|
|
3722
|
+
}
|
|
3723
|
+
function Z(s, e) {
|
|
3724
|
+
const t = s.match($e);
|
|
3725
|
+
if (t === null)
|
|
3726
|
+
throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
3727
|
+
const { path: n, signature: r } = t.groups;
|
|
3728
|
+
return e.verify(
|
|
3729
|
+
n,
|
|
3730
|
+
r,
|
|
3731
|
+
`Signature verification failed for: ${s}`
|
|
3732
|
+
), n;
|
|
3733
|
+
}
|
|
3734
|
+
function Dr(s, e) {
|
|
3735
|
+
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
3736
|
+
}
|
|
3737
|
+
const Ce = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
|
|
3738
|
+
function _r(s) {
|
|
3739
|
+
return !!s.match(Ce);
|
|
3740
|
+
}
|
|
3741
|
+
function $r(s, e) {
|
|
3742
|
+
const t = s.match(Ce);
|
|
3743
|
+
if (t === null)
|
|
3744
|
+
throw new Error(
|
|
3745
|
+
`Remote handle is malformed: ${s}, matches: ${t}`
|
|
3746
|
+
);
|
|
3747
|
+
const { content: n, resourceType: r, resourceVersion: o, resourceId: c, signature: i } = t.groups;
|
|
3748
|
+
return e.verify(
|
|
3749
|
+
n,
|
|
3750
|
+
i,
|
|
3751
|
+
`Signature verification failed for ${s}`
|
|
3752
|
+
), {
|
|
3753
|
+
id: Q(BigInt(c)),
|
|
3754
|
+
type: { name: r, version: o }
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
function Cr(s, e) {
|
|
3758
|
+
const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
|
|
3759
|
+
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
3760
|
+
}
|
|
3761
|
+
const Or = L.object({
|
|
3762
|
+
localPath: L.string(),
|
|
3763
|
+
pathSignature: L.string(),
|
|
3764
|
+
modificationTime: L.string()
|
|
3765
|
+
}), Er = L.union([Or, L.object({})]), Fr = ye({
|
|
3766
|
+
data: Er,
|
|
3767
|
+
fields: {
|
|
3768
|
+
blob: !1,
|
|
3769
|
+
// for BlobUpload
|
|
3770
|
+
incarnation: !1
|
|
3771
|
+
// for BlobIndex
|
|
3772
|
+
}
|
|
3773
|
+
});
|
|
3774
|
+
class Cn {
|
|
3775
|
+
constructor(e, t, n, r, o = {
|
|
3776
|
+
nConcurrentPartUploads: 10,
|
|
3777
|
+
nConcurrentGetProgresses: 10,
|
|
3778
|
+
pollingInterval: 1e3,
|
|
3779
|
+
stopPollingDelay: 1e3
|
|
3780
|
+
}) {
|
|
3781
|
+
d(this, "idToProgress", /* @__PURE__ */ new Map());
|
|
3782
|
+
/** Holds a queue that upload blobs. */
|
|
3783
|
+
d(this, "uploadQueue");
|
|
3784
|
+
d(this, "hooks");
|
|
3785
|
+
d(this, "scheduledOnNextState", []);
|
|
3786
|
+
/** If true, main loop will continue polling pl state. */
|
|
3787
|
+
d(this, "keepRunning", !1);
|
|
3788
|
+
/** Actual state of main loop. */
|
|
3789
|
+
d(this, "currentLoop");
|
|
3790
|
+
this.logger = e, this.signer = t, this.clientBlob = n, this.clientProgress = r, this.opts = o, this.uploadQueue = new X(this.logger, 1, {
|
|
3791
|
+
type: "exponentialWithMaxDelayBackoff",
|
|
3792
|
+
initialDelay: 20,
|
|
3793
|
+
maxDelay: 15e3,
|
|
3794
|
+
// 15 seconds
|
|
3795
|
+
backoffMultiplier: 1.5,
|
|
3796
|
+
jitter: 0.5
|
|
3797
|
+
}), this.hooks = new me(
|
|
3798
|
+
() => this.startUpdating(),
|
|
3799
|
+
() => this.stopUpdating(),
|
|
3800
|
+
{ stopDebounce: o.stopPollingDelay },
|
|
3801
|
+
(c, i) => this.scheduleOnNextState(c, i)
|
|
3802
|
+
);
|
|
3803
|
+
}
|
|
3804
|
+
getProgressId(e, t) {
|
|
3805
|
+
if (t == null)
|
|
3806
|
+
return b.make((c) => this.getProgressId(e, c));
|
|
3807
|
+
const n = be(e) ? Te(e, Fr, t) : e, r = k();
|
|
3808
|
+
t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(n.id, r));
|
|
3809
|
+
const o = this.getProgressIdNoCtx(t.watcher, n, r);
|
|
3810
|
+
return de(o) || t.markUnstable(
|
|
3811
|
+
`upload/index progress was got, but it's not stable: ${o}`
|
|
3812
|
+
), o;
|
|
3813
|
+
}
|
|
3814
|
+
getProgressIdNoCtx(e, t, n) {
|
|
3815
|
+
const r = t.fields.blob != null || t.fields.incarnation != null, o = this.idToProgress.get(t.id);
|
|
3816
|
+
if (o != null)
|
|
3817
|
+
return o.attach(e, n), o.mustGetProgress(r);
|
|
3818
|
+
const c = new Wr(
|
|
3819
|
+
this.logger,
|
|
3820
|
+
this.clientBlob,
|
|
3821
|
+
this.clientProgress,
|
|
3822
|
+
this.opts.nConcurrentPartUploads,
|
|
3823
|
+
this.signer,
|
|
3824
|
+
t
|
|
3825
|
+
);
|
|
3826
|
+
return this.idToProgress.set(t.id, c), c.attach(e, n), c.progress.isUpload && c.progress.isUploadSignMatch && this.uploadQueue.push({
|
|
3827
|
+
fn: () => c.uploadBlobTask(),
|
|
3828
|
+
recoverableErrorPredicate: (i) => !Oe(i)
|
|
3829
|
+
}), c.mustGetProgress(r);
|
|
3830
|
+
}
|
|
3831
|
+
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
3832
|
+
async release(e, t) {
|
|
3833
|
+
const n = this.idToProgress.get(e);
|
|
3834
|
+
if (n === void 0) return;
|
|
3835
|
+
n.decCounter(t) && this.idToProgress.delete(e);
|
|
3836
|
+
}
|
|
3837
|
+
/** Must be called when the driver is closing. */
|
|
3838
|
+
async releaseAll() {
|
|
3839
|
+
this.uploadQueue.stop();
|
|
3840
|
+
}
|
|
3841
|
+
scheduleOnNextState(e, t) {
|
|
3842
|
+
this.scheduledOnNextState.push({ resolve: e, reject: t });
|
|
3843
|
+
}
|
|
3844
|
+
/** Called from observer */
|
|
3845
|
+
startUpdating() {
|
|
3846
|
+
this.keepRunning = !0, this.currentLoop === void 0 && (this.currentLoop = this.mainLoop());
|
|
3847
|
+
}
|
|
3848
|
+
/** Called from observer */
|
|
3849
|
+
stopUpdating() {
|
|
3850
|
+
this.keepRunning = !1;
|
|
3851
|
+
}
|
|
3852
|
+
async mainLoop() {
|
|
3853
|
+
for (; this.keepRunning; ) {
|
|
3854
|
+
const e = this.scheduledOnNextState;
|
|
3855
|
+
this.scheduledOnNextState = [];
|
|
3856
|
+
try {
|
|
3857
|
+
await Y(
|
|
3858
|
+
this.opts.nConcurrentGetProgresses,
|
|
3859
|
+
this.getAllNotDoneProgresses().map(
|
|
3860
|
+
(t) => async () => await t.updateStatus()
|
|
3861
|
+
)
|
|
3862
|
+
), e.forEach((t) => t.resolve());
|
|
3863
|
+
} catch (t) {
|
|
3864
|
+
console.error(t), e.forEach((n) => n.reject(t));
|
|
3865
|
+
}
|
|
3866
|
+
if (!this.keepRunning) break;
|
|
3867
|
+
await te.wait(this.opts.pollingInterval);
|
|
3868
|
+
}
|
|
3869
|
+
this.currentLoop = void 0;
|
|
3870
|
+
}
|
|
3871
|
+
getAllNotDoneProgresses() {
|
|
3872
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !de(t.progress)).map(([e, t]) => t);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
class Wr {
|
|
3876
|
+
constructor(e, t, n, r, o, c) {
|
|
3877
|
+
d(this, "change", new S());
|
|
3878
|
+
d(this, "counter", new D());
|
|
3879
|
+
d(this, "progress");
|
|
3880
|
+
d(this, "uploadOpts");
|
|
3881
|
+
d(this, "uploadingTerminallyFailed");
|
|
3882
|
+
this.logger = e, this.clientBlob = t, this.clientProgress = n, this.nConcurrentPartsUpload = r, this.res = c;
|
|
3883
|
+
const i = c.type.name.startsWith("BlobUpload");
|
|
3884
|
+
let l;
|
|
3885
|
+
i && (this.uploadOpts = Ar(c), l = xr(
|
|
3886
|
+
o,
|
|
3887
|
+
this.uploadOpts.localPath,
|
|
3888
|
+
this.uploadOpts.pathSignature
|
|
3889
|
+
)), this.progress = {
|
|
3890
|
+
done: !1,
|
|
3891
|
+
status: void 0,
|
|
3892
|
+
isUpload: i,
|
|
3893
|
+
isUploadSignMatch: l,
|
|
3894
|
+
lastError: void 0
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
mustGetProgress(e) {
|
|
3898
|
+
if (e)
|
|
3899
|
+
return this.setDone(e), this.progress;
|
|
3900
|
+
if (this.uploadingTerminallyFailed)
|
|
3901
|
+
throw this.logger.error(
|
|
3902
|
+
`Uploading terminally failed: ${this.progress.lastError}`
|
|
3903
|
+
), new Error(this.progress.lastError);
|
|
3904
|
+
return this.progress;
|
|
3905
|
+
}
|
|
3906
|
+
attach(e, t) {
|
|
3907
|
+
this.change.attachWatcher(e), this.counter.inc(t);
|
|
3908
|
+
}
|
|
3909
|
+
decCounter(e) {
|
|
3910
|
+
return this.counter.dec(e);
|
|
3911
|
+
}
|
|
3912
|
+
/** Uploads a blob if it's not BlobIndex. */
|
|
3913
|
+
async uploadBlobTask() {
|
|
3914
|
+
try {
|
|
3915
|
+
await this.uploadBlob();
|
|
3916
|
+
} catch (e) {
|
|
3917
|
+
if (this.setLastError(e), he(e)) {
|
|
3918
|
+
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3919
|
+
return;
|
|
3920
|
+
}
|
|
3921
|
+
throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Oe(e) && this.terminateWithError(e), e;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
/** Uploads a blob using client. */
|
|
3925
|
+
async uploadBlob() {
|
|
3926
|
+
if (this.counter.isZero()) return;
|
|
3927
|
+
const e = await this.clientBlob.initUpload(this.res);
|
|
3928
|
+
this.logger.info(
|
|
3929
|
+
`start to upload blob ${this.res.id}, parts count: ${e.length}`
|
|
3930
|
+
);
|
|
3931
|
+
const t = (n) => async () => {
|
|
3932
|
+
this.counter.isZero() || await this.clientBlob.partUpload(
|
|
3933
|
+
this.res,
|
|
3934
|
+
this.uploadOpts.localPath,
|
|
3935
|
+
n,
|
|
3936
|
+
e.length,
|
|
3937
|
+
BigInt(this.uploadOpts.modificationTime)
|
|
3938
|
+
);
|
|
3939
|
+
};
|
|
3940
|
+
await Y(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());
|
|
3941
|
+
}
|
|
3942
|
+
terminateWithError(e) {
|
|
3943
|
+
this.progress.lastError = String(e), this.progress.done = !1, this.uploadingTerminallyFailed = !0;
|
|
3944
|
+
}
|
|
3945
|
+
setLastError(e) {
|
|
3946
|
+
this.progress.lastError = String(e);
|
|
3947
|
+
}
|
|
3948
|
+
setDone(e) {
|
|
3949
|
+
this.progress.done = e;
|
|
3950
|
+
}
|
|
3951
|
+
async updateStatus() {
|
|
3952
|
+
try {
|
|
3953
|
+
const e = await this.clientProgress.getStatus(this.res), t = this.progress.status;
|
|
3954
|
+
this.progress.status = zr(e), this.setDone(e.done), (e.done || e.progress != (t == null ? void 0 : t.progress)) && this.change.markChanged();
|
|
3955
|
+
} catch (e) {
|
|
3956
|
+
if (this.setLastError(e), e.name == "RpcError" && e.code == "DEADLINE_EXCEEDED") {
|
|
3957
|
+
this.logger.warn(
|
|
3958
|
+
"deadline exceeded while getting a status of BlobImport"
|
|
3959
|
+
);
|
|
3960
|
+
return;
|
|
3961
|
+
}
|
|
3962
|
+
if (he(e)) {
|
|
3963
|
+
this.logger.warn(
|
|
3964
|
+
`resource was not found while updating a status of BlobImport: ${e}, ${B(this.res)}`
|
|
3965
|
+
), this.change.markChanged(), this.setDone(!0);
|
|
3966
|
+
return;
|
|
3967
|
+
}
|
|
3968
|
+
this.logger.error(`error while updating a status of BlobImport: ${e}`), this.change.markChanged(), this.terminateWithError(e);
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
function de(s) {
|
|
3973
|
+
return s.done && s.status !== void 0 && s.status !== null && s.status.progress >= 1;
|
|
3974
|
+
}
|
|
3975
|
+
function Ar(s) {
|
|
3976
|
+
if (s.data == null || !("modificationTime" in s.data))
|
|
3977
|
+
throw new Error(
|
|
3978
|
+
"no upload options in BlobUpload resource data: " + B(s.data)
|
|
3979
|
+
);
|
|
3980
|
+
const e = s.data;
|
|
3981
|
+
if (e.modificationTime === void 0)
|
|
3982
|
+
throw new Error(
|
|
3983
|
+
"no modification time in data: " + B(s.data)
|
|
3984
|
+
);
|
|
3985
|
+
if (e.localPath === void 0)
|
|
3986
|
+
throw new Error(
|
|
3987
|
+
"no local path in data: " + B(s.data)
|
|
3988
|
+
);
|
|
3989
|
+
if (e.pathSignature === void 0)
|
|
3990
|
+
throw new Error(
|
|
3991
|
+
"no path signature in data: " + B(s.data)
|
|
3992
|
+
);
|
|
3993
|
+
return {
|
|
3994
|
+
modificationTime: e.modificationTime,
|
|
3995
|
+
localPath: e.localPath,
|
|
3996
|
+
pathSignature: e.pathSignature
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
function zr(s) {
|
|
4000
|
+
return {
|
|
4001
|
+
progress: s.progress ?? 0,
|
|
4002
|
+
bytesProcessed: Number(s.bytesProcessed),
|
|
4003
|
+
bytesTotal: Number(s.bytesTotal)
|
|
4004
|
+
};
|
|
4005
|
+
}
|
|
4006
|
+
function xr(s, e, t) {
|
|
4007
|
+
try {
|
|
4008
|
+
return s.verify(e, t), !0;
|
|
4009
|
+
} catch {
|
|
4010
|
+
return !1;
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
function Oe(s) {
|
|
4014
|
+
return s instanceof ke || s instanceof Le || s instanceof Pe;
|
|
4015
|
+
}
|
|
4016
|
+
function he(s) {
|
|
4017
|
+
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
4018
|
+
}
|
|
4019
|
+
class On {
|
|
4020
|
+
constructor(e, t = {
|
|
4021
|
+
nConcurrentGetLogs: 10,
|
|
4022
|
+
pollingInterval: 1e3,
|
|
4023
|
+
stopPollingDelay: 1e3
|
|
4024
|
+
}) {
|
|
4025
|
+
/** Holds a map of StreamManager Resource Id to all logs of this stream. */
|
|
4026
|
+
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
4027
|
+
/** Holds a map of StreamManager Resource Id to the last log line of this stream. */
|
|
4028
|
+
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
4029
|
+
/** Holds a map of StreamManager Resource Id to log id smart object. */
|
|
4030
|
+
d(this, "hooks");
|
|
4031
|
+
d(this, "scheduledOnNextState", []);
|
|
4032
|
+
/** If true, main loop will continue polling pl state. */
|
|
4033
|
+
d(this, "keepRunning", !1);
|
|
4034
|
+
/** Actual state of main loop. */
|
|
4035
|
+
d(this, "currentLoop");
|
|
4036
|
+
this.clientLogs = e, this.opts = t, this.hooks = new me(
|
|
4037
|
+
() => this.startUpdating(),
|
|
4038
|
+
() => this.stopUpdating(),
|
|
4039
|
+
{ stopDebounce: t.stopPollingDelay },
|
|
4040
|
+
(n, r) => this.scheduleOnNextState(n, r)
|
|
4041
|
+
);
|
|
4042
|
+
}
|
|
4043
|
+
getLastLogs(e, t, n) {
|
|
4044
|
+
if (n == null)
|
|
4045
|
+
return b.make((i) => this.getLastLogs(e, t, i));
|
|
4046
|
+
const r = N(e, n), o = k();
|
|
4047
|
+
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseLastLogs(r.id, o));
|
|
4048
|
+
const c = this.getLastLogsNoCtx(n.watcher, r, t, o);
|
|
4049
|
+
return n.markUnstable(
|
|
4050
|
+
"The logs are from stream, so we consider them unstable. Final values will be got from blobs."
|
|
4051
|
+
), c;
|
|
4052
|
+
}
|
|
4053
|
+
getLastLogsNoCtx(e, t, n, r) {
|
|
4054
|
+
let o = this.idToLastLines.get(t.id);
|
|
4055
|
+
if (o == null) {
|
|
4056
|
+
const i = new ue(this.clientLogs, t, n);
|
|
4057
|
+
this.idToLastLines.set(t.id, i), o = i;
|
|
4058
|
+
}
|
|
4059
|
+
o.attach(e, r);
|
|
4060
|
+
const c = o.getLog();
|
|
4061
|
+
if (c.error != null) throw c.error;
|
|
4062
|
+
return c.log;
|
|
4063
|
+
}
|
|
4064
|
+
getProgressLog(e, t, n) {
|
|
4065
|
+
if (n == null)
|
|
4066
|
+
return b.make(
|
|
4067
|
+
(i) => this.getProgressLog(e, t, i)
|
|
4068
|
+
);
|
|
4069
|
+
const r = N(e, n), o = k();
|
|
4070
|
+
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseProgressLog(r.id, o));
|
|
4071
|
+
const c = this.getProgressLogNoCtx(
|
|
4072
|
+
n.watcher,
|
|
4073
|
+
r,
|
|
4074
|
+
t,
|
|
4075
|
+
o
|
|
4076
|
+
);
|
|
4077
|
+
return n.markUnstable(
|
|
4078
|
+
"The progress log is from the stream, so we consider it unstable. Final value will be got from blobs."
|
|
4079
|
+
), c;
|
|
4080
|
+
}
|
|
4081
|
+
getProgressLogNoCtx(e, t, n, r) {
|
|
4082
|
+
let o = this.idToProgressLog.get(t.id);
|
|
4083
|
+
if (o == null) {
|
|
4084
|
+
const i = new ue(
|
|
4085
|
+
this.clientLogs,
|
|
4086
|
+
t,
|
|
4087
|
+
1,
|
|
4088
|
+
n
|
|
4089
|
+
);
|
|
4090
|
+
this.idToProgressLog.set(t.id, i), o = i;
|
|
4091
|
+
}
|
|
4092
|
+
o.attach(e, r);
|
|
4093
|
+
const c = o.getLog();
|
|
4094
|
+
if (c.error) throw c.error;
|
|
4095
|
+
return c.log;
|
|
4096
|
+
}
|
|
4097
|
+
getLogHandle(e, t) {
|
|
4098
|
+
if (t == null)
|
|
4099
|
+
return b.make((o) => this.getLogHandle(e, o));
|
|
4100
|
+
const n = N(e, t), r = this.getLogHandleNoCtx(n);
|
|
4101
|
+
return t.markUnstable(), r;
|
|
4102
|
+
}
|
|
4103
|
+
getLogHandleNoCtx(e) {
|
|
4104
|
+
return ve(!0, e);
|
|
4105
|
+
}
|
|
4106
|
+
async lastLines(e, t, n, r) {
|
|
4107
|
+
return await this.tryWithNotFound(
|
|
4108
|
+
e,
|
|
4109
|
+
() => this.clientLogs.lastLines(
|
|
4110
|
+
$(e),
|
|
4111
|
+
t,
|
|
4112
|
+
BigInt(n ?? 0),
|
|
4113
|
+
r
|
|
4114
|
+
)
|
|
4115
|
+
);
|
|
4116
|
+
}
|
|
4117
|
+
async readText(e, t, n, r) {
|
|
4118
|
+
return await this.tryWithNotFound(
|
|
4119
|
+
e,
|
|
4120
|
+
() => this.clientLogs.readText(
|
|
4121
|
+
$(e),
|
|
4122
|
+
t,
|
|
4123
|
+
BigInt(n ?? 0),
|
|
4124
|
+
r
|
|
4125
|
+
)
|
|
4126
|
+
);
|
|
4127
|
+
}
|
|
4128
|
+
async tryWithNotFound(e, t) {
|
|
4129
|
+
if (!C(e))
|
|
4130
|
+
throw new Error(
|
|
4131
|
+
`Not live log handle was passed to live log driver, handle: ${e}`
|
|
4132
|
+
);
|
|
4133
|
+
try {
|
|
4134
|
+
const n = await t();
|
|
4135
|
+
return {
|
|
4136
|
+
live: !0,
|
|
4137
|
+
shouldUpdateHandle: !1,
|
|
4138
|
+
data: n.data,
|
|
4139
|
+
size: Number(n.size),
|
|
4140
|
+
newOffset: Number(n.newOffset)
|
|
4141
|
+
};
|
|
4142
|
+
} catch (n) {
|
|
4143
|
+
if (n.name == "RpcError" && n.code == "NOT_FOUND")
|
|
4144
|
+
return { shouldUpdateHandle: !0 };
|
|
4145
|
+
throw n;
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
async releaseLastLogs(e, t) {
|
|
4149
|
+
var r;
|
|
4150
|
+
((r = this.idToLastLines.get(e)) == null ? void 0 : r.release(t)) && this.idToLastLines.delete(e);
|
|
4151
|
+
}
|
|
4152
|
+
async releaseProgressLog(e, t) {
|
|
4153
|
+
var r;
|
|
4154
|
+
((r = this.idToProgressLog.get(e)) == null ? void 0 : r.release(t)) && this.idToProgressLog.delete(e);
|
|
4155
|
+
}
|
|
4156
|
+
async releaseAll() {
|
|
4157
|
+
}
|
|
4158
|
+
scheduleOnNextState(e, t) {
|
|
4159
|
+
this.scheduledOnNextState.push({ resolve: e, reject: t });
|
|
4160
|
+
}
|
|
4161
|
+
/** Called from observer */
|
|
4162
|
+
startUpdating() {
|
|
4163
|
+
this.keepRunning = !0, this.currentLoop === void 0 && (this.currentLoop = this.mainLoop());
|
|
4164
|
+
}
|
|
4165
|
+
/** Called from observer */
|
|
4166
|
+
stopUpdating() {
|
|
4167
|
+
this.keepRunning = !1;
|
|
4168
|
+
}
|
|
4169
|
+
async mainLoop() {
|
|
4170
|
+
for (; this.keepRunning; ) {
|
|
4171
|
+
const e = this.scheduledOnNextState;
|
|
4172
|
+
this.scheduledOnNextState = [];
|
|
4173
|
+
try {
|
|
4174
|
+
await Y(
|
|
4175
|
+
this.opts.nConcurrentGetLogs,
|
|
4176
|
+
this.getAllNotDoneLogs().map(
|
|
4177
|
+
(t) => async () => await t.update()
|
|
4178
|
+
)
|
|
4179
|
+
), e.forEach((t) => t.resolve());
|
|
4180
|
+
} catch (t) {
|
|
4181
|
+
console.error(t), e.forEach((n) => n.reject(t));
|
|
4182
|
+
}
|
|
4183
|
+
if (!this.keepRunning) break;
|
|
4184
|
+
await te.wait(this.opts.pollingInterval);
|
|
4185
|
+
}
|
|
4186
|
+
this.currentLoop = void 0;
|
|
4187
|
+
}
|
|
4188
|
+
getAllNotDoneLogs() {
|
|
4189
|
+
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).filter(([e, t]) => !t.getLog().done).map(([e, t]) => t);
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
class ue {
|
|
4193
|
+
constructor(e, t, n, r) {
|
|
4194
|
+
d(this, "logs");
|
|
4195
|
+
d(this, "error");
|
|
4196
|
+
d(this, "done", !1);
|
|
4197
|
+
d(this, "change", new S());
|
|
4198
|
+
d(this, "counter", new D());
|
|
4199
|
+
this.clientLogs = e, this.rInfo = t, this.lines = n, this.patternToSearch = r;
|
|
4200
|
+
}
|
|
4201
|
+
getLog() {
|
|
4202
|
+
return {
|
|
4203
|
+
log: this.logs,
|
|
4204
|
+
error: this.error,
|
|
4205
|
+
done: this.done
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
attach(e, t) {
|
|
4209
|
+
this.change.attachWatcher(e), this.counter.inc(t);
|
|
4210
|
+
}
|
|
4211
|
+
release(e) {
|
|
4212
|
+
return this.counter.dec(e);
|
|
4213
|
+
}
|
|
4214
|
+
async update() {
|
|
4215
|
+
try {
|
|
4216
|
+
const t = (await this.clientLogs.lastLines(
|
|
4217
|
+
this.rInfo,
|
|
4218
|
+
this.lines,
|
|
4219
|
+
0n,
|
|
4220
|
+
this.patternToSearch
|
|
4221
|
+
)).data.toString();
|
|
4222
|
+
this.logs != t && this.change.markChanged(), this.logs = t;
|
|
4223
|
+
return;
|
|
4224
|
+
} catch (e) {
|
|
4225
|
+
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
4226
|
+
this.logs = "", this.error = e, this.done = !0, this.change.markChanged();
|
|
4227
|
+
return;
|
|
4228
|
+
}
|
|
4229
|
+
throw e;
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
class En {
|
|
4234
|
+
constructor(e, t, n, r = {
|
|
4235
|
+
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
4236
|
+
withGunzip: !0,
|
|
4237
|
+
nConcurrentDownloads: 50
|
|
4238
|
+
}) {
|
|
4239
|
+
d(this, "downloadHelper");
|
|
4240
|
+
d(this, "urlToDownload", /* @__PURE__ */ new Map());
|
|
4241
|
+
d(this, "downloadQueue");
|
|
4242
|
+
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4243
|
+
* file that should be kept. */
|
|
4244
|
+
d(this, "cache");
|
|
4245
|
+
this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new X(
|
|
4246
|
+
this.logger,
|
|
4247
|
+
this.opts.nConcurrentDownloads
|
|
4248
|
+
), this.cache = new Be(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ie(t);
|
|
4249
|
+
}
|
|
4250
|
+
getPath(e, t) {
|
|
4251
|
+
if (t === void 0) return b.make((o) => this.getPath(e, o));
|
|
4252
|
+
const n = k();
|
|
4253
|
+
t.addOnDestroy(() => this.releasePath(e, n));
|
|
4254
|
+
const r = this.getPathNoCtx(e, t.watcher, n);
|
|
4255
|
+
return (r == null ? void 0 : r.path) === void 0 && t.markUnstable(
|
|
4256
|
+
`a path to the downloaded and untared archive might be undefined. The current result: ${r}`
|
|
4257
|
+
), r;
|
|
4258
|
+
}
|
|
4259
|
+
getPathNoCtx(e, t, n) {
|
|
4260
|
+
const r = e.toString(), o = this.urlToDownload.get(r);
|
|
4261
|
+
if (o != null)
|
|
4262
|
+
return o.attach(t, n), o.getPath();
|
|
4263
|
+
const c = this.setNewTask(t, e, n);
|
|
4264
|
+
return this.downloadQueue.push({
|
|
4265
|
+
fn: async () => this.downloadUrl(c, n),
|
|
4266
|
+
recoverableErrorPredicate: (i) => !0
|
|
4267
|
+
}), c.getPath();
|
|
4268
|
+
}
|
|
4269
|
+
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4270
|
+
async downloadUrl(e, t) {
|
|
4271
|
+
var n;
|
|
4272
|
+
await e.download(this.downloadHelper, this.opts.withGunzip), ((n = e.getPath()) == null ? void 0 : n.path) != null && this.cache.addCache(e, t);
|
|
4273
|
+
}
|
|
4274
|
+
/** Removes a directory and aborts a downloading task when all callers
|
|
4275
|
+
* are not interested in it. */
|
|
4276
|
+
async releasePath(e, t) {
|
|
4277
|
+
const n = e.toString(), r = this.urlToDownload.get(n);
|
|
4278
|
+
if (r != null)
|
|
4279
|
+
if (this.cache.existsFile(r.path)) {
|
|
4280
|
+
const o = this.cache.removeFile(r.path, t);
|
|
4281
|
+
await Promise.all(
|
|
4282
|
+
o.map(async (c) => {
|
|
4283
|
+
await J(c.path), this.cache.removeCache(c), this.removeTask(
|
|
4284
|
+
c,
|
|
4285
|
+
`the task ${JSON.stringify(c)} was removedfrom cache along with ${JSON.stringify(o)}`
|
|
4286
|
+
);
|
|
4287
|
+
})
|
|
4288
|
+
);
|
|
4289
|
+
} else
|
|
4290
|
+
r.counter.dec(t) && this.removeTask(
|
|
4291
|
+
r,
|
|
4292
|
+
`the task ${JSON.stringify(r)} was removed from cache`
|
|
4293
|
+
);
|
|
4294
|
+
}
|
|
4295
|
+
/** Removes all files from a hard drive. */
|
|
4296
|
+
async releaseAll() {
|
|
4297
|
+
this.downloadQueue.stop(), await Promise.all(
|
|
4298
|
+
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4299
|
+
await J(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4300
|
+
t,
|
|
4301
|
+
`the task ${t} was released when the driver was closed`
|
|
4302
|
+
);
|
|
4303
|
+
})
|
|
4304
|
+
);
|
|
4305
|
+
}
|
|
4306
|
+
setNewTask(e, t, n) {
|
|
4307
|
+
const r = new Mr(this.getFilePath(t), t);
|
|
4308
|
+
return r.attach(e, n), this.urlToDownload.set(t.toString(), r), r;
|
|
4309
|
+
}
|
|
4310
|
+
removeTask(e, t) {
|
|
4311
|
+
e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
|
|
4312
|
+
}
|
|
4313
|
+
getFilePath(e) {
|
|
4314
|
+
const t = Xe("sha256").update(e.toString()).digest("hex");
|
|
4315
|
+
return m.join(this.saveDir, t);
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
class Mr {
|
|
4319
|
+
constructor(e, t) {
|
|
4320
|
+
d(this, "counter", new D());
|
|
4321
|
+
d(this, "change", new S());
|
|
4322
|
+
d(this, "signalCtl", new AbortController());
|
|
4323
|
+
d(this, "error");
|
|
4324
|
+
d(this, "done", !1);
|
|
4325
|
+
d(this, "sizeBytes", 0);
|
|
4326
|
+
this.path = e, this.url = t;
|
|
4327
|
+
}
|
|
4328
|
+
attach(e, t) {
|
|
4329
|
+
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
4330
|
+
}
|
|
4331
|
+
async download(e, t) {
|
|
4332
|
+
try {
|
|
4333
|
+
const n = await this.downloadAndUntar(
|
|
4334
|
+
e,
|
|
4335
|
+
t,
|
|
4336
|
+
this.signalCtl.signal
|
|
4337
|
+
);
|
|
4338
|
+
this.setDone(n);
|
|
4339
|
+
} catch (n) {
|
|
4340
|
+
if (n instanceof pe || n instanceof re) {
|
|
4341
|
+
this.setError(n), await J(this.path);
|
|
4342
|
+
return;
|
|
4343
|
+
}
|
|
4344
|
+
throw n;
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
async downloadAndUntar(e, t, n) {
|
|
4348
|
+
if (await Hr(this.path))
|
|
4349
|
+
return await Ee(this.path);
|
|
4350
|
+
const r = await e.downloadRemoteFile(
|
|
4351
|
+
this.url.toString(),
|
|
4352
|
+
{},
|
|
4353
|
+
n
|
|
4354
|
+
);
|
|
4355
|
+
let o = r.content;
|
|
4356
|
+
if (t) {
|
|
4357
|
+
const i = Ze.toWeb(Ye.createGunzip());
|
|
4358
|
+
o = o.pipeThrough(i, { signal: n });
|
|
4359
|
+
}
|
|
4360
|
+
const c = ee.toWeb(Ke.extract(this.path));
|
|
4361
|
+
return await o.pipeTo(c, { signal: n }), r.size;
|
|
4362
|
+
}
|
|
4363
|
+
getPath() {
|
|
4364
|
+
if (this.done) return { path: O(this.path) };
|
|
4365
|
+
if (this.error) return { error: this.error };
|
|
4366
|
+
}
|
|
4367
|
+
setDone(e) {
|
|
4368
|
+
this.done = !0, this.sizeBytes = e, this.change.markChanged();
|
|
4369
|
+
}
|
|
4370
|
+
abort(e) {
|
|
4371
|
+
this.signalCtl.abort(new pe(e));
|
|
4372
|
+
}
|
|
4373
|
+
setError(e) {
|
|
4374
|
+
this.error = String(e), this.change.markChanged();
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
class pe extends Error {
|
|
4378
|
+
}
|
|
4379
|
+
async function Hr(s) {
|
|
4380
|
+
try {
|
|
4381
|
+
return await w.access(s), !0;
|
|
4382
|
+
} catch {
|
|
4383
|
+
return !1;
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4386
|
+
async function Ee(s) {
|
|
4387
|
+
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
4388
|
+
return (await Promise.all(
|
|
4389
|
+
e.map(async (n) => {
|
|
4390
|
+
const r = m.join(s, n.name);
|
|
4391
|
+
return n.isDirectory() ? await Ee(r) : (await w.stat(r)).size;
|
|
4392
|
+
})
|
|
4393
|
+
)).reduce((n, r) => n + r, 0);
|
|
4394
|
+
}
|
|
4395
|
+
async function J(s) {
|
|
4396
|
+
await w.rm(s, { recursive: !0, force: !0 });
|
|
4397
|
+
}
|
|
4398
|
+
function jr(s) {
|
|
4399
|
+
var t;
|
|
4400
|
+
return {
|
|
4401
|
+
parent: s.list.items.length > 0 ? (t = s.list.items[0]) == null ? void 0 : t.directory : void 0,
|
|
4402
|
+
entries: s.list.items.map((n) => Gr(n, s))
|
|
4403
|
+
};
|
|
4404
|
+
}
|
|
4405
|
+
function Gr(s, e) {
|
|
4406
|
+
return s.isDir ? {
|
|
4407
|
+
type: "dir",
|
|
4408
|
+
name: s.name,
|
|
4409
|
+
fullPath: s.fullName
|
|
4410
|
+
} : {
|
|
4411
|
+
type: "file",
|
|
4412
|
+
name: s.name,
|
|
4413
|
+
fullPath: s.fullName,
|
|
4414
|
+
handle: Vr({ item: s, ...e })
|
|
4415
|
+
};
|
|
4416
|
+
}
|
|
4417
|
+
function Vr(s) {
|
|
4418
|
+
return s.remote ? qr(s) : Fe(
|
|
4419
|
+
s.item.fullName,
|
|
4420
|
+
s.signer,
|
|
4421
|
+
s.item.size,
|
|
4422
|
+
O(s.item.lastModified).seconds
|
|
4423
|
+
);
|
|
4424
|
+
}
|
|
4425
|
+
function qr(s) {
|
|
4426
|
+
return `index://index/${encodeURIComponent(
|
|
4427
|
+
JSON.stringify({
|
|
4428
|
+
storageId: s.storageName,
|
|
4429
|
+
path: s.item.fullName
|
|
4430
|
+
})
|
|
4431
|
+
)}`;
|
|
4432
|
+
}
|
|
4433
|
+
function Fe(s, e, t, n) {
|
|
4434
|
+
const r = {
|
|
4435
|
+
localPath: s,
|
|
4436
|
+
pathSignature: e.sign(s),
|
|
4437
|
+
sizeBytes: String(t),
|
|
4438
|
+
modificationTime: String(n)
|
|
4439
|
+
};
|
|
4440
|
+
return `upload://upload/${encodeURIComponent(JSON.stringify(r))}`;
|
|
4441
|
+
}
|
|
4442
|
+
function Zr(s, e) {
|
|
4443
|
+
if (!(e.dirent.isFile() || e.dirent.isDirectory())) {
|
|
4444
|
+
s.warn(
|
|
4445
|
+
`tried to get non-dir and non-file ${e.dirent.name}, skip it`
|
|
4446
|
+
);
|
|
4447
|
+
return;
|
|
4448
|
+
}
|
|
4449
|
+
return {
|
|
4450
|
+
directory: e.directory,
|
|
4451
|
+
isDir: e.dirent.isDirectory(),
|
|
4452
|
+
name: e.dirent.name,
|
|
4453
|
+
fullName: e.fullName,
|
|
4454
|
+
lastModified: {
|
|
4455
|
+
seconds: BigInt(Math.floor(e.stat.mtimeMs / 1e3)),
|
|
4456
|
+
nanos: 0
|
|
4457
|
+
},
|
|
4458
|
+
size: BigInt(e.stat.size)
|
|
4459
|
+
};
|
|
4460
|
+
}
|
|
4461
|
+
function Jr(s, e) {
|
|
4462
|
+
const t = Object.entries(s).map(Xr), n = Object.entries(e).map(tn);
|
|
4463
|
+
return t.concat(n);
|
|
4464
|
+
}
|
|
4465
|
+
function Qr(s) {
|
|
4466
|
+
if (rn(s))
|
|
4467
|
+
return on(s);
|
|
4468
|
+
if (Yr(s))
|
|
4469
|
+
return en(s);
|
|
4470
|
+
qe(s);
|
|
4471
|
+
}
|
|
4472
|
+
function Xr([s, e]) {
|
|
4473
|
+
return {
|
|
4474
|
+
name: s,
|
|
4475
|
+
handle: Kr(s, e),
|
|
4476
|
+
initialFullPath: e
|
|
4477
|
+
};
|
|
4478
|
+
}
|
|
4479
|
+
const We = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4480
|
+
function Yr(s) {
|
|
4481
|
+
return We.test(s);
|
|
4482
|
+
}
|
|
4483
|
+
function Kr(s, e) {
|
|
4484
|
+
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4485
|
+
}
|
|
4486
|
+
function en(s) {
|
|
4487
|
+
const e = s.match(We);
|
|
4488
|
+
if (e == null)
|
|
4489
|
+
throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4490
|
+
const { name: t, path: n } = e.groups;
|
|
4491
|
+
return {
|
|
4492
|
+
path: decodeURIComponent(n),
|
|
4493
|
+
name: t,
|
|
4494
|
+
remote: !1
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
function tn([s, e]) {
|
|
4498
|
+
return {
|
|
4499
|
+
name: s,
|
|
4500
|
+
handle: nn(s, e),
|
|
4501
|
+
initialFullPath: ""
|
|
4502
|
+
};
|
|
4503
|
+
}
|
|
4504
|
+
const Ae = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4505
|
+
function rn(s) {
|
|
4506
|
+
return Ae.test(s);
|
|
4507
|
+
}
|
|
4508
|
+
function nn(s, e) {
|
|
4509
|
+
return `remote://${s}/${BigInt(e)}`;
|
|
4510
|
+
}
|
|
4511
|
+
function on(s) {
|
|
4512
|
+
const e = s.match(Ae);
|
|
4513
|
+
if (e == null)
|
|
4514
|
+
throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4515
|
+
const { name: t, resourceId: n } = e.groups;
|
|
4516
|
+
return {
|
|
4517
|
+
id: Q(BigInt(n)),
|
|
4518
|
+
type: sn(t),
|
|
4519
|
+
name: t,
|
|
4520
|
+
remote: !0
|
|
4521
|
+
};
|
|
4522
|
+
}
|
|
4523
|
+
function sn(s) {
|
|
4524
|
+
return { name: `LS/${s}`, version: "1" };
|
|
4525
|
+
}
|
|
4526
|
+
class Fn {
|
|
4527
|
+
constructor(e, t, n, r, o) {
|
|
4528
|
+
d(this, "storageIdToResourceId");
|
|
4529
|
+
this.logger = e, this.clientLs = t, this.client = n, this.signer = r, this.localStorageToPath = o;
|
|
4530
|
+
}
|
|
4531
|
+
async getLocalFileHandle(e) {
|
|
4532
|
+
const t = await w.stat(e, { bigint: !0 });
|
|
4533
|
+
return Fe(
|
|
4534
|
+
e,
|
|
4535
|
+
this.signer,
|
|
4536
|
+
t.size,
|
|
4537
|
+
t.mtimeMs / 1000n
|
|
4538
|
+
// integer division
|
|
4539
|
+
);
|
|
4540
|
+
}
|
|
4541
|
+
async getStorageList() {
|
|
4542
|
+
return Jr(
|
|
4543
|
+
this.localStorageToPath,
|
|
4544
|
+
await this.getAvailableStorageIds()
|
|
4545
|
+
);
|
|
4546
|
+
}
|
|
4547
|
+
async listFiles(e, t) {
|
|
4548
|
+
const n = Qr(e);
|
|
4549
|
+
let r;
|
|
4550
|
+
return n.remote ? r = await this.clientLs.list(n, t) : r = await this.getLocalFiles(this.logger, n.path, t), jr({
|
|
4551
|
+
storageName: n.name,
|
|
4552
|
+
list: r,
|
|
4553
|
+
signer: this.signer,
|
|
4554
|
+
remote: n.remote
|
|
4555
|
+
});
|
|
4556
|
+
}
|
|
4557
|
+
async getAvailableStorageIds() {
|
|
4558
|
+
return this.storageIdToResourceId == null && (this.storageIdToResourceId = await an(this.client)), this.storageIdToResourceId;
|
|
4559
|
+
}
|
|
4560
|
+
async getLocalFiles(e, t, n) {
|
|
4561
|
+
const r = m.resolve(t), o = m.isAbsolute(n) ? n : m.resolve(m.join(r, n)), c = await w.opendir(o), i = [];
|
|
4562
|
+
for await (const a of c) {
|
|
4563
|
+
const p = m.join(o, a.name);
|
|
4564
|
+
i.push({
|
|
4565
|
+
directory: o,
|
|
4566
|
+
fullName: p,
|
|
4567
|
+
dirent: a,
|
|
4568
|
+
stat: await w.stat(p)
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
return {
|
|
4572
|
+
delimiter: m.sep,
|
|
4573
|
+
items: i.map((a) => Zr(e, a)).filter((a) => a != null).map((a) => a)
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
async function an(s) {
|
|
4578
|
+
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4579
|
+
const t = await e.getResourceByName("LSProvider"), n = await e.getResourceData(t, !0);
|
|
4580
|
+
return ln(n);
|
|
4581
|
+
});
|
|
4582
|
+
}
|
|
4583
|
+
function ln(s) {
|
|
4584
|
+
return Object.fromEntries(
|
|
4585
|
+
s.fields.filter((e) => e.type == "Dynamic" && Ge(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4586
|
+
);
|
|
4587
|
+
}
|
|
4588
|
+
export {
|
|
4589
|
+
Jt as ClientDownload,
|
|
4590
|
+
Tr as ClientLogs,
|
|
4591
|
+
ir as ClientLs,
|
|
4592
|
+
At as ClientProgress,
|
|
4593
|
+
It as ClientUpload,
|
|
4594
|
+
Br as Download,
|
|
4595
|
+
_n as DownloadDriver,
|
|
4596
|
+
En as DownloadUrlDriver,
|
|
4597
|
+
Dn as LogsDriver,
|
|
4598
|
+
On as LogsStreamDriver,
|
|
4599
|
+
Un as LongUpdater,
|
|
4600
|
+
Fn as LsDriver,
|
|
4601
|
+
ke as MTimeError,
|
|
4602
|
+
Pt as NetworkError,
|
|
4603
|
+
Pe as NoFileForUploading,
|
|
4604
|
+
Nr as OnDemandBlobResourceSnapshot,
|
|
4605
|
+
kr as PL_STORAGE_TO_PATH,
|
|
4606
|
+
Le as UnexpectedEOF,
|
|
4607
|
+
Ne as UnknownStorageError,
|
|
4608
|
+
Se as Updater,
|
|
4609
|
+
Cn as UploadDriver,
|
|
4610
|
+
Fr as UploadResourceSnapshot,
|
|
4611
|
+
Re as WrongLocalFileUrl,
|
|
4612
|
+
Pn as createDownloadClient,
|
|
4613
|
+
In as createLogsClient,
|
|
4614
|
+
Sn as createLsFilesClient,
|
|
4615
|
+
Rn as createUploadBlobClient,
|
|
4616
|
+
Nn as createUploadProgressClient,
|
|
4617
|
+
ve as dataToHandle,
|
|
4618
|
+
Bn as getStream,
|
|
4619
|
+
$ as handleToData,
|
|
4620
|
+
Qt as headersFromProto,
|
|
4621
|
+
Ar as importToUploadOpts,
|
|
4622
|
+
C as isLiveLogHandle,
|
|
4623
|
+
Ir as isReadyLogHandle,
|
|
4624
|
+
Pr as lineToProgress,
|
|
4625
|
+
vn as mixcrProgressFromLogs
|
|
4626
|
+
};
|
|
4627
|
+
//# sourceMappingURL=index.mjs.map
|