@milaboratories/pl-drivers 1.3.6 → 1.3.8
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/drivers/logs.d.ts +3 -1
- package/dist/drivers/logs.d.ts.map +1 -1
- package/dist/drivers/logs_stream.d.ts +4 -2
- package/dist/drivers/logs_stream.d.ts.map +1 -1
- package/dist/drivers/virtual_storages.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/drivers/logs.test.ts +7 -6
- package/src/drivers/logs.ts +3 -1
- package/src/drivers/logs_stream.ts +22 -13
- package/src/drivers/ls.test.ts +12 -34
- package/src/drivers/virtual_storages.ts +8 -6
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (s, e, t) =>
|
|
1
|
+
var je = Object.defineProperty;
|
|
2
|
+
var Ge = (s, e, t) => e in s ? je(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var d = (s, e, t) => Ge(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import * as m from "node:fs/promises";
|
|
5
|
-
import { addRTypeToMetadata as k, valErr as
|
|
5
|
+
import { addRTypeToMetadata as k, valErr as Ve, getField as qe, isNullResourceId as Je, bigintToResourceId as Y, stringifyWithResourceId as be, isNotNullResourceId as Ze } from "@milaboratories/pl-client";
|
|
6
6
|
import { ServiceType as D, stackIntercept as y } from "@protobuf-ts/runtime-rpc";
|
|
7
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as
|
|
8
|
-
import { request as
|
|
7
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as Te } from "@protobuf-ts/runtime";
|
|
8
|
+
import { request as ke } from "undici";
|
|
9
9
|
import { notEmpty as K, mapGet as ce, mapEntries as Qe, TaskProcessor as ee, CallersCounter as v, asyncPool as te, fileExists as Xe, assertNever as Ye } from "@milaboratories/ts-helpers";
|
|
10
10
|
import { Readable as re, Writable as ne, Transform as Ke } from "node:stream";
|
|
11
11
|
import * as O from "node:fs";
|
|
12
12
|
import * as w from "node:path";
|
|
13
13
|
import Z from "node:path";
|
|
14
|
-
import { text as et, buffer as
|
|
15
|
-
import { Computable as b, ChangeSource as N, PollingComputableHooks as
|
|
14
|
+
import { text as et, buffer as Le } from "node:stream/consumers";
|
|
15
|
+
import { Computable as b, ChangeSource as N, PollingComputableHooks as Pe } from "@milaboratories/computable";
|
|
16
16
|
import { scheduler as oe } from "node:timers/promises";
|
|
17
17
|
import * as tt from "node:readline/promises";
|
|
18
18
|
import rt from "denque";
|
|
@@ -797,13 +797,13 @@ class _t {
|
|
|
797
797
|
return y("unary", this._transport, n, r, e);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
class Pe extends Error {
|
|
801
|
-
}
|
|
802
800
|
class Ie extends Error {
|
|
803
801
|
}
|
|
802
|
+
class Re extends Error {
|
|
803
|
+
}
|
|
804
804
|
class Ct extends Error {
|
|
805
805
|
}
|
|
806
|
-
class
|
|
806
|
+
class Se extends Error {
|
|
807
807
|
}
|
|
808
808
|
class Ot {
|
|
809
809
|
constructor(e, t, n, r) {
|
|
@@ -827,10 +827,10 @@ class Ot {
|
|
|
827
827
|
k(t, i)
|
|
828
828
|
).response, { chunk: l, mTime: p } = await this.readChunk(n, c.chunkStart, c.chunkEnd);
|
|
829
829
|
if (p > a)
|
|
830
|
-
throw new
|
|
830
|
+
throw new Ie(
|
|
831
831
|
"file was modified, expected mtime: " + a + ", got: " + p + "."
|
|
832
832
|
);
|
|
833
|
-
const P = await
|
|
833
|
+
const P = await ke(c.uploadUrl, this.prepareUploadOpts(c, l)), le = await P.body.text();
|
|
834
834
|
if (this.logger.info(
|
|
835
835
|
`uploaded chunk ${r} from ${o} of resource: ${e}, response: '${le.toString()}', status code: ${P.statusCode}`
|
|
836
836
|
), P.statusCode != 200)
|
|
@@ -858,7 +858,7 @@ class Ot {
|
|
|
858
858
|
mTime: BigInt(Math.floor(l.mtimeMs / 1e3))
|
|
859
859
|
};
|
|
860
860
|
} catch (o) {
|
|
861
|
-
throw o.code == "ENOENT" ? new
|
|
861
|
+
throw o.code == "ENOENT" ? new Se(`there is no file ${e} for uploading`) : o;
|
|
862
862
|
} finally {
|
|
863
863
|
r == null || r.close();
|
|
864
864
|
}
|
|
@@ -875,7 +875,7 @@ class Ot {
|
|
|
875
875
|
r + o
|
|
876
876
|
);
|
|
877
877
|
if (a === 0)
|
|
878
|
-
throw new
|
|
878
|
+
throw new Re("file ended earlier than expected.");
|
|
879
879
|
o += a;
|
|
880
880
|
}
|
|
881
881
|
return o;
|
|
@@ -938,7 +938,7 @@ class Ft extends g {
|
|
|
938
938
|
internalJsonRead(e, t, n) {
|
|
939
939
|
if (typeof e != "string")
|
|
940
940
|
throw new Error(
|
|
941
|
-
"Unable to parse Duration from JSON " +
|
|
941
|
+
"Unable to parse Duration from JSON " + Te(e) + ". Expected string."
|
|
942
942
|
);
|
|
943
943
|
let r = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
|
|
944
944
|
if (r === null)
|
|
@@ -1798,12 +1798,12 @@ class or {
|
|
|
1798
1798
|
}
|
|
1799
1799
|
class ae extends Error {
|
|
1800
1800
|
}
|
|
1801
|
-
class
|
|
1801
|
+
class Ne {
|
|
1802
1802
|
constructor(e) {
|
|
1803
1803
|
this.httpClient = e;
|
|
1804
1804
|
}
|
|
1805
1805
|
async downloadRemoteFile(e, t, n) {
|
|
1806
|
-
const { statusCode: r, body: o, headers: a } = await
|
|
1806
|
+
const { statusCode: r, body: o, headers: a } = await ke(e, {
|
|
1807
1807
|
dispatcher: this.httpClient,
|
|
1808
1808
|
headers: t,
|
|
1809
1809
|
signal: n
|
|
@@ -1825,10 +1825,10 @@ function B(s) {
|
|
|
1825
1825
|
return s;
|
|
1826
1826
|
}
|
|
1827
1827
|
const sr = "storage://";
|
|
1828
|
-
class Ne extends Error {
|
|
1829
|
-
}
|
|
1830
1828
|
class Ue extends Error {
|
|
1831
1829
|
}
|
|
1830
|
+
class Be extends Error {
|
|
1831
|
+
}
|
|
1832
1832
|
class ir {
|
|
1833
1833
|
constructor(e, t, n, r) {
|
|
1834
1834
|
d(this, "grpcClient");
|
|
@@ -1837,7 +1837,7 @@ class ir {
|
|
|
1837
1837
|
d(this, "isLocal", (e) => e.startsWith(sr));
|
|
1838
1838
|
this.grpcTransport = e, this.httpClient = t, this.logger = n;
|
|
1839
1839
|
for (const o of r) o.localPath !== "" && B(o.localPath);
|
|
1840
|
-
this.grpcClient = new or(this.grpcTransport), this.downloadHelper = new
|
|
1840
|
+
this.grpcClient = new or(this.grpcTransport), this.downloadHelper = new Ne(t), this.localStorageIdsToRoot = new Map(
|
|
1841
1841
|
r.map((o) => [o.storageId, o.localPath])
|
|
1842
1842
|
);
|
|
1843
1843
|
}
|
|
@@ -1869,10 +1869,10 @@ class ir {
|
|
|
1869
1869
|
function ar(s, e) {
|
|
1870
1870
|
const t = new URL(s);
|
|
1871
1871
|
if (t.pathname == "")
|
|
1872
|
-
throw new
|
|
1872
|
+
throw new Be(`url for local filepath ${s} does not match url scheme`);
|
|
1873
1873
|
const n = t.host, r = e.get(n);
|
|
1874
1874
|
if (r === void 0)
|
|
1875
|
-
throw new
|
|
1875
|
+
throw new Ue(`Unknown storage location: ${n}`);
|
|
1876
1876
|
const o = decodeURIComponent(t.pathname.slice(1));
|
|
1877
1877
|
return r === "" ? o : w.join(r, o);
|
|
1878
1878
|
}
|
|
@@ -1949,7 +1949,7 @@ class cr extends g {
|
|
|
1949
1949
|
internalJsonRead(e, t, n) {
|
|
1950
1950
|
if (typeof e != "string")
|
|
1951
1951
|
throw new Error(
|
|
1952
|
-
"Unable to parse Timestamp from JSON " +
|
|
1952
|
+
"Unable to parse Timestamp from JSON " + Te(e) + "."
|
|
1953
1953
|
);
|
|
1954
1954
|
let r = e.match(
|
|
1955
1955
|
/^([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]))$/
|
|
@@ -3145,7 +3145,7 @@ class Wn {
|
|
|
3145
3145
|
constructor(e, t) {
|
|
3146
3146
|
d(this, "updater");
|
|
3147
3147
|
d(this, "schedule", () => this.updater.schedule());
|
|
3148
|
-
this.onUpdate = e, this.sleepMs = t, this.updater = new
|
|
3148
|
+
this.onUpdate = e, this.sleepMs = t, this.updater = new De(async () => {
|
|
3149
3149
|
for (; ; ) {
|
|
3150
3150
|
if (await this.onUpdate()) return;
|
|
3151
3151
|
await oe.wait(this.sleepMs);
|
|
@@ -3153,7 +3153,7 @@ class Wn {
|
|
|
3153
3153
|
});
|
|
3154
3154
|
}
|
|
3155
3155
|
}
|
|
3156
|
-
class
|
|
3156
|
+
class De {
|
|
3157
3157
|
constructor(e) {
|
|
3158
3158
|
d(this, "updating");
|
|
3159
3159
|
this.onUpdate = e;
|
|
@@ -3172,16 +3172,16 @@ class Be {
|
|
|
3172
3172
|
}
|
|
3173
3173
|
async function An(s, e) {
|
|
3174
3174
|
return s.withReadTx("LogsDriverGetStream", async (t) => {
|
|
3175
|
-
const n = await t.getResourceData(e, !0), r = await
|
|
3175
|
+
const n = await t.getResourceData(e, !0), r = await Ve(t, qe(n, "stream"));
|
|
3176
3176
|
if (r.error != "")
|
|
3177
3177
|
throw new Error(`while getting stream: ${r.error}`);
|
|
3178
|
-
if (!
|
|
3178
|
+
if (!Je(r.valueId))
|
|
3179
3179
|
return await t.getResourceData(r.valueId, !1);
|
|
3180
3180
|
});
|
|
3181
3181
|
}
|
|
3182
|
-
const
|
|
3182
|
+
const ve = "8C7#F1328%9E089B3D22", Cr = /(?<stage>.*):\s*(?<progress>[\d.]+%)\s.*(?<eta>ETA:.*)/g;
|
|
3183
3183
|
function Or(s) {
|
|
3184
|
-
const t = s.replace(
|
|
3184
|
+
const t = s.replace(ve, "").match(Cr);
|
|
3185
3185
|
if (t == null || t.length != 4)
|
|
3186
3186
|
return;
|
|
3187
3187
|
const [n, r, o, a] = t;
|
|
@@ -3195,7 +3195,7 @@ function Or(s) {
|
|
|
3195
3195
|
};
|
|
3196
3196
|
}
|
|
3197
3197
|
async function zn(s, e, t) {
|
|
3198
|
-
const n = await e.lastLines(s, 1, 0n,
|
|
3198
|
+
const n = await e.lastLines(s, 1, 0n, ve, t);
|
|
3199
3199
|
if (n.data == null || n.data.length == 0)
|
|
3200
3200
|
return { found: !1 };
|
|
3201
3201
|
const r = n.data.toString().split(/\r?\n/)[0];
|
|
@@ -3204,7 +3204,7 @@ async function zn(s, e, t) {
|
|
|
3204
3204
|
const o = Or(r);
|
|
3205
3205
|
return o === void 0 ? { found: !1 } : { found: !0, ...o };
|
|
3206
3206
|
}
|
|
3207
|
-
class
|
|
3207
|
+
class $e {
|
|
3208
3208
|
constructor(e) {
|
|
3209
3209
|
d(this, "cache", /* @__PURE__ */ new Map());
|
|
3210
3210
|
d(this, "totalSizeBytes", 0);
|
|
@@ -3243,8 +3243,8 @@ class ve {
|
|
|
3243
3243
|
}
|
|
3244
3244
|
}
|
|
3245
3245
|
class xn {
|
|
3246
|
-
constructor(e, t) {
|
|
3247
|
-
this.
|
|
3246
|
+
constructor(e, t, n) {
|
|
3247
|
+
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = n;
|
|
3248
3248
|
}
|
|
3249
3249
|
getLastLogs(e, t, n) {
|
|
3250
3250
|
if (n === void 0) return b.make((o) => this.getLastLogs(e, t, o));
|
|
@@ -3309,9 +3309,9 @@ function q(s, e) {
|
|
|
3309
3309
|
function _(s) {
|
|
3310
3310
|
let e;
|
|
3311
3311
|
if (C(s))
|
|
3312
|
-
e = s.match(_e);
|
|
3313
|
-
else if (Fr(s))
|
|
3314
3312
|
e = s.match(Ce);
|
|
3313
|
+
else if (Fr(s))
|
|
3314
|
+
e = s.match(Oe);
|
|
3315
3315
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
3316
3316
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
3317
3317
|
const { resourceType: t, resourceVersion: n, resourceId: r } = e.groups;
|
|
@@ -3320,16 +3320,16 @@ function _(s) {
|
|
|
3320
3320
|
type: { name: t, version: n }
|
|
3321
3321
|
};
|
|
3322
3322
|
}
|
|
3323
|
-
function
|
|
3323
|
+
function _e(s, e) {
|
|
3324
3324
|
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)}`;
|
|
3325
3325
|
}
|
|
3326
|
-
const
|
|
3326
|
+
const Ce = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3327
3327
|
function C(s) {
|
|
3328
|
-
return
|
|
3328
|
+
return Ce.test(s);
|
|
3329
3329
|
}
|
|
3330
|
-
const
|
|
3330
|
+
const Oe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3331
3331
|
function Fr(s) {
|
|
3332
|
-
return
|
|
3332
|
+
return Oe.test(s);
|
|
3333
3333
|
}
|
|
3334
3334
|
const Er = se({
|
|
3335
3335
|
kv: {
|
|
@@ -3351,7 +3351,7 @@ class Mn {
|
|
|
3351
3351
|
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3352
3352
|
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3353
3353
|
d(this, "saveDir");
|
|
3354
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new
|
|
3354
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new $e(a.cacheSoftSizeBytes), this.downloadQueue = new ee(this.logger, a.nConcurrentDownloads), this.saveDir = w.resolve(r);
|
|
3355
3355
|
}
|
|
3356
3356
|
getDownloadedBlob(e, t) {
|
|
3357
3357
|
if (t === void 0) return b.make((a) => this.getDownloadedBlob(e, a));
|
|
@@ -3372,7 +3372,7 @@ class Mn {
|
|
|
3372
3372
|
if (Mr(e)) return await Ar(this.getLocalPath(e));
|
|
3373
3373
|
if (!jr(e)) throw new Error("Malformed remote handle");
|
|
3374
3374
|
const t = Gr(e, this.signer), { content: n } = await this.clientDownload.downloadBlob(t);
|
|
3375
|
-
return await
|
|
3375
|
+
return await Le(n);
|
|
3376
3376
|
}
|
|
3377
3377
|
getDownloadedBlobNoCtx(e, t, n) {
|
|
3378
3378
|
let r = this.idToDownload.get(t.id);
|
|
@@ -3462,7 +3462,7 @@ class Mn {
|
|
|
3462
3462
|
return this.getLogHandleNoCtx(n);
|
|
3463
3463
|
}
|
|
3464
3464
|
getLogHandleNoCtx(e) {
|
|
3465
|
-
return
|
|
3465
|
+
return _e(!1, e);
|
|
3466
3466
|
}
|
|
3467
3467
|
async lastLines(e, t, n, r) {
|
|
3468
3468
|
const o = await this.clientLogs.lastLines(
|
|
@@ -3549,7 +3549,7 @@ class he {
|
|
|
3549
3549
|
d(this, "log");
|
|
3550
3550
|
d(this, "change", new N());
|
|
3551
3551
|
d(this, "error");
|
|
3552
|
-
this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new
|
|
3552
|
+
this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new De(async () => this.update());
|
|
3553
3553
|
}
|
|
3554
3554
|
getOrSchedule(e) {
|
|
3555
3555
|
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
@@ -3578,7 +3578,7 @@ async function ue(s) {
|
|
|
3578
3578
|
}
|
|
3579
3579
|
}
|
|
3580
3580
|
async function Ar(s) {
|
|
3581
|
-
return await
|
|
3581
|
+
return await Le(re.toWeb(O.createReadStream(s)));
|
|
3582
3582
|
}
|
|
3583
3583
|
function zr(s, e, t) {
|
|
3584
3584
|
const n = O.createReadStream(s), r = new ne();
|
|
@@ -3615,7 +3615,7 @@ let xr = class {
|
|
|
3615
3615
|
}
|
|
3616
3616
|
this.setDone(t);
|
|
3617
3617
|
} catch (e) {
|
|
3618
|
-
if (e instanceof pe || e instanceof ae || e instanceof
|
|
3618
|
+
if (e instanceof pe || e instanceof ae || e instanceof Ue || e instanceof Be || e.code == "ENOENT") {
|
|
3619
3619
|
this.setError(e), await m.rm(this.path);
|
|
3620
3620
|
return;
|
|
3621
3621
|
}
|
|
@@ -3649,12 +3649,12 @@ let xr = class {
|
|
|
3649
3649
|
};
|
|
3650
3650
|
class pe extends Error {
|
|
3651
3651
|
}
|
|
3652
|
-
const
|
|
3652
|
+
const Fe = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
3653
3653
|
function Mr(s) {
|
|
3654
|
-
return !!s.match(
|
|
3654
|
+
return !!s.match(Fe);
|
|
3655
3655
|
}
|
|
3656
3656
|
function J(s, e) {
|
|
3657
|
-
const t = s.match(
|
|
3657
|
+
const t = s.match(Fe);
|
|
3658
3658
|
if (t === null) throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
3659
3659
|
const { path: n, signature: r } = t.groups;
|
|
3660
3660
|
return e.verify(n, r, `Signature verification failed for: ${s}`), n;
|
|
@@ -3662,12 +3662,12 @@ function J(s, e) {
|
|
|
3662
3662
|
function Hr(s, e) {
|
|
3663
3663
|
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
3664
3664
|
}
|
|
3665
|
-
const
|
|
3665
|
+
const Ee = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
|
|
3666
3666
|
function jr(s) {
|
|
3667
|
-
return !!s.match(
|
|
3667
|
+
return !!s.match(Ee);
|
|
3668
3668
|
}
|
|
3669
3669
|
function Gr(s, e) {
|
|
3670
|
-
const t = s.match(
|
|
3670
|
+
const t = s.match(Ee);
|
|
3671
3671
|
if (t === null) throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
3672
3672
|
const { content: n, resourceType: r, resourceVersion: o, resourceId: a, signature: i } = t.groups;
|
|
3673
3673
|
return e.verify(n, i, `Signature verification failed for ${s}`), {
|
|
@@ -3688,14 +3688,14 @@ const F = T.object({
|
|
|
3688
3688
|
sizeBytes: T.string(),
|
|
3689
3689
|
/** Modification time unix timestamp in seconds */
|
|
3690
3690
|
modificationTime: T.string()
|
|
3691
|
-
}),
|
|
3691
|
+
}), We = T.object({
|
|
3692
3692
|
/** Pl storage id */
|
|
3693
3693
|
storageId: T.string(),
|
|
3694
3694
|
/** Path inside storage */
|
|
3695
3695
|
path: T.string()
|
|
3696
3696
|
}), jn = T.union([
|
|
3697
3697
|
F,
|
|
3698
|
-
|
|
3698
|
+
We
|
|
3699
3699
|
]), qr = se({
|
|
3700
3700
|
data: F,
|
|
3701
3701
|
fields: {
|
|
@@ -3733,7 +3733,7 @@ class Gn {
|
|
|
3733
3733
|
// 15 seconds
|
|
3734
3734
|
backoffMultiplier: 1.5,
|
|
3735
3735
|
jitter: 0.5
|
|
3736
|
-
}), this.hooks = new
|
|
3736
|
+
}), this.hooks = new Pe(
|
|
3737
3737
|
() => this.startUpdating(),
|
|
3738
3738
|
() => this.stopUpdating(),
|
|
3739
3739
|
{ stopDebounce: o.stopPollingDelay },
|
|
@@ -3761,7 +3761,7 @@ class Gn {
|
|
|
3761
3761
|
);
|
|
3762
3762
|
return this.idToProgress.set(t.id, a), a.attach(e, n), a.progress.isUpload && a.progress.isUploadSignMatch && this.uploadQueue.push({
|
|
3763
3763
|
fn: () => a.uploadBlobTask(),
|
|
3764
|
-
recoverableErrorPredicate: (i) => !
|
|
3764
|
+
recoverableErrorPredicate: (i) => !Ae(i)
|
|
3765
3765
|
}), a.mustGetProgress(r);
|
|
3766
3766
|
}
|
|
3767
3767
|
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
@@ -3851,7 +3851,7 @@ class Qr {
|
|
|
3851
3851
|
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3852
3852
|
return;
|
|
3853
3853
|
}
|
|
3854
|
-
throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(),
|
|
3854
|
+
throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ae(e) && this.terminateWithError(e), e;
|
|
3855
3855
|
}
|
|
3856
3856
|
}
|
|
3857
3857
|
/** Uploads a blob using client. */
|
|
@@ -3890,7 +3890,7 @@ class Qr {
|
|
|
3890
3890
|
}
|
|
3891
3891
|
if (fe(e)) {
|
|
3892
3892
|
this.logger.warn(
|
|
3893
|
-
`resource was not found while updating a status of BlobImport: ${e}, ${
|
|
3893
|
+
`resource was not found while updating a status of BlobImport: ${e}, ${be(this.res)}`
|
|
3894
3894
|
), this.change.markChanged(), this.setDone(!0);
|
|
3895
3895
|
return;
|
|
3896
3896
|
}
|
|
@@ -3915,14 +3915,14 @@ function Yr(s, e, t) {
|
|
|
3915
3915
|
return !1;
|
|
3916
3916
|
}
|
|
3917
3917
|
}
|
|
3918
|
-
function
|
|
3919
|
-
return s instanceof
|
|
3918
|
+
function Ae(s) {
|
|
3919
|
+
return s instanceof Ie || s instanceof Re || s instanceof Se;
|
|
3920
3920
|
}
|
|
3921
3921
|
function fe(s) {
|
|
3922
3922
|
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
3923
3923
|
}
|
|
3924
3924
|
class Vn {
|
|
3925
|
-
constructor(e, t = {
|
|
3925
|
+
constructor(e, t, n = {
|
|
3926
3926
|
nConcurrentGetLogs: 10,
|
|
3927
3927
|
pollingInterval: 1e3,
|
|
3928
3928
|
stopPollingDelay: 1e3
|
|
@@ -3938,11 +3938,11 @@ class Vn {
|
|
|
3938
3938
|
d(this, "keepRunning", !1);
|
|
3939
3939
|
/** Actual state of main loop. */
|
|
3940
3940
|
d(this, "currentLoop");
|
|
3941
|
-
this.
|
|
3941
|
+
this.logger = e, this.clientLogs = t, this.opts = n, this.hooks = new Pe(
|
|
3942
3942
|
() => this.startUpdating(),
|
|
3943
3943
|
() => this.stopUpdating(),
|
|
3944
|
-
{ stopDebounce:
|
|
3945
|
-
(
|
|
3944
|
+
{ stopDebounce: n.stopPollingDelay },
|
|
3945
|
+
(r, o) => this.scheduleOnNextState(r, o)
|
|
3946
3946
|
);
|
|
3947
3947
|
}
|
|
3948
3948
|
getLastLogs(e, t, n) {
|
|
@@ -3957,7 +3957,7 @@ class Vn {
|
|
|
3957
3957
|
getLastLogsNoCtx(e, t, n, r) {
|
|
3958
3958
|
let o = this.idToLastLines.get(t.id);
|
|
3959
3959
|
if (o == null) {
|
|
3960
|
-
const i = new me(this.clientLogs, t, n);
|
|
3960
|
+
const i = new me(this.logger, this.clientLogs, t, n);
|
|
3961
3961
|
this.idToLastLines.set(t.id, i), o = i;
|
|
3962
3962
|
}
|
|
3963
3963
|
o.attach(e, r);
|
|
@@ -3978,7 +3978,7 @@ class Vn {
|
|
|
3978
3978
|
getProgressLogNoCtx(e, t, n, r) {
|
|
3979
3979
|
let o = this.idToProgressLog.get(t.id);
|
|
3980
3980
|
if (o == null) {
|
|
3981
|
-
const i = new me(this.clientLogs, t, 1, n);
|
|
3981
|
+
const i = new me(this.logger, this.clientLogs, t, 1, n);
|
|
3982
3982
|
this.idToProgressLog.set(t.id, i), o = i;
|
|
3983
3983
|
}
|
|
3984
3984
|
o.attach(e, r);
|
|
@@ -3992,7 +3992,7 @@ class Vn {
|
|
|
3992
3992
|
return t.markUnstable(), r;
|
|
3993
3993
|
}
|
|
3994
3994
|
getLogHandleNoCtx(e) {
|
|
3995
|
-
return
|
|
3995
|
+
return _e(!0, e);
|
|
3996
3996
|
}
|
|
3997
3997
|
async lastLines(e, t, n, r) {
|
|
3998
3998
|
return await this.tryWithNotFound(
|
|
@@ -4055,10 +4055,11 @@ class Vn {
|
|
|
4055
4055
|
const e = this.scheduledOnNextState;
|
|
4056
4056
|
this.scheduledOnNextState = [];
|
|
4057
4057
|
try {
|
|
4058
|
+
const t = this.getAllLogs();
|
|
4058
4059
|
await te(
|
|
4059
4060
|
this.opts.nConcurrentGetLogs,
|
|
4060
|
-
|
|
4061
|
-
), e.forEach((
|
|
4061
|
+
t.map((n) => async () => await n.update())
|
|
4062
|
+
), e.forEach((n) => n.resolve());
|
|
4062
4063
|
} catch (t) {
|
|
4063
4064
|
console.error(t), e.forEach((n) => n.reject(t));
|
|
4064
4065
|
}
|
|
@@ -4067,24 +4068,22 @@ class Vn {
|
|
|
4067
4068
|
}
|
|
4068
4069
|
this.currentLoop = void 0;
|
|
4069
4070
|
}
|
|
4070
|
-
|
|
4071
|
-
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).
|
|
4071
|
+
getAllLogs() {
|
|
4072
|
+
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
|
|
4072
4073
|
}
|
|
4073
4074
|
}
|
|
4074
4075
|
class me {
|
|
4075
|
-
constructor(e, t, n, r) {
|
|
4076
|
+
constructor(e, t, n, r, o) {
|
|
4076
4077
|
d(this, "logs");
|
|
4077
4078
|
d(this, "error");
|
|
4078
|
-
d(this, "done", !1);
|
|
4079
4079
|
d(this, "change", new N());
|
|
4080
4080
|
d(this, "counter", new v());
|
|
4081
|
-
this.
|
|
4081
|
+
this.logger = e, this.clientLogs = t, this.rInfo = n, this.lines = r, this.patternToSearch = o;
|
|
4082
4082
|
}
|
|
4083
4083
|
getLog() {
|
|
4084
4084
|
return {
|
|
4085
4085
|
log: this.logs,
|
|
4086
|
-
error: this.error
|
|
4087
|
-
done: this.done
|
|
4086
|
+
error: this.error
|
|
4088
4087
|
};
|
|
4089
4088
|
}
|
|
4090
4089
|
attach(e, t) {
|
|
@@ -4101,14 +4100,16 @@ class me {
|
|
|
4101
4100
|
0n,
|
|
4102
4101
|
this.patternToSearch
|
|
4103
4102
|
)).data.toString();
|
|
4104
|
-
this.logs != t && this.change.markChanged(), this.logs = t;
|
|
4103
|
+
this.logs != t && this.change.markChanged(), this.logs = t, this.error = void 0;
|
|
4105
4104
|
return;
|
|
4106
4105
|
} catch (e) {
|
|
4107
4106
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
4108
|
-
this.logs = "", this.error = e, this.
|
|
4107
|
+
this.logs = "", this.error = e, this.change.markChanged();
|
|
4109
4108
|
return;
|
|
4110
4109
|
}
|
|
4111
|
-
throw
|
|
4110
|
+
throw this.logger.error(
|
|
4111
|
+
`Stream log lines for ${be(this.rInfo.id)} failed, reason: ${e}`
|
|
4112
|
+
), e;
|
|
4112
4113
|
}
|
|
4113
4114
|
}
|
|
4114
4115
|
}
|
|
@@ -4124,7 +4125,7 @@ class qn {
|
|
|
4124
4125
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4125
4126
|
* file that should be kept. */
|
|
4126
4127
|
d(this, "cache");
|
|
4127
|
-
this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new ee(this.logger, this.opts.nConcurrentDownloads), this.cache = new
|
|
4128
|
+
this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new ee(this.logger, this.opts.nConcurrentDownloads), this.cache = new $e(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ne(t);
|
|
4128
4129
|
}
|
|
4129
4130
|
getPath(e, t) {
|
|
4130
4131
|
if (t === void 0) return b.make((o) => this.getPath(e, o));
|
|
@@ -4219,7 +4220,7 @@ class Kr {
|
|
|
4219
4220
|
}
|
|
4220
4221
|
async downloadAndUntar(e, t, n) {
|
|
4221
4222
|
if (await Xe(this.path))
|
|
4222
|
-
return await
|
|
4223
|
+
return await ze(this.path);
|
|
4223
4224
|
const r = await e.downloadRemoteFile(this.url.toString(), {}, n);
|
|
4224
4225
|
let o = r.content;
|
|
4225
4226
|
if (t) {
|
|
@@ -4245,12 +4246,12 @@ class Kr {
|
|
|
4245
4246
|
}
|
|
4246
4247
|
class we extends Error {
|
|
4247
4248
|
}
|
|
4248
|
-
async function
|
|
4249
|
+
async function ze(s) {
|
|
4249
4250
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
4250
4251
|
return (await Promise.all(
|
|
4251
4252
|
e.map(async (n) => {
|
|
4252
4253
|
const r = w.join(s, n.name);
|
|
4253
|
-
return n.isDirectory() ? await
|
|
4254
|
+
return n.isDirectory() ? await ze(r) : (await m.stat(r)).size;
|
|
4254
4255
|
})
|
|
4255
4256
|
)).reduce((n, r) => n + r, 0);
|
|
4256
4257
|
}
|
|
@@ -4280,7 +4281,7 @@ function tn(s) {
|
|
|
4280
4281
|
}
|
|
4281
4282
|
function rn(s) {
|
|
4282
4283
|
const e = new URL(s);
|
|
4283
|
-
return
|
|
4284
|
+
return We.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4284
4285
|
}
|
|
4285
4286
|
function nn(s) {
|
|
4286
4287
|
if (ln(s))
|
|
@@ -4289,15 +4290,15 @@ function nn(s) {
|
|
|
4289
4290
|
return an(s);
|
|
4290
4291
|
Ye(s);
|
|
4291
4292
|
}
|
|
4292
|
-
const
|
|
4293
|
+
const xe = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4293
4294
|
function on(s) {
|
|
4294
|
-
return
|
|
4295
|
+
return xe.test(s);
|
|
4295
4296
|
}
|
|
4296
4297
|
function sn(s, e) {
|
|
4297
4298
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4298
4299
|
}
|
|
4299
4300
|
function an(s) {
|
|
4300
|
-
const e = s.match(
|
|
4301
|
+
const e = s.match(xe);
|
|
4301
4302
|
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4302
4303
|
const { name: t, path: n } = e.groups;
|
|
4303
4304
|
return {
|
|
@@ -4306,15 +4307,15 @@ function an(s) {
|
|
|
4306
4307
|
isRemote: !1
|
|
4307
4308
|
};
|
|
4308
4309
|
}
|
|
4309
|
-
const
|
|
4310
|
+
const Me = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4310
4311
|
function ln(s) {
|
|
4311
|
-
return
|
|
4312
|
+
return Me.test(s);
|
|
4312
4313
|
}
|
|
4313
4314
|
function cn(s, e) {
|
|
4314
4315
|
return `remote://${s}/${BigInt(e)}`;
|
|
4315
4316
|
}
|
|
4316
4317
|
function dn(s) {
|
|
4317
|
-
const e = s.match(
|
|
4318
|
+
const e = s.match(Me);
|
|
4318
4319
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4319
4320
|
const { name: t, resourceId: n } = e.groups;
|
|
4320
4321
|
return {
|
|
@@ -4350,15 +4351,17 @@ async function un() {
|
|
|
4350
4351
|
};
|
|
4351
4352
|
});
|
|
4352
4353
|
} catch {
|
|
4353
|
-
return [
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4354
|
+
return [
|
|
4355
|
+
{
|
|
4356
|
+
name: `local_disk_${t}`,
|
|
4357
|
+
root: `${t}:\\`,
|
|
4358
|
+
initialPath: s
|
|
4359
|
+
}
|
|
4360
|
+
];
|
|
4358
4361
|
}
|
|
4359
4362
|
}
|
|
4360
4363
|
}
|
|
4361
|
-
class
|
|
4364
|
+
class He {
|
|
4362
4365
|
constructor(e, t, n, r, o, a, i) {
|
|
4363
4366
|
this.logger = e, this.lsClient = t, this.storageIdToResourceId = n, this.signer = r, this.virtualStoragesMap = o, this.localProjectionsMap = a, this.openFileDialogCallback = i;
|
|
4364
4367
|
}
|
|
@@ -4480,7 +4483,7 @@ class Me {
|
|
|
4480
4483
|
throw new Error(
|
|
4481
4484
|
"Intersection between local projection storage ids and virtual storages names detected."
|
|
4482
4485
|
);
|
|
4483
|
-
return new
|
|
4486
|
+
return new He(
|
|
4484
4487
|
e,
|
|
4485
4488
|
i,
|
|
4486
4489
|
await pn(t),
|
|
@@ -4513,29 +4516,29 @@ export {
|
|
|
4513
4516
|
Mn as DownloadDriver,
|
|
4514
4517
|
qn as DownloadUrlDriver,
|
|
4515
4518
|
jn as ImportFileHandleData,
|
|
4516
|
-
|
|
4519
|
+
We as ImportFileHandleIndexData,
|
|
4517
4520
|
F as ImportFileHandleUploadData,
|
|
4518
4521
|
Jr as IndexResourceSnapshot,
|
|
4519
4522
|
xn as LogsDriver,
|
|
4520
4523
|
Vn as LogsStreamDriver,
|
|
4521
4524
|
Wn as LongUpdater,
|
|
4522
|
-
|
|
4523
|
-
|
|
4525
|
+
He as LsDriver,
|
|
4526
|
+
Ie as MTimeError,
|
|
4524
4527
|
Ct as NetworkError,
|
|
4525
|
-
|
|
4528
|
+
Se as NoFileForUploading,
|
|
4526
4529
|
Er as OnDemandBlobResourceSnapshot,
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
+
Re as UnexpectedEOF,
|
|
4531
|
+
Ue as UnknownStorageError,
|
|
4532
|
+
De as Updater,
|
|
4530
4533
|
Gn as UploadDriver,
|
|
4531
4534
|
qr as UploadResourceSnapshot,
|
|
4532
|
-
|
|
4535
|
+
Be as WrongLocalFileUrl,
|
|
4533
4536
|
Cn as createDownloadClient,
|
|
4534
4537
|
On as createLogsClient,
|
|
4535
4538
|
_r as createLsFilesClient,
|
|
4536
4539
|
En as createUploadBlobClient,
|
|
4537
4540
|
Fn as createUploadProgressClient,
|
|
4538
|
-
|
|
4541
|
+
_e as dataToHandle,
|
|
4539
4542
|
An as getStream,
|
|
4540
4543
|
_ as handleToData,
|
|
4541
4544
|
lr as headersFromProto,
|