@platforma-sdk/bootstrap 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import * as me from "node:os";
6
6
  import N from "node:os";
7
7
  import f, { createWriteStream as Lr } from "node:fs";
8
8
  import m, { resolve as Ar } from "node:path";
9
- import { execSync as Re, spawn as Ir, spawnSync as Or } from "node:child_process";
9
+ import { execSync as xe, spawn as Ir, spawnSync as Or } from "node:child_process";
10
10
  import fe from "winston";
11
11
  import { randomBytes as Er } from "node:crypto";
12
12
  import re from "readline-sync";
@@ -75,7 +75,7 @@ const ye = {
75
75
  description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
76
76
  env: "PLATFORMA_DEBUG_LISTEN"
77
77
  })
78
- }, He = {
78
+ }, we = {
79
79
  "s3-port": p.integer({
80
80
  description: "port that S3 will listen, default is 9000",
81
81
  default: 9e3,
@@ -94,12 +94,12 @@ const ye = {
94
94
  "minio-presign-host": p.boolean({
95
95
  description: "use 'minio' host instead of 'localhost' in presign URLs"
96
96
  })
97
- }, we = {
97
+ }, pe = {
98
98
  mount: p.string({
99
99
  multiple: !0,
100
100
  description: "things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths"
101
101
  })
102
- }, pe = {
102
+ }, Pe = {
103
103
  "pl-log-file": p.file({
104
104
  description: "specify path for Platforma Backend log file"
105
105
  })
@@ -107,15 +107,15 @@ const ye = {
107
107
  "pl-workdir": p.file({
108
108
  description: "specify working directory for Platforma Backend process"
109
109
  })
110
- }, Pe = {
110
+ }, ke = {
111
111
  "pl-binary": p.file({
112
112
  description: "start given Platforma Backend binary instead of automatically downloaded version"
113
113
  })
114
- }, ke = {
114
+ }, Se = {
115
115
  "pl-sources": p.file({
116
116
  description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
117
117
  })
118
- }, Se = {
118
+ }, $e = {
119
119
  config: p.string({
120
120
  description: "use custom Platforma Backend config"
121
121
  })
@@ -203,14 +203,14 @@ function jr(a) {
203
203
  function Br(a) {
204
204
  return a.startsWith("~") ? m.join(N.homedir(), a.slice(1)) : a;
205
205
  }
206
- function Le(a, e) {
206
+ function Ae(a, e) {
207
207
  f.existsSync(a) || (f.mkdirSync(a, { recursive: !0 }), e != null && e.mode && f.chmodSync(a, e.mode));
208
208
  }
209
209
  function Ur(a) {
210
210
  try {
211
211
  if (N.platform() !== "win32")
212
- return Re(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
213
- const e = `wmic process where processid=${a} get Caption`, t = Re(e, { encoding: "utf8" }).split(`
212
+ return xe(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
213
+ const e = `wmic process where processid=${a} get Caption`, t = xe(e, { encoding: "utf8" }).split(`
214
214
  `);
215
215
  return t.length <= 1 ? "" : t[1].trim();
216
216
  } catch {
@@ -218,12 +218,12 @@ function Ur(a) {
218
218
  }
219
219
  }
220
220
  function Gr(a) {
221
- const e = Re(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
221
+ const e = xe(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
222
222
  for (const r of t)
223
223
  if (r.Name === a)
224
224
  return r;
225
225
  }
226
- const xe = ["Python"], br = ["Tengo", "Python"], Jr = C.union([C.literal("Tengo"), C.literal("Python")]), Hr = C.object({
226
+ const Te = ["Python"], br = ["Tengo", "Python"], Jr = C.union([C.literal("Tengo"), C.literal("Python")]), Hr = C.object({
227
227
  npmOrgName: C.string().min(1),
228
228
  orgName: C.string().min(1, { message: "Organization name must be provided" }),
229
229
  blockName: C.string().min(1, { message: "Block name must be provided" }),
@@ -240,7 +240,7 @@ async function Wr(a) {
240
240
  "platforma-block-boilerplate-main",
241
241
  s
242
242
  );
243
- const i = br.filter((o) => n.indexOf(o) < 0), c = xe.length == i.length;
243
+ const i = br.filter((o) => n.indexOf(o) < 0), c = Te.length == i.length;
244
244
  a.info(`Keep platforms '${n}', remove: '${i}'. Will remove all platforms? ${c}`);
245
245
  for (const o of i)
246
246
  await Yr(s, o);
@@ -268,9 +268,9 @@ function qr() {
268
268
  let n = ["Tengo"];
269
269
  if (r)
270
270
  for (; n.length < br.length; ) {
271
- const i = re.keyInSelect(xe, "Choose software platform:");
271
+ const i = re.keyInSelect(Te, "Choose software platform:");
272
272
  if (i < 0) break;
273
- n.push(xe[i]);
273
+ n.push(Te[i]);
274
274
  }
275
275
  n = Array.from(new Set(n)).sort();
276
276
  const s = Hr.safeParse({ npmOrgName: a, orgName: e, blockName: t, softwarePlatforms: n });
@@ -352,14 +352,14 @@ const ae = class ae extends L {
352
352
  l(ae, "description", "Helps to create a new block by downloading a block's template."), l(ae, "examples", ["<%= name %>"]), l(ae, "flags", {
353
353
  ...A
354
354
  });
355
- let Te = ae;
355
+ let Fe = ae;
356
356
  function pr(...a) {
357
357
  return Ar(__dirname, "..", ...a);
358
358
  }
359
359
  function Z(...a) {
360
360
  return pr("assets", ...a);
361
361
  }
362
- function Ae(...a) {
362
+ function Ie(...a) {
363
363
  return f.readFileSync(pr(...a));
364
364
  }
365
365
  function fr(a) {
@@ -374,7 +374,7 @@ const W = class W {
374
374
  l(this, "dirPath");
375
375
  e = e ?? m.resolve(N.homedir(), ".config", "pl-bootstrap");
376
376
  const t = m.join(e, "state.json");
377
- this.dirPath = e, this.filePath = t, f.existsSync(e) || f.mkdirSync(e, { recursive: !0 }), f.existsSync(t) && (this.state = JSON.parse(Ae(t).toString()));
377
+ this.dirPath = e, this.filePath = t, f.existsSync(e) || f.mkdirSync(e, { recursive: !0 }), f.existsSync(t) && (this.state = JSON.parse(Ie(t).toString()));
378
378
  }
379
379
  static getStateInstance() {
380
380
  return W.instance || (W.instance = new W()), W.instance;
@@ -401,7 +401,7 @@ const W = class W {
401
401
  const t = this.instanceDir(e, "instance.json");
402
402
  if (!f.existsSync(t))
403
403
  throw new Error(`platforma backend instance '${e}' does not exist or is corrupted`);
404
- const r = JSON.parse(Ae(t).toString());
404
+ const r = JSON.parse(Ie(t).toString());
405
405
  return {
406
406
  name: e,
407
407
  ...r
@@ -411,7 +411,7 @@ const W = class W {
411
411
  f.existsSync(this.instanceDir(e)) || f.mkdirSync(this.instanceDir(e), { recursive: !0 });
412
412
  const r = this.instanceDir(e, "instance.json");
413
413
  let n = {};
414
- f.existsSync(r) && (n = JSON.parse(Ae(r).toString())), f.writeFileSync(r, JSON.stringify({ ...n, ...t }));
414
+ f.existsSync(r) && (n = JSON.parse(Ie(r).toString())), f.writeFileSync(r, JSON.stringify({ ...n, ...t }));
415
415
  }
416
416
  isInstanceActive(e) {
417
417
  switch (e.type) {
@@ -454,13 +454,13 @@ const W = class W {
454
454
  }
455
455
  };
456
456
  l(W, "instance");
457
- let Fe = W;
457
+ let De = W;
458
458
  function mr(a) {
459
459
  const e = Ur(a);
460
460
  return e === "platforma" || e.endsWith("/platforma") || e.endsWith("\\platforma");
461
461
  }
462
- const u = Fe.getStateInstance();
463
- function Ie(a, e, t) {
462
+ const u = De.getStateInstance();
463
+ function Oe(a, e, t) {
464
464
  const r = [], n = [];
465
465
  for (const s of e) {
466
466
  const i = {
@@ -509,7 +509,7 @@ function Zr(a, e, t, r) {
509
509
  opts: ${JSON.stringify(r)}`
510
510
  ), r.env = { ...process.env, ...r.env }, Or(e, t, r);
511
511
  }
512
- function Oe(a, e, t, r, n) {
512
+ function Ee(a, e, t, r, n) {
513
513
  const s = f.readFileSync(a, { encoding: "utf-8" }), i = ur.parse(s.toString());
514
514
  if (!i.services)
515
515
  throw new Error(`file '${a}' seems to be not a docker-compose file or has unsupported version`);
@@ -559,7 +559,7 @@ function et(a) {
559
559
  uploadKeyPrefix: ""
560
560
  };
561
561
  }
562
- function vr(a) {
562
+ function Pr(a) {
563
563
  return {
564
564
  id: a,
565
565
  type: "FS",
@@ -617,15 +617,15 @@ function ee(a, e, t) {
617
617
  }
618
618
  }
619
619
  function rt(a, e) {
620
- var w, y, P, $, k, v, S, _, ge, E, qe, ze, Ye, Ve, Ke, Xe, Qe, Ze, er, rr, tr, ar, nr, sr, ir, cr, or, lr, dr, gr;
620
+ var w, y, v, $, k, P, S, _, ge, E, qe, ze, Ye, Ve, Ke, Xe, Qe, Ze, er, rr, tr, ar, nr, sr, ir, cr, or, lr, dr, gr;
621
621
  const t = (e == null ? void 0 : e.localRoot) ?? u.instanceDir("default"), r = {
622
622
  level: ((w = e == null ? void 0 : e.log) == null ? void 0 : w.level) ?? "info",
623
623
  path: ((y = e == null ? void 0 : e.log) == null ? void 0 : y.path) ?? `${t}/logs/platforma.log`
624
624
  }, n = {
625
- listen: ((P = e == null ? void 0 : e.grpc) == null ? void 0 : P.listen) ?? "localhost:6345",
625
+ listen: ((v = e == null ? void 0 : e.grpc) == null ? void 0 : v.listen) ?? "localhost:6345",
626
626
  tls: {
627
627
  enable: ue((k = ($ = e == null ? void 0 : e.grpc) == null ? void 0 : $.tls) == null ? void 0 : k.enable, !1),
628
- clientAuthMode: ((S = (v = e == null ? void 0 : e.grpc) == null ? void 0 : v.tls) == null ? void 0 : S.clientAuthMode) ?? "NoAuth",
628
+ clientAuthMode: ((S = (P = e == null ? void 0 : e.grpc) == null ? void 0 : P.tls) == null ? void 0 : S.clientAuthMode) ?? "NoAuth",
629
629
  certFile: ((ge = (_ = e == null ? void 0 : e.grpc) == null ? void 0 : _.tls) == null ? void 0 : ge.certFile) ?? `${t}/certs/tls.cert`,
630
630
  keyFile: ((qe = (E = e == null ? void 0 : e.grpc) == null ? void 0 : E.tls) == null ? void 0 : qe.keyFile) ?? `${t}/certs/tls.key`,
631
631
  ...(ze = e == null ? void 0 : e.grpc) == null ? void 0 : ze.tls
@@ -651,7 +651,7 @@ function rt(a, e) {
651
651
  switch ((er = (Ze = e == null ? void 0 : e.storages) == null ? void 0 : Ze.work) == null ? void 0 : er.type) {
652
652
  case void 0:
653
653
  case "FS":
654
- c = vr("work"), c.rootPath = ((tr = (rr = e == null ? void 0 : e.storages) == null ? void 0 : rr.work) == null ? void 0 : tr.rootPath) ?? `${t}/storages/work`, c.indexCachePeriod = ((nr = (ar = e == null ? void 0 : e.storages) == null ? void 0 : ar.work) == null ? void 0 : nr.indexCachePeriod) ?? "1m";
654
+ c = Pr("work"), c.rootPath = ((tr = (rr = e == null ? void 0 : e.storages) == null ? void 0 : rr.work) == null ? void 0 : tr.rootPath) ?? `${t}/storages/work`, c.indexCachePeriod = ((nr = (ar = e == null ? void 0 : e.storages) == null ? void 0 : ar.work) == null ? void 0 : nr.indexCachePeriod) ?? "1m";
655
655
  break;
656
656
  default:
657
657
  throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
@@ -689,7 +689,7 @@ function hr(a, e, t, r) {
689
689
  switch (r == null ? void 0 : r.type) {
690
690
  case void 0:
691
691
  case "FS":
692
- n = vr(a), n.rootPath = (r == null ? void 0 : r.rootPath) ?? e;
692
+ n = Pr(a), n.rootPath = (r == null ? void 0 : r.rootPath) ?? e;
693
693
  break;
694
694
  case "S3":
695
695
  n = et(a), n.endpoint = r == null ? void 0 : r.endpoint, n.region = r == null ? void 0 : r.region, n.presignEndpoint = (r == null ? void 0 : r.presignEndpoint) ?? (r == null ? void 0 : r.endpoint), n.bucketName = (r == null ? void 0 : r.bucketName) ?? t, n.createBucket = ue(r == null ? void 0 : r.createBucket, !0), n.forcePathStyle = ue(r == null ? void 0 : r.forcePathStyle, !0), n.key = (r == null ? void 0 : r.key) ?? "", n.secret = (r == null ? void 0 : r.secret) ?? "", n.keyPrefix = (r == null ? void 0 : r.keyPrefix) ?? "", n.accessPrefixes = (r == null ? void 0 : r.accessPrefixes) ?? [""], n.uploadKeyPrefix = (r == null ? void 0 : r.uploadKeyPrefix) ?? "";
@@ -810,7 +810,7 @@ function nt(a) {
810
810
  }
811
811
  }
812
812
  const st = ["amd64", "arm64"];
813
- function Pr(a) {
813
+ function vr(a) {
814
814
  const e = N.arch();
815
815
  switch (e) {
816
816
  case "arm64":
@@ -824,7 +824,7 @@ function Pr(a) {
824
824
  }
825
825
  }
826
826
  function it(a, e) {
827
- const t = (e == null ? void 0 : e.version) ?? he(), r = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, n = `pl-${t}-${Pr()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${nt()}/${n}`, i = (e == null ? void 0 : e.saveTo) ?? u.binaries(n);
827
+ const t = (e == null ? void 0 : e.version) ?? he(), r = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, n = `pl-${t}-${vr()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${nt()}/${n}`, i = (e == null ? void 0 : e.saveTo) ?? u.binaries(n);
828
828
  if (f.existsSync(i))
829
829
  return a.info(`Platforma Backend archive download skipped: '${i}' already exists`), Promise.resolve(i);
830
830
  f.mkdirSync(m.dirname(i), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
@@ -848,8 +848,8 @@ function it(a, e) {
848
848
  const w = f.createWriteStream(i);
849
849
  d.pipe(w), d.on("data", (y) => {
850
850
  b += y.length;
851
- const P = b / h * 100;
852
- r && process.stdout.write(` downloading: ${P.toFixed(2)}%\r`);
851
+ const v = b / h * 100;
852
+ r && process.stdout.write(` downloading: ${v.toFixed(2)}%\r`);
853
853
  }), d.on("error", (y) => {
854
854
  f.unlinkSync(i), a.error(`Failed to download Platforma Binary: ${y.message}`), c.destroy(), g(y);
855
855
  }), w.on("finish", () => {
@@ -880,11 +880,11 @@ function ct(a, e) {
880
880
  sync: !0
881
881
  }), a.info(" ... unpack done."), s;
882
882
  }
883
- function $e(a, e) {
883
+ function Le(a, e) {
884
884
  return it(a, e).then((t) => ct(a, { archivePath: t }));
885
885
  }
886
886
  function kr(a) {
887
- return `pl-${(a == null ? void 0 : a.version) ?? he()}-${Pr()}`;
887
+ return `pl-${(a == null ? void 0 : a.version) ?? he()}-${vr()}`;
888
888
  }
889
889
  function ot(a, ...e) {
890
890
  return u.binaries(kr({ version: a }), ...e);
@@ -909,16 +909,16 @@ class O {
909
909
  this.logger.info(`Starting platforma backend instance '${e.name}':
910
910
  ${r}`);
911
911
  }
912
- const t = Ie(
912
+ const t = Oe(
913
913
  this.logger,
914
914
  e.upCommands
915
915
  );
916
- return Ee(t.executed), t.spawned.length > 0 && e.type === "process" && (e.pid = t.spawned[t.spawned.length - 1].pid, u.setInstanceInfo(e.name, e), this.logger.info(`instance '${e.name}' started`)), u.currentInstanceName = e.name, t.spawned;
916
+ return Re(t.executed), t.spawned.length > 0 && e.type === "process" && (e.pid = t.spawned[t.spawned.length - 1].pid, u.setInstanceInfo(e.name, e), this.logger.info(`instance '${e.name}' started`)), u.currentInstanceName = e.name, t.spawned;
917
917
  }
918
918
  stopInstance(e) {
919
919
  this.logger.info(`stopping platforma backend instance '${e.name}'...`);
920
- const t = Ie(this.logger, e.downCommands);
921
- switch (Ee(t.executed), e.type) {
920
+ const t = Oe(this.logger, e.downCommands);
921
+ switch (Re(t.executed), e.type) {
922
922
  case "docker":
923
923
  return;
924
924
  case "process": {
@@ -938,7 +938,7 @@ ${r}`);
938
938
  return this.startInstance(e);
939
939
  }
940
940
  createLocal(e, t) {
941
- var d, h, b, w, y, P, $, k, v, S, _, ge;
941
+ var d, h, b, w, y, v, $, k, P, S, _, ge;
942
942
  let r = ot(t == null ? void 0 : t.version, "binaries", "platforma");
943
943
  t != null && t.sourcesPath && (r = m.join(N.tmpdir(), "platforma-custom-build")), t != null && t.binaryPath && (r = t.binaryPath);
944
944
  let n = t == null ? void 0 : t.configPath;
@@ -953,11 +953,11 @@ ${r}`);
953
953
  ...t.configOptions,
954
954
  storages: {
955
955
  ...(w = t.configOptions) == null ? void 0 : w.storages,
956
- library: ee(t.libraryURL, s, (P = (y = t.configOptions) == null ? void 0 : y.storages) == null ? void 0 : P.library)
956
+ library: ee(t.libraryURL, s, (v = (y = t.configOptions) == null ? void 0 : y.storages) == null ? void 0 : v.library)
957
957
  }
958
958
  });
959
959
  const i = rt(this.getLastJwt(), t == null ? void 0 : t.configOptions);
960
- this.logger.debug(" checking license..."), this.checkLicense((k = ($ = t == null ? void 0 : t.configOptions) == null ? void 0 : $.license) == null ? void 0 : k.value, (S = (v = t == null ? void 0 : t.configOptions) == null ? void 0 : v.license) == null ? void 0 : S.file);
960
+ this.logger.debug(" checking license..."), this.checkLicense((k = ($ = t == null ? void 0 : t.configOptions) == null ? void 0 : $.license) == null ? void 0 : k.value, (S = (P = t == null ? void 0 : t.configOptions) == null ? void 0 : P.license) == null ? void 0 : S.file);
961
961
  const c = [
962
962
  `${i.localRoot}/packages`,
963
963
  `${i.localRoot}/packages-local`,
@@ -1031,7 +1031,7 @@ ${r}`);
1031
1031
  createMinio(e, t) {
1032
1032
  this.logger.debug(" creating docker compose for minio service...");
1033
1033
  const r = Z("compose-backend.yaml"), n = u.instanceDir(e, "compose-minio.yaml");
1034
- Oe(
1034
+ Ee(
1035
1035
  r,
1036
1036
  n,
1037
1037
  `pl-${e}-minio`,
@@ -1045,7 +1045,7 @@ ${r}`);
1045
1045
  const i = (t == null ? void 0 : t.image) ?? `quay.io/minio/minio${s}`;
1046
1046
  this.logger.debug(` minio image: ${i}`);
1047
1047
  const c = (t == null ? void 0 : t.storage) ?? u.instanceDir(e, "minio");
1048
- Le(c, { mode: "0775" });
1048
+ Ae(c, { mode: "0775" });
1049
1049
  const o = (t == null ? void 0 : t.minioPort) ?? 9e3, g = (t == null ? void 0 : t.minioConsolePort) ?? 9001, d = {
1050
1050
  MINIO_IMAGE: i,
1051
1051
  MINIO_STORAGE: m.resolve(c),
@@ -1080,9 +1080,9 @@ ${r}`);
1080
1080
  this.logger.debug("creating platforma instance in 'docker s3' mode...");
1081
1081
  const n = Z("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? fr(r == null ? void 0 : r.version);
1082
1082
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
1083
- const i = (...v) => m.join(t, ...v), c = (v) => {
1084
- const S = i(v);
1085
- return Le(S, { mode: "0775" }), S;
1083
+ const i = (...P) => m.join(t, ...P), c = (P) => {
1084
+ const S = i(P);
1085
+ return Ae(S, { mode: "0775" }), S;
1086
1086
  }, o = i("logs", "platforma.log");
1087
1087
  f.existsSync(o) || (f.mkdirSync(m.dirname(o), { recursive: !0 }), f.writeFileSync(o, ""));
1088
1088
  const g = (r == null ? void 0 : r.presignHost) ?? "localhost", d = ee("s3e://testuser:testpassword@minio:9000/main-bucket");
@@ -1095,15 +1095,15 @@ ${r}`);
1095
1095
  h.presignEndpoint = `http://${g}:9000`;
1096
1096
  const b = c("db"), w = c("work"), y = i("users.htpasswd");
1097
1097
  f.existsSync(y) || f.copyFileSync(Z("users.htpasswd"), y);
1098
- const P = i("compose.yaml");
1099
- f.existsSync(P) && this.logger.info(`replacing docker compose file ${P}`);
1098
+ const v = i("compose.yaml");
1099
+ f.existsSync(v) && this.logger.info(`replacing docker compose file ${v}`);
1100
1100
  const $ = [];
1101
- for (const v of (r == null ? void 0 : r.customMounts) ?? [])
1101
+ for (const P of (r == null ? void 0 : r.customMounts) ?? [])
1102
1102
  $.push({
1103
- hostPath: v.hostPath,
1104
- containerPath: v.containerPath ?? v.hostPath
1103
+ hostPath: P.hostPath,
1104
+ containerPath: P.containerPath ?? P.hostPath
1105
1105
  });
1106
- Oe(n, P, `pl-${e}`, /* @__PURE__ */ new Map([
1106
+ Ee(n, v, `pl-${e}`, /* @__PURE__ */ new Map([
1107
1107
  ["minio", {}],
1108
1108
  ["backend", {
1109
1109
  platform: r == null ? void 0 : r.platformOverride,
@@ -1131,27 +1131,27 @@ ${r}`);
1131
1131
  ...this.configureDockerStorage("library", h)
1132
1132
  };
1133
1133
  if (r != null && r.grpcAddr && (k.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (k.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (k.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (k.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (k.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (k.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.s3Port && (k.MINIO_PORT = r.s3Port.toString()), r != null && r.s3ConsolePort && (k.MINIO_CONSOLE_PORT = r.s3ConsolePort.toString()), r != null && r.auth && (r.auth.enabled && (k.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1134
- for (const v of r.auth.drivers)
1135
- v.driver === "htpasswd" && (k.PL_AUTH_HTPASSWD_PATH = m.resolve(v.path), v.path = "/etc/platforma/users.htpasswd");
1134
+ for (const P of r.auth.drivers)
1135
+ P.driver === "htpasswd" && (k.PL_AUTH_HTPASSWD_PATH = m.resolve(P.path), P.path = "/etc/platforma/users.htpasswd");
1136
1136
  k.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1137
1137
  }
1138
1138
  return u.setInstanceInfo(e, {
1139
1139
  type: "docker",
1140
1140
  upCommands: [{
1141
1141
  cmd: "docker",
1142
- args: ["compose", `--file=${P}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1142
+ args: ["compose", `--file=${v}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1143
1143
  envs: k,
1144
1144
  runOpts: { stdio: "inherit" }
1145
1145
  }],
1146
1146
  downCommands: [{
1147
1147
  cmd: "docker",
1148
- args: ["compose", `--file=${P}`, "down"],
1148
+ args: ["compose", `--file=${v}`, "down"],
1149
1149
  envs: k,
1150
1150
  runOpts: { stdio: "inherit" }
1151
1151
  }],
1152
1152
  cleanupCommands: [{
1153
1153
  cmd: "docker",
1154
- args: ["compose", `--file=${P}`, "down", "--volumes", "--remove-orphans"],
1154
+ args: ["compose", `--file=${v}`, "down", "--volumes", "--remove-orphans"],
1155
1155
  envs: k,
1156
1156
  runOpts: { stdio: "inherit" }
1157
1157
  }],
@@ -1172,26 +1172,26 @@ ${r}`);
1172
1172
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
1173
1173
  const i = (...S) => m.join(t, ...S), c = (S) => {
1174
1174
  const _ = i(S);
1175
- return Le(_, { mode: "0775" }), _;
1175
+ return Ae(_, { mode: "0775" }), _;
1176
1176
  }, o = i("logs", "platforma.log");
1177
1177
  f.existsSync(o) || (f.mkdirSync(m.dirname(o), { recursive: !0 }), f.writeFileSync(o, ""));
1178
1178
  const g = c("db"), d = c("primary"), h = c("library"), b = c("work"), w = i("users.htpasswd");
1179
1179
  f.existsSync(w) || f.copyFileSync(Z("users.htpasswd"), w);
1180
1180
  const y = i("compose.yaml");
1181
1181
  f.existsSync(y) && this.logger.info(`replacing docker compose file ${y}`);
1182
- const P = [];
1182
+ const v = [];
1183
1183
  for (const S of (r == null ? void 0 : r.customMounts) ?? [])
1184
- P.push({
1184
+ v.push({
1185
1185
  hostPath: S.hostPath,
1186
1186
  containerPath: S.containerPath ?? S.hostPath
1187
1187
  });
1188
- this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), Oe(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1188
+ this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), Ee(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1189
1189
  ["backend", {
1190
1190
  platform: r == null ? void 0 : r.platformOverride,
1191
- mounts: P
1191
+ mounts: v
1192
1192
  }]
1193
1193
  ]));
1194
- const $ = ee((r == null ? void 0 : r.primaryStorageURL) ?? `file:${d}`, "."), k = ee((r == null ? void 0 : r.libraryStorageURL) ?? `file:${h}`, "."), v = {
1194
+ const $ = ee((r == null ? void 0 : r.primaryStorageURL) ?? `file:${d}`, "."), k = ee((r == null ? void 0 : r.libraryStorageURL) ?? `file:${h}`, "."), P = {
1195
1195
  PL_IMAGE: s,
1196
1196
  PL_AUTH_HTPASSWD_PATH: w,
1197
1197
  PL_LICENSE: r == null ? void 0 : r.license,
@@ -1208,29 +1208,29 @@ ${r}`);
1208
1208
  ...this.configureDockerStorage("primary", $),
1209
1209
  ...this.configureDockerStorage("library", k)
1210
1210
  };
1211
- if (r != null && r.grpcAddr && (v.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (v.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (v.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (v.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (v.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (v.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (v.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1211
+ if (r != null && r.grpcAddr && (P.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (P.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (P.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (P.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (P.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (P.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (P.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1212
1212
  for (const S of r.auth.drivers)
1213
- S.driver === "htpasswd" && (v.PL_AUTH_HTPASSWD_PATH = m.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
1214
- v.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1213
+ S.driver === "htpasswd" && (P.PL_AUTH_HTPASSWD_PATH = m.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
1214
+ P.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1215
1215
  }
1216
1216
  return u.setInstanceInfo(e, {
1217
1217
  type: "docker",
1218
1218
  upCommands: [{
1219
1219
  cmd: "docker",
1220
1220
  args: ["compose", `--file=${y}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1221
- envs: v,
1221
+ envs: P,
1222
1222
  runOpts: { stdio: "inherit" }
1223
1223
  }],
1224
1224
  downCommands: [{
1225
1225
  cmd: "docker",
1226
1226
  args: ["compose", `--file=${y}`, "down"],
1227
- envs: v,
1227
+ envs: P,
1228
1228
  runOpts: { stdio: "inherit" }
1229
1229
  }],
1230
1230
  cleanupCommands: [{
1231
1231
  cmd: "docker",
1232
1232
  args: ["compose", `--file=${y}`, "down", "--volumes", "--remove-orphans"],
1233
- envs: v,
1233
+ envs: P,
1234
1234
  runOpts: { stdio: "inherit" }
1235
1235
  }],
1236
1236
  runInfo: {
@@ -1287,8 +1287,8 @@ You are going to reset the state of all platforma services configured with pl-bo
1287
1287
  for (const [s, i] of r.entries()) {
1288
1288
  if (i.cleanupCommands.length) {
1289
1289
  this.logger.info(`Wiping instance ${s} services`);
1290
- const c = Ie(this.logger, i.cleanupCommands);
1291
- Ee(c.executed, `failed to wipe instance ${s} services`);
1290
+ const c = Oe(this.logger, i.cleanupCommands);
1291
+ Re(c.executed, `failed to wipe instance ${s} services`);
1292
1292
  }
1293
1293
  this.logger.info(`Destroying instance '${s}' data directory`), f.rmSync(u.instanceDir(s), { recursive: !0, force: !0 });
1294
1294
  }
@@ -1382,7 +1382,7 @@ You can obtain the license from "https://licensing.milaboratories.com".`), new E
1382
1382
  `);
1383
1383
  }
1384
1384
  }
1385
- function Ee(a, e) {
1385
+ function Re(a, e) {
1386
1386
  for (const t of a) {
1387
1387
  if (t.error)
1388
1388
  throw t.error;
@@ -1400,7 +1400,7 @@ const ne = class ne extends L {
1400
1400
  l(ne, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), l(ne, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ne, "flags", {
1401
1401
  ...A
1402
1402
  });
1403
- let De = ne;
1403
+ let Ne = ne;
1404
1404
  const se = class se extends L {
1405
1405
  async run() {
1406
1406
  const { flags: e } = await this.parse(se), t = I(e["log-level"]);
@@ -1410,7 +1410,7 @@ const se = class se extends L {
1410
1410
  l(se, "description", "Start last run service configuraiton"), l(se, "examples", ["<%= config.bin %> <%= command.id %>"]), l(se, "flags", {
1411
1411
  ...A
1412
1412
  });
1413
- let Ne = se;
1413
+ let _e = se;
1414
1414
  const ie = class ie extends L {
1415
1415
  async run() {
1416
1416
  const { flags: e } = await this.parse(ie), t = I(e["log-level"]), r = new O(t);
@@ -1420,7 +1420,7 @@ const ie = class ie extends L {
1420
1420
  l(ie, "description", "Stop platforma service"), l(ie, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ie, "flags", {
1421
1421
  ...A
1422
1422
  });
1423
- let _e = ie;
1423
+ let Ce = ie;
1424
1424
  var x;
1425
1425
  let dt = (x = class extends L {
1426
1426
  async run() {
@@ -1460,7 +1460,7 @@ let dt = (x = class extends L {
1460
1460
  ...be,
1461
1461
  ...J,
1462
1462
  ...B,
1463
- ...we,
1463
+ ...pe,
1464
1464
  ...G,
1465
1465
  ...le,
1466
1466
  ...oe,
@@ -1502,29 +1502,29 @@ let gt = (T = class extends L {
1502
1502
  numCpu: Math.max(me.cpus().length - 2, 1)
1503
1503
  }
1504
1504
  }, y = r.createLocal(n, w);
1505
- w.binaryPath || w.sourcesPath ? r.switchInstance(y) : $e(t, { version: e.version }).then(() => {
1506
- const P = r.switchInstance(y);
1505
+ w.binaryPath || w.sourcesPath ? r.switchInstance(y) : Le(t, { version: e.version }).then(() => {
1506
+ const v = r.switchInstance(y);
1507
1507
  setTimeout(() => {
1508
- for (const $ of P)
1508
+ for (const $ of v)
1509
1509
  $.unref();
1510
1510
  }, 1e3);
1511
- }).catch(function(P) {
1512
- t.error(P.message);
1511
+ }).catch(function(v) {
1512
+ t.error(v.message);
1513
1513
  });
1514
1514
  }
1515
1515
  }, l(T, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(T, "examples", ["<%= config.bin %> <%= command.id %>"]), l(T, "flags", {
1516
1516
  ...A,
1517
1517
  ...j,
1518
1518
  ...U,
1519
- ...Pe,
1520
1519
  ...ke,
1521
1520
  ...Se,
1521
+ ...$e,
1522
1522
  ...B,
1523
1523
  ...G,
1524
1524
  ...le,
1525
1525
  ...oe,
1526
1526
  ...de,
1527
- ...pe,
1527
+ ...Pe,
1528
1528
  ...ve,
1529
1529
  ...J
1530
1530
  }), T);
@@ -1543,7 +1543,7 @@ l(q, "description", "List available instances"), l(q, "examples", ["<%= config.b
1543
1543
  }), l(q, "args", {
1544
1544
  name: Q.string({ required: !1 })
1545
1545
  });
1546
- let Ce = q;
1546
+ let Me = q;
1547
1547
  const z = class z extends L {
1548
1548
  async run() {
1549
1549
  const { flags: e, args: t } = await this.parse(z), r = I(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
@@ -1555,7 +1555,7 @@ l(z, "description", "List available instances"), l(z, "examples", ["<%= config.b
1555
1555
  }), l(z, "args", {
1556
1556
  name: Q.string({ required: !1 })
1557
1557
  });
1558
- let Me = z;
1558
+ let je = z;
1559
1559
  const ce = class ce extends L {
1560
1560
  async run() {
1561
1561
  await this.parse(ce);
@@ -1567,7 +1567,7 @@ const ce = class ce extends L {
1567
1567
  }
1568
1568
  };
1569
1569
  l(ce, "description", "List available instances"), l(ce, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ce, "flags", {});
1570
- let je = ce;
1570
+ let Be = ce;
1571
1571
  const Y = class Y extends L {
1572
1572
  async run() {
1573
1573
  const { flags: e, args: t } = await this.parse(Y), r = I(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
@@ -1585,7 +1585,7 @@ l(Y, "description", "List available instances"), l(Y, "examples", ["<%= config.b
1585
1585
  }), l(Y, "args", {
1586
1586
  name: Q.string({ required: !1 })
1587
1587
  });
1588
- let Be = Y;
1588
+ let Ue = Y;
1589
1589
  var F;
1590
1590
  let ut = (F = class extends L {
1591
1591
  async run() {
@@ -1620,13 +1620,13 @@ let ut = (F = class extends L {
1620
1620
  }, l(F, "description", "Run platforma backend service with 'S3' primary storage type"), l(F, "examples", ["<%= config.bin %> <%= command.id %>"]), l(F, "flags", {
1621
1621
  ...A,
1622
1622
  ...U,
1623
- ...He,
1623
+ ...we,
1624
1624
  ...ye,
1625
1625
  ...j,
1626
1626
  ...be,
1627
1627
  ...J,
1628
1628
  ...B,
1629
- ...we,
1629
+ ...pe,
1630
1630
  ...G,
1631
1631
  ...yr
1632
1632
  }), F);
@@ -1670,31 +1670,31 @@ let ft = (D = class extends L {
1670
1670
  }
1671
1671
  }
1672
1672
  }, y = r.createLocalS3(n, w);
1673
- w.binaryPath || w.sourcesPath ? r.switchInstance(y) : await $e(t, { version: e.version }).then(() => {
1674
- const P = r.switchInstance(y), $ = [];
1675
- for (const k of P)
1676
- $.push(new Promise((v, S) => {
1677
- k.on("close", v), k.on("error", S);
1673
+ w.binaryPath || w.sourcesPath ? r.switchInstance(y) : await Le(t, { version: e.version }).then(() => {
1674
+ const v = r.switchInstance(y), $ = [];
1675
+ for (const k of v)
1676
+ $.push(new Promise((P, S) => {
1677
+ k.on("close", P), k.on("error", S);
1678
1678
  }));
1679
1679
  return Promise.all($);
1680
- }).catch(function(P) {
1681
- t.error(P.message);
1680
+ }).catch(function(v) {
1681
+ t.error(v.message);
1682
1682
  });
1683
1683
  }
1684
1684
  }, l(D, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(D, "examples", ["<%= config.bin %> <%= command.id %>"]), l(D, "flags", {
1685
1685
  ...A,
1686
1686
  ...j,
1687
1687
  ...U,
1688
- ...He,
1689
- ...Pe,
1688
+ ...we,
1690
1689
  ...ke,
1691
1690
  ...Se,
1691
+ ...$e,
1692
1692
  ...B,
1693
1693
  ...G,
1694
1694
  ...le,
1695
1695
  ...oe,
1696
1696
  ...de,
1697
- ...pe,
1697
+ ...Pe,
1698
1698
  ...ve,
1699
1699
  ...J
1700
1700
  }), D);
@@ -1737,7 +1737,7 @@ l(V, "description", "Run Platforma Backend service as docker container on curren
1737
1737
  ...be,
1738
1738
  ...J,
1739
1739
  ...B,
1740
- ...we,
1740
+ ...pe,
1741
1741
  ...G,
1742
1742
  ...le,
1743
1743
  ...oe,
@@ -1745,7 +1745,7 @@ l(V, "description", "Run Platforma Backend service as docker container on curren
1745
1745
  }), l(V, "args", {
1746
1746
  name: Q.string({ required: !0 })
1747
1747
  });
1748
- let Ue = V;
1748
+ let Ge = V;
1749
1749
  var R;
1750
1750
  let mt = (R = class extends L {
1751
1751
  async run() {
@@ -1786,23 +1786,23 @@ let mt = (R = class extends L {
1786
1786
  r.info(`Instance '${s}' was created. To start it run 'up' command`);
1787
1787
  return;
1788
1788
  }
1789
- $e(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(P) {
1790
- r.error(P.message);
1789
+ Le(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v) {
1790
+ r.error(v.message);
1791
1791
  });
1792
1792
  }
1793
1793
  }, l(R, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(R, "examples", ["<%= config.bin %> <%= command.id %>"]), l(R, "flags", {
1794
1794
  ...A,
1795
1795
  ...j,
1796
1796
  ...U,
1797
- ...Pe,
1798
1797
  ...ke,
1799
1798
  ...Se,
1799
+ ...$e,
1800
1800
  ...B,
1801
1801
  ...G,
1802
1802
  ...le,
1803
1803
  ...oe,
1804
1804
  ...de,
1805
- ...pe,
1805
+ ...Pe,
1806
1806
  ...ve,
1807
1807
  ...J
1808
1808
  }), l(R, "args", {
@@ -1833,6 +1833,8 @@ const K = class K extends L {
1833
1833
  monitoringPort: e["monitoring-port"],
1834
1834
  debugAddr: e["debug-listen"],
1835
1835
  debugPort: e["debug-port"],
1836
+ s3Port: e["s3-port"],
1837
+ s3ConsolePort: e["s3-console-port"],
1836
1838
  presignHost: h
1837
1839
  }), r.info(`Instance '${s}' was created. To start it run 'up' command`), e["minio-presign-host"] && r.info(" NOTE: make sure you have 'minio' host in your hosts file as 127.0.0.1 address");
1838
1840
  }
@@ -1840,18 +1842,19 @@ const K = class K extends L {
1840
1842
  l(K, "description", "Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"), l(K, "examples", ["<%= config.bin %> <%= command.id %>"]), l(K, "flags", {
1841
1843
  ...A,
1842
1844
  ...U,
1845
+ ...we,
1843
1846
  ...ye,
1844
1847
  ...j,
1845
1848
  ...be,
1846
1849
  ...J,
1847
1850
  ...B,
1848
- ...we,
1851
+ ...pe,
1849
1852
  ...G,
1850
1853
  ...yr
1851
1854
  }), l(K, "args", {
1852
1855
  name: Q.string({ required: !0 })
1853
1856
  });
1854
- let Ge = K;
1857
+ let Je = K;
1855
1858
  const X = class X extends L {
1856
1859
  async run() {
1857
1860
  const { flags: e, args: t } = await this.parse(X), r = I(e["log-level"]), n = new O(r);
@@ -1893,48 +1896,48 @@ const X = class X extends L {
1893
1896
  r.info(`Instance '${s}' was created. To start it run 'up' command`);
1894
1897
  return;
1895
1898
  }
1896
- $e(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(P) {
1897
- r.error(P.message);
1899
+ Le(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v) {
1900
+ r.error(v.message);
1898
1901
  });
1899
1902
  }
1900
1903
  };
1901
1904
  l(X, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(X, "examples", ["<%= config.bin %> <%= command.id %>"]), l(X, "flags", {
1902
1905
  ...A,
1903
1906
  ...j,
1904
- ...He,
1907
+ ...we,
1905
1908
  ...U,
1906
- ...Pe,
1907
1909
  ...ke,
1908
1910
  ...Se,
1911
+ ...$e,
1909
1912
  ...B,
1910
1913
  ...G,
1911
1914
  ...le,
1912
1915
  ...oe,
1913
1916
  ...de,
1914
- ...pe,
1917
+ ...Pe,
1915
1918
  ...ve,
1916
1919
  ...J
1917
1920
  }), l(X, "args", {
1918
1921
  name: Q.string({ required: !0 })
1919
1922
  });
1920
- let Je = X;
1923
+ let He = X;
1921
1924
  const Rt = {
1922
- "create-block": Te,
1923
- reset: De,
1924
- start: Ne,
1925
- stop: _e,
1925
+ "create-block": Fe,
1926
+ reset: Ne,
1927
+ start: _e,
1928
+ stop: Ce,
1926
1929
  "start:docker": dt,
1927
1930
  "start:local": gt,
1928
- "svc:delete": Ce,
1929
- "svc:down": Me,
1930
- "svc:list": je,
1931
- "svc:up": Be,
1931
+ "svc:delete": Me,
1932
+ "svc:down": je,
1933
+ "svc:list": Be,
1934
+ "svc:up": Ue,
1932
1935
  "start:docker:s3": ut,
1933
1936
  "start:local:s3": ft,
1934
- "svc:create:docker": Ue,
1937
+ "svc:create:docker": Ge,
1935
1938
  "svc:create:local": mt,
1936
- "svc:create:docker:s3": Ge,
1937
- "svc:create:local:s3": Je
1939
+ "svc:create:docker:s3": Je,
1940
+ "svc:create:local:s3": He
1938
1941
  };
1939
1942
  export {
1940
1943
  Rt as COMMANDS