@platforma-sdk/bootstrap 2.0.0 → 2.0.2

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.
Files changed (49) hide show
  1. package/assets/compose-backend.yaml +6 -6
  2. package/dist/cmd-opts.d.ts +6 -3
  3. package/dist/cmd-opts.d.ts.map +1 -1
  4. package/dist/commands/start/docker/s3.d.ts +6 -3
  5. package/dist/commands/start/docker/s3.d.ts.map +1 -1
  6. package/dist/commands/start/docker.d.ts +6 -3
  7. package/dist/commands/start/docker.d.ts.map +1 -1
  8. package/dist/commands/start/local/s3.d.ts +6 -3
  9. package/dist/commands/start/local/s3.d.ts.map +1 -1
  10. package/dist/commands/start/local.d.ts +6 -3
  11. package/dist/commands/start/local.d.ts.map +1 -1
  12. package/dist/core.d.ts +15 -6
  13. package/dist/core.d.ts.map +1 -1
  14. package/dist/index.d.ts +16 -6
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +53 -46
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +947 -487
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/package.d.ts +0 -1
  21. package/dist/package.d.ts.map +1 -1
  22. package/dist/platforma.d.ts.map +1 -1
  23. package/dist/state.d.ts +3 -0
  24. package/dist/state.d.ts.map +1 -1
  25. package/dist/templates/pl-config.d.ts.map +1 -1
  26. package/dist/templates/types.d.ts +6 -0
  27. package/dist/templates/types.d.ts.map +1 -1
  28. package/dist/util.d.ts +2 -0
  29. package/dist/util.d.ts.map +1 -1
  30. package/package.json +14 -9
  31. package/src/block.ts +0 -82
  32. package/src/cmd-opts.ts +0 -175
  33. package/src/commands/create-block.ts +0 -21
  34. package/src/commands/reset.ts +0 -23
  35. package/src/commands/start/docker/s3.ts +0 -59
  36. package/src/commands/start/docker.ts +0 -65
  37. package/src/commands/start/local/s3.ts +0 -96
  38. package/src/commands/start/local.ts +0 -89
  39. package/src/commands/start.ts +0 -23
  40. package/src/commands/stop.ts +0 -23
  41. package/src/core.ts +0 -696
  42. package/src/index.ts +0 -10
  43. package/src/package.ts +0 -54
  44. package/src/platforma.ts +0 -194
  45. package/src/run.ts +0 -120
  46. package/src/state.ts +0 -105
  47. package/src/templates/pl-config.ts +0 -280
  48. package/src/templates/types.ts +0 -172
  49. package/src/util.ts +0 -55
package/dist/index.mjs CHANGED
@@ -1,39 +1,270 @@
1
- var Le = Object.defineProperty;
2
- var Re = (t, e, r) => e in t ? Le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var m = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { Flags as d, Command as W } from "@oclif/core";
5
- import { spawn as Oe, spawnSync as M } from "node:child_process";
6
- import be from "yaml";
7
- import g from "node:fs";
8
- import R from "node:os";
9
- import o, { resolve as Te } from "node:path";
10
- import F from "winston";
11
- import { randomBytes as Ee } from "node:crypto";
12
- import $e from "readline-sync";
13
- import "tar";
14
- function Y(...t) {
15
- return Te(__dirname, "..", ...t);
16
- }
17
- function k(...t) {
18
- return Y("assets", ...t);
19
- }
20
- function ke(...t) {
21
- return Y("binaries", ...t);
22
- }
23
- function Ie() {
24
- return g.readdirSync(k()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => k(e));
25
- }
26
- function we(...t) {
27
- return g.readFileSync(Y(...t));
28
- }
29
- var B;
30
- function Se() {
31
- return B || (B = JSON.parse(we("package.json").toString())), B;
32
- }
33
- function G(t) {
34
- return t || (t = Se()["pl-version"]), `quay.io/milaboratories/platforma:${t}`;
35
- }
36
- const w = class w {
1
+ var er = Object.defineProperty;
2
+ var rr = (a, e, r) => e in a ? er(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
3
+ var m = (a, e, r) => rr(a, typeof e != "symbol" ? e + "" : e, r);
4
+ import { Flags as y, Command as O } from "@oclif/core";
5
+ import p from "node:os";
6
+ import o, { createWriteStream as tr } from "node:fs";
7
+ import f, { resolve as ar } from "node:path";
8
+ import { execSync as Me, spawn as ir, spawnSync as H } from "node:child_process";
9
+ import j from "winston";
10
+ import { randomBytes as sr } from "node:crypto";
11
+ import V from "readline-sync";
12
+ import { Writable as cr } from "node:stream";
13
+ import { z as K } from "zod";
14
+ import nr from "decompress";
15
+ import Ce from "yaml";
16
+ import lr from "node:https";
17
+ import * as or from "tar";
18
+ const T = {
19
+ "log-level": y.string({
20
+ description: "logging level",
21
+ default: "info",
22
+ options: ["error", "warn", "info", "debug"],
23
+ required: !1
24
+ })
25
+ }, Ue = {
26
+ image: y.string({
27
+ description: "use custom docker image to run platforma"
28
+ })
29
+ }, Q = {
30
+ version: y.string({
31
+ description: "use custom platforma release (official docker image or binary package)"
32
+ })
33
+ }, X = {
34
+ license: y.string({
35
+ description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
36
+ }),
37
+ "license-file": y.file({
38
+ exists: !0,
39
+ description: "specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
40
+ })
41
+ }, Z = {
42
+ "grpc-port": y.integer({
43
+ description: "port for Platforma Backend gRPC API. Default is 6345",
44
+ env: "PLATFORMA_GRPC_PORT"
45
+ }),
46
+ "grpc-listen": y.string({
47
+ description: "full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",
48
+ env: "PLATFORMA_GRPC_LISTEN"
49
+ }),
50
+ "monitoring-port": y.integer({
51
+ description: "port for Platforma Backend monitoring API. Default is 9090",
52
+ env: "PLATFORMA_MONITORING_PORT"
53
+ }),
54
+ "monitoring-listen": y.string({
55
+ description: "full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",
56
+ env: "PLATFORMA_MONITORING_LISTEN"
57
+ }),
58
+ "debug-port": y.integer({
59
+ description: "port for Platforma Backend debug API. Default is 9091",
60
+ env: "PLATFORMA_DEBUG_PORT"
61
+ }),
62
+ "debug-listen": y.string({
63
+ description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
64
+ env: "PLATFORMA_DEBUG_LISTEN"
65
+ })
66
+ }, dr = {
67
+ "s3-address-port": y.integer({
68
+ description: "port that S3 will listen, default is 9000",
69
+ default: 9e3,
70
+ env: "PLATFORMA_S3_PORT"
71
+ }),
72
+ "s3-console-address-port": y.integer({
73
+ description: "port that a console of S3 will listen, default is 9001",
74
+ default: 9001,
75
+ env: "PLATFORMA_S3_CONSOLE_PORT"
76
+ })
77
+ }, ee = {
78
+ storage: y.string({
79
+ description: "specify path on host to be used as storage for all Platforma Backend data"
80
+ })
81
+ }, We = {
82
+ "pl-log-file": y.file({
83
+ description: "specify path for Platforma Backend log file"
84
+ })
85
+ }, je = {
86
+ "pl-workdir": y.file({
87
+ description: "specify working directory for Platforma Backend process"
88
+ })
89
+ }, Je = {
90
+ "pl-binary": y.file({
91
+ description: "start given Platforma Backend binary instead of automatically downloaded version"
92
+ })
93
+ }, He = {
94
+ "pl-sources": y.file({
95
+ description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
96
+ })
97
+ }, Ye = {
98
+ config: y.string({
99
+ description: "use custom Platforma Backend config"
100
+ })
101
+ };
102
+ y.file({
103
+ description: "specify path on host to be used as 'primary' storage"
104
+ });
105
+ const fe = {
106
+ "storage-work": y.file({
107
+ description: "specify path on host to be used as 'work' storage"
108
+ })
109
+ };
110
+ y.file({
111
+ description: "specify path on host to be used as 'library' storage"
112
+ });
113
+ const he = {
114
+ "storage-primary": y.string({
115
+ description: `specify 'primary' storage destination URL.
116
+ file:/path/to/dir for directory on local FS
117
+ s3://<bucket>/?region=<name> for real AWS bucket
118
+ s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
119
+ s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
120
+ })
121
+ }, me = {
122
+ "storage-library": y.string({
123
+ description: `specify 'library' storage destination URL.
124
+ file:/path/to/dir for directory on local FS
125
+ s3://<bucket>/?region=<name> for real AWS bucket
126
+ s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
127
+ s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
128
+ })
129
+ }, gr = {
130
+ "auth-enabled": y.boolean({
131
+ description: "enable authorization"
132
+ })
133
+ }, ur = {
134
+ "auth-htpasswd-file": y.file({
135
+ description: "path to .htpasswd file with Platforma users (static user DB auth source)"
136
+ })
137
+ }, fr = {
138
+ "auth-ldap-server": y.string({
139
+ description: "address of LDAP server to use for auth in Platforma (auth source)"
140
+ })
141
+ }, hr = {
142
+ "auth-ldap-default-dn": y.string({
143
+ description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"
144
+ })
145
+ }, re = {
146
+ ...gr,
147
+ ...ur,
148
+ ...fr,
149
+ ...hr
150
+ };
151
+ function mr(a) {
152
+ return V.question(`${a} [y/N] `).toLowerCase() === "y";
153
+ }
154
+ function Y(a) {
155
+ throw new Error("this should never happen");
156
+ }
157
+ function E(a = "debug") {
158
+ return j.createLogger({
159
+ level: a,
160
+ format: j.format.combine(
161
+ j.format.printf(({ level: e, message: r }) => {
162
+ const t = " ".repeat(e.length + 2), i = r.split(`
163
+ `).map((c, n) => n === 0 ? c : t + c).join(`
164
+ `);
165
+ return `${((c) => j.format.colorize().colorize(c, c))(e)}: ${i}`;
166
+ })
167
+ ),
168
+ transports: [
169
+ new j.transports.Console({
170
+ stderrLevels: ["error", "warn", "info", "debug"],
171
+ handleExceptions: !0
172
+ })
173
+ ]
174
+ });
175
+ }
176
+ function yr(a) {
177
+ return sr(Math.ceil(a / 2)).toString("hex").slice(0, a);
178
+ }
179
+ function Pr(a) {
180
+ return a.startsWith("~") ? f.join(p.homedir(), a.slice(1)) : a;
181
+ }
182
+ function q(a) {
183
+ o.existsSync(a) || o.mkdirSync(a, { recursive: !0 });
184
+ }
185
+ function br(a) {
186
+ try {
187
+ if (p.platform() !== "win32")
188
+ return Me(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
189
+ const e = `wmic process where processid=${a} get Caption`, r = Me(e, { encoding: "utf8" }).split(`
190
+ `);
191
+ return r.length <= 1 ? "" : r[1].trim();
192
+ } catch {
193
+ return "";
194
+ }
195
+ }
196
+ const vr = K.object({
197
+ npmOrgName: K.string().min(1),
198
+ orgName: K.string().min(1),
199
+ blockName: K.string().min(1)
200
+ });
201
+ async function wr(a) {
202
+ const e = kr(), r = f.join(process.cwd(), e.blockName);
203
+ a.info("Downloading boilerplate code..."), await Sr(
204
+ "https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip",
205
+ "platforma-block-boilerplate-main",
206
+ r
207
+ ), a.info("Replace everything in the template with provided options..."), Ar(
208
+ r,
209
+ /pl-open\/my-org.block-boilerplate/g,
210
+ `${e.npmOrgName}/${e.orgName}.${e.blockName}`
211
+ );
212
+ }
213
+ function kr() {
214
+ let a = V.question('Write an organization name for npm. Default is "pl-open": ');
215
+ a === "" && (a = "pl-open");
216
+ const e = V.question('Write an organization name, e.g. "my-org": '), r = V.question('Write a name of the block, e.g. "hello-world": ');
217
+ return vr.parse({ npmOrgName: a, orgName: e, blockName: r });
218
+ }
219
+ async function Sr(a, e, r) {
220
+ const i = await (await fetch(a)).blob(), s = o.mkdtempSync(f.join(p.tmpdir(), "create-repo")), c = f.join(s, "packed-repo.zip"), n = cr.toWeb(tr(c));
221
+ await i.stream().pipeTo(n);
222
+ const h = f.join(s, "unpacked-repo");
223
+ o.mkdirSync(h), await nr(c, h), o.cpSync(f.join(h, e), r, { recursive: !0 });
224
+ }
225
+ function Ar(a, e, r) {
226
+ Lr(a).forEach((t) => Rr(t, e, r));
227
+ }
228
+ function Lr(a) {
229
+ return o.readdirSync(a, {
230
+ withFileTypes: !0,
231
+ recursive: !0
232
+ }).filter((r) => r.isFile()).map((r) => f.join(r.parentPath, r.name));
233
+ }
234
+ function Rr(a, e, r) {
235
+ const i = o.readFileSync(a).toString().replaceAll(e, r);
236
+ o.writeFileSync(a, i);
237
+ }
238
+ const I = class I extends O {
239
+ async run() {
240
+ const { flags: e } = await this.parse(I), r = E(e["log-level"]);
241
+ await wr(r);
242
+ }
243
+ };
244
+ m(I, "description", "Helps to create a new block by downloading a block's template."), m(I, "examples", ["<%= name %>"]), m(I, "flags", {
245
+ ...T
246
+ });
247
+ let se = I;
248
+ function ze(...a) {
249
+ return ar(__dirname, "..", ...a);
250
+ }
251
+ function $(...a) {
252
+ return ze("assets", ...a);
253
+ }
254
+ function pr() {
255
+ return o.readdirSync($()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => $(e));
256
+ }
257
+ function Ke(...a) {
258
+ return o.readFileSync(ze(...a));
259
+ }
260
+ var ae;
261
+ function te() {
262
+ return ae || (ae = JSON.parse(Ke("package.json").toString())), ae;
263
+ }
264
+ function ie(a) {
265
+ return a || (a = te()["pl-version"]), `quay.io/milaboratories/platforma:${a}`;
266
+ }
267
+ const F = class F {
37
268
  constructor(e) {
38
269
  m(this, "state", {
39
270
  lastRun: void 0,
@@ -41,21 +272,35 @@ const w = class w {
41
272
  });
42
273
  m(this, "filePath");
43
274
  m(this, "dirPath");
44
- e = e ?? o.resolve(R.homedir(), ".config", "pl-bootstrap");
45
- const r = o.join(e, "state.json");
46
- this.dirPath = e, this.filePath = r, g.existsSync(e) || g.mkdirSync(e, { recursive: !0 }), g.existsSync(r) && (this.state = JSON.parse(we(r).toString()));
275
+ e = e ?? f.resolve(p.homedir(), ".config", "pl-bootstrap");
276
+ const r = f.join(e, "state.json");
277
+ this.dirPath = e, this.filePath = r, o.existsSync(e) || o.mkdirSync(e, { recursive: !0 }), o.existsSync(r) && (this.state = JSON.parse(Ke(r).toString()));
47
278
  }
48
279
  static getInstance() {
49
- return w.instance || (w.instance = new w()), w.instance;
280
+ return F.instance || (F.instance = new F()), F.instance;
50
281
  }
51
282
  path(...e) {
52
- return o.join(this.dirPath, ...e);
283
+ return f.join(this.dirPath, ...e);
284
+ }
285
+ data(...e) {
286
+ return this.path("data", ...e);
287
+ }
288
+ binaries(...e) {
289
+ return this.path("binaries", ...e);
53
290
  }
54
291
  writeState() {
55
- g.writeFileSync(this.filePath, JSON.stringify(this.state));
292
+ o.writeFileSync(this.filePath, JSON.stringify(this.state));
56
293
  }
57
294
  get isActive() {
58
- return this.state.isActive;
295
+ var e, r;
296
+ return this.state.isActive ? this.state.isActive : (r = (e = this.state.lastRun) == null ? void 0 : e.process) != null && r.pid ? this.isValidPID : !1;
297
+ }
298
+ get isValidPID() {
299
+ var r, t;
300
+ if (!((t = (r = this.state.lastRun) == null ? void 0 : r.process) != null && t.pid))
301
+ return !1;
302
+ const e = br(this.state.lastRun.process.pid);
303
+ return e === "platforma" || e.endsWith("/platforma") || e.endsWith("\\platforma");
59
304
  }
60
305
  set isActive(e) {
61
306
  this.state.isActive = e, this.writeState();
@@ -67,10 +312,10 @@ const w = class w {
67
312
  this.state.lastRun = e, this.writeState();
68
313
  }
69
314
  };
70
- m(w, "instance");
71
- let U = w;
72
- const l = U.getInstance();
73
- function ve(t, e, r, a) {
315
+ m(F, "instance");
316
+ let ce = F;
317
+ const l = ce.getInstance();
318
+ function Be(a, e, r, t) {
74
319
  var i;
75
320
  return l.lastRun = {
76
321
  ...l.lastRun,
@@ -81,31 +326,31 @@ function ve(t, e, r, a) {
81
326
  envs: r.env,
82
327
  docker: {
83
328
  ...(i = l.lastRun) == null ? void 0 : i.docker,
84
- ...a
329
+ ...t
85
330
  }
86
- }, _e(t, "docker", e, r);
331
+ }, qe(a, "docker", e, r);
87
332
  }
88
- function Ne(t, e, r, a, i) {
89
- var s;
333
+ function _r(a, e, r, t, i) {
334
+ var c;
90
335
  l.lastRun = {
91
336
  ...l.lastRun,
92
337
  mode: "process",
93
338
  cmd: e,
94
339
  args: r,
95
- workdir: a.cwd,
96
- envs: a.env,
340
+ workdir: t.cwd,
341
+ envs: t.env,
97
342
  process: {
98
- ...(s = l.lastRun) == null ? void 0 : s.process,
343
+ ...(c = l.lastRun) == null ? void 0 : c.process,
99
344
  ...i
100
345
  }
101
346
  };
102
- const c = Fe(t, e, r, a);
347
+ const s = Or(a, e, r, t);
103
348
  return l.lastRun.process = {
104
349
  ...l.lastRun.process,
105
- pid: c.pid
106
- }, c;
350
+ pid: s.pid
351
+ }, s;
107
352
  }
108
- function De(t, e) {
353
+ function $r(a, e) {
109
354
  if (!l.lastRun)
110
355
  throw new Error("no previous run info found: this is the first run after package installation");
111
356
  return e = {
@@ -115,35 +360,35 @@ function De(t, e) {
115
360
  ...e.env
116
361
  },
117
362
  ...e
118
- }, _e(t, l.lastRun.cmd, l.lastRun.args, e);
363
+ }, qe(a, l.lastRun.cmd, l.lastRun.args, e);
119
364
  }
120
- function Fe(t, e, r, a) {
121
- t.debug(
365
+ function Or(a, e, r, t) {
366
+ a.debug(
122
367
  `Running:
123
- env: ${JSON.stringify(a.env)}
368
+ env: ${JSON.stringify(t.env)}
124
369
  cmd: ${JSON.stringify([e, ...r])}
125
- wd: ${a.cwd}`
126
- ), a.env = { ...process.env, ...a.env }, t.debug(" spawning child process");
127
- const i = Oe(e, r, a);
128
- var c = !1;
129
- const s = () => {
130
- i.kill("SIGINT"), c = !0;
370
+ wd: ${t.cwd}`
371
+ ), t.env = { ...process.env, ...t.env }, a.debug(" spawning child process");
372
+ const i = ir(e, r, t);
373
+ var s = !1;
374
+ const c = () => {
375
+ i.kill("SIGINT"), s = !0;
131
376
  };
132
- return t.debug(" setting up signal handler"), process.on("SIGINT", s), i.on("close", (n) => {
133
- process.removeListener("SIGINT", s), c && process.exit(n);
377
+ return a.debug(" setting up signal handler"), process.on("SIGINT", c), i.on("close", (n) => {
378
+ process.removeListener("SIGINT", c), s && process.exit(n);
134
379
  }), i;
135
380
  }
136
- function _e(t, e, r, a) {
137
- return t.debug(
381
+ function qe(a, e, r, t) {
382
+ return a.debug(
138
383
  `Running:
139
- env: ${JSON.stringify(a.env)}
384
+ env: ${JSON.stringify(t.env)}
140
385
  cmd: ${JSON.stringify([e, ...r])}
141
- wd: ${a.cwd}`
142
- ), a.env = { ...process.env, ...a.env }, M(e, r, a);
386
+ wd: ${t.cwd}`
387
+ ), t.env = { ...process.env, ...t.env }, H(e, r, t);
143
388
  }
144
- function pe(t) {
389
+ function Tr(a) {
145
390
  return {
146
- id: t,
391
+ id: a,
147
392
  type: "S3",
148
393
  indexCachePeriod: "0s",
149
394
  endpoint: "",
@@ -159,187 +404,159 @@ function pe(t) {
159
404
  uploadKeyPrefix: ""
160
405
  };
161
406
  }
162
- function Ae(t) {
407
+ function Ve(a) {
163
408
  return {
164
- id: t,
409
+ id: a,
165
410
  type: "FS",
166
411
  indexCachePeriod: "0s",
167
412
  rootPath: ""
168
413
  };
169
414
  }
170
- function Me(t) {
171
- return $e.question(`${t} [y/N] `).toLowerCase() === "y";
172
- }
173
- function C(t) {
174
- throw new Error("this should never happen");
175
- }
176
- function K(t = "debug") {
177
- return F.createLogger({
178
- level: t,
179
- format: F.format.combine(
180
- F.format.printf(({ level: e, message: r }) => {
181
- const a = " ".repeat(e.length + 2), i = r.split(`
182
- `).map((s, n) => n === 0 ? s : a + s).join(`
183
- `);
184
- return `${((s) => F.format.colorize().colorize(s, s))(e)}: ${i}`;
185
- })
186
- ),
187
- transports: [
188
- new F.transports.Console({
189
- stderrLevels: ["error", "warn", "info", "debug"],
190
- handleExceptions: !0
191
- })
192
- ]
193
- });
194
- }
195
- function Ce(t) {
196
- return Ee(Math.ceil(t / 2)).toString("hex").slice(0, t);
197
- }
198
- function xe(t) {
199
- return t.startsWith("~") ? o.join(R.homedir(), t.slice(1)) : t;
200
- }
201
- function S(t, e, r) {
202
- t = xe(t);
203
- const a = new URL(t, `file:${e}`);
204
- switch (a.protocol) {
415
+ function N(a, e, r) {
416
+ a = Pr(a);
417
+ const t = new URL(a, `file:${e}`);
418
+ switch (t.protocol) {
205
419
  case "s3:":
206
- var s = a.hostname, i = a.searchParams.get("region");
420
+ var c = t.hostname, i = t.searchParams.get("region");
207
421
  return {
208
422
  ...r,
209
423
  type: "S3",
210
- bucketName: s,
424
+ bucketName: c,
211
425
  region: i
212
426
  };
213
427
  case "s3e:":
214
- var c = a.pathname.split("/").slice(1), s = c[0], n = c.length > 1 ? c[1] : "";
428
+ var s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
215
429
  return {
216
430
  ...r,
217
431
  type: "S3",
218
- endpoint: `http://${a.host}/`,
219
- bucketName: s,
432
+ endpoint: `http://${t.host}/`,
433
+ bucketName: c,
220
434
  keyPrefix: n,
221
- region: a.searchParams.get("region"),
222
- key: a.username ? `static:${a.username}` : "",
223
- secret: a.password ? `static:${a.password}` : ""
435
+ region: t.searchParams.get("region"),
436
+ key: t.username ? `static:${t.username}` : "",
437
+ secret: t.password ? `static:${t.password}` : ""
224
438
  };
225
439
  case "s3es:":
226
- var c = a.pathname.split("/").slice(1), s = c[0], n = c.length > 1 ? c[1] : "";
440
+ var s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
227
441
  return {
228
442
  ...r,
229
443
  type: "S3",
230
- endpoint: `https://${a.host}/`,
231
- bucketName: s,
444
+ endpoint: `https://${t.host}/`,
445
+ bucketName: c,
232
446
  keyPrefix: n,
233
- region: a.searchParams.get("region"),
234
- key: a.username ? `static:${a.username}` : "",
235
- secret: a.password ? `static:${a.password}` : ""
447
+ region: t.searchParams.get("region"),
448
+ key: t.username ? `static:${t.username}` : "",
449
+ secret: t.password ? `static:${t.password}` : ""
236
450
  };
237
451
  case "file:":
238
452
  return {
239
453
  type: "FS",
240
- rootPath: a.pathname
454
+ rootPath: t.pathname
241
455
  };
242
456
  default:
243
- throw new Error(`storage protocol '${a.protocol}' is not supported`);
457
+ throw new Error(`storage protocol '${t.protocol}' is not supported`);
244
458
  }
245
459
  }
246
- function Be(t, e) {
247
- var P, O, T, E, $, I, N, D, y, V, Q, X, Z, ee, re, ae, te, ce, ie, se, le, ne, de, ue, ge, he, fe, oe, me, ye;
248
- const r = (e == null ? void 0 : e.localRoot) ?? l.path("data", "local-custom"), a = {
249
- level: ((P = e == null ? void 0 : e.log) == null ? void 0 : P.level) ?? "info",
250
- path: ((O = e == null ? void 0 : e.log) == null ? void 0 : O.path) ?? `${r}/platforma.log`
460
+ function Er(a, e) {
461
+ var d, b, w, S, L, k, _, W, A, ye, Pe, be, ve, we, ke, Se, Ae, Le, Re, pe, _e, $e, Oe, Te, Ee, Fe, De, Ne, Ie, xe;
462
+ const r = (e == null ? void 0 : e.localRoot) ?? l.data("local-custom"), t = {
463
+ level: ((d = e == null ? void 0 : e.log) == null ? void 0 : d.level) ?? "info",
464
+ path: ((b = e == null ? void 0 : e.log) == null ? void 0 : b.path) ?? `${r}/platforma.log`
251
465
  }, i = {
252
- listen: ((T = e == null ? void 0 : e.grpc) == null ? void 0 : T.listen) ?? "localhost:6345",
466
+ listen: ((w = e == null ? void 0 : e.grpc) == null ? void 0 : w.listen) ?? "localhost:6345",
253
467
  tls: {
254
- enable: x(($ = (E = e == null ? void 0 : e.grpc) == null ? void 0 : E.tls) == null ? void 0 : $.enable, !1),
255
- clientAuthMode: ((N = (I = e == null ? void 0 : e.grpc) == null ? void 0 : I.tls) == null ? void 0 : N.clientAuthMode) ?? "NoAuth",
256
- certFile: ((y = (D = e == null ? void 0 : e.grpc) == null ? void 0 : D.tls) == null ? void 0 : y.certFile) ?? `${r}/certs/tls.cert`,
257
- keyFile: ((Q = (V = e == null ? void 0 : e.grpc) == null ? void 0 : V.tls) == null ? void 0 : Q.keyFile) ?? `${r}/certs/tls.key`,
258
- ...(X = e == null ? void 0 : e.grpc) == null ? void 0 : X.tls
468
+ enable: z((L = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : L.enable, !1),
469
+ clientAuthMode: ((_ = (k = e == null ? void 0 : e.grpc) == null ? void 0 : k.tls) == null ? void 0 : _.clientAuthMode) ?? "NoAuth",
470
+ certFile: ((A = (W = e == null ? void 0 : e.grpc) == null ? void 0 : W.tls) == null ? void 0 : A.certFile) ?? `${r}/certs/tls.cert`,
471
+ keyFile: ((Pe = (ye = e == null ? void 0 : e.grpc) == null ? void 0 : ye.tls) == null ? void 0 : Pe.keyFile) ?? `${r}/certs/tls.key`,
472
+ ...(be = e == null ? void 0 : e.grpc) == null ? void 0 : be.tls
259
473
  }
260
- }, c = {
474
+ }, s = {
261
475
  auth: {
262
- enabled: ((ee = (Z = e == null ? void 0 : e.core) == null ? void 0 : Z.auth) == null ? void 0 : ee.enabled) ?? !1,
263
- drivers: ((ae = (re = e == null ? void 0 : e.core) == null ? void 0 : re.auth) == null ? void 0 : ae.drivers) ?? [
264
- { driver: "jwt", key: t },
476
+ enabled: ((we = (ve = e == null ? void 0 : e.core) == null ? void 0 : ve.auth) == null ? void 0 : we.enabled) ?? !1,
477
+ drivers: ((Se = (ke = e == null ? void 0 : e.core) == null ? void 0 : ke.auth) == null ? void 0 : Se.drivers) ?? [
478
+ { driver: "jwt", key: a },
265
479
  { driver: "htpasswd", path: `${r}/users.htpasswd` }
266
480
  ]
481
+ },
482
+ db: {
483
+ path: `${r}/db`
267
484
  }
268
- }, s = Pe(
485
+ }, c = Ge(
269
486
  "main",
270
487
  `${r}/storages/main`,
271
488
  "main-bucket",
272
- (te = e == null ? void 0 : e.storages) == null ? void 0 : te.primary
489
+ (Ae = e == null ? void 0 : e.storages) == null ? void 0 : Ae.primary
273
490
  );
274
491
  var n;
275
- switch ((ie = (ce = e == null ? void 0 : e.storages) == null ? void 0 : ce.work) == null ? void 0 : ie.type) {
492
+ switch ((Re = (Le = e == null ? void 0 : e.storages) == null ? void 0 : Le.work) == null ? void 0 : Re.type) {
276
493
  case void 0:
277
494
  case "FS":
278
- n = Ae("work"), n.rootPath = ((le = (se = e == null ? void 0 : e.storages) == null ? void 0 : se.work) == null ? void 0 : le.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((de = (ne = e == null ? void 0 : e.storages) == null ? void 0 : ne.work) == null ? void 0 : de.indexCachePeriod) ?? "1m";
495
+ n = Ve("work"), n.rootPath = ((_e = (pe = e == null ? void 0 : e.storages) == null ? void 0 : pe.work) == null ? void 0 : _e.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((Oe = ($e = e == null ? void 0 : e.storages) == null ? void 0 : $e.work) == null ? void 0 : Oe.indexCachePeriod) ?? "1m";
279
496
  break;
280
497
  default:
281
498
  throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
282
499
  }
283
- const f = Pe(
500
+ const u = Ge(
284
501
  "library",
285
502
  `${r}/storages/library`,
286
503
  "library-bucket",
287
- (ue = e == null ? void 0 : e.storages) == null ? void 0 : ue.library
288
- ), v = {
289
- enabled: x((ge = e == null ? void 0 : e.monitoring) == null ? void 0 : ge.enabled, !0),
290
- listen: ((he = e == null ? void 0 : e.monitoring) == null ? void 0 : he.listen) ?? "127.0.0.1:9090"
291
- }, h = {
292
- enabled: x((fe = e == null ? void 0 : e.debug) == null ? void 0 : fe.enabled, !0),
293
- listen: ((oe = e == null ? void 0 : e.debug) == null ? void 0 : oe.listen) ?? "127.0.0.1:9091"
294
- }, b = {
295
- value: ((me = e == null ? void 0 : e.license) == null ? void 0 : me.value) ?? "",
296
- file: ((ye = e == null ? void 0 : e.license) == null ? void 0 : ye.file) ?? ""
504
+ (Te = e == null ? void 0 : e.storages) == null ? void 0 : Te.library
505
+ ), g = {
506
+ enabled: z((Ee = e == null ? void 0 : e.monitoring) == null ? void 0 : Ee.enabled, !0),
507
+ listen: ((Fe = e == null ? void 0 : e.monitoring) == null ? void 0 : Fe.listen) ?? "127.0.0.1:9090"
508
+ }, v = {
509
+ enabled: z((De = e == null ? void 0 : e.debug) == null ? void 0 : De.enabled, !0),
510
+ listen: ((Ne = e == null ? void 0 : e.debug) == null ? void 0 : Ne.listen) ?? "127.0.0.1:9091"
511
+ }, P = {
512
+ value: ((Ie = e == null ? void 0 : e.license) == null ? void 0 : Ie.value) ?? "",
513
+ file: ((xe = e == null ? void 0 : e.license) == null ? void 0 : xe.file) ?? ""
297
514
  };
298
515
  return {
299
516
  localRoot: r,
300
- license: b,
301
- log: a,
517
+ license: P,
518
+ log: t,
302
519
  grpc: i,
303
- core: c,
304
- monitoring: v,
305
- debug: h,
306
- storages: { primary: s, work: n, library: f },
520
+ core: s,
521
+ monitoring: g,
522
+ debug: v,
523
+ storages: { primary: c, work: n, library: u },
307
524
  hacks: { libraryDownloadable: !0 }
308
525
  };
309
526
  }
310
- function Pe(t, e, r, a) {
527
+ function Ge(a, e, r, t) {
311
528
  var i;
312
- switch (a == null ? void 0 : a.type) {
529
+ switch (t == null ? void 0 : t.type) {
313
530
  case void 0:
314
531
  case "FS":
315
- i = Ae(t), i.rootPath = (a == null ? void 0 : a.rootPath) ?? e;
532
+ i = Ve(a), i.rootPath = (t == null ? void 0 : t.rootPath) ?? e;
316
533
  break;
317
534
  case "S3":
318
- i = pe(t), i.endpoint = (a == null ? void 0 : a.endpoint) ?? "http://localhost:9000", i.presignEndpoint = (a == null ? void 0 : a.presignEndpoint) ?? "http://localhost:9000", i.bucketName = (a == null ? void 0 : a.bucketName) ?? r, i.createBucket = x(a == null ? void 0 : a.createBucket, !0), i.forcePathStyle = x(a == null ? void 0 : a.forcePathStyle, !0), i.key = (a == null ? void 0 : a.key) ?? "", i.secret = (a == null ? void 0 : a.secret) ?? "", i.keyPrefix = (a == null ? void 0 : a.keyPrefix) ?? "", i.accessPrefixes = (a == null ? void 0 : a.accessPrefixes) ?? [""], i.uploadKeyPrefix = (a == null ? void 0 : a.uploadKeyPrefix) ?? "";
535
+ i = Tr(a), i.endpoint = (t == null ? void 0 : t.endpoint) ?? "http://localhost:9000", i.presignEndpoint = (t == null ? void 0 : t.presignEndpoint) ?? "http://localhost:9000", i.bucketName = (t == null ? void 0 : t.bucketName) ?? r, i.createBucket = z(t == null ? void 0 : t.createBucket, !0), i.forcePathStyle = z(t == null ? void 0 : t.forcePathStyle, !0), i.key = (t == null ? void 0 : t.key) ?? "", i.secret = (t == null ? void 0 : t.secret) ?? "", i.keyPrefix = (t == null ? void 0 : t.keyPrefix) ?? "", i.accessPrefixes = (t == null ? void 0 : t.accessPrefixes) ?? [""], i.uploadKeyPrefix = (t == null ? void 0 : t.uploadKeyPrefix) ?? "";
319
536
  break;
320
537
  default:
321
- throw C(), new Error("unknown storage type");
538
+ throw Y(), new Error("unknown storage type");
322
539
  }
323
540
  return i;
324
541
  }
325
- function Ge(t) {
326
- const e = t.monitoring.enabled ? "" : " disabled", r = t.debug.enabled ? "" : " disabled", a = t.hacks.libraryDownloadable ? "true" : "false";
327
- var i = t.license.value;
328
- return t.license.file != "" && (i = g.readFileSync(t.license.file).toString().trimEnd()), `
542
+ function Fr(a) {
543
+ const e = a.monitoring.enabled ? "" : " disabled", r = a.debug.enabled ? "" : " disabled", t = a.hacks.libraryDownloadable ? "true" : "false";
544
+ var i = a.license.value;
545
+ return a.license.file != "" && (i = o.readFileSync(a.license.file).toString().trimEnd()), `
329
546
  license:
330
- value: '${t.license.value}'
331
- file: '${t.license.file}'
547
+ value: '${a.license.value}'
548
+ file: '${a.license.file}'
332
549
 
333
550
  logging:
334
- level: '${t.log.level}'
551
+ level: '${a.log.level}'
335
552
  destinations:
336
- - path: '${t.log.path}'
553
+ - path: '${a.log.path}'
337
554
 
338
555
  monitoring${e}:
339
- listen: '${t.monitoring.listen}'
556
+ listen: '${a.monitoring.listen}'
340
557
 
341
558
  debug${r}:
342
- listen: '${t.debug.listen}'
559
+ listen: '${a.debug.listen}'
343
560
 
344
561
  core:
345
562
  logging:
@@ -347,20 +564,20 @@ core:
347
564
  dumpResourceData: true
348
565
 
349
566
  grpc:
350
- listen: '${t.grpc.listen}'
567
+ listen: '${a.grpc.listen}'
351
568
 
352
- tlsEnabled: ${JSON.stringify(t.grpc.tls.enable)}
569
+ tlsEnabled: ${JSON.stringify(a.grpc.tls.enable)}
353
570
  tls:
354
- clientAuthMode: '${t.grpc.tls.clientAuthMode}'
571
+ clientAuthMode: '${a.grpc.tls.clientAuthMode}'
355
572
  certificates:
356
- - certFile: '${t.grpc.tls.certFile}'
357
- keyFile: '${t.grpc.tls.keyFile}'
573
+ - certFile: '${a.grpc.tls.certFile}'
574
+ keyFile: '${a.grpc.tls.keyFile}'
358
575
 
359
576
 
360
- authEnabled: ${JSON.stringify(t.core.auth.enabled)}
361
- auth: ${JSON.stringify(t.core.auth.drivers)}
577
+ authEnabled: ${JSON.stringify(a.core.auth.enabled)}
578
+ auth: ${JSON.stringify(a.core.auth.drivers)}
362
579
  db:
363
- path: '${t.localRoot}/db'
580
+ path: '${a.core.db.path}'
364
581
 
365
582
  controllers:
366
583
  data:
@@ -372,36 +589,52 @@ controllers:
372
589
 
373
590
  library:
374
591
  mode: passive
375
- downloadable: ${a}
592
+ downloadable: ${t}
376
593
 
377
594
  work:
378
595
  mode: active
379
596
  downloadable: false
380
597
 
381
598
  storages:
382
- - ${JSON.stringify(t.storages.primary)}
383
- - ${JSON.stringify(t.storages.library)}
384
- - ${JSON.stringify(t.storages.work)}
599
+ - ${JSON.stringify(a.storages.primary)}
600
+ - ${JSON.stringify(a.storages.library)}
601
+ - ${JSON.stringify(a.storages.work)}
385
602
 
386
603
  runner:
387
604
  type: local
388
- storageRoot: '${t.storages.work.rootPath}'
605
+ storageRoot: '${a.storages.work.rootPath}'
389
606
  secrets:
390
607
  - map:
391
608
  MI_LICENSE: ${JSON.stringify(i)}
392
609
 
393
610
  packageLoader:
394
- packagesRoot: '${t.localRoot}/packages'
611
+ packagesRoot: '${a.localRoot}/packages'
395
612
 
396
613
  workflows: {}
397
614
  `;
398
615
  }
399
- function x(t, e) {
400
- return t === void 0 ? e : t;
616
+ function z(a, e) {
617
+ return a === void 0 ? e : a;
618
+ }
619
+ const Dr = ["linux", "macos", "windows"];
620
+ function Nr(a) {
621
+ const e = p.platform();
622
+ switch (e) {
623
+ case "darwin":
624
+ return "macos";
625
+ case "linux":
626
+ return "linux";
627
+ case "win32":
628
+ return "windows";
629
+ default:
630
+ throw new Error(
631
+ `operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(Dr)
632
+ );
633
+ }
401
634
  }
402
- const Ue = ["amd64", "arm64"];
403
- function Je(t) {
404
- const e = R.arch();
635
+ const Ir = ["amd64", "arm64"];
636
+ function Qe(a) {
637
+ const e = p.arch();
405
638
  switch (e) {
406
639
  case "arm64":
407
640
  return "arm64";
@@ -409,104 +642,150 @@ function Je(t) {
409
642
  return "amd64";
410
643
  default:
411
644
  throw new Error(
412
- `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Ue)
645
+ `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Ir)
413
646
  );
414
647
  }
415
648
  }
416
- function je(t) {
417
- return `pl-${(t == null ? void 0 : t.version) ?? Se()["pl-version"]}-${Je()}`;
649
+ function xr(a, e) {
650
+ const r = (e == null ? void 0 : e.version) ?? te()["pl-version"], t = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, i = `pl-${r}-${Qe()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${Nr()}/${i}`, c = (e == null ? void 0 : e.saveTo) ?? l.binaries(i);
651
+ if (o.existsSync(c))
652
+ return a.info(`Platforma Backend archive download skipped: '${c}' already exists`), Promise.resolve(c);
653
+ o.mkdirSync(f.dirname(c), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
654
+ URL: ${s}
655
+ Save to: ${c}`);
656
+ const n = lr.get(s);
657
+ return new Promise((h, u) => {
658
+ n.on("response", (g) => {
659
+ if (!g.statusCode) {
660
+ const b = new Error("failed to download archive: no HTTP status code in response from server");
661
+ n.destroy(), u(b);
662
+ return;
663
+ }
664
+ if (g.statusCode !== 200) {
665
+ const b = new Error(`failed to download archive: ${g.statusCode} ${g.statusMessage}`);
666
+ n.destroy(), u(b);
667
+ return;
668
+ }
669
+ const v = parseInt(g.headers["content-length"] || "0", 10);
670
+ let P = 0;
671
+ const d = o.createWriteStream(c);
672
+ g.pipe(d), g.on("data", (b) => {
673
+ P += b.length;
674
+ const w = P / v * 100;
675
+ t && process.stdout.write(` downloading: ${w.toFixed(2)}%\r`);
676
+ }), g.on("error", (b) => {
677
+ o.unlinkSync(c), a.error(`Failed to download Platforma Binary: ${b.message}`), n.destroy(), u(b);
678
+ }), d.on("finish", () => {
679
+ d.close(), a.info(" ... download done."), n.destroy(), h(c);
680
+ });
681
+ });
682
+ });
683
+ }
684
+ function Mr(a, e) {
685
+ a.debug("extracting archive...");
686
+ const r = (e == null ? void 0 : e.version) ?? te()["pl-version"];
687
+ a.debug(` version: '${r}'`);
688
+ const t = `${Ze({ version: r })}.tgz`, i = (e == null ? void 0 : e.archivePath) ?? l.binaries(t);
689
+ a.debug(` archive path: '${i}'`);
690
+ const s = (e == null ? void 0 : e.extractTo) ?? Br(i);
691
+ if (a.debug(` target dir: '${s}'`), o.existsSync(s))
692
+ return a.info(`Platforma Backend binaries unpack skipped: '${s}' exists`), s;
693
+ if (!o.existsSync(i)) {
694
+ const c = `Platforma Backend binary archive not found at '${i}'`;
695
+ throw a.error(c), new Error(c);
696
+ }
697
+ return o.existsSync(s) || (a.debug(` creating target dir '${s}'`), o.mkdirSync(s, { recursive: !0 })), a.info(`Unpacking Platforma Backend archive:
698
+ Archive: ${i}
699
+ Target dir: ${s}`), or.x({
700
+ file: i,
701
+ cwd: s,
702
+ gzip: !0,
703
+ sync: !0
704
+ }), a.info(" ... unpack done."), s;
705
+ }
706
+ function Xe(a, e) {
707
+ return xr(a, e).then((r) => Mr(a, { archivePath: r }));
708
+ }
709
+ function Ze(a) {
710
+ return `pl-${(a == null ? void 0 : a.version) ?? te()["pl-version"]}-${Qe()}`;
711
+ }
712
+ function Cr(a, ...e) {
713
+ return l.binaries(Ze({ version: a }), ...e);
418
714
  }
419
- function He(t, ...e) {
420
- return ke(je({ version: t }), ...e);
715
+ function Br(a) {
716
+ const e = a.lastIndexOf(".");
717
+ return e === -1 ? a : a.slice(0, e);
421
718
  }
422
- class q {
719
+ class D {
423
720
  constructor(e) {
424
721
  this.logger = e;
425
722
  }
426
723
  startLast() {
427
- const e = De(this.logger, { stdio: "inherit" });
428
- p(e, "failed to bring back Platforma Backend in the last started configuration");
724
+ const e = $r(this.logger, { stdio: "inherit" });
725
+ J(e, "failed to bring back Platforma Backend in the last started configuration");
429
726
  }
430
727
  startLocal(e) {
431
- var h, b, P, O, T, E, $, I, N, D;
432
- const r = (e == null ? void 0 : e.binaryPath) ?? He(e == null ? void 0 : e.version, "binaries", "platforma");
433
- var a = e == null ? void 0 : e.configPath;
434
- const i = (e == null ? void 0 : e.workdir) ?? (a ? process.cwd() : l.path());
728
+ var h, u, g, v, P, d, b, w, S, L;
729
+ const r = (e == null ? void 0 : e.binaryPath) ?? Cr(e == null ? void 0 : e.version, "binaries", "platforma");
730
+ var t = e == null ? void 0 : e.configPath;
731
+ const i = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : l.path());
435
732
  e != null && e.primaryURL && (e.configOptions = {
436
733
  ...e.configOptions,
437
734
  storages: {
438
735
  ...(h = e.configOptions) == null ? void 0 : h.storages,
439
- primary: S(e.primaryURL, i, (P = (b = e.configOptions) == null ? void 0 : b.storages) == null ? void 0 : P.primary)
736
+ primary: N(e.primaryURL, i, (g = (u = e.configOptions) == null ? void 0 : u.storages) == null ? void 0 : g.primary)
440
737
  }
441
738
  }), e != null && e.libraryURL && (e.configOptions = {
442
739
  ...e.configOptions,
443
740
  storages: {
444
- ...(O = e.configOptions) == null ? void 0 : O.storages,
445
- library: S(e.libraryURL, i, (E = (T = e.configOptions) == null ? void 0 : T.storages) == null ? void 0 : E.library)
741
+ ...(v = e.configOptions) == null ? void 0 : v.storages,
742
+ library: N(e.libraryURL, i, (d = (P = e.configOptions) == null ? void 0 : P.storages) == null ? void 0 : d.library)
446
743
  }
447
744
  });
448
- const c = Be(this.getLastJwt(), e == null ? void 0 : e.configOptions);
449
- this.logger.debug(" checking license..."), this.checkLicense((I = ($ = e == null ? void 0 : e.configOptions) == null ? void 0 : $.license) == null ? void 0 : I.value, (D = (N = e == null ? void 0 : e.configOptions) == null ? void 0 : N.license) == null ? void 0 : D.file);
450
- const s = [
451
- `${c.localRoot}/packages`,
452
- `${c.localRoot}/packages-local`,
453
- `${c.localRoot}/blocks-local`
745
+ const s = Er(this.getLastJwt(), e == null ? void 0 : e.configOptions);
746
+ this.logger.debug(" checking license..."), this.checkLicense((w = (b = e == null ? void 0 : e.configOptions) == null ? void 0 : b.license) == null ? void 0 : w.value, (L = (S = e == null ? void 0 : e.configOptions) == null ? void 0 : S.license) == null ? void 0 : L.file);
747
+ const c = [
748
+ `${s.localRoot}/packages`,
749
+ `${s.localRoot}/packages-local`,
750
+ `${s.localRoot}/blocks-local`
454
751
  ];
455
- c.storages.primary.type === "FS" && s.push(c.storages.primary.rootPath), c.storages.library.type === "FS" && (s.push(c.storages.library.rootPath), c.hacks.libraryDownloadable = !1), c.storages.work.type === "FS" && s.push(c.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
456
- for (const y of s)
457
- g.existsSync(y) || (this.logger.debug(` '${y}'`), g.mkdirSync(y, { recursive: !0 }));
458
- for (const y of c.core.auth.drivers)
459
- y.driver === "htpasswd" && (g.existsSync(y.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${y.path}...`), g.copyFileSync(k("users.htpasswd"), y.path)));
460
- a || (a = l.path("config-local.yaml"), this.logger.debug(` rendering configuration '${a}'...`), g.writeFileSync(a, Ge(c)));
461
- var n = [];
462
- const u = (y) => y.padStart(10, " ");
463
- switch (n.push(`${u("config")}: ${a}`), n.push(`${u("API")}: ${c.grpc.listen}`), n.push(`${u("log")}: ${c.log.path}`), c.storages.primary.type) {
464
- case "FS":
465
- n.push(`${u("primary")}: ${c.storages.primary.rootPath}`);
466
- break;
467
- case "S3":
468
- n.push(
469
- `${u("primary")}: S3 at '${c.storages.primary.endpoint ?? "AWS"}', bucket '${c.storages.primary.bucketName}', prefix: '${c.storages.primary.keyPrefix}'`
470
- );
471
- break;
472
- default:
473
- C();
474
- }
475
- switch (c.storages.library.type) {
476
- case "FS":
477
- n.push(`${u("library")}: ${c.storages.library.rootPath}`);
478
- break;
479
- case "S3":
480
- n.push(
481
- `${u("library")}: S3 at '${c.storages.library.endpoint ?? "AWS"}', bucket '${c.storages.library.bucketName}', prefix: '${c.storages.library.keyPrefix}'`
482
- );
483
- break;
484
- default:
485
- C();
486
- }
487
- return n.push(`${u("workdirs")}: ${c.storages.work.rootPath}`), this.logger.info(`Starting platforma:
488
- ${n.join(`
489
- `)}`), Ne(
752
+ s.storages.primary.type === "FS" && c.push(s.storages.primary.rootPath), s.storages.library.type === "FS" && (c.push(s.storages.library.rootPath), s.hacks.libraryDownloadable = !1), s.storages.work.type === "FS" && c.push(s.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
753
+ for (const k of c)
754
+ o.existsSync(k) || (this.logger.debug(` '${k}'`), o.mkdirSync(k, { recursive: !0 }));
755
+ for (const k of s.core.auth.drivers)
756
+ k.driver === "htpasswd" && (o.existsSync(k.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${k.path}...`), o.copyFileSync($("users.htpasswd"), k.path)));
757
+ t || (t = f.join(s.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${t}'...`), o.writeFileSync(t, Fr(s)));
758
+ const n = this.renderRunInfo({
759
+ configPath: t,
760
+ dbPath: s.core.db.path,
761
+ apiAddr: s.grpc.listen,
762
+ logPath: s.log.path,
763
+ primary: s.storages.primary,
764
+ work: s.storages.work,
765
+ library: s.storages.library
766
+ });
767
+ return this.logger.info(`Starting platforma:
768
+ ${n}`), _r(
490
769
  this.logger,
491
770
  r,
492
- ["-config", a],
771
+ ["-config", t],
493
772
  {
494
773
  cwd: i,
495
774
  stdio: "inherit"
496
775
  },
497
776
  {
498
- storagePath: c.localRoot
777
+ storagePath: s.localRoot
499
778
  }
500
779
  );
501
780
  }
502
781
  startLocalS3(e) {
503
782
  var i;
504
783
  this.logger.debug("starting platforma in 'local s3' mode...");
505
- const r = (e == null ? void 0 : e.minioPort) ?? 9e3, a = (i = e == null ? void 0 : e.configOptions) == null ? void 0 : i.localRoot;
784
+ const r = (e == null ? void 0 : e.minioPort) ?? 9e3, t = (i = e == null ? void 0 : e.configOptions) == null ? void 0 : i.localRoot;
506
785
  return this.startMinio({
507
786
  minioPort: r,
508
787
  minioConsolePort: e == null ? void 0 : e.minioConsolePort,
509
- storage: a ? o.join(a, "minio") : void 0
788
+ storage: t ? f.join(t, "minio") : void 0
510
789
  }), this.startLocal({
511
790
  ...e,
512
791
  primaryURL: (e == null ? void 0 : e.primaryURL) ?? `s3e://testuser:testpassword@localhost:${r}/main-bucket/?region=no-region`,
@@ -515,86 +794,95 @@ ${n.join(`
515
794
  }
516
795
  startMinio(e) {
517
796
  this.logger.debug(" starting minio...");
518
- var r = k("compose-backend.yaml");
519
- const a = e != null && e.version ? `:${e.version}` : "";
520
- this.logger.debug(` minio version: ${a}`);
521
- const i = (e == null ? void 0 : e.image) ?? `quay.io/minio/minio${a}`;
797
+ var r = $("compose-backend.yaml");
798
+ const t = e != null && e.version ? `:${e.version}` : "";
799
+ this.logger.debug(` minio version: ${t}`);
800
+ const i = (e == null ? void 0 : e.image) ?? `quay.io/minio/minio${t}`;
522
801
  this.logger.debug(` minio image: ${i}`);
523
- const c = (e == null ? void 0 : e.storage) ?? l.path("data", "minio"), s = l.path("data", "stub"), n = (e == null ? void 0 : e.minioPort) ?? 9e3, u = (e == null ? void 0 : e.minioConsolePort) ?? 9001, f = {
802
+ const s = (e == null ? void 0 : e.storage) ?? l.data("minio");
803
+ q(s);
804
+ const c = l.data("stub");
805
+ q(c);
806
+ const n = (e == null ? void 0 : e.minioPort) ?? 9e3, h = (e == null ? void 0 : e.minioConsolePort) ?? 9001, u = {
524
807
  MINIO_IMAGE: i,
525
- MINIO_STORAGE: o.resolve(c),
808
+ MINIO_STORAGE: f.resolve(s),
526
809
  MINIO_PORT: n.toString(),
527
- MINIO_CONSOLE_PORT: u.toString(),
528
- PL_DATA_DB_ROOT: s,
529
- PL_DATA_PRIMARY_ROOT: s,
530
- PL_DATA_LIBRARY_ROOT: s,
531
- PL_DATA_WORKDIR_ROOT: s,
532
- PL_DATA_PACKAGE_ROOT: s,
810
+ MINIO_CONSOLE_PORT: h.toString(),
811
+ PL_DATA_DB_ROOT: c,
812
+ PL_DATA_PRIMARY_ROOT: c,
813
+ PL_DATA_LIBRARY_ROOT: c,
814
+ PL_DATA_WORKDIR_ROOT: c,
815
+ PL_DATA_PACKAGE_ROOT: c,
533
816
  PL_IMAGE: "scratch"
534
817
  };
535
- this.readComposeFile(r), this.logger.debug(" spawning child 'docker' process...");
536
- const v = M(
818
+ this.logger.debug(" spawning child 'docker' process...");
819
+ const g = H(
537
820
  "docker",
538
821
  ["compose", `--file=${r}`, "up", "--detach", "--remove-orphans", "--pull=missing", "minio"],
539
822
  {
540
823
  env: {
541
824
  ...process.env,
542
- ...f
825
+ ...u
543
826
  },
544
827
  stdio: "inherit"
545
828
  }
546
829
  );
547
- p(v, "failed to start MinIO service in docker");
830
+ J(g, "failed to start MinIO service in docker");
548
831
  }
549
832
  buildPlatforma(e) {
550
- const r = o.resolve(e.repoRoot, "cmd", "platforma"), a = e.binPath ?? o.join(R.tmpdir(), "platforma-local-build");
551
- this.logger.info("Building Platforma Backend binary from sources"), this.logger.info(` sources path: ${e.repoRoot}`), this.logger.info(` binary path: ${a}`);
552
- const i = M("go", ["build", "-o", a, "."], {
833
+ const r = f.resolve(e.repoRoot, "cmd", "platforma"), t = e.binPath ?? f.join(p.tmpdir(), "platforma-local-build");
834
+ this.logger.info("Building Platforma Backend binary from sources"), this.logger.info(` sources path: ${e.repoRoot}`), this.logger.info(` binary path: ${t}`);
835
+ const i = H("go", ["build", "-o", t, "."], {
553
836
  cwd: r,
554
837
  stdio: "inherit"
555
838
  });
556
- return p(i, "failed to build platforma binary from sources using 'go build' command"), a;
839
+ return J(i, "failed to build platforma binary from sources using 'go build' command"), t;
557
840
  }
558
841
  startDockerS3(e, r) {
559
- const a = k("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? G(r == null ? void 0 : r.version);
842
+ const t = $("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? ie(r == null ? void 0 : r.version);
560
843
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
561
- const c = (h) => o.join(e, h), s = c("platforma.log");
562
- g.existsSync(s) || (g.mkdirSync(o.dirname(s), { recursive: !0 }), g.writeFileSync(s, ""));
563
- const n = S("s3e://testuser:testpassword@minio:9000/main-bucket");
564
- if (n.type !== "S3")
844
+ const s = (S) => f.join(e, S), c = (S) => {
845
+ const L = s(S);
846
+ return q(L), L;
847
+ }, n = s("platforma.log");
848
+ o.existsSync(n) || (o.mkdirSync(f.dirname(n), { recursive: !0 }), o.writeFileSync(n, ""));
849
+ const h = N("s3e://testuser:testpassword@minio:9000/main-bucket");
850
+ if (h.type !== "S3")
565
851
  throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
566
- n.presignEndpoint = "http://localhost:9000";
567
- const u = S("s3e://testuser:testpassword@minio:9000/library-bucket");
852
+ h.presignEndpoint = "http://localhost:9000";
853
+ const u = N("s3e://testuser:testpassword@minio:9000/library-bucket");
568
854
  if (u.type !== "S3")
569
855
  throw new Error(`${u.type} storage type is not supported for library storage`);
570
856
  u.presignEndpoint = "http://localhost:9000";
571
- const f = {
857
+ const g = c("db"), v = c("work"), P = s("users.htpasswd");
858
+ o.existsSync(P) || o.copyFileSync($("users.htpasswd"), P);
859
+ const d = {
572
860
  MINIO_IMAGE: "quay.io/minio/minio",
573
861
  MINIO_STORAGE: c("minio"),
574
862
  PL_IMAGE: i,
575
- PL_AUTH_HTPASSWD_PATH: k("users.htpasswd"),
863
+ PL_AUTH_HTPASSWD_PATH: P,
576
864
  PL_LICENSE: r == null ? void 0 : r.license,
577
865
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
578
- PL_LOG_LEVEL: "info",
579
- PL_LOG_FILE: s,
580
- PL_DATA_DB_ROOT: c("db"),
866
+ PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
867
+ PL_LOG_FILE: n,
868
+ PL_DATA_DB_ROOT: g,
581
869
  PL_DATA_PRIMARY_ROOT: c("primary"),
582
870
  PL_DATA_LIBRARY_ROOT: c("library"),
583
- PL_DATA_WORKDIR_ROOT: c("work"),
871
+ PL_DATA_WORKDIR_ROOT: v,
584
872
  PL_DATA_PACKAGE_ROOT: c("packages"),
585
- ...this.configureDockerStorage("primary", n),
873
+ ...this.configureDockerStorage("primary", h),
586
874
  ...this.configureDockerStorage("library", u)
587
875
  };
588
- if ((r == null ? void 0 : r["grpc-port"]) != null && (f.PL_GRPC_PORT = r["grpc-port"].toString()), (r == null ? void 0 : r["monitoring-port"]) != null && (f.PL_MONITORING_PORT = r["monitoring-port"].toString()), (r == null ? void 0 : r["debug-port"]) != null && (f.PL_DEBUG_PORT = r["debug-port"].toString()), r != null && r.auth && (r.auth.enabled && (f.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
589
- for (const h of r.auth.drivers)
590
- h.driver === "htpasswd" && (f.PL_AUTH_HTPASSWD_PATH = o.resolve(h.path), h.path = "/etc/platforma/users.htpasswd");
591
- f.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
876
+ if (r != null && r.grpcAddr && (d.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (d.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (d.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (d.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (d.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (d.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (d.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
877
+ for (const S of r.auth.drivers)
878
+ S.driver === "htpasswd" && (d.PL_AUTH_HTPASSWD_PATH = f.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
879
+ d.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
592
880
  }
593
- const v = ve(
881
+ const b = Be(
594
882
  this.logger,
595
883
  [
596
884
  "compose",
597
- `--file=${a}`,
885
+ `--file=${t}`,
598
886
  "up",
599
887
  "--detach",
600
888
  "--remove-orphans",
@@ -603,56 +891,87 @@ ${n.join(`
603
891
  "backend"
604
892
  ],
605
893
  {
606
- env: f,
894
+ env: d,
607
895
  stdio: "inherit"
608
896
  },
609
897
  {
610
898
  plImage: i,
611
- composePath: a
899
+ composePath: t
612
900
  }
613
901
  );
614
- p(v, "failed to start Platforma Backend in Docker"), l.isActive = !0;
902
+ J(b, "failed to start Platforma Backend in Docker"), l.isActive = !0;
903
+ const w = this.renderRunInfo({
904
+ apiPort: r == null ? void 0 : r.grpcPort,
905
+ apiAddr: r == null ? void 0 : r.grpcAddr,
906
+ logPath: n,
907
+ primary: h,
908
+ work: { type: "FS", rootPath: v },
909
+ library: u,
910
+ dbPath: g
911
+ });
912
+ this.logger.info(`Started platforma:
913
+ ${w}`);
615
914
  }
616
915
  startDocker(e, r) {
617
- var a = k("compose-backend.yaml");
618
- const i = (r == null ? void 0 : r.image) ?? G(r == null ? void 0 : r.version);
916
+ var t = $("compose-backend.yaml");
917
+ const i = (r == null ? void 0 : r.image) ?? ie(r == null ? void 0 : r.version);
619
918
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
620
- const c = (P) => o.join(e, P), s = c("primary"), n = c("work"), u = c("library"), f = S((r == null ? void 0 : r.primaryStorageURL) ?? "file:.", "."), v = S((r == null ? void 0 : r.libraryStorageURL) ?? "file:.", "."), h = {
919
+ const s = (k) => f.join(e, k), c = (k) => {
920
+ const _ = s(k);
921
+ return q(_), _;
922
+ }, n = s("platforma.log");
923
+ o.existsSync(n) || (o.mkdirSync(f.dirname(n), { recursive: !0 }), o.writeFileSync(n, ""));
924
+ const h = c("db"), u = c("primary"), g = c("library"), v = c("work"), P = s("users.htpasswd");
925
+ o.existsSync(P) || o.copyFileSync($("users.htpasswd"), P);
926
+ const d = N((r == null ? void 0 : r.primaryStorageURL) ?? `file:${u}`, "."), b = N((r == null ? void 0 : r.libraryStorageURL) ?? `file:${g}`, "."), w = {
621
927
  MINIO_IMAGE: "quay.io/minio/minio",
622
928
  MINIO_STORAGE: c("minio"),
623
929
  PL_IMAGE: i,
624
- PL_AUTH_HTPASSWD_PATH: k("users.htpasswd"),
930
+ PL_AUTH_HTPASSWD_PATH: P,
625
931
  PL_LICENSE: r == null ? void 0 : r.license,
626
932
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
627
- PL_DATA_DB_ROOT: c("db"),
628
- PL_DATA_PRIMARY_ROOT: s,
629
- PL_DATA_LIBRARY_ROOT: u,
630
- PL_DATA_WORKDIR_ROOT: c("work"),
933
+ PL_LOG_LEVEL: "info",
934
+ PL_LOG_FILE: n,
935
+ PL_DATA_DB_ROOT: h,
936
+ PL_DATA_PRIMARY_ROOT: u,
937
+ PL_DATA_LIBRARY_ROOT: g,
938
+ PL_DATA_WORKDIR_ROOT: v,
631
939
  PL_DATA_PACKAGE_ROOT: c("packages"),
632
- ...this.configureDockerStorage("primary", f),
633
- ...this.configureDockerStorage("library", v)
940
+ ...this.configureDockerStorage("primary", d),
941
+ ...this.configureDockerStorage("library", b)
634
942
  };
635
- if ((r == null ? void 0 : r["grpc-port"]) != null && (h.PL_GRPC_PORT = r["grpc-port"].toString()), (r == null ? void 0 : r["monitoring-port"]) != null && (h.PL_MONITORING_PORT = r["monitoring-port"].toString()), (r == null ? void 0 : r["debug-port"]) != null && (h.PL_DEBUG_PORT = r["debug-port"].toString()), this.readComposeFile(a), r != null && r.auth && (r.auth.enabled && (h.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
636
- for (const P of r.auth.drivers)
637
- P.driver === "htpasswd" && (h.PL_AUTH_HTPASSWD_PATH = o.resolve(P.path), P.path = "/etc/platforma/users.htpasswd");
638
- h.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
943
+ 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)) {
944
+ for (const k of r.auth.drivers)
945
+ k.driver === "htpasswd" && (w.PL_AUTH_HTPASSWD_PATH = f.resolve(k.path), k.path = "/etc/platforma/users.htpasswd");
946
+ w.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
639
947
  }
640
- const b = ve(
948
+ const S = Be(
641
949
  this.logger,
642
- ["compose", `--file=${a}`, "up", "--detach", "--remove-orphans", "--pull=missing", "backend"],
950
+ ["compose", `--file=${t}`, "up", "--detach", "--remove-orphans", "--pull=missing", "backend"],
643
951
  {
644
- env: h,
952
+ env: w,
645
953
  stdio: "inherit"
646
954
  },
647
955
  {
648
956
  plImage: i,
649
- composePath: a,
650
- primaryPath: s,
651
- workPath: n,
652
- libraryPath: u
957
+ composePath: t,
958
+ primaryPath: u,
959
+ workPath: v,
960
+ libraryPath: g
653
961
  }
654
962
  );
655
- p(b, "failed to start Platforma Backend in Docker"), l.isActive = !0;
963
+ J(S, "failed to start Platforma Backend in Docker"), l.isActive = !0;
964
+ const L = this.renderRunInfo({
965
+ apiPort: r == null ? void 0 : r.grpcPort,
966
+ apiAddr: r == null ? void 0 : r.grpcAddr,
967
+ logPath: n,
968
+ primary: d,
969
+ work: { type: "FS", rootPath: v },
970
+ library: b,
971
+ dbPath: h
972
+ });
973
+ this.logger.info(`Started platforma:
974
+ ${L}`);
656
975
  }
657
976
  stop() {
658
977
  if (!l.isActive) {
@@ -662,7 +981,7 @@ ${n.join(`
662
981
  const e = l.lastRun;
663
982
  switch (e.mode) {
664
983
  case "docker":
665
- const r = M("docker", ["compose", "--file", e.docker.composePath, "down"], {
984
+ const r = H("docker", ["compose", "--file", e.docker.composePath, "down"], {
666
985
  env: {
667
986
  ...process.env,
668
987
  ...e.envs
@@ -672,84 +991,95 @@ ${n.join(`
672
991
  l.isActive = !1, r.status !== 0 && process.exit(r.status);
673
992
  return;
674
993
  case "process":
675
- l.isActive = !1, process.kill(e.process.pid);
994
+ l.isValidPID && process.kill(e.process.pid), l.isActive = !1;
676
995
  return;
677
996
  default:
678
- C(e.mode);
997
+ Y(e.mode);
679
998
  }
680
999
  }
681
1000
  cleanup() {
682
- var s, n, u, f, v, h;
1001
+ var n, h, u, g, v, P, d, b, w, S, L, k, _, W;
683
1002
  const e = [
684
1003
  "last command run cache ('pl-service start' shorthand will stop working until next full start command call)",
685
1004
  "'platforma' docker compose service containers and volumes"
686
- ], r = [l.path("data")];
687
- (n = (s = l.lastRun) == null ? void 0 : s.docker) != null && n.primaryPath && r.push(l.lastRun.docker.primaryPath), (f = (u = l.lastRun) == null ? void 0 : u.process) != null && f.storagePath && r.push(l.lastRun.process.storagePath);
688
- const a = r.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in the service instance):
689
- - ${r.join(`
1005
+ ], r = l.data(), t = [r];
1006
+ if ((h = (n = l.lastRun) == null ? void 0 : n.docker) != null && h.primaryPath) {
1007
+ const A = (g = (u = l.lastRun) == null ? void 0 : u.docker) == null ? void 0 : g.primaryPath;
1008
+ A.startsWith(r) || t.push(A);
1009
+ }
1010
+ if ((P = (v = l.lastRun) == null ? void 0 : v.docker) != null && P.workPath) {
1011
+ const A = (b = (d = l.lastRun) == null ? void 0 : d.docker) == null ? void 0 : b.workPath;
1012
+ A.startsWith(r) || t.push(A);
1013
+ }
1014
+ if ((S = (w = l.lastRun) == null ? void 0 : w.process) != null && S.storagePath) {
1015
+ const A = (k = (L = l.lastRun) == null ? void 0 : L.process) == null ? void 0 : k.storagePath;
1016
+ A.startsWith(r) || t.push(A);
1017
+ }
1018
+ const i = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
1019
+ - ${t.join(`
690
1020
  - `)}` : "";
691
- var i = `
1021
+ var s = `
692
1022
  You are going to reset the state of platforma service
693
1023
  Things to be removed:
694
1024
  - ${e.join(`
695
1025
  - `)}
696
- ${a}
1026
+ ${i}
697
1027
  `;
698
- if (this.logger.warn(i), !Me("Are you sure?")) {
1028
+ if (this.logger.warn(s), !mr("Are you sure?")) {
699
1029
  this.logger.info("Reset action was canceled");
700
1030
  return;
701
1031
  }
702
- const c = new Set(Ie());
703
- (h = (v = l.lastRun) == null ? void 0 : v.docker) != null && h.composePath && c.add(l.lastRun.docker.composePath);
704
- for (const b of c)
705
- this.logger.info(`Destroying docker compose '${b}'`), this.destroyDocker(b, G());
706
- for (const b of r)
707
- this.logger.info(`Destroying '${b}'`), g.rmSync(b, { recursive: !0, force: !0 });
708
- this.logger.info(`Destroying state dir '${l.path()}'`), g.rmSync(l.path(), { recursive: !0, force: !0 }), this.logger.info(
1032
+ const c = new Set(pr());
1033
+ (W = (_ = l.lastRun) == null ? void 0 : _.docker) != null && W.composePath && c.add(l.lastRun.docker.composePath);
1034
+ for (const A of c)
1035
+ this.logger.info(`Destroying docker compose '${A}'`), this.destroyDocker(A, ie());
1036
+ for (const A of t)
1037
+ this.logger.info(`Destroying '${A}'`), o.rmSync(A, { recursive: !0, force: !0 });
1038
+ this.logger.info(`Destroying state dir '${l.path()}'`), o.rmSync(l.path(), { recursive: !0, force: !0 }), this.logger.info(
709
1039
  `
710
- If you want to remove all downloaded platforma binaries, delete '${ke()}' dir manually
1040
+ If you want to remove all downloaded platforma binaries, delete '${l.binaries()}' dir manually
711
1041
  `
712
1042
  );
713
1043
  }
714
1044
  mergeLicenseEnvs(e) {
715
- e.license === void 0 && ((process.env.MI_LICENSE ?? "") != "" ? e.license = process.env.MI_LICENSE : (process.env.PL_LICENSE ?? "") != "" && (e.license = process.env.PL_LICENSE)), e["license-file"] === void 0 && e.license === void 0 && ((process.env.MI_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.MI_LICENSE_FILE : (process.env.PL_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.PL_LICENSE_FILE : g.existsSync(o.resolve(R.homedir(), ".pl.license")) && (e["license-file"] = o.resolve(R.homedir(), ".pl.license")));
1045
+ e.license === void 0 && ((process.env.MI_LICENSE ?? "") != "" ? e.license = process.env.MI_LICENSE : (process.env.PL_LICENSE ?? "") != "" && (e.license = process.env.PL_LICENSE)), e["license-file"] === void 0 && e.license === void 0 && ((process.env.MI_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.MI_LICENSE_FILE : (process.env.PL_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.PL_LICENSE_FILE : o.existsSync(f.resolve(p.homedir(), ".pl.license")) && (e["license-file"] = f.resolve(p.homedir(), ".pl.license")));
716
1046
  }
717
1047
  initAuthDriversList(e, r) {
718
- var a = [];
719
- if (e["auth-htpasswd-file"] && a.push({
1048
+ var t = [];
1049
+ if (e["auth-htpasswd-file"] && t.push({
720
1050
  driver: "htpasswd",
721
- path: o.resolve(r, e["auth-htpasswd-file"])
1051
+ path: f.resolve(r, e["auth-htpasswd-file"])
722
1052
  }), !!e["auth-ldap-server"] != !!e["auth-ldap-default-dn"])
723
1053
  throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");
724
- if (e["auth-ldap-server"] && a.push({
1054
+ if (e["auth-ldap-server"] && t.push({
725
1055
  driver: "ldap",
726
1056
  serverUrl: e["auth-ldap-server"],
727
1057
  defaultDN: e["auth-ldap-default-dn"]
728
- }), a.length !== 0)
729
- return [{ driver: "jwt", key: this.getLastJwt() }, ...a];
1058
+ }), t.length !== 0)
1059
+ return [{ driver: "jwt", key: this.getLastJwt() }, ...t];
730
1060
  }
731
1061
  /** Gets the last stored JWT secret key or generates it and stores in a file. */
732
1062
  getLastJwt() {
733
1063
  const e = l.path("auth.jwt"), r = "utf-8";
734
- let a = "";
1064
+ let t = "";
735
1065
  try {
736
- a = g.readFileSync(e, { encoding: r });
1066
+ t = o.readFileSync(e, { encoding: r });
737
1067
  } catch {
738
1068
  }
739
- return a == "" && (a = Ce(64), g.writeFileSync(e, a, { encoding: r })), a;
1069
+ return t == "" && (t = yr(64), o.writeFileSync(e, t, { encoding: r })), t;
740
1070
  }
741
1071
  destroyDocker(e, r) {
742
- const a = l.path("data", "stub"), i = M("docker", ["compose", "--file", e, "down", "--volumes", "--remove-orphans"], {
1072
+ const t = l.data("stub"), i = H("docker", ["compose", "--file", e, "down", "--volumes", "--remove-orphans"], {
743
1073
  env: {
744
1074
  ...process.env,
745
1075
  PL_IMAGE: "scratch",
746
- PL_DATA_DB_ROOT: a,
747
- PL_DATA_PRIMARY_ROOT: a,
748
- PL_DATA_LIBRARY_ROOT: a,
749
- PL_DATA_WORKDIR_ROOT: a,
750
- PL_DATA_PACKAGE_ROOT: a,
1076
+ PL_DATA_DB_ROOT: t,
1077
+ PL_DATA_PRIMARY_ROOT: t,
1078
+ PL_DATA_LIBRARY_ROOT: t,
1079
+ PL_DATA_WORKDIR_ROOT: t,
1080
+ PL_DATA_PACKAGE_ROOT: t,
751
1081
  MINIO_IMAGE: "scratch",
752
- MINIO_STORAGE: a
1082
+ MINIO_STORAGE: t
753
1083
  },
754
1084
  stdio: "inherit"
755
1085
  });
@@ -770,163 +1100,293 @@ or stored in '$HOME/.pl.license'.
770
1100
  You can obtain the license from "https://licensing.milaboratories.com".`), new Error("The license was not provided.");
771
1101
  }
772
1102
  configureDockerStorage(e, r) {
773
- const a = {}, i = r.type;
1103
+ const t = {}, i = r.type;
774
1104
  switch (e = e.toUpperCase(), i) {
775
1105
  case "S3":
776
- return a[`PL_DATA_${e}_TYPE`] = "S3", a[`PL_DATA_${e}_S3_BUCKET`] = r.bucketName, r.endpoint && (a[`PL_DATA_${e}_S3_ENDPOINT`] = r.endpoint), r.presignEndpoint && (a[`PL_DATA_${e}_S3_PRESIGN_ENDPOINT`] = r.presignEndpoint), r.region && (a[`PL_DATA_${e}_S3_REGION`] = r.region), r.key && (a[`PL_DATA_${e}_S3_KEY`] = r.key), r.secret && (a[`PL_DATA_${e}_S3_SECRET`] = r.secret), a;
1106
+ return t[`PL_DATA_${e}_TYPE`] = "S3", t[`PL_DATA_${e}_S3_BUCKET`] = r.bucketName, r.endpoint && (t[`PL_DATA_${e}_S3_ENDPOINT`] = r.endpoint), r.presignEndpoint && (t[`PL_DATA_${e}_S3_PRESIGN_ENDPOINT`] = r.presignEndpoint), r.region && (t[`PL_DATA_${e}_S3_REGION`] = r.region), r.key && (t[`PL_DATA_${e}_S3_KEY`] = r.key), r.secret && (t[`PL_DATA_${e}_S3_SECRET`] = r.secret), t;
777
1107
  case "FS":
778
- return a[`PL_DATA_${e}_TYPE`] = "FS", a;
1108
+ return t[`PL_DATA_${e}_TYPE`] = "FS", t;
779
1109
  default:
780
- C();
1110
+ Y();
781
1111
  }
782
1112
  return {};
783
1113
  }
1114
+ renderRunInfo(e, r = 10) {
1115
+ var n, h;
1116
+ const t = [], i = (u) => u.padStart(r, " ");
1117
+ switch (e.configPath && t.push(`${i("config")}: ${e.configPath}`), e.apiAddr ? t.push(`${i("API")}: ${e.apiAddr}`) : e.apiPort ? t.push(`${i("API")}: 127.0.0.1:${e.apiPort.toString()}`) : t.push(`${i("API")}: 127.0.0.1:6345`), e.logPath && t.push(`${i("log")}: ${e.logPath}`), (n = e.primary) == null ? void 0 : n.type) {
1118
+ case void 0:
1119
+ break;
1120
+ case "FS":
1121
+ t.push(`${i("primary")}: ${e.primary.rootPath}`);
1122
+ break;
1123
+ case "S3":
1124
+ t.push(
1125
+ `${i("primary")}: S3 at '${e.primary.endpoint ?? "AWS"}', bucket '${e.primary.bucketName}', prefix: '${e.primary.keyPrefix ?? ""}'`
1126
+ );
1127
+ break;
1128
+ default:
1129
+ Y();
1130
+ }
1131
+ switch ((h = e.library) == null ? void 0 : h.type) {
1132
+ case void 0:
1133
+ break;
1134
+ case "FS":
1135
+ t.push(`${i("library")}: ${e.library.rootPath}`);
1136
+ break;
1137
+ case "S3":
1138
+ t.push(
1139
+ `${i("library")}: S3 at '${e.library.endpoint ?? "AWS"}', bucket '${e.library.bucketName}', prefix: '${e.library.keyPrefix ?? ""}'`
1140
+ );
1141
+ break;
1142
+ default:
1143
+ Y();
1144
+ }
1145
+ return e.work && t.push(`${i("workdirs")}: ${e.work.rootPath}`), e.dbPath && t.push(`${i("db")}: ${e.dbPath}`), t.join(`
1146
+ `);
1147
+ }
784
1148
  readComposeFile(e) {
785
- const r = g.readFileSync(e);
786
- return be.parse(r.toString());
1149
+ const r = o.readFileSync(e);
1150
+ return Ce.parse(r.toString());
787
1151
  }
788
1152
  writeComposeFile(e, r) {
789
- g.writeFileSync(e, be.stringify(r));
1153
+ o.writeFileSync(e, Ce.stringify(r));
790
1154
  }
791
1155
  }
792
- function p(t, e) {
793
- if (t.error)
794
- throw t.error;
1156
+ function J(a, e) {
1157
+ if (a.error)
1158
+ throw a.error;
795
1159
  const r = e ?? "failed to run command";
796
- if (t.status !== 0)
797
- throw new Error(`${r}, process exited with code '${t.status}'`);
1160
+ if (a.status !== 0)
1161
+ throw new Error(`${r}, process exited with code '${a.status}'`);
798
1162
  }
799
- const z = {
800
- "log-level": d.string({
801
- description: "logging level",
802
- default: "info",
803
- options: ["error", "warn", "info", "debug"],
804
- required: !1
805
- })
1163
+ const x = class x extends O {
1164
+ async run() {
1165
+ const { flags: e } = await this.parse(x), r = E(e["log-level"]);
1166
+ new D(r).cleanup();
1167
+ }
806
1168
  };
807
- d.string({
808
- description: "use custom docker image to run platforma"
809
- });
810
- d.string({
811
- description: "use custom platforma release (official docker image or binary package)"
812
- });
813
- d.string({
814
- description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
815
- }), d.file({
816
- exists: !0,
817
- description: "specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
818
- });
819
- d.integer({
820
- description: "port that the platform's grpc server will listen, by default it's 6345",
821
- default: 6345,
822
- env: "PLATFORMA_GRPC_PORT"
823
- }), d.integer({
824
- description: "port that the platform's monitoring server will listen, by default it's 9090",
825
- default: 9090,
826
- env: "PLATFORMA_MONITORING_PORT"
827
- }), d.integer({
828
- description: "port that the platform's debug server will listen, by default it's 9091",
829
- default: 9091,
830
- env: "PLATFORMA_DEBUG_PORT"
831
- });
832
- d.integer({
833
- description: "port that S3 will listen, default is 9000",
834
- default: 9e3,
835
- env: "PLATFORMA_S3_PORT"
836
- }), d.integer({
837
- description: "port that a console of S3 will listen, default is 9001",
838
- default: 9001,
839
- env: "PLATFORMA_S3_CONSOLE_PORT"
840
- });
841
- d.string({
842
- description: "specify path on host to be used as storage for all Platforma Backend data"
843
- });
844
- d.file({
845
- description: "specify path for Platforma Backend log file"
846
- });
847
- d.file({
848
- description: "specify working directory for Platforma Backend process"
849
- });
850
- d.file({
851
- description: "start given Platforma Backend binary instead of automatically downloaded version"
852
- });
853
- d.file({
854
- description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
855
- });
856
- d.string({
857
- description: "use custom Platforma Backend config"
858
- });
859
- d.file({
860
- description: "specify path on host to be used as 'primary' storage"
861
- });
862
- d.file({
863
- description: "specify path on host to be used as 'work' storage"
864
- });
865
- d.file({
866
- description: "specify path on host to be used as 'library' storage"
867
- });
868
- d.string({
869
- description: `specify 'primary' storage destination URL.
870
- file:/path/to/dir for directory on local FS
871
- s3://<bucket>/?region=<name> for real AWS bucket
872
- s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
873
- s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
874
- });
875
- d.string({
876
- description: `specify 'library' storage destination URL.
877
- file:/path/to/dir for directory on local FS
878
- s3://<bucket>/?region=<name> for real AWS bucket
879
- s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
880
- s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
881
- });
882
- d.boolean({
883
- description: "enable authorization"
1169
+ m(x, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), m(x, "examples", ["<%= config.bin %> <%= command.id %>"]), m(x, "flags", {
1170
+ ...T
884
1171
  });
885
- d.file({
886
- description: "path to .htpasswd file with Platforma users (static user DB auth source)"
887
- });
888
- d.string({
889
- description: "address of LDAP server to use for auth in Platforma (auth source)"
1172
+ let ne = x;
1173
+ const M = class M extends O {
1174
+ async run() {
1175
+ const { flags: e } = await this.parse(M), r = E(e["log-level"]);
1176
+ new D(r).startLast();
1177
+ }
1178
+ };
1179
+ m(M, "description", "Start last run service configuraiton"), m(M, "examples", ["<%= config.bin %> <%= command.id %>"]), m(M, "flags", {
1180
+ ...T
890
1181
  });
891
- d.string({
892
- description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"
1182
+ let le = M;
1183
+ const C = class C extends O {
1184
+ async run() {
1185
+ const { flags: e } = await this.parse(C), r = E(e["log-level"]);
1186
+ new D(r).stop();
1187
+ }
1188
+ };
1189
+ m(C, "description", "Stop platforma service"), m(C, "examples", ["<%= config.bin %> <%= command.id %>"]), m(C, "flags", {
1190
+ ...T
893
1191
  });
894
- const _ = class _ extends W {
1192
+ let oe = C;
1193
+ const B = class B extends O {
895
1194
  async run() {
896
- const { flags: e } = await this.parse(_), r = K(e["log-level"]);
897
- new q(r).stop();
1195
+ const { flags: e } = await this.parse(B), r = E(e["log-level"]), t = new D(r);
1196
+ t.mergeLicenseEnvs(e);
1197
+ const i = e["auth-enabled"], s = i ? {
1198
+ enabled: i,
1199
+ drivers: t.initAuthDriversList(e, ".")
1200
+ } : void 0, c = e.storage ? f.join(".", e.storage) : l.data("docker");
1201
+ t.startDocker(c, {
1202
+ primaryStorageURL: e["storage-primary"],
1203
+ workStoragePath: e["storage-work"],
1204
+ libraryStorageURL: e["storage-library"],
1205
+ image: e.image,
1206
+ version: e.version,
1207
+ license: e.license,
1208
+ licenseFile: e["license-file"],
1209
+ auth: s,
1210
+ grpcAddr: e["grpc-listen"],
1211
+ grpcPort: e["grpc-port"],
1212
+ monitoringAddr: e["monitoring-listen"],
1213
+ monitoringPort: e["monitoring-port"],
1214
+ debugAddr: e["debug-listen"],
1215
+ debugPort: e["debug-port"]
1216
+ });
898
1217
  }
899
1218
  };
900
- m(_, "description", "Stop platforma service"), m(_, "examples", ["<%= config.bin %> <%= command.id %>"]), m(_, "flags", {
901
- ...z
1219
+ m(B, "description", "Run platforma backend service with 'FS' primary storage type"), m(B, "examples", ["<%= config.bin %> <%= command.id %>"]), m(B, "flags", {
1220
+ ...T,
1221
+ ...Z,
1222
+ ...Ue,
1223
+ ...Q,
1224
+ ...re,
1225
+ ...X,
1226
+ ...ee,
1227
+ ...he,
1228
+ ...fe,
1229
+ ...me
902
1230
  });
903
- let J = _;
904
- const A = class A extends W {
1231
+ let de = B;
1232
+ const G = class G extends O {
905
1233
  async run() {
906
- const { flags: e } = await this.parse(A), r = K(e["log-level"]);
907
- new q(r).cleanup();
1234
+ const { flags: e } = await this.parse(G), r = E(e["log-level"]), t = new D(r);
1235
+ t.mergeLicenseEnvs(e);
1236
+ const i = e["pl-workdir"] ?? ".", s = e.storage ? f.join(i, e.storage) : l.data("local"), c = e["pl-log-file"] ? f.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), h = e["auth-enabled"] ?? n !== void 0;
1237
+ var u = e["pl-binary"];
1238
+ e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1239
+ var g = "127.0.0.1:6345";
1240
+ e["grpc-listen"] ? g = e["grpc-listen"] : e["grpc-port"] && (g = `127.0.0.1:${e["grpc-port"]}`);
1241
+ var v = "127.0.0.1:9090";
1242
+ e["monitoring-listen"] ? v = e["monitoring-listen"] : e["monitoring-port"] && (v = `127.0.0.1:${e["monitoring-port"]}`);
1243
+ var P = "127.0.0.1:9091";
1244
+ e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
1245
+ const d = {
1246
+ binaryPath: u,
1247
+ version: e.version,
1248
+ configPath: e.config,
1249
+ workdir: e["pl-workdir"],
1250
+ primaryURL: e["storage-primary"],
1251
+ libraryURL: e["storage-library"],
1252
+ configOptions: {
1253
+ grpc: { listen: g },
1254
+ monitoring: { listen: v },
1255
+ debug: { listen: P },
1256
+ license: { value: e.license, file: e["license-file"] },
1257
+ log: { path: c },
1258
+ localRoot: s,
1259
+ core: { auth: { enabled: h, drivers: n } },
1260
+ storages: {
1261
+ work: { type: "FS", rootPath: e["storage-work"] }
1262
+ }
1263
+ }
1264
+ };
1265
+ d.binaryPath ? t.startLocal(d) : Xe(r, { version: e.version }).then(() => t.startLocal(d)).catch(function(b) {
1266
+ r.error(b.message);
1267
+ });
908
1268
  }
909
1269
  };
910
- m(A, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), m(A, "examples", ["<%= config.bin %> <%= command.id %>"]), m(A, "flags", {
911
- ...z
1270
+ m(G, "description", "Run Platforma Backend service as local process on current host (no docker container)"), m(G, "examples", ["<%= config.bin %> <%= command.id %>"]), m(G, "flags", {
1271
+ ...T,
1272
+ ...Q,
1273
+ ...Z,
1274
+ ...Je,
1275
+ ...He,
1276
+ ...Ye,
1277
+ ...X,
1278
+ ...ee,
1279
+ ...he,
1280
+ ...fe,
1281
+ ...me,
1282
+ ...We,
1283
+ ...je,
1284
+ ...re
912
1285
  });
913
- let j = A;
914
- const L = class L extends W {
1286
+ let ge = G;
1287
+ var R;
1288
+ let Gr = (R = class extends O {
1289
+ async run() {
1290
+ const { flags: e } = await this.parse(R), r = E(e["log-level"]), t = new D(r);
1291
+ t.mergeLicenseEnvs(e);
1292
+ const i = e["auth-enabled"], s = i ? {
1293
+ enabled: i,
1294
+ drivers: t.initAuthDriversList(e, ".")
1295
+ } : void 0, c = e.storage ? f.join(".", e.storage) : l.data("docker-s3");
1296
+ t.startDockerS3(c, {
1297
+ image: e.image,
1298
+ version: e.version,
1299
+ license: e.license,
1300
+ licenseFile: e["license-file"],
1301
+ auth: s,
1302
+ grpcAddr: e["grpc-listen"],
1303
+ grpcPort: e["grpc-port"],
1304
+ monitoringAddr: e["monitoring-listen"],
1305
+ monitoringPort: e["monitoring-port"],
1306
+ debugAddr: e["debug-listen"],
1307
+ debugPort: e["debug-port"]
1308
+ });
1309
+ }
1310
+ }, m(R, "description", "Run platforma backend service with 'S3' primary storage type"), m(R, "examples", ["<%= config.bin %> <%= command.id %>"]), m(R, "flags", {
1311
+ ...T,
1312
+ ...Z,
1313
+ ...Ue,
1314
+ ...Q,
1315
+ ...ee,
1316
+ ...X,
1317
+ ...re
1318
+ }), R);
1319
+ const U = class U extends O {
915
1320
  async run() {
916
- const { flags: e } = await this.parse(L), r = K(e["log-level"]);
917
- new q(r).startLast();
1321
+ const { flags: e } = await this.parse(U), r = E(e["log-level"]), t = new D(r);
1322
+ t.mergeLicenseEnvs(e);
1323
+ const i = e["pl-workdir"] ?? ".", s = e.storage ? f.join(i, e.storage) : l.data("local-s3"), c = e["pl-log-file"] ? f.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), h = e["auth-enabled"] ?? n !== void 0;
1324
+ var u = e["pl-binary"];
1325
+ e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1326
+ var g = "127.0.0.1:6345";
1327
+ e["grpc-listen"] ? g = e["grpc-listen"] : e["grpc-port"] && (g = `127.0.0.1:${e["grpc-port"]}`);
1328
+ var v = "127.0.0.1:9090";
1329
+ e["monitoring-listen"] ? v = e["monitoring-listen"] : e["monitoring-port"] && (v = `127.0.0.1:${e["monitoring-port"]}`);
1330
+ var P = "127.0.0.1:9091";
1331
+ e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
1332
+ const d = {
1333
+ binaryPath: u,
1334
+ version: e.version,
1335
+ configPath: e.config,
1336
+ workdir: e["pl-workdir"],
1337
+ primaryURL: e["storage-primary"],
1338
+ libraryURL: e["storage-library"],
1339
+ minioPort: e["s3-address-port"],
1340
+ minioConsolePort: e["s3-console-address-port"],
1341
+ configOptions: {
1342
+ grpc: { listen: g },
1343
+ monitoring: { listen: v },
1344
+ debug: { listen: P },
1345
+ license: { value: e.license, file: e["license-file"] },
1346
+ log: { path: c },
1347
+ localRoot: s,
1348
+ core: {
1349
+ auth: { enabled: h, drivers: n }
1350
+ },
1351
+ storages: {
1352
+ work: { type: "FS", rootPath: e["storage-work"] }
1353
+ }
1354
+ }
1355
+ };
1356
+ d.binaryPath ? t.startLocalS3(d) : Xe(r, { version: e.version }).then(() => t.startLocalS3(d)).catch(function(b) {
1357
+ r.error(b.message);
1358
+ });
918
1359
  }
919
1360
  };
920
- m(L, "description", "Start last run service configuraiton"), m(L, "examples", ["<%= config.bin %> <%= command.id %>"]), m(L, "flags", {
921
- ...z
1361
+ m(U, "description", "Run Platforma Backend service as local process on current host (no docker container)"), m(U, "examples", ["<%= config.bin %> <%= command.id %>"]), m(U, "flags", {
1362
+ ...T,
1363
+ ...Q,
1364
+ ...Z,
1365
+ ...dr,
1366
+ ...Je,
1367
+ ...He,
1368
+ ...Ye,
1369
+ ...X,
1370
+ ...ee,
1371
+ ...he,
1372
+ ...fe,
1373
+ ...me,
1374
+ ...We,
1375
+ ...je,
1376
+ ...re
922
1377
  });
923
- let H = L;
924
- const ar = {
925
- stop: J,
926
- start: H,
927
- reset: j
1378
+ let ue = U;
1379
+ const rt = {
1380
+ "create-block": se,
1381
+ reset: ne,
1382
+ start: le,
1383
+ stop: oe,
1384
+ "start:docker": de,
1385
+ "start:local": ge,
1386
+ "start:docker:s3": Gr,
1387
+ "start:local:s3": ue
928
1388
  };
929
1389
  export {
930
- ar as COMMANDS
1390
+ rt as COMMANDS
931
1391
  };
932
1392
  //# sourceMappingURL=index.mjs.map