@platforma-sdk/bootstrap 2.9.0 → 2.9.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
@@ -1,6 +1,6 @@
1
1
  var cr = Object.defineProperty;
2
2
  var lr = (a, e, r) => e in a ? cr(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
3
- var y = (a, e, r) => lr(a, typeof e != "symbol" ? e + "" : e, r);
3
+ var P = (a, e, r) => lr(a, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { Flags as h, Command as F } from "@oclif/core";
5
5
  import _ from "node:os";
6
6
  import o, { createWriteStream as or } from "node:fs";
@@ -88,6 +88,10 @@ const D = {
88
88
  storage: h.string({
89
89
  description: "specify path on host to be used as storage for all Platforma Backend data"
90
90
  })
91
+ }, br = {
92
+ "minio-presign-host": h.boolean({
93
+ description: "use 'minio' host instead of 'localhost' in presign URLs"
94
+ })
91
95
  }, ze = {
92
96
  mount: h.string({
93
97
  multiple: !0,
@@ -141,29 +145,29 @@ const Pe = {
141
145
  s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
142
146
  s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
143
147
  })
144
- }, br = {
148
+ }, vr = {
145
149
  "auth-enabled": h.boolean({
146
150
  description: "enable authorization"
147
151
  })
148
- }, vr = {
152
+ }, wr = {
149
153
  "auth-htpasswd-file": h.file({
150
154
  description: "path to .htpasswd file with Platforma users (static user DB auth source)"
151
155
  })
152
- }, wr = {
156
+ }, kr = {
153
157
  "auth-ldap-server": h.string({
154
158
  description: "address of LDAP server to use for auth in Platforma (auth source)"
155
159
  })
156
- }, kr = {
160
+ }, Sr = {
157
161
  "auth-ldap-default-dn": h.string({
158
162
  description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"
159
163
  })
160
164
  }, ie = {
161
- ...br,
162
165
  ...vr,
163
166
  ...wr,
164
- ...kr
167
+ ...kr,
168
+ ...Sr
165
169
  };
166
- function Sr(a) {
170
+ function pr(a) {
167
171
  return C.question(`${a} [y/N] `).toLowerCase() === "y";
168
172
  }
169
173
  function q(a) {
@@ -191,16 +195,16 @@ function N(a = "debug") {
191
195
  ]
192
196
  });
193
197
  }
194
- function pr(a) {
198
+ function Ar(a) {
195
199
  return ur(Math.ceil(a / 2)).toString("hex").slice(0, a);
196
200
  }
197
- function Ar(a) {
201
+ function Rr(a) {
198
202
  return a.startsWith("~") ? g.join(_.homedir(), a.slice(1)) : a;
199
203
  }
200
204
  function X(a, e) {
201
205
  o.existsSync(a) || (o.mkdirSync(a, { recursive: !0 }), e != null && e.mode && o.chmodSync(a, e.mode));
202
206
  }
203
- function Rr(a) {
207
+ function Lr(a) {
204
208
  try {
205
209
  if (_.platform() !== "win32")
206
210
  return je(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
@@ -211,17 +215,17 @@ function Rr(a) {
211
215
  return "";
212
216
  }
213
217
  }
214
- const ce = ["Python"], Ze = ["Tengo", "Python"], Lr = T.union([T.literal("Tengo"), T.literal("Python")]), $r = T.object({
218
+ const ce = ["Python"], Ze = ["Tengo", "Python"], $r = T.union([T.literal("Tengo"), T.literal("Python")]), _r = T.object({
215
219
  npmOrgName: T.string().min(1),
216
220
  orgName: T.string().min(1),
217
221
  blockName: T.string().min(1),
218
- softwarePlatforms: T.array(Lr).refine((a) => new Set(a).size === a.length, {
222
+ softwarePlatforms: T.array($r).refine((a) => new Set(a).size === a.length, {
219
223
  message: "Must be an array of unique software platforms"
220
224
  })
221
225
  });
222
- async function _r(a) {
223
- const { npmOrgName: e, orgName: r, blockName: t, softwarePlatforms: s } = Or(), i = g.join(process.cwd(), t);
224
- a.info("Downloading boilerplate code..."), await Tr(
226
+ async function Or(a) {
227
+ const { npmOrgName: e, orgName: r, blockName: t, softwarePlatforms: s } = Tr(), i = g.join(process.cwd(), t);
228
+ a.info("Downloading boilerplate code..."), await Er(
225
229
  // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',
226
230
  // 'platforma-block-boilerplate-software_platforms',
227
231
  "https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip",
@@ -231,8 +235,8 @@ async function _r(a) {
231
235
  const n = Ze.filter((l) => s.indexOf(l) < 0), c = ce.length == n.length;
232
236
  a.info(`Keep platforms '${s}', remove: '${n}'. Will remove all platforms? ${c}`);
233
237
  for (const l of n)
234
- await Er(i, l);
235
- c && await Fr(i), a.info("Replace everything in the template with provided options..."), Dr(i, [
238
+ await Fr(i, l);
239
+ c && await Dr(i), a.info("Replace everything in the template with provided options..."), Nr(i, [
236
240
  // '@' literal ensures only npm org name will be renamed,
237
241
  // as public registry for software also is called platforma-open, but without '@'.
238
242
  // Also, don't rename an organization for runenv-python-3 package.
@@ -241,7 +245,7 @@ async function _r(a) {
241
245
  { from: /block-boilerplate/g, to: t }
242
246
  ]);
243
247
  }
244
- function Or() {
248
+ function Tr() {
245
249
  let a = C.question(
246
250
  'Write an organization name for npm. Default is "platforma-open": '
247
251
  );
@@ -254,15 +258,15 @@ function Or() {
254
258
  if (i < 0) break;
255
259
  s.push(ce[i]);
256
260
  }
257
- return s = Array.from(new Set(s)).sort(), $r.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: s });
261
+ return s = Array.from(new Set(s)).sort(), _r.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: s });
258
262
  }
259
- async function Tr(a, e, r) {
263
+ async function Er(a, e, r) {
260
264
  const s = await (await fetch(a)).blob(), i = await E.mkdtemp(g.join(_.tmpdir(), "create-repo")), n = g.join(i, "packed-repo.zip"), c = fr.toWeb(or(n));
261
265
  await s.stream().pipeTo(c);
262
266
  const l = g.join(i, "unpacked-repo");
263
267
  await E.mkdir(l), await mr(n, l), await E.cp(g.join(l, e), r, { recursive: !0 });
264
268
  }
265
- async function Er(a, e) {
269
+ async function Fr(a, e) {
266
270
  const r = e.toLowerCase();
267
271
  await B(
268
272
  g.join(a, "ui", "src", "pages", "MainPage.vue"),
@@ -287,7 +291,7 @@ async function Er(a, e) {
287
291
  }
288
292
  );
289
293
  }
290
- async function Fr(a) {
294
+ async function Dr(a) {
291
295
  await E.rm(g.join(a, "software"), { recursive: !0 }), await ve(
292
296
  g.join(a, "workflow", "package.json"),
293
297
  (e) => {
@@ -299,13 +303,13 @@ async function Fr(a) {
299
303
  /.*- software$\n/gm
300
304
  );
301
305
  }
302
- async function Dr(a, e) {
303
- const r = await Nr(a);
306
+ async function Nr(a, e) {
307
+ const r = await Ir(a);
304
308
  for (const { from: t, to: s } of e)
305
309
  for (const i of r)
306
310
  await er(i, t, s);
307
311
  }
308
- async function Nr(a) {
312
+ async function Ir(a) {
309
313
  return (await E.readdir(a, {
310
314
  withFileTypes: !0,
311
315
  recursive: !0
@@ -324,10 +328,10 @@ async function B(a, e) {
324
328
  const G = class G extends F {
325
329
  async run() {
326
330
  const { flags: e } = await this.parse(G), r = N(e["log-level"]);
327
- await _r(r);
331
+ await Or(r);
328
332
  }
329
333
  };
330
- y(G, "description", "Helps to create a new block by downloading a block's template."), y(G, "examples", ["<%= name %>"]), y(G, "flags", {
334
+ P(G, "description", "Helps to create a new block by downloading a block's template."), P(G, "examples", ["<%= name %>"]), P(G, "flags", {
331
335
  ...D
332
336
  });
333
337
  let le = G;
@@ -337,10 +341,10 @@ function rr(...a) {
337
341
  function O(...a) {
338
342
  return rr("assets", ...a);
339
343
  }
340
- function Ir() {
344
+ function xr() {
341
345
  return o.readdirSync(O()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => O(e));
342
346
  }
343
- function xr(...a) {
347
+ function Mr(...a) {
344
348
  return o.readFileSync(rr(...a));
345
349
  }
346
350
  function ne(a) {
@@ -348,15 +352,15 @@ function ne(a) {
348
352
  }
349
353
  const I = class I {
350
354
  constructor(e) {
351
- y(this, "state", {
355
+ P(this, "state", {
352
356
  lastRun: void 0,
353
357
  isActive: !1
354
358
  });
355
- y(this, "filePath");
356
- y(this, "dirPath");
359
+ P(this, "filePath");
360
+ P(this, "dirPath");
357
361
  e = e ?? g.resolve(_.homedir(), ".config", "pl-bootstrap");
358
362
  const r = g.join(e, "state.json");
359
- this.dirPath = e, this.filePath = r, o.existsSync(e) || o.mkdirSync(e, { recursive: !0 }), o.existsSync(r) && (this.state = JSON.parse(xr(r).toString()));
363
+ this.dirPath = e, this.filePath = r, o.existsSync(e) || o.mkdirSync(e, { recursive: !0 }), o.existsSync(r) && (this.state = JSON.parse(Mr(r).toString()));
360
364
  }
361
365
  static getInstance() {
362
366
  return I.instance || (I.instance = new I()), I.instance;
@@ -381,7 +385,7 @@ const I = class I {
381
385
  var r, t;
382
386
  if (!((t = (r = this.state.lastRun) == null ? void 0 : r.process) != null && t.pid))
383
387
  return !1;
384
- const e = Rr(this.state.lastRun.process.pid);
388
+ const e = Lr(this.state.lastRun.process.pid);
385
389
  return e === "platforma" || e.endsWith("/platforma") || e.endsWith("\\platforma");
386
390
  }
387
391
  set isActive(e) {
@@ -394,7 +398,7 @@ const I = class I {
394
398
  this.state.lastRun = e, this.writeState();
395
399
  }
396
400
  };
397
- y(I, "instance");
401
+ P(I, "instance");
398
402
  let oe = I;
399
403
  const d = oe.getInstance();
400
404
  function Ue(a, e, r, t) {
@@ -412,7 +416,7 @@ function Ue(a, e, r, t) {
412
416
  }
413
417
  }, tr(a, "docker", e, r);
414
418
  }
415
- function Mr(a, e, r, t, s) {
419
+ function Cr(a, e, r, t, s) {
416
420
  var n;
417
421
  d.lastRun = {
418
422
  ...d.lastRun,
@@ -426,13 +430,13 @@ function Mr(a, e, r, t, s) {
426
430
  ...s
427
431
  }
428
432
  };
429
- const i = Br(a, e, r, t);
433
+ const i = Gr(a, e, r, t);
430
434
  return d.lastRun.process = {
431
435
  ...d.lastRun.process,
432
436
  pid: i.pid
433
437
  }, i;
434
438
  }
435
- function Cr(a, e) {
439
+ function Br(a, e) {
436
440
  if (!d.lastRun)
437
441
  throw new Error("no previous run info found: this is the first run after package installation");
438
442
  return e = {
@@ -444,7 +448,7 @@ function Cr(a, e) {
444
448
  ...e
445
449
  }, tr(a, d.lastRun.cmd, d.lastRun.args, e);
446
450
  }
447
- function Br(a, e, r, t) {
451
+ function Gr(a, e, r, t) {
448
452
  a.debug(
449
453
  `Running:
450
454
  env: ${JSON.stringify(t.env)}
@@ -485,15 +489,15 @@ function We(a, e, r) {
485
489
  if (n.platform && (c.platform = n.platform), n.envs) {
486
490
  c.environment || (c.environment = []);
487
491
  for (let l = 0; l < ((c == null ? void 0 : c.environment.length) ?? 0); ) {
488
- const f = c.environment[l].split("=")[0];
489
- if (n.envs[f]) {
492
+ const u = c.environment[l].split("=")[0];
493
+ if (n.envs[u]) {
490
494
  const b = c.environment.pop();
491
495
  b && c.environment.length !== l && (c.environment[l] = b);
492
496
  } else
493
497
  l++;
494
498
  }
495
- for (const [l, u] of Object.entries(n.envs))
496
- c.environment.push(`${l}=${u}`);
499
+ for (const [l, f] of Object.entries(n.envs))
500
+ c.environment.push(`${l}=${f}`);
497
501
  }
498
502
  if (n.mounts) {
499
503
  c.volumes || (c.volumes = []);
@@ -503,7 +507,7 @@ function We(a, e, r) {
503
507
  }
504
508
  o.writeFileSync(e, Z.stringify(s));
505
509
  }
506
- function Gr(a) {
510
+ function jr(a) {
507
511
  return {
508
512
  id: a,
509
513
  type: "S3",
@@ -530,7 +534,7 @@ function ar(a) {
530
534
  };
531
535
  }
532
536
  function M(a, e, r) {
533
- a = Ar(a);
537
+ a = Rr(a);
534
538
  const t = new URL(a, `file:${e}`);
535
539
  switch (t.protocol) {
536
540
  case "s3:":
@@ -574,17 +578,17 @@ function M(a, e, r) {
574
578
  throw new Error(`storage protocol '${t.protocol}' is not supported`);
575
579
  }
576
580
  }
577
- function jr(a, e) {
578
- var m, v, k, R, S, P, L, A, p, we, ke, Se, pe, Ae, Re, Le, $e, _e, Oe, Te, Ee, Fe, De, Ne, Ie, xe, Me, Ce, Be, Ge;
581
+ function Ur(a, e) {
582
+ var m, y, L, w, k, R, A, S, p, we, ke, Se, pe, Ae, Re, Le, $e, _e, Oe, Te, Ee, Fe, De, Ne, Ie, xe, Me, Ce, Be, Ge;
579
583
  const r = (e == null ? void 0 : e.localRoot) ?? d.data("local-custom"), t = {
580
584
  level: ((m = e == null ? void 0 : e.log) == null ? void 0 : m.level) ?? "info",
581
- path: ((v = e == null ? void 0 : e.log) == null ? void 0 : v.path) ?? `${r}/logs/platforma.log`
585
+ path: ((y = e == null ? void 0 : e.log) == null ? void 0 : y.path) ?? `${r}/logs/platforma.log`
582
586
  }, s = {
583
- listen: ((k = e == null ? void 0 : e.grpc) == null ? void 0 : k.listen) ?? "localhost:6345",
587
+ listen: ((L = e == null ? void 0 : e.grpc) == null ? void 0 : L.listen) ?? "localhost:6345",
584
588
  tls: {
585
- enable: V((S = (R = e == null ? void 0 : e.grpc) == null ? void 0 : R.tls) == null ? void 0 : S.enable, !1),
586
- clientAuthMode: ((L = (P = e == null ? void 0 : e.grpc) == null ? void 0 : P.tls) == null ? void 0 : L.clientAuthMode) ?? "NoAuth",
587
- certFile: ((p = (A = e == null ? void 0 : e.grpc) == null ? void 0 : A.tls) == null ? void 0 : p.certFile) ?? `${r}/certs/tls.cert`,
589
+ enable: V((k = (w = e == null ? void 0 : e.grpc) == null ? void 0 : w.tls) == null ? void 0 : k.enable, !1),
590
+ clientAuthMode: ((A = (R = e == null ? void 0 : e.grpc) == null ? void 0 : R.tls) == null ? void 0 : A.clientAuthMode) ?? "NoAuth",
591
+ certFile: ((p = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : p.certFile) ?? `${r}/certs/tls.cert`,
588
592
  keyFile: ((ke = (we = e == null ? void 0 : e.grpc) == null ? void 0 : we.tls) == null ? void 0 : ke.keyFile) ?? `${r}/certs/tls.key`,
589
593
  ...(Se = e == null ? void 0 : e.grpc) == null ? void 0 : Se.tls
590
594
  }
@@ -614,30 +618,30 @@ function jr(a, e) {
614
618
  default:
615
619
  throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
616
620
  }
617
- const u = Je(
621
+ const f = Je(
618
622
  "library",
619
623
  `${r}/storages/library`,
620
624
  "library-bucket",
621
625
  (Ne = e == null ? void 0 : e.storages) == null ? void 0 : Ne.library
622
- ), f = {
626
+ ), u = {
623
627
  enabled: V((Ie = e == null ? void 0 : e.monitoring) == null ? void 0 : Ie.enabled, !0),
624
628
  listen: ((xe = e == null ? void 0 : e.monitoring) == null ? void 0 : xe.listen) ?? "127.0.0.1:9090"
625
629
  }, b = {
626
630
  enabled: V((Me = e == null ? void 0 : e.debug) == null ? void 0 : Me.enabled, !0),
627
631
  listen: ((Ce = e == null ? void 0 : e.debug) == null ? void 0 : Ce.listen) ?? "127.0.0.1:9091"
628
- }, w = {
632
+ }, v = {
629
633
  value: ((Be = e == null ? void 0 : e.license) == null ? void 0 : Be.value) ?? "",
630
634
  file: ((Ge = e == null ? void 0 : e.license) == null ? void 0 : Ge.file) ?? ""
631
635
  };
632
636
  return {
633
637
  localRoot: r,
634
- license: w,
638
+ license: v,
635
639
  log: t,
636
640
  grpc: s,
637
641
  core: i,
638
- monitoring: f,
642
+ monitoring: u,
639
643
  debug: b,
640
- storages: { primary: n, work: c, library: u },
644
+ storages: { primary: n, work: c, library: f },
641
645
  hacks: { libraryDownloadable: !0 }
642
646
  };
643
647
  }
@@ -649,14 +653,14 @@ function Je(a, e, r, t) {
649
653
  s = ar(a), s.rootPath = (t == null ? void 0 : t.rootPath) ?? e;
650
654
  break;
651
655
  case "S3":
652
- s = Gr(a), s.endpoint = (t == null ? void 0 : t.endpoint) ?? "http://localhost:9000", s.presignEndpoint = (t == null ? void 0 : t.presignEndpoint) ?? "http://localhost:9000", s.bucketName = (t == null ? void 0 : t.bucketName) ?? r, s.createBucket = V(t == null ? void 0 : t.createBucket, !0), s.forcePathStyle = V(t == null ? void 0 : t.forcePathStyle, !0), s.key = (t == null ? void 0 : t.key) ?? "", s.secret = (t == null ? void 0 : t.secret) ?? "", s.keyPrefix = (t == null ? void 0 : t.keyPrefix) ?? "", s.accessPrefixes = (t == null ? void 0 : t.accessPrefixes) ?? [""], s.uploadKeyPrefix = (t == null ? void 0 : t.uploadKeyPrefix) ?? "";
656
+ s = jr(a), s.endpoint = (t == null ? void 0 : t.endpoint) ?? "http://localhost:9000", s.presignEndpoint = (t == null ? void 0 : t.presignEndpoint) ?? "http://localhost:9000", s.bucketName = (t == null ? void 0 : t.bucketName) ?? r, s.createBucket = V(t == null ? void 0 : t.createBucket, !0), s.forcePathStyle = V(t == null ? void 0 : t.forcePathStyle, !0), s.key = (t == null ? void 0 : t.key) ?? "", s.secret = (t == null ? void 0 : t.secret) ?? "", s.keyPrefix = (t == null ? void 0 : t.keyPrefix) ?? "", s.accessPrefixes = (t == null ? void 0 : t.accessPrefixes) ?? [""], s.uploadKeyPrefix = (t == null ? void 0 : t.uploadKeyPrefix) ?? "";
653
657
  break;
654
658
  default:
655
659
  throw q(), new Error("unknown storage type");
656
660
  }
657
661
  return s;
658
662
  }
659
- function Ur(a) {
663
+ function Wr(a) {
660
664
  const e = a.monitoring.enabled ? "" : " disabled", r = a.debug.enabled ? "" : " disabled", t = a.hacks.libraryDownloadable ? "true" : "false";
661
665
  var s = a.license.value;
662
666
  return a.license.file != "" && (s = o.readFileSync(a.license.file).toString().trimEnd()), `
@@ -738,8 +742,8 @@ controllers:
738
742
  function V(a, e) {
739
743
  return a === void 0 ? e : a;
740
744
  }
741
- const Wr = ["linux", "macos", "windows"];
742
- function Jr(a) {
745
+ const Jr = ["linux", "macos", "windows"];
746
+ function Hr(a) {
743
747
  const e = _.platform();
744
748
  switch (e) {
745
749
  case "darwin":
@@ -750,11 +754,11 @@ function Jr(a) {
750
754
  return "windows";
751
755
  default:
752
756
  throw new Error(
753
- `operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(Wr)
757
+ `operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(Jr)
754
758
  );
755
759
  }
756
760
  }
757
- const Hr = ["amd64", "arm64"];
761
+ const Yr = ["amd64", "arm64"];
758
762
  function sr(a) {
759
763
  const e = _.arch();
760
764
  switch (e) {
@@ -764,52 +768,52 @@ function sr(a) {
764
768
  return "amd64";
765
769
  default:
766
770
  throw new Error(
767
- `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Hr)
771
+ `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Yr)
768
772
  );
769
773
  }
770
774
  }
771
- function Yr(a, e) {
772
- const r = (e == null ? void 0 : e.version) ?? ee(), t = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, s = `pl-${r}-${sr()}.tgz`, i = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${Jr()}/${s}`, n = (e == null ? void 0 : e.saveTo) ?? d.binaries(s);
775
+ function zr(a, e) {
776
+ const r = (e == null ? void 0 : e.version) ?? ee(), t = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, s = `pl-${r}-${sr()}.tgz`, i = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${Hr()}/${s}`, n = (e == null ? void 0 : e.saveTo) ?? d.binaries(s);
773
777
  if (o.existsSync(n))
774
778
  return a.info(`Platforma Backend archive download skipped: '${n}' already exists`), Promise.resolve(n);
775
779
  o.mkdirSync(g.dirname(n), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
776
780
  URL: ${i}
777
781
  Save to: ${n}`);
778
782
  const c = hr.get(i);
779
- return new Promise((l, u) => {
780
- c.on("response", (f) => {
781
- if (!f.statusCode) {
782
- const v = new Error("failed to download archive: no HTTP status code in response from server");
783
- c.destroy(), u(v);
783
+ return new Promise((l, f) => {
784
+ c.on("response", (u) => {
785
+ if (!u.statusCode) {
786
+ const y = new Error("failed to download archive: no HTTP status code in response from server");
787
+ c.destroy(), f(y);
784
788
  return;
785
789
  }
786
- if (f.statusCode !== 200) {
787
- const v = new Error(`failed to download archive: ${f.statusCode} ${f.statusMessage}`);
788
- c.destroy(), u(v);
790
+ if (u.statusCode !== 200) {
791
+ const y = new Error(`failed to download archive: ${u.statusCode} ${u.statusMessage}`);
792
+ c.destroy(), f(y);
789
793
  return;
790
794
  }
791
- const b = parseInt(f.headers["content-length"] || "0", 10);
792
- let w = 0;
795
+ const b = parseInt(u.headers["content-length"] || "0", 10);
796
+ let v = 0;
793
797
  const m = o.createWriteStream(n);
794
- f.pipe(m), f.on("data", (v) => {
795
- w += v.length;
796
- const k = w / b * 100;
797
- t && process.stdout.write(` downloading: ${k.toFixed(2)}%\r`);
798
- }), f.on("error", (v) => {
799
- o.unlinkSync(n), a.error(`Failed to download Platforma Binary: ${v.message}`), c.destroy(), u(v);
798
+ u.pipe(m), u.on("data", (y) => {
799
+ v += y.length;
800
+ const L = v / b * 100;
801
+ t && process.stdout.write(` downloading: ${L.toFixed(2)}%\r`);
802
+ }), u.on("error", (y) => {
803
+ o.unlinkSync(n), a.error(`Failed to download Platforma Binary: ${y.message}`), c.destroy(), f(y);
800
804
  }), m.on("finish", () => {
801
805
  m.close(), a.info(" ... download done."), c.destroy(), l(n);
802
806
  });
803
807
  });
804
808
  });
805
809
  }
806
- function zr(a, e) {
810
+ function Kr(a, e) {
807
811
  a.debug("extracting archive...");
808
812
  const r = (e == null ? void 0 : e.version) ?? ee();
809
813
  a.debug(` version: '${r}'`);
810
814
  const t = `${nr({ version: r })}.tgz`, s = (e == null ? void 0 : e.archivePath) ?? d.binaries(t);
811
815
  a.debug(` archive path: '${s}'`);
812
- const i = (e == null ? void 0 : e.extractTo) ?? qr(s);
816
+ const i = (e == null ? void 0 : e.extractTo) ?? Vr(s);
813
817
  if (a.debug(` target dir: '${i}'`), o.existsSync(i))
814
818
  return a.info(`Platforma Backend binaries unpack skipped: '${i}' exists`), i;
815
819
  if (!o.existsSync(s)) {
@@ -826,15 +830,15 @@ function zr(a, e) {
826
830
  }), a.info(" ... unpack done."), i;
827
831
  }
828
832
  function ir(a, e) {
829
- return Yr(a, e).then((r) => zr(a, { archivePath: r }));
833
+ return zr(a, e).then((r) => Kr(a, { archivePath: r }));
830
834
  }
831
835
  function nr(a) {
832
836
  return `pl-${(a == null ? void 0 : a.version) ?? ee()}-${sr()}`;
833
837
  }
834
- function Kr(a, ...e) {
838
+ function qr(a, ...e) {
835
839
  return d.binaries(nr({ version: a }), ...e);
836
840
  }
837
- function qr(a) {
841
+ function Vr(a) {
838
842
  const e = a.lastIndexOf(".");
839
843
  return e === -1 ? a : a.slice(0, e);
840
844
  }
@@ -843,40 +847,40 @@ class x {
843
847
  this.logger = e;
844
848
  }
845
849
  startLast() {
846
- const e = Cr(this.logger, { stdio: "inherit" });
850
+ const e = Br(this.logger, { stdio: "inherit" });
847
851
  z(e, "failed to bring back Platforma Backend in the last started configuration");
848
852
  }
849
853
  startLocal(e) {
850
- var l, u, f, b, w, m, v, k, R, S;
851
- const r = (e == null ? void 0 : e.binaryPath) ?? Kr(e == null ? void 0 : e.version, "binaries", "platforma");
854
+ var l, f, u, b, v, m, y, L, w, k;
855
+ const r = (e == null ? void 0 : e.binaryPath) ?? qr(e == null ? void 0 : e.version, "binaries", "platforma");
852
856
  let t = e == null ? void 0 : e.configPath;
853
857
  const s = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : d.path());
854
858
  e != null && e.primaryURL && (e.configOptions = {
855
859
  ...e.configOptions,
856
860
  storages: {
857
861
  ...(l = e.configOptions) == null ? void 0 : l.storages,
858
- primary: M(e.primaryURL, s, (f = (u = e.configOptions) == null ? void 0 : u.storages) == null ? void 0 : f.primary)
862
+ primary: M(e.primaryURL, s, (u = (f = e.configOptions) == null ? void 0 : f.storages) == null ? void 0 : u.primary)
859
863
  }
860
864
  }), e != null && e.libraryURL && (e.configOptions = {
861
865
  ...e.configOptions,
862
866
  storages: {
863
867
  ...(b = e.configOptions) == null ? void 0 : b.storages,
864
- library: M(e.libraryURL, s, (m = (w = e.configOptions) == null ? void 0 : w.storages) == null ? void 0 : m.library)
868
+ library: M(e.libraryURL, s, (m = (v = e.configOptions) == null ? void 0 : v.storages) == null ? void 0 : m.library)
865
869
  }
866
870
  });
867
- const i = jr(this.getLastJwt(), e == null ? void 0 : e.configOptions);
868
- this.logger.debug(" checking license..."), this.checkLicense((k = (v = e == null ? void 0 : e.configOptions) == null ? void 0 : v.license) == null ? void 0 : k.value, (S = (R = e == null ? void 0 : e.configOptions) == null ? void 0 : R.license) == null ? void 0 : S.file);
871
+ const i = Ur(this.getLastJwt(), e == null ? void 0 : e.configOptions);
872
+ this.logger.debug(" checking license..."), this.checkLicense((L = (y = e == null ? void 0 : e.configOptions) == null ? void 0 : y.license) == null ? void 0 : L.value, (k = (w = e == null ? void 0 : e.configOptions) == null ? void 0 : w.license) == null ? void 0 : k.file);
869
873
  const n = [
870
874
  `${i.localRoot}/packages`,
871
875
  `${i.localRoot}/packages-local`,
872
876
  `${i.localRoot}/blocks-local`
873
877
  ];
874
878
  i.storages.primary.type === "FS" && n.push(i.storages.primary.rootPath), i.storages.library.type === "FS" && (n.push(i.storages.library.rootPath), i.hacks.libraryDownloadable = !1), i.storages.work.type === "FS" && n.push(i.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
875
- for (const P of n)
876
- o.existsSync(P) || (this.logger.debug(` '${P}'`), o.mkdirSync(P, { recursive: !0 }));
877
- for (const P of i.core.auth.drivers)
878
- P.driver === "htpasswd" && (o.existsSync(P.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${P.path}...`), o.copyFileSync(O("users.htpasswd"), P.path)));
879
- t || (t = g.join(i.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${t}'...`), o.writeFileSync(t, Ur(i)));
879
+ for (const R of n)
880
+ o.existsSync(R) || (this.logger.debug(` '${R}'`), o.mkdirSync(R, { recursive: !0 }));
881
+ for (const R of i.core.auth.drivers)
882
+ R.driver === "htpasswd" && (o.existsSync(R.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${R.path}...`), o.copyFileSync(O("users.htpasswd"), R.path)));
883
+ t || (t = g.join(i.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${t}'...`), o.writeFileSync(t, Wr(i)));
880
884
  const c = this.renderRunInfo({
881
885
  configPath: t,
882
886
  dbPath: i.core.db.path,
@@ -887,7 +891,7 @@ class x {
887
891
  library: i.storages.library
888
892
  });
889
893
  return this.logger.info(`Starting platforma:
890
- ${c}`), Mr(
894
+ ${c}`), Cr(
891
895
  this.logger,
892
896
  r,
893
897
  ["-config", t],
@@ -924,7 +928,7 @@ ${c}`), Mr(
924
928
  X(i, { mode: "0775" });
925
929
  const n = d.data("stub");
926
930
  X(n);
927
- const c = (e == null ? void 0 : e.minioPort) ?? 9e3, l = (e == null ? void 0 : e.minioConsolePort) ?? 9001, u = {
931
+ const c = (e == null ? void 0 : e.minioPort) ?? 9e3, l = (e == null ? void 0 : e.minioConsolePort) ?? 9001, f = {
928
932
  MINIO_IMAGE: s,
929
933
  MINIO_STORAGE: g.resolve(i),
930
934
  MINIO_PORT: c.toString(),
@@ -937,18 +941,18 @@ ${c}`), Mr(
937
941
  PL_IMAGE: "scratch"
938
942
  };
939
943
  this.logger.debug(" spawning child 'docker' process...");
940
- const f = K(
944
+ const u = K(
941
945
  "docker",
942
946
  ["compose", `--file=${r}`, "up", "--detach", "--remove-orphans", "--pull=missing", "minio"],
943
947
  {
944
948
  env: {
945
949
  ...process.env,
946
- ...u
950
+ ...f
947
951
  },
948
952
  stdio: "inherit"
949
953
  }
950
954
  );
951
- z(f, "failed to start MinIO service in docker");
955
+ z(u, "failed to start MinIO service in docker");
952
956
  }
953
957
  buildPlatforma(e) {
954
958
  const r = g.resolve(e.repoRoot, "cmd", "platforma"), t = e.binPath ?? g.join(_.tmpdir(), "platforma-local-build");
@@ -962,64 +966,64 @@ ${c}`), Mr(
962
966
  startDockerS3(e, r) {
963
967
  const t = O("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? ne(r == null ? void 0 : r.version);
964
968
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
965
- const i = (...P) => g.join(e, ...P), n = (P) => {
966
- const L = i(P);
967
- return X(L, { mode: "0775" }), L;
969
+ const i = (...A) => g.join(e, ...A), n = (A) => {
970
+ const S = i(A);
971
+ return X(S, { mode: "0775" }), S;
968
972
  }, c = i("logs", "platforma.log");
969
973
  o.existsSync(c) || (o.mkdirSync(g.dirname(c), { recursive: !0 }), o.writeFileSync(c, ""));
970
- const l = M("s3e://testuser:testpassword@minio:9000/main-bucket");
971
- if (l.type !== "S3")
974
+ const l = (r == null ? void 0 : r.presignHost) ?? "localhost", f = M("s3e://testuser:testpassword@minio:9000/main-bucket");
975
+ if (f.type !== "S3")
972
976
  throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
973
- l.presignEndpoint = "http://localhost:9000";
977
+ f.presignEndpoint = `http://${l}:9000`;
974
978
  const u = M("s3e://testuser:testpassword@minio:9000/library-bucket");
975
979
  if (u.type !== "S3")
976
980
  throw new Error(`${u.type} storage type is not supported for library storage`);
977
- u.presignEndpoint = "http://localhost:9000";
978
- const f = n("db"), b = n("work"), w = i("users.htpasswd");
979
- o.existsSync(w) || o.copyFileSync(O("users.htpasswd"), w);
980
- const m = i("compose.yaml");
981
- o.existsSync(m) && this.logger.info(`replacing docker compose file ${m}`);
982
- const v = [];
983
- for (const P of (r == null ? void 0 : r.customMounts) ?? [])
984
- v.push({
985
- hostPath: P.hostPath,
986
- containerPath: P.containerPath ?? P.hostPath
981
+ u.presignEndpoint = `http://${l}:9000`;
982
+ const b = n("db"), v = n("work"), m = i("users.htpasswd");
983
+ o.existsSync(m) || o.copyFileSync(O("users.htpasswd"), m);
984
+ const y = i("compose.yaml");
985
+ o.existsSync(y) && this.logger.info(`replacing docker compose file ${y}`);
986
+ const L = [];
987
+ for (const A of (r == null ? void 0 : r.customMounts) ?? [])
988
+ L.push({
989
+ hostPath: A.hostPath,
990
+ containerPath: A.containerPath ?? A.hostPath
987
991
  });
988
- We(t, m, /* @__PURE__ */ new Map([
992
+ We(t, y, /* @__PURE__ */ new Map([
989
993
  ["minio", {}],
990
994
  ["backend", {
991
995
  platform: r == null ? void 0 : r.platformOverride,
992
- mounts: v
996
+ mounts: L
993
997
  }]
994
998
  ]));
995
- const k = {
999
+ const w = {
996
1000
  MINIO_IMAGE: "quay.io/minio/minio",
997
1001
  MINIO_STORAGE: n("minio"),
998
1002
  PL_IMAGE: s,
999
- PL_AUTH_HTPASSWD_PATH: w,
1003
+ PL_AUTH_HTPASSWD_PATH: m,
1000
1004
  PL_LICENSE: r == null ? void 0 : r.license,
1001
1005
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
1002
1006
  PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
1003
1007
  PL_LOG_DIR: g.dirname(c),
1004
1008
  PL_LOG_ROTATION_ENABLED: "true",
1005
- PL_DATA_DB_ROOT: f,
1009
+ PL_DATA_DB_ROOT: b,
1006
1010
  PL_DATA_PRIMARY_ROOT: n("primary"),
1007
1011
  PL_DATA_LIBRARY_ROOT: n("library"),
1008
- PL_DATA_WORKDIR_ROOT: b,
1012
+ PL_DATA_WORKDIR_ROOT: v,
1009
1013
  PL_DATA_PACKAGE_ROOT: n("packages"),
1010
- ...this.configureDockerStorage("primary", l),
1014
+ ...this.configureDockerStorage("primary", f),
1011
1015
  ...this.configureDockerStorage("library", u)
1012
1016
  };
1013
- 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.auth && (r.auth.enabled && (k.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1014
- for (const P of r.auth.drivers)
1015
- P.driver === "htpasswd" && (k.PL_AUTH_HTPASSWD_PATH = g.resolve(P.path), P.path = "/etc/platforma/users.htpasswd");
1016
- k.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1017
+ if (r != null && r.grpcAddr && (w.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (w.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (w.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (w.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (w.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (w.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (w.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1018
+ for (const A of r.auth.drivers)
1019
+ A.driver === "htpasswd" && (w.PL_AUTH_HTPASSWD_PATH = g.resolve(A.path), A.path = "/etc/platforma/users.htpasswd");
1020
+ w.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1017
1021
  }
1018
- const R = Ue(
1022
+ const k = Ue(
1019
1023
  this.logger,
1020
1024
  [
1021
1025
  "compose",
1022
- `--file=${m}`,
1026
+ `--file=${y}`,
1023
1027
  "up",
1024
1028
  "--detach",
1025
1029
  "--remove-orphans",
@@ -1028,101 +1032,101 @@ ${c}`), Mr(
1028
1032
  "backend"
1029
1033
  ],
1030
1034
  {
1031
- env: k,
1035
+ env: w,
1032
1036
  stdio: "inherit"
1033
1037
  },
1034
1038
  {
1035
1039
  plImage: s,
1036
- composePath: m
1040
+ composePath: y
1037
1041
  }
1038
1042
  );
1039
- z(R, "failed to start Platforma Backend in Docker"), d.isActive = !0;
1040
- const S = this.renderRunInfo({
1043
+ z(k, "failed to start Platforma Backend in Docker"), d.isActive = !0;
1044
+ const R = this.renderRunInfo({
1041
1045
  apiPort: r == null ? void 0 : r.grpcPort,
1042
1046
  apiAddr: r == null ? void 0 : r.grpcAddr,
1043
1047
  logPath: c,
1044
- primary: l,
1045
- work: { type: "FS", rootPath: b },
1048
+ primary: f,
1049
+ work: { type: "FS", rootPath: v },
1046
1050
  library: u,
1047
- dbPath: f
1051
+ dbPath: b
1048
1052
  });
1049
1053
  this.logger.info(`Started platforma:
1050
- ${S}`);
1054
+ ${R}`);
1051
1055
  }
1052
1056
  startDocker(e, r) {
1053
1057
  const t = O("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? ne(r == null ? void 0 : r.version);
1054
1058
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
1055
- const i = (...A) => g.join(e, ...A), n = (A) => {
1056
- const p = i(A);
1059
+ const i = (...S) => g.join(e, ...S), n = (S) => {
1060
+ const p = i(S);
1057
1061
  return X(p, { mode: "0775" }), p;
1058
1062
  }, c = i("logs", "platforma.log");
1059
1063
  o.existsSync(c) || (o.mkdirSync(g.dirname(c), { recursive: !0 }), o.writeFileSync(c, ""));
1060
- const l = n("db"), u = n("primary"), f = n("library"), b = n("work"), w = i("users.htpasswd");
1061
- o.existsSync(w) || o.copyFileSync(O("users.htpasswd"), w);
1064
+ const l = n("db"), f = n("primary"), u = n("library"), b = n("work"), v = i("users.htpasswd");
1065
+ o.existsSync(v) || o.copyFileSync(O("users.htpasswd"), v);
1062
1066
  const m = i("compose.yaml");
1063
1067
  o.existsSync(m) && this.logger.info(`replacing docker compose file ${m}`);
1064
- const v = [];
1065
- for (const A of (r == null ? void 0 : r.customMounts) ?? [])
1066
- v.push({
1067
- hostPath: A.hostPath,
1068
- containerPath: A.containerPath ?? A.hostPath
1068
+ const y = [];
1069
+ for (const S of (r == null ? void 0 : r.customMounts) ?? [])
1070
+ y.push({
1071
+ hostPath: S.hostPath,
1072
+ containerPath: S.containerPath ?? S.hostPath
1069
1073
  });
1070
1074
  this.logger.debug(`Rendering docker compose file '${m}' using '${t}' as base template`), We(t, m, /* @__PURE__ */ new Map([
1071
1075
  ["backend", {
1072
1076
  platform: r == null ? void 0 : r.platformOverride,
1073
- mounts: v
1077
+ mounts: y
1074
1078
  }]
1075
1079
  ]));
1076
- const k = M((r == null ? void 0 : r.primaryStorageURL) ?? `file:${u}`, "."), R = M((r == null ? void 0 : r.libraryStorageURL) ?? `file:${f}`, "."), S = {
1080
+ const L = M((r == null ? void 0 : r.primaryStorageURL) ?? `file:${f}`, "."), w = M((r == null ? void 0 : r.libraryStorageURL) ?? `file:${u}`, "."), k = {
1077
1081
  MINIO_IMAGE: "quay.io/minio/minio",
1078
1082
  MINIO_STORAGE: n("minio"),
1079
1083
  PL_IMAGE: s,
1080
- PL_AUTH_HTPASSWD_PATH: w,
1084
+ PL_AUTH_HTPASSWD_PATH: v,
1081
1085
  PL_LICENSE: r == null ? void 0 : r.license,
1082
1086
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
1083
1087
  PL_LOG_LEVEL: "info",
1084
1088
  PL_LOG_DIR: g.dirname(c),
1085
1089
  PL_LOG_ROTATION_ENABLED: "true",
1086
1090
  PL_DATA_DB_ROOT: l,
1087
- PL_DATA_PRIMARY_ROOT: u,
1088
- PL_DATA_LIBRARY_ROOT: f,
1091
+ PL_DATA_PRIMARY_ROOT: f,
1092
+ PL_DATA_LIBRARY_ROOT: u,
1089
1093
  PL_DATA_WORKDIR_ROOT: b,
1090
1094
  PL_DATA_PACKAGE_ROOT: n("packages"),
1091
- ...this.configureDockerStorage("primary", k),
1092
- ...this.configureDockerStorage("library", R)
1095
+ ...this.configureDockerStorage("primary", L),
1096
+ ...this.configureDockerStorage("library", w)
1093
1097
  };
1094
- if (r != null && r.grpcAddr && (S.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (S.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (S.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (S.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (S.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (S.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (S.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1095
- for (const A of r.auth.drivers)
1096
- A.driver === "htpasswd" && (S.PL_AUTH_HTPASSWD_PATH = g.resolve(A.path), A.path = "/etc/platforma/users.htpasswd");
1097
- S.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1098
+ 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.auth && (r.auth.enabled && (k.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1099
+ for (const S of r.auth.drivers)
1100
+ S.driver === "htpasswd" && (k.PL_AUTH_HTPASSWD_PATH = g.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
1101
+ k.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1098
1102
  }
1099
- const P = Ue(
1103
+ const R = Ue(
1100
1104
  this.logger,
1101
1105
  ["compose", `--file=${m}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1102
1106
  {
1103
- env: S,
1107
+ env: k,
1104
1108
  stdio: "inherit"
1105
1109
  },
1106
1110
  {
1107
1111
  plImage: s,
1108
1112
  composePath: m,
1109
- primaryPath: u,
1113
+ primaryPath: f,
1110
1114
  workPath: b,
1111
- libraryPath: f
1115
+ libraryPath: u
1112
1116
  }
1113
1117
  );
1114
- z(P, "failed to start Platforma Backend in Docker"), d.isActive = !0;
1115
- const L = this.renderRunInfo({
1118
+ z(R, "failed to start Platforma Backend in Docker"), d.isActive = !0;
1119
+ const A = this.renderRunInfo({
1116
1120
  apiPort: r == null ? void 0 : r.grpcPort,
1117
1121
  apiAddr: r == null ? void 0 : r.grpcAddr,
1118
1122
  logPath: c,
1119
- primary: k,
1123
+ primary: L,
1120
1124
  work: { type: "FS", rootPath: b },
1121
- library: R,
1125
+ library: w,
1122
1126
  dbPath: l
1123
1127
  });
1124
1128
  this.logger.info(`Started platforma:
1125
- ${L}`);
1129
+ ${A}`);
1126
1130
  }
1127
1131
  stop() {
1128
1132
  if (!d.isActive) {
@@ -1151,21 +1155,21 @@ ${L}`);
1151
1155
  }
1152
1156
  }
1153
1157
  cleanup() {
1154
- var c, l, u, f, b, w, m, v, k, R, S, P, L, A;
1158
+ var c, l, f, u, b, v, m, y, L, w, k, R, A, S;
1155
1159
  const e = [
1156
1160
  "last command run cache ('pl-service start' shorthand will stop working until next full start command call)",
1157
1161
  "'platforma' docker compose service containers and volumes"
1158
1162
  ], r = d.data(), t = [r];
1159
1163
  if ((l = (c = d.lastRun) == null ? void 0 : c.docker) != null && l.primaryPath) {
1160
- const p = (f = (u = d.lastRun) == null ? void 0 : u.docker) == null ? void 0 : f.primaryPath;
1164
+ const p = (u = (f = d.lastRun) == null ? void 0 : f.docker) == null ? void 0 : u.primaryPath;
1161
1165
  p.startsWith(r) || t.push(p);
1162
1166
  }
1163
- if ((w = (b = d.lastRun) == null ? void 0 : b.docker) != null && w.workPath) {
1164
- const p = (v = (m = d.lastRun) == null ? void 0 : m.docker) == null ? void 0 : v.workPath;
1167
+ if ((v = (b = d.lastRun) == null ? void 0 : b.docker) != null && v.workPath) {
1168
+ const p = (y = (m = d.lastRun) == null ? void 0 : m.docker) == null ? void 0 : y.workPath;
1165
1169
  p.startsWith(r) || t.push(p);
1166
1170
  }
1167
- if ((R = (k = d.lastRun) == null ? void 0 : k.process) != null && R.storagePath) {
1168
- const p = (P = (S = d.lastRun) == null ? void 0 : S.process) == null ? void 0 : P.storagePath;
1171
+ if ((w = (L = d.lastRun) == null ? void 0 : L.process) != null && w.storagePath) {
1172
+ const p = (R = (k = d.lastRun) == null ? void 0 : k.process) == null ? void 0 : R.storagePath;
1169
1173
  p.startsWith(r) || t.push(p);
1170
1174
  }
1171
1175
  const s = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
@@ -1177,12 +1181,12 @@ Things to be removed:
1177
1181
  - `)}
1178
1182
  ${s}
1179
1183
  `;
1180
- if (this.logger.warn(i), !Sr("Are you sure?")) {
1184
+ if (this.logger.warn(i), !pr("Are you sure?")) {
1181
1185
  this.logger.info("Reset action was canceled");
1182
1186
  return;
1183
1187
  }
1184
- const n = new Set(Ir());
1185
- (A = (L = d.lastRun) == null ? void 0 : L.docker) != null && A.composePath && n.add(d.lastRun.docker.composePath);
1188
+ const n = new Set(xr());
1189
+ (S = (A = d.lastRun) == null ? void 0 : A.docker) != null && S.composePath && n.add(d.lastRun.docker.composePath);
1186
1190
  for (const p of n)
1187
1191
  this.logger.info(`Destroying docker compose '${p}'`), this.destroyDocker(p, ne());
1188
1192
  for (const p of t)
@@ -1214,7 +1218,7 @@ If you want to remove all downloaded platforma binaries, delete '${d.binaries()}
1214
1218
  getLastJwt() {
1215
1219
  const e = d.path("auth.jwt"), r = "utf-8";
1216
1220
  let t = "";
1217
- return o.existsSync(e) && (t = o.readFileSync(e, { encoding: r })), t == "" && (t = pr(64), o.writeFileSync(e, t, { encoding: r })), t;
1221
+ return o.existsSync(e) && (t = o.readFileSync(e, { encoding: r })), t == "" && (t = Ar(64), o.writeFileSync(e, t, { encoding: r })), t;
1218
1222
  }
1219
1223
  destroyDocker(e, r) {
1220
1224
  const t = d.data("stub"), s = K("docker", ["compose", "--file", e, "down", "--volumes", "--remove-orphans"], {
@@ -1261,7 +1265,7 @@ You can obtain the license from "https://licensing.milaboratories.com".`), new E
1261
1265
  }
1262
1266
  renderRunInfo(e, r = 10) {
1263
1267
  var c, l;
1264
- const t = [], s = (u) => u.padStart(r, " ");
1268
+ const t = [], s = (f) => f.padStart(r, " ");
1265
1269
  switch (e.configPath && t.push(`${s("config")}: ${e.configPath}`), e.apiAddr ? t.push(`${s("API")}: ${e.apiAddr}`) : e.apiPort ? t.push(`${s("API")}: 127.0.0.1:${e.apiPort.toString()}`) : t.push(`${s("API")}: 127.0.0.1:6345`), e.logPath && t.push(`${s("log")}: ${e.logPath}`), (c = e.primary) == null ? void 0 : c.type) {
1266
1270
  case void 0:
1267
1271
  break;
@@ -1315,7 +1319,7 @@ const j = class j extends F {
1315
1319
  new x(r).cleanup();
1316
1320
  }
1317
1321
  };
1318
- y(j, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), y(j, "examples", ["<%= config.bin %> <%= command.id %>"]), y(j, "flags", {
1322
+ P(j, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), P(j, "examples", ["<%= config.bin %> <%= command.id %>"]), P(j, "flags", {
1319
1323
  ...D
1320
1324
  });
1321
1325
  let de = j;
@@ -1325,7 +1329,7 @@ const U = class U extends F {
1325
1329
  new x(r).startLast();
1326
1330
  }
1327
1331
  };
1328
- y(U, "description", "Start last run service configuraiton"), y(U, "examples", ["<%= config.bin %> <%= command.id %>"]), y(U, "flags", {
1332
+ P(U, "description", "Start last run service configuraiton"), P(U, "examples", ["<%= config.bin %> <%= command.id %>"]), P(U, "flags", {
1329
1333
  ...D
1330
1334
  });
1331
1335
  let ge = U;
@@ -1335,7 +1339,7 @@ const W = class W extends F {
1335
1339
  new x(r).stop();
1336
1340
  }
1337
1341
  };
1338
- y(W, "description", "Stop platforma service"), y(W, "examples", ["<%= config.bin %> <%= command.id %>"]), y(W, "flags", {
1342
+ P(W, "description", "Stop platforma service"), P(W, "examples", ["<%= config.bin %> <%= command.id %>"]), P(W, "flags", {
1339
1343
  ...D
1340
1344
  });
1341
1345
  let ue = W;
@@ -1347,8 +1351,8 @@ const J = class J extends F {
1347
1351
  enabled: s,
1348
1352
  drivers: t.initAuthDriversList(e, ".")
1349
1353
  } : void 0, n = e.storage ? g.join(".", e.storage) : d.data("docker"), c = [];
1350
- for (const u of e.mount ?? [])
1351
- c.push({ hostPath: u });
1354
+ for (const f of e.mount ?? [])
1355
+ c.push({ hostPath: f });
1352
1356
  const l = e.arch ? `linux/${e.arch}` : void 0;
1353
1357
  t.startDocker(n, {
1354
1358
  primaryStorageURL: e["storage-primary"],
@@ -1370,7 +1374,7 @@ const J = class J extends F {
1370
1374
  });
1371
1375
  }
1372
1376
  };
1373
- y(J, "description", "Run platforma backend service with 'FS' primary storage type"), y(J, "examples", ["<%= config.bin %> <%= command.id %>"]), y(J, "flags", {
1377
+ P(J, "description", "Run platforma backend service with 'FS' primary storage type"), P(J, "examples", ["<%= config.bin %> <%= command.id %>"]), P(J, "flags", {
1374
1378
  ...D,
1375
1379
  ...ae,
1376
1380
  ...He,
@@ -1390,25 +1394,25 @@ const H = class H extends F {
1390
1394
  const { flags: e } = await this.parse(H), r = N(e["log-level"]), t = new x(r);
1391
1395
  t.mergeLicenseEnvs(e);
1392
1396
  const s = e["pl-workdir"] ?? ".", i = e.storage ? g.join(s, e.storage) : d.data("local"), n = e["pl-log-file"] ? g.join(s, e["pl-log-file"]) : void 0, c = t.initAuthDriversList(e, s), l = e["auth-enabled"] ?? c !== void 0;
1393
- var u = e["pl-binary"];
1394
- e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1395
- var f = "127.0.0.1:6345";
1396
- e["grpc-listen"] ? f = e["grpc-listen"] : e["grpc-port"] && (f = `127.0.0.1:${e["grpc-port"]}`);
1397
+ var f = e["pl-binary"];
1398
+ e["pl-sources"] && (f = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1399
+ var u = "127.0.0.1:6345";
1400
+ e["grpc-listen"] ? u = e["grpc-listen"] : e["grpc-port"] && (u = `127.0.0.1:${e["grpc-port"]}`);
1397
1401
  var b = "127.0.0.1:9090";
1398
1402
  e["monitoring-listen"] ? b = e["monitoring-listen"] : e["monitoring-port"] && (b = `127.0.0.1:${e["monitoring-port"]}`);
1399
- var w = "127.0.0.1:9091";
1400
- e["debug-listen"] ? w = e["debug-listen"] : e["debug-port"] && (w = `127.0.0.1:${e["debug-port"]}`);
1403
+ var v = "127.0.0.1:9091";
1404
+ e["debug-listen"] ? v = e["debug-listen"] : e["debug-port"] && (v = `127.0.0.1:${e["debug-port"]}`);
1401
1405
  const m = {
1402
- binaryPath: u,
1406
+ binaryPath: f,
1403
1407
  version: e.version,
1404
1408
  configPath: e.config,
1405
1409
  workdir: e["pl-workdir"],
1406
1410
  primaryURL: e["storage-primary"],
1407
1411
  libraryURL: e["storage-library"],
1408
1412
  configOptions: {
1409
- grpc: { listen: f },
1413
+ grpc: { listen: u },
1410
1414
  monitoring: { listen: b },
1411
- debug: { listen: w },
1415
+ debug: { listen: v },
1412
1416
  license: { value: e.license, file: e["license-file"] },
1413
1417
  log: { path: n },
1414
1418
  localRoot: i,
@@ -1418,12 +1422,12 @@ const H = class H extends F {
1418
1422
  }
1419
1423
  }
1420
1424
  };
1421
- m.binaryPath ? t.startLocal(m) : ir(r, { version: e.version }).then(() => t.startLocal(m)).catch(function(v) {
1422
- r.error(v.message);
1425
+ m.binaryPath ? t.startLocal(m) : ir(r, { version: e.version }).then(() => t.startLocal(m)).catch(function(y) {
1426
+ r.error(y.message);
1423
1427
  });
1424
1428
  }
1425
1429
  };
1426
- y(H, "description", "Run Platforma Backend service as local process on current host (no docker container)"), y(H, "examples", ["<%= config.bin %> <%= command.id %>"]), y(H, "flags", {
1430
+ P(H, "description", "Run Platforma Backend service as local process on current host (no docker container)"), P(H, "examples", ["<%= config.bin %> <%= command.id %>"]), P(H, "flags", {
1427
1431
  ...D,
1428
1432
  ...re,
1429
1433
  ...ae,
@@ -1441,7 +1445,7 @@ y(H, "description", "Run Platforma Backend service as local process on current h
1441
1445
  });
1442
1446
  let me = H;
1443
1447
  var $;
1444
- let Vr = ($ = class extends F {
1448
+ let Qr = ($ = class extends F {
1445
1449
  async run() {
1446
1450
  const { flags: e } = await this.parse($), r = N(e["log-level"]), t = new x(r);
1447
1451
  t.mergeLicenseEnvs(e);
@@ -1451,7 +1455,7 @@ let Vr = ($ = class extends F {
1451
1455
  } : void 0, n = e.storage ? g.join(".", e.storage) : d.data("docker-s3"), c = [];
1452
1456
  for (const u of e.mount ?? [])
1453
1457
  c.push({ hostPath: u });
1454
- const l = e.arch ? `linux/${e.arch}` : void 0;
1458
+ const l = e.arch ? `linux/${e.arch}` : void 0, f = e["minio-presign-host"] ? "minio" : "localhost";
1455
1459
  t.startDockerS3(n, {
1456
1460
  image: e.image,
1457
1461
  version: e.version,
@@ -1465,10 +1469,11 @@ let Vr = ($ = class extends F {
1465
1469
  monitoringAddr: e["monitoring-listen"],
1466
1470
  monitoringPort: e["monitoring-port"],
1467
1471
  debugAddr: e["debug-listen"],
1468
- debugPort: e["debug-port"]
1472
+ debugPort: e["debug-port"],
1473
+ presignHost: f
1469
1474
  });
1470
1475
  }
1471
- }, y($, "description", "Run platforma backend service with 'S3' primary storage type"), y($, "examples", ["<%= config.bin %> <%= command.id %>"]), y($, "flags", {
1476
+ }, P($, "description", "Run platforma backend service with 'S3' primary storage type"), P($, "examples", ["<%= config.bin %> <%= command.id %>"]), P($, "flags", {
1472
1477
  ...D,
1473
1478
  ...ae,
1474
1479
  ...He,
@@ -1477,23 +1482,24 @@ let Vr = ($ = class extends F {
1477
1482
  ...ie,
1478
1483
  ...te,
1479
1484
  ...ze,
1480
- ...se
1485
+ ...se,
1486
+ ...br
1481
1487
  }), $);
1482
1488
  const Y = class Y extends F {
1483
1489
  async run() {
1484
1490
  const { flags: e } = await this.parse(Y), r = N(e["log-level"]), t = new x(r);
1485
1491
  t.mergeLicenseEnvs(e);
1486
1492
  const s = e["pl-workdir"] ?? ".", i = e.storage ? g.join(s, e.storage) : d.data("local-s3"), n = e["pl-log-file"] ? g.join(s, e["pl-log-file"]) : void 0, c = t.initAuthDriversList(e, s), l = e["auth-enabled"] ?? c !== void 0;
1487
- var u = e["pl-binary"];
1488
- e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1489
- var f = "127.0.0.1:6345";
1490
- e["grpc-listen"] ? f = e["grpc-listen"] : e["grpc-port"] && (f = `127.0.0.1:${e["grpc-port"]}`);
1493
+ var f = e["pl-binary"];
1494
+ e["pl-sources"] && (f = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1495
+ var u = "127.0.0.1:6345";
1496
+ e["grpc-listen"] ? u = e["grpc-listen"] : e["grpc-port"] && (u = `127.0.0.1:${e["grpc-port"]}`);
1491
1497
  var b = "127.0.0.1:9090";
1492
1498
  e["monitoring-listen"] ? b = e["monitoring-listen"] : e["monitoring-port"] && (b = `127.0.0.1:${e["monitoring-port"]}`);
1493
- var w = "127.0.0.1:9091";
1494
- e["debug-listen"] ? w = e["debug-listen"] : e["debug-port"] && (w = `127.0.0.1:${e["debug-port"]}`);
1499
+ var v = "127.0.0.1:9091";
1500
+ e["debug-listen"] ? v = e["debug-listen"] : e["debug-port"] && (v = `127.0.0.1:${e["debug-port"]}`);
1495
1501
  const m = {
1496
- binaryPath: u,
1502
+ binaryPath: f,
1497
1503
  version: e.version,
1498
1504
  configPath: e.config,
1499
1505
  workdir: e["pl-workdir"],
@@ -1502,9 +1508,9 @@ const Y = class Y extends F {
1502
1508
  minioPort: e["s3-address-port"],
1503
1509
  minioConsolePort: e["s3-console-address-port"],
1504
1510
  configOptions: {
1505
- grpc: { listen: f },
1511
+ grpc: { listen: u },
1506
1512
  monitoring: { listen: b },
1507
- debug: { listen: w },
1513
+ debug: { listen: v },
1508
1514
  license: { value: e.license, file: e["license-file"] },
1509
1515
  log: { path: n },
1510
1516
  localRoot: i,
@@ -1516,12 +1522,12 @@ const Y = class Y extends F {
1516
1522
  }
1517
1523
  }
1518
1524
  };
1519
- m.binaryPath ? t.startLocalS3(m) : ir(r, { version: e.version }).then(() => t.startLocalS3(m)).catch(function(v) {
1520
- r.error(v.message);
1525
+ m.binaryPath ? t.startLocalS3(m) : ir(r, { version: e.version }).then(() => t.startLocalS3(m)).catch(function(y) {
1526
+ r.error(y.message);
1521
1527
  });
1522
1528
  }
1523
1529
  };
1524
- y(Y, "description", "Run Platforma Backend service as local process on current host (no docker container)"), y(Y, "examples", ["<%= config.bin %> <%= command.id %>"]), y(Y, "flags", {
1530
+ P(Y, "description", "Run Platforma Backend service as local process on current host (no docker container)"), P(Y, "examples", ["<%= config.bin %> <%= command.id %>"]), P(Y, "flags", {
1525
1531
  ...D,
1526
1532
  ...re,
1527
1533
  ...ae,
@@ -1539,17 +1545,17 @@ y(Y, "description", "Run Platforma Backend service as local process on current h
1539
1545
  ...ie
1540
1546
  });
1541
1547
  let he = Y;
1542
- const ut = {
1548
+ const ft = {
1543
1549
  "create-block": le,
1544
1550
  reset: de,
1545
1551
  start: ge,
1546
1552
  stop: ue,
1547
1553
  "start:docker": fe,
1548
1554
  "start:local": me,
1549
- "start:docker:s3": Vr,
1555
+ "start:docker:s3": Qr,
1550
1556
  "start:local:s3": he
1551
1557
  };
1552
1558
  export {
1553
- ut as COMMANDS
1559
+ ft as COMMANDS
1554
1560
  };
1555
1561
  //# sourceMappingURL=index.mjs.map