@camstack/system 1.2.419 → 1.2.420
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/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +136 -16
- package/dist/builtins/system-config/system-config.addon.mjs +413 -294
- package/dist/index.js +183 -15
- package/dist/index.mjs +180 -18
- package/dist/kernel/index.d.ts +5 -1
- package/dist/kernel/moleculer/agent-event-scope.d.ts +49 -0
- package/dist/kernel/moleculer/agent-mesh-authenticator.d.ts +15 -3
- package/dist/kernel/moleculer/broker-factory.d.ts +6 -0
- package/dist/kernel/moleculer/mesh-access-middleware.d.ts +8 -4
- package/dist/kernel/moleculer/mesh-join-hold.d.ts +85 -0
- package/dist/kernel/moleculer/mesh-mtls/index.d.ts +1 -1
- package/dist/kernel/moleculer/mesh-mtls/tls-tcp-transporter.d.ts +65 -4
- package/dist/{restore-archive-gGHgAZsz.mjs → restore-archive-Bt65Em24.mjs} +76 -76
- package/package.json +1 -1
|
@@ -3,15 +3,15 @@ import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createP
|
|
|
3
3
|
import { Buffer as Buffer$1 } from "buffer";
|
|
4
4
|
import * as fsp from "node:fs/promises";
|
|
5
5
|
import jn from "node:fs/promises";
|
|
6
|
-
import * as path$
|
|
6
|
+
import * as path$1 from "node:path";
|
|
7
7
|
import path, { basename, join, posix, win32 } from "node:path";
|
|
8
|
-
import * as fs$
|
|
8
|
+
import * as fs$1 from "node:fs";
|
|
9
9
|
import Kt from "node:fs";
|
|
10
10
|
import { EventEmitter } from "node:events";
|
|
11
11
|
import As, { Transform } from "node:stream";
|
|
12
12
|
import { StringDecoder } from "node:string_decoder";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import I from "fs";
|
|
14
|
+
import qs, { dirname as dirname$1, parse } from "path";
|
|
15
15
|
import * as Ms from "zlib";
|
|
16
16
|
import Jr from "zlib";
|
|
17
17
|
import Pi from "assert";
|
|
@@ -376,7 +376,7 @@ async function readBackupEncryptionHeader(file) {
|
|
|
376
376
|
async function decryptBackupFile(input, output, secretKey) {
|
|
377
377
|
const decrypt = createBackupDecryptStream(secretKey);
|
|
378
378
|
try {
|
|
379
|
-
await pipeline(fs$
|
|
379
|
+
await pipeline(fs$1.createReadStream(input), decrypt, fs$1.createWriteStream(output, { mode: 384 }));
|
|
380
380
|
} catch (err) {
|
|
381
381
|
await fsp.rm(output, { force: true }).catch(() => void 0);
|
|
382
382
|
throw err;
|
|
@@ -714,7 +714,7 @@ while (this[Ns](this[Ae]()) && this[b].length);
|
|
|
714
714
|
return zr;
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
|
-
var Xr =
|
|
717
|
+
var Xr = I.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol("_ended"), m = Symbol("_fd"), Ni = Symbol("_finished"), j = Symbol("_flags"), Di = Symbol("_flush"), Ci = Symbol("_handleChunk"), ki = Symbol("_makeBuf"), ie = Symbol("_mode"), Ce = Symbol("_needDrain"), Ut = Symbol("_onerror"), Ht = Symbol("_onopen"), Ai = Symbol("_onread"), Pt = Symbol("_onwrite"), ht = Symbol("_open"), U = Symbol("_path"), nt = Symbol("_pos"), Y = Symbol("_queue"), zt = Symbol("_read"), Ii = Symbol("_readSize"), J = Symbol("_reading"), ee = Symbol("_remain"), Fi = Symbol("_size"), ke = Symbol("_write"), gt = Symbol("_writing"), ve = Symbol("_defaultFlag"), bt = Symbol("_errored"), _t = class extends A {
|
|
718
718
|
[bt] = !1;
|
|
719
719
|
[m];
|
|
720
720
|
[U];
|
|
@@ -740,7 +740,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
740
740
|
throw new TypeError("this is a readable stream");
|
|
741
741
|
}
|
|
742
742
|
[ht]() {
|
|
743
|
-
|
|
743
|
+
I.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
744
744
|
}
|
|
745
745
|
[Ht](t, e) {
|
|
746
746
|
t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
|
|
@@ -753,7 +753,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
753
753
|
this[J] = !0;
|
|
754
754
|
let t = this[ki]();
|
|
755
755
|
if (t.length === 0) return process.nextTick(() => this[Ai](null, 0, t));
|
|
756
|
-
|
|
756
|
+
I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ai](e, i, r));
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
[Ai](t, e, i) {
|
|
@@ -762,7 +762,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
762
762
|
[H]() {
|
|
763
763
|
if (this[ot] && typeof this[m] == "number") {
|
|
764
764
|
let t = this[m];
|
|
765
|
-
this[m] = void 0,
|
|
765
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
[Ut](t) {
|
|
@@ -785,7 +785,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
785
785
|
[ht]() {
|
|
786
786
|
let t = !0;
|
|
787
787
|
try {
|
|
788
|
-
this[Ht](null,
|
|
788
|
+
this[Ht](null, I.openSync(this[U], "r")), t = !1;
|
|
789
789
|
} finally {
|
|
790
790
|
t && this[H]();
|
|
791
791
|
}
|
|
@@ -796,7 +796,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
796
796
|
if (!this[J]) {
|
|
797
797
|
this[J] = !0;
|
|
798
798
|
do {
|
|
799
|
-
let e = this[ki](), i = e.length === 0 ? 0 :
|
|
799
|
+
let e = this[ki](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
|
|
800
800
|
if (!this[Ci](i, e)) break;
|
|
801
801
|
} while (!0);
|
|
802
802
|
this[J] = !1;
|
|
@@ -809,7 +809,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
809
809
|
[H]() {
|
|
810
810
|
if (this[ot] && typeof this[m] == "number") {
|
|
811
811
|
let t = this[m];
|
|
812
|
-
this[m] = void 0,
|
|
812
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
}, tt = class extends $r {
|
|
@@ -850,7 +850,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
850
850
|
this[H](), this[gt] = !0, this.emit("error", t);
|
|
851
851
|
}
|
|
852
852
|
[ht]() {
|
|
853
|
-
|
|
853
|
+
I.open(this[U], this[j], this[ie], (t, e) => this[Ht](t, e));
|
|
854
854
|
}
|
|
855
855
|
[Ht](t, e) {
|
|
856
856
|
this[ve] && this[j] === "r+" && t && t.code === "ENOENT" ? (this[j] = "w", this[ht]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[gt] || this[Di]());
|
|
@@ -862,7 +862,7 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
862
862
|
return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[Ce] = !0, !1) : (this[gt] = !0, this[ke](t), !0);
|
|
863
863
|
}
|
|
864
864
|
[ke](t) {
|
|
865
|
-
|
|
865
|
+
I.write(this[m], t, 0, t.length, this[nt], (e, i) => this[Pt](e, i));
|
|
866
866
|
}
|
|
867
867
|
[Pt](t, e) {
|
|
868
868
|
t ? this[Ut](t) : (this[nt] !== void 0 && typeof e == "number" && (this[nt] += e), this[Y].length ? this[Di]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[Ce] && (this[Ce] = !1, this.emit("drain"))));
|
|
@@ -878,31 +878,31 @@ var Xr = fs.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol
|
|
|
878
878
|
[H]() {
|
|
879
879
|
if (this[ot] && typeof this[m] == "number") {
|
|
880
880
|
let t = this[m];
|
|
881
|
-
this[m] = void 0,
|
|
881
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
}, Wt = class extends tt {
|
|
885
885
|
[ht]() {
|
|
886
886
|
let t;
|
|
887
887
|
if (this[ve] && this[j] === "r+") try {
|
|
888
|
-
t =
|
|
888
|
+
t = I.openSync(this[U], this[j], this[ie]);
|
|
889
889
|
} catch (e) {
|
|
890
890
|
if (e?.code === "ENOENT") return this[j] = "w", this[ht]();
|
|
891
891
|
throw e;
|
|
892
892
|
}
|
|
893
|
-
else t =
|
|
893
|
+
else t = I.openSync(this[U], this[j], this[ie]);
|
|
894
894
|
this[Ht](null, t);
|
|
895
895
|
}
|
|
896
896
|
[H]() {
|
|
897
897
|
if (this[ot] && typeof this[m] == "number") {
|
|
898
898
|
let t = this[m];
|
|
899
|
-
this[m] = void 0,
|
|
899
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
[ke](t) {
|
|
903
903
|
let e = !0;
|
|
904
904
|
try {
|
|
905
|
-
this[Pt](null,
|
|
905
|
+
this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[nt])), e = !1;
|
|
906
906
|
} finally {
|
|
907
907
|
if (e) try {
|
|
908
908
|
this[H]();
|
|
@@ -1862,7 +1862,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1862
1862
|
let [o, a] = le(this.path);
|
|
1863
1863
|
o && typeof a == "string" && (this.path = a, r = o);
|
|
1864
1864
|
}
|
|
1865
|
-
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = $s(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute ||
|
|
1865
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = $s(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || qs.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
|
|
1866
1866
|
entry: this,
|
|
1867
1867
|
path: r + this.path
|
|
1868
1868
|
});
|
|
@@ -1876,7 +1876,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1876
1876
|
return t === "error" && (this.#t = !0), super.emit(t, ...e);
|
|
1877
1877
|
}
|
|
1878
1878
|
[es]() {
|
|
1879
|
-
|
|
1879
|
+
I.lstat(this.absolute, (t, e) => {
|
|
1880
1880
|
if (t) return this.emit("error", t);
|
|
1881
1881
|
this[ii](e);
|
|
1882
1882
|
});
|
|
@@ -1935,7 +1935,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1935
1935
|
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[ce](), this.end();
|
|
1936
1936
|
}
|
|
1937
1937
|
[ts]() {
|
|
1938
|
-
|
|
1938
|
+
I.readlink(this.absolute, (t, e) => {
|
|
1939
1939
|
if (t) return this.emit("error", t);
|
|
1940
1940
|
this[ss](e);
|
|
1941
1941
|
});
|
|
@@ -1945,7 +1945,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1945
1945
|
}
|
|
1946
1946
|
[tr](t) {
|
|
1947
1947
|
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
1948
|
-
this.type = "Link", this.linkpath = f(
|
|
1948
|
+
this.type = "Link", this.linkpath = f(qs.relative(this.cwd, t)), this.stat.size = 0, this[ce](), this.end();
|
|
1949
1949
|
}
|
|
1950
1950
|
[Js]() {
|
|
1951
1951
|
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
@@ -1958,7 +1958,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1958
1958
|
this[rs]();
|
|
1959
1959
|
}
|
|
1960
1960
|
[rs]() {
|
|
1961
|
-
|
|
1961
|
+
I.open(this.absolute, "r", (t, e) => {
|
|
1962
1962
|
if (t) return this.emit("error", t);
|
|
1963
1963
|
this[ns](e);
|
|
1964
1964
|
});
|
|
@@ -1973,13 +1973,13 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
1973
1973
|
[ei]() {
|
|
1974
1974
|
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
1975
1975
|
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
1976
|
-
|
|
1976
|
+
I.read(t, e, i, r, n, (o, a) => {
|
|
1977
1977
|
if (o) return this[pt](() => this.emit("error", o));
|
|
1978
1978
|
this[is](a);
|
|
1979
1979
|
});
|
|
1980
1980
|
}
|
|
1981
1981
|
[pt](t = () => {}) {
|
|
1982
|
-
this.fd !== void 0 &&
|
|
1982
|
+
this.fd !== void 0 && I.close(this.fd, t);
|
|
1983
1983
|
}
|
|
1984
1984
|
[is](t) {
|
|
1985
1985
|
if (t <= 0 && this.remain > 0) {
|
|
@@ -2021,20 +2021,20 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
2021
2021
|
}, ri = class extends fe {
|
|
2022
2022
|
sync = !0;
|
|
2023
2023
|
[es]() {
|
|
2024
|
-
this[ii](
|
|
2024
|
+
this[ii](I.lstatSync(this.absolute));
|
|
2025
2025
|
}
|
|
2026
2026
|
[ts]() {
|
|
2027
|
-
this[ss](
|
|
2027
|
+
this[ss](I.readlinkSync(this.absolute));
|
|
2028
2028
|
}
|
|
2029
2029
|
[rs]() {
|
|
2030
|
-
this[ns](
|
|
2030
|
+
this[ns](I.openSync(this.absolute, "r"));
|
|
2031
2031
|
}
|
|
2032
2032
|
[ei]() {
|
|
2033
2033
|
let t = !0;
|
|
2034
2034
|
try {
|
|
2035
2035
|
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
2036
2036
|
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
2037
|
-
let a =
|
|
2037
|
+
let a = I.readSync(e, i, r, n, o);
|
|
2038
2038
|
this[is](a), t = !1;
|
|
2039
2039
|
} finally {
|
|
2040
2040
|
if (t) try {
|
|
@@ -2046,7 +2046,7 @@ var er = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(
|
|
|
2046
2046
|
t();
|
|
2047
2047
|
}
|
|
2048
2048
|
[pt](t = () => {}) {
|
|
2049
|
-
this.fd !== void 0 &&
|
|
2049
|
+
this.fd !== void 0 && I.closeSync(this.fd), t();
|
|
2050
2050
|
}
|
|
2051
2051
|
}, ni = class extends A {
|
|
2052
2052
|
blockLen = 0;
|
|
@@ -2314,7 +2314,7 @@ var mi = class {
|
|
|
2314
2314
|
constructor(t, e) {
|
|
2315
2315
|
this.path = t || "./", this.absolute = e;
|
|
2316
2316
|
}
|
|
2317
|
-
}, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs
|
|
2317
|
+
}, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs = Symbol("readdir"), ci = Symbol("onreaddir"), fi = Symbol("pipe"), rr = Symbol("entry"), as = Symbol("entryOpt"), di = Symbol("writeEntryClass"), or = Symbol("write"), ls = Symbol("ondrain"), wt = class extends A {
|
|
2318
2318
|
sync = !1;
|
|
2319
2319
|
opt;
|
|
2320
2320
|
cwd;
|
|
@@ -2365,7 +2365,7 @@ var mi = class {
|
|
|
2365
2365
|
return typeof t == "string" ? this[li](t) : this[sr](t), this.flowing;
|
|
2366
2366
|
}
|
|
2367
2367
|
[sr](t) {
|
|
2368
|
-
let e = f(
|
|
2368
|
+
let e = f(qs.resolve(this.cwd, t.path));
|
|
2369
2369
|
if (!this.filter(t.path, t)) t.resume();
|
|
2370
2370
|
else {
|
|
2371
2371
|
let i = new mi(t.path, e);
|
|
@@ -2374,12 +2374,12 @@ var mi = class {
|
|
|
2374
2374
|
this[Ct]();
|
|
2375
2375
|
}
|
|
2376
2376
|
[li](t) {
|
|
2377
|
-
let e = f(
|
|
2377
|
+
let e = f(qs.resolve(this.cwd, t));
|
|
2378
2378
|
this[W].push(new mi(t, e)), this[Ct]();
|
|
2379
2379
|
}
|
|
2380
2380
|
[cs](t) {
|
|
2381
2381
|
t.pending = !0, this[G] += 1;
|
|
2382
|
-
|
|
2382
|
+
I[this.follow ? "stat" : "lstat"](t.absolute, (i, r) => {
|
|
2383
2383
|
t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[ai](t, r);
|
|
2384
2384
|
});
|
|
2385
2385
|
}
|
|
@@ -2392,8 +2392,8 @@ var mi = class {
|
|
|
2392
2392
|
}
|
|
2393
2393
|
this[Ct]();
|
|
2394
2394
|
}
|
|
2395
|
-
[fs
|
|
2396
|
-
t.pending = !0, this[G] += 1,
|
|
2395
|
+
[fs](t) {
|
|
2396
|
+
t.pending = !0, this[G] += 1, I.readdir(t.absolute, (e, i) => {
|
|
2397
2397
|
if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
|
|
2398
2398
|
this[ci](t, i);
|
|
2399
2399
|
});
|
|
@@ -2439,7 +2439,7 @@ var mi = class {
|
|
|
2439
2439
|
if (t.stat && !t.ignore) {
|
|
2440
2440
|
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2441
2441
|
let e = this.readdirCache.get(t.absolute);
|
|
2442
|
-
if (e ? this[ci](t, e) : this[fs
|
|
2442
|
+
if (e ? this[ci](t, e) : this[fs](t), !t.readdir) return;
|
|
2443
2443
|
}
|
|
2444
2444
|
if (t.entry = this[rr](t), !t.entry) {
|
|
2445
2445
|
t.ignore = !0;
|
|
@@ -2506,10 +2506,10 @@ var mi = class {
|
|
|
2506
2506
|
resume() {}
|
|
2507
2507
|
[cs](t) {
|
|
2508
2508
|
let e = this.follow ? "statSync" : "lstatSync";
|
|
2509
|
-
this[ai](t,
|
|
2509
|
+
this[ai](t, I[e](t.absolute));
|
|
2510
2510
|
}
|
|
2511
|
-
[fs
|
|
2512
|
-
this[ci](t,
|
|
2511
|
+
[fs](t) {
|
|
2512
|
+
this[ci](t, I.readdirSync(t.absolute));
|
|
2513
2513
|
}
|
|
2514
2514
|
[fi](t) {
|
|
2515
2515
|
let e = t.entry, i = this.zip;
|
|
@@ -2561,7 +2561,7 @@ var Wn = (s, t) => {
|
|
|
2561
2561
|
}, Kn = K(Wn, Gn, Zn, Yn, (s, t) => {
|
|
2562
2562
|
if (!t?.length) throw new TypeError("no paths specified to add to archive");
|
|
2563
2563
|
});
|
|
2564
|
-
var ur = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: mr, O_NOFOLLOW: cr, O_TRUNC: pr, O_WRONLY: Er } =
|
|
2564
|
+
var ur = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: mr, O_NOFOLLOW: cr, O_TRUNC: pr, O_WRONLY: Er } = I.constants, wr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, $n = ur && !!wr, Xn = 512 * 1024, qn = wr | pr | mr | Er, fr = !ur && typeof cr == "number" ? cr | pr | mr | Er : null, ds = fr !== null ? () => fr : $n ? (s) => s < Xn ? qn : "w" : () => "w";
|
|
2565
2565
|
var us = (s, t, e) => {
|
|
2566
2566
|
try {
|
|
2567
2567
|
return Kt.lchownSync(s, t, e);
|
|
@@ -3542,8 +3542,8 @@ var SystemBackupService = class {
|
|
|
3542
3542
|
return value;
|
|
3543
3543
|
}
|
|
3544
3544
|
async statLocation(loc) {
|
|
3545
|
-
const abs = path$
|
|
3546
|
-
if (!fs$
|
|
3545
|
+
const abs = path$1.isAbsolute(loc) ? loc : path$1.join(this.dataDir, loc);
|
|
3546
|
+
if (!fs$1.existsSync(abs)) return {
|
|
3547
3547
|
name: loc,
|
|
3548
3548
|
sizeBytes: 0,
|
|
3549
3549
|
fileCount: 0,
|
|
@@ -3587,19 +3587,19 @@ var SystemBackupService = class {
|
|
|
3587
3587
|
const requested = opts.locations ?? DEFAULT_BACKUP_LOCATIONS;
|
|
3588
3588
|
const present = [];
|
|
3589
3589
|
for (const loc of requested) {
|
|
3590
|
-
const abs = path$
|
|
3591
|
-
if (fs$
|
|
3590
|
+
const abs = path$1.isAbsolute(loc) ? loc : path$1.join(this.dataDir, loc);
|
|
3591
|
+
if (fs$1.existsSync(abs)) present.push(loc);
|
|
3592
3592
|
else this.logger.debug("createArchive: skipping missing location", { meta: { location: loc } });
|
|
3593
3593
|
}
|
|
3594
3594
|
if (present.length === 0) throw new Error(`createArchive: no locations from {${requested.join(", ")}} exist under ${this.dataDir}`);
|
|
3595
|
-
fs$
|
|
3595
|
+
fs$1.mkdirSync(path$1.dirname(opts.archivePath), { recursive: true });
|
|
3596
3596
|
const walked = [];
|
|
3597
3597
|
for (const loc of present) {
|
|
3598
3598
|
throwIfCancelled(opts.signal);
|
|
3599
|
-
const abs = path$
|
|
3599
|
+
const abs = path$1.join(this.dataDir, loc);
|
|
3600
3600
|
const stat = await fsp.stat(abs);
|
|
3601
3601
|
if (stat.isDirectory()) for (const e of await walkAbs(abs, this.dataDir, this.exclusionPredicate(), opts.signal)) walked.push(e);
|
|
3602
|
-
else if (!isExcludedFromBackup(path$
|
|
3602
|
+
else if (!isExcludedFromBackup(path$1.relative(this.dataDir, abs))) walked.push(toArchiveEntry(abs, this.dataDir, stat));
|
|
3603
3603
|
}
|
|
3604
3604
|
const walkedPaths = new Set(walked.map((e) => e.path));
|
|
3605
3605
|
const owned = walked.some((e) => isSqlitePath(e.path)) ? await this.ownedDatabasesInScope(opts.owner, walkedPaths) : /* @__PURE__ */ new Set();
|
|
@@ -3665,7 +3665,7 @@ var SystemBackupService = class {
|
|
|
3665
3665
|
async writeArchive(opts) {
|
|
3666
3666
|
const { present, manifest } = opts;
|
|
3667
3667
|
const manifestStagePath = `${opts.archivePath}.${process.pid}.manifest.json`;
|
|
3668
|
-
fs$
|
|
3668
|
+
fs$1.writeFileSync(manifestStagePath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
3669
3669
|
this.logger.info("createArchive: tarring", { meta: {
|
|
3670
3670
|
archivePath: opts.archivePath,
|
|
3671
3671
|
locations: [...present],
|
|
@@ -3673,10 +3673,10 @@ var SystemBackupService = class {
|
|
|
3673
3673
|
totalBytes: manifest.totalBytes
|
|
3674
3674
|
} });
|
|
3675
3675
|
try {
|
|
3676
|
-
const stagedInDataDir = path$
|
|
3677
|
-
fs$
|
|
3678
|
-
const stagingRel = path$
|
|
3679
|
-
const excludePrefix = stagingRel && !stagingRel.startsWith("..") && !path$
|
|
3676
|
+
const stagedInDataDir = path$1.join(this.dataDir, ARCHIVE_MANIFEST_NAME);
|
|
3677
|
+
fs$1.copyFileSync(manifestStagePath, stagedInDataDir);
|
|
3678
|
+
const stagingRel = path$1.relative(this.dataDir, path$1.dirname(opts.archivePath));
|
|
3679
|
+
const excludePrefix = stagingRel && !stagingRel.startsWith("..") && !path$1.isAbsolute(stagingRel) ? stagingRel : null;
|
|
3680
3680
|
try {
|
|
3681
3681
|
const pack = Kn({
|
|
3682
3682
|
gzip: true,
|
|
@@ -3690,29 +3690,29 @@ var SystemBackupService = class {
|
|
|
3690
3690
|
return norm !== excludePrefix && !norm.startsWith(`${excludePrefix}/`);
|
|
3691
3691
|
}
|
|
3692
3692
|
}, [ARCHIVE_MANIFEST_NAME, ...present]);
|
|
3693
|
-
const sink = fs$
|
|
3693
|
+
const sink = fs$1.createWriteStream(opts.archivePath, { mode: 384 });
|
|
3694
3694
|
try {
|
|
3695
3695
|
const streamOpts = opts.signal ? { signal: opts.signal } : {};
|
|
3696
3696
|
if (opts.encryptTo !== void 0) await pipeline(pack, createBackupEncryptStream(opts.encryptTo), byteCountingPassthrough(opts.onArchiveBytes), sink, streamOpts);
|
|
3697
3697
|
else await pipeline(pack, byteCountingPassthrough(opts.onArchiveBytes), sink, streamOpts);
|
|
3698
3698
|
} catch (err) {
|
|
3699
3699
|
try {
|
|
3700
|
-
fs$
|
|
3700
|
+
fs$1.rmSync(opts.archivePath, { force: true });
|
|
3701
3701
|
} catch {}
|
|
3702
3702
|
if (opts.signal?.aborted) throw new BackupCancelledError();
|
|
3703
3703
|
throw err;
|
|
3704
3704
|
}
|
|
3705
3705
|
} finally {
|
|
3706
3706
|
try {
|
|
3707
|
-
fs$
|
|
3707
|
+
fs$1.rmSync(stagedInDataDir, { force: true });
|
|
3708
3708
|
} catch {}
|
|
3709
3709
|
}
|
|
3710
3710
|
} finally {
|
|
3711
3711
|
try {
|
|
3712
|
-
fs$
|
|
3712
|
+
fs$1.rmSync(manifestStagePath, { force: true });
|
|
3713
3713
|
} catch {}
|
|
3714
3714
|
}
|
|
3715
|
-
const sizeBytes = fs$
|
|
3715
|
+
const sizeBytes = fs$1.statSync(opts.archivePath).size;
|
|
3716
3716
|
return {
|
|
3717
3717
|
archivePath: opts.archivePath,
|
|
3718
3718
|
includedLocations: [...present],
|
|
@@ -3725,7 +3725,7 @@ var SystemBackupService = class {
|
|
|
3725
3725
|
* one entry we care about, then aborts.
|
|
3726
3726
|
*/
|
|
3727
3727
|
async readArchiveManifest(archivePath) {
|
|
3728
|
-
if (!fs$
|
|
3728
|
+
if (!fs$1.existsSync(archivePath)) throw new Error(`readArchiveManifest: ${archivePath} does not exist`);
|
|
3729
3729
|
return new Promise((resolve, reject) => {
|
|
3730
3730
|
const chunks = [];
|
|
3731
3731
|
let found = false;
|
|
@@ -3757,7 +3757,7 @@ var SystemBackupService = class {
|
|
|
3757
3757
|
reject(err);
|
|
3758
3758
|
}
|
|
3759
3759
|
});
|
|
3760
|
-
const reader = fs$
|
|
3760
|
+
const reader = fs$1.createReadStream(archivePath);
|
|
3761
3761
|
reader.on("error", (err) => {
|
|
3762
3762
|
if (!resolved) {
|
|
3763
3763
|
resolved = true;
|
|
@@ -3775,7 +3775,7 @@ var SystemBackupService = class {
|
|
|
3775
3775
|
* restart.
|
|
3776
3776
|
*/
|
|
3777
3777
|
scheduleRestoreMarker(opts) {
|
|
3778
|
-
if (!fs$
|
|
3778
|
+
if (!fs$1.existsSync(opts.archivePath)) throw new Error(`scheduleRestoreMarker: ${opts.archivePath} missing`);
|
|
3779
3779
|
const markerPath = this.getRestoreMarkerPath();
|
|
3780
3780
|
const marker = {
|
|
3781
3781
|
archivePath: opts.archivePath,
|
|
@@ -3783,16 +3783,16 @@ var SystemBackupService = class {
|
|
|
3783
3783
|
source: opts.source,
|
|
3784
3784
|
...opts.locations ? { locations: [...opts.locations] } : {}
|
|
3785
3785
|
};
|
|
3786
|
-
fs$
|
|
3787
|
-
fs$
|
|
3786
|
+
fs$1.mkdirSync(path$1.dirname(markerPath), { recursive: true });
|
|
3787
|
+
fs$1.writeFileSync(markerPath, JSON.stringify(marker, null, 2), { mode: 384 });
|
|
3788
3788
|
return markerPath;
|
|
3789
3789
|
}
|
|
3790
3790
|
/** Read the pending-restore marker if one is present. */
|
|
3791
3791
|
readPendingMarker() {
|
|
3792
3792
|
const markerPath = this.getRestoreMarkerPath();
|
|
3793
|
-
if (!fs$
|
|
3793
|
+
if (!fs$1.existsSync(markerPath)) return null;
|
|
3794
3794
|
try {
|
|
3795
|
-
const raw = fs$
|
|
3795
|
+
const raw = fs$1.readFileSync(markerPath, "utf-8");
|
|
3796
3796
|
const parsed = JSON.parse(raw);
|
|
3797
3797
|
if (typeof parsed === "object" && parsed != null && typeof parsed.archivePath === "string") return parsed;
|
|
3798
3798
|
} catch (err) {
|
|
@@ -3803,7 +3803,7 @@ var SystemBackupService = class {
|
|
|
3803
3803
|
/** Drop the marker after a successful boot-time restore. */
|
|
3804
3804
|
clearPendingMarker() {
|
|
3805
3805
|
const markerPath = this.getRestoreMarkerPath();
|
|
3806
|
-
if (fs$
|
|
3806
|
+
if (fs$1.existsSync(markerPath)) fs$1.rmSync(markerPath, { force: true });
|
|
3807
3807
|
}
|
|
3808
3808
|
/**
|
|
3809
3809
|
* The databases the owner declares, archive-relative, that this walk found.
|
|
@@ -3845,7 +3845,7 @@ var SystemBackupService = class {
|
|
|
3845
3845
|
*/
|
|
3846
3846
|
async takeOwnerSnapshot(owner, owned, signal) {
|
|
3847
3847
|
const removeOwnedSnapshots = async () => {
|
|
3848
|
-
for (const db of owned) await this.removeSnapshot(path$
|
|
3848
|
+
for (const db of owned) await this.removeSnapshot(path$1.join(this.dataDir, db + DATABASE_SNAPSHOT_SUFFIX));
|
|
3849
3849
|
};
|
|
3850
3850
|
let result;
|
|
3851
3851
|
try {
|
|
@@ -3876,7 +3876,7 @@ var SystemBackupService = class {
|
|
|
3876
3876
|
if (snapshotPath !== livePath + ".backup-snapshot") throw new BackupSnapshotRefusedError(`snapshot ${snapshotPath} does not sit beside the database ${livePath} it copies`);
|
|
3877
3877
|
const uncovered = [...owned].filter((db) => db !== livePath);
|
|
3878
3878
|
if (!owned.has(livePath) || uncovered.length > 0) throw new BackupSnapshotRefusedError(`snapshot copies ${livePath}, but the owned database(s) in this archive are ${[...owned].join(", ")}`);
|
|
3879
|
-
const absPath = path$
|
|
3879
|
+
const absPath = path$1.join(this.dataDir, snapshotPath);
|
|
3880
3880
|
const stat = await fsp.stat(absPath);
|
|
3881
3881
|
this.logger.info("createArchive: carrying the owner snapshot in place of the live database", { meta: {
|
|
3882
3882
|
database: livePath,
|
|
@@ -3912,12 +3912,12 @@ var SystemBackupService = class {
|
|
|
3912
3912
|
}
|
|
3913
3913
|
/** `abs` relative to the data root, or null when it lies outside it. */
|
|
3914
3914
|
archiveRelative(abs) {
|
|
3915
|
-
const rel = path$
|
|
3916
|
-
if (rel.length === 0 || rel.startsWith("..") || path$
|
|
3915
|
+
const rel = path$1.relative(path$1.resolve(this.dataDir), path$1.resolve(abs));
|
|
3916
|
+
if (rel.length === 0 || rel.startsWith("..") || path$1.isAbsolute(rel)) return null;
|
|
3917
3917
|
return normalizeArchivePath(rel);
|
|
3918
3918
|
}
|
|
3919
3919
|
getRestoreMarkerPath() {
|
|
3920
|
-
return path$
|
|
3920
|
+
return path$1.join(this.dataDir, ".pending-restore.json");
|
|
3921
3921
|
}
|
|
3922
3922
|
/**
|
|
3923
3923
|
* Absolute-path form of {@link isExcludedFromBackup}, anchored on
|
|
@@ -3925,7 +3925,7 @@ var SystemBackupService = class {
|
|
|
3925
3925
|
* stats so both agree with the tar filter about what a backup contains.
|
|
3926
3926
|
*/
|
|
3927
3927
|
exclusionPredicate() {
|
|
3928
|
-
return (abs) => isExcludedFromBackup(path$
|
|
3928
|
+
return (abs) => isExcludedFromBackup(path$1.relative(this.dataDir, abs));
|
|
3929
3929
|
}
|
|
3930
3930
|
};
|
|
3931
3931
|
/**
|
|
@@ -3956,7 +3956,7 @@ async function walkRec(abs, dataDir, out, shouldSkip, signal) {
|
|
|
3956
3956
|
} catch {
|
|
3957
3957
|
return;
|
|
3958
3958
|
}
|
|
3959
|
-
for (const child of children) await walkRec(path$
|
|
3959
|
+
for (const child of children) await walkRec(path$1.join(abs, child), dataDir, out, shouldSkip, signal);
|
|
3960
3960
|
}
|
|
3961
3961
|
}
|
|
3962
3962
|
/**
|
|
@@ -3973,10 +3973,10 @@ function byteCountingPassthrough(onBytes) {
|
|
|
3973
3973
|
} });
|
|
3974
3974
|
}
|
|
3975
3975
|
function toArchiveEntry(abs, dataDir, stat) {
|
|
3976
|
-
const rel = path$
|
|
3976
|
+
const rel = path$1.relative(dataDir, abs).replace(/\\/g, "/");
|
|
3977
3977
|
const kind = stat.isDirectory() ? "dir" : stat.isSymbolicLink() ? "symlink" : "file";
|
|
3978
3978
|
return {
|
|
3979
|
-
path: rel || path$
|
|
3979
|
+
path: rel || path$1.basename(abs),
|
|
3980
3980
|
kind,
|
|
3981
3981
|
sizeBytes: kind === "file" ? stat.size : 0,
|
|
3982
3982
|
mtime: stat.mtimeMs
|