@platforma-sdk/bootstrap 5.2.41 → 5.2.43

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 (168) hide show
  1. package/README.md +10 -2
  2. package/assets/compose-backend.yaml +2 -2
  3. package/bin/run.js +3 -3
  4. package/dist/block.cjs +36 -31
  5. package/dist/block.cjs.map +1 -1
  6. package/dist/block.d.ts +2 -2
  7. package/dist/block.d.ts.map +1 -1
  8. package/dist/block.js +36 -31
  9. package/dist/block.js.map +1 -1
  10. package/dist/cmd-opts.cjs +74 -74
  11. package/dist/cmd-opts.cjs.map +1 -1
  12. package/dist/cmd-opts.d.ts +23 -23
  13. package/dist/cmd-opts.d.ts.map +1 -1
  14. package/dist/cmd-opts.js +74 -74
  15. package/dist/cmd-opts.js.map +1 -1
  16. package/dist/commands/create-block.cjs +3 -3
  17. package/dist/commands/create-block.cjs.map +1 -1
  18. package/dist/commands/create-block.d.ts +2 -2
  19. package/dist/commands/create-block.d.ts.map +1 -1
  20. package/dist/commands/create-block.js +3 -3
  21. package/dist/commands/create-block.js.map +1 -1
  22. package/dist/commands/reset.cjs +3 -3
  23. package/dist/commands/reset.cjs.map +1 -1
  24. package/dist/commands/reset.d.ts +2 -2
  25. package/dist/commands/reset.d.ts.map +1 -1
  26. package/dist/commands/reset.js +3 -3
  27. package/dist/commands/reset.js.map +1 -1
  28. package/dist/commands/start/docker/s3.cjs +18 -18
  29. package/dist/commands/start/docker/s3.cjs.map +1 -1
  30. package/dist/commands/start/docker/s3.d.ts +15 -15
  31. package/dist/commands/start/docker/s3.d.ts.map +1 -1
  32. package/dist/commands/start/docker/s3.js +18 -18
  33. package/dist/commands/start/docker/s3.js.map +1 -1
  34. package/dist/commands/start/docker.cjs +18 -18
  35. package/dist/commands/start/docker.cjs.map +1 -1
  36. package/dist/commands/start/docker.d.ts +16 -16
  37. package/dist/commands/start/docker.d.ts.map +1 -1
  38. package/dist/commands/start/docker.js +18 -18
  39. package/dist/commands/start/docker.js.map +1 -1
  40. package/dist/commands/start/local/s3.cjs +36 -34
  41. package/dist/commands/start/local/s3.cjs.map +1 -1
  42. package/dist/commands/start/local/s3.d.ts +18 -18
  43. package/dist/commands/start/local/s3.d.ts.map +1 -1
  44. package/dist/commands/start/local/s3.js +36 -34
  45. package/dist/commands/start/local/s3.js.map +1 -1
  46. package/dist/commands/start/local.cjs +32 -30
  47. package/dist/commands/start/local.cjs.map +1 -1
  48. package/dist/commands/start/local.d.ts +16 -16
  49. package/dist/commands/start/local.d.ts.map +1 -1
  50. package/dist/commands/start/local.js +32 -30
  51. package/dist/commands/start/local.js.map +1 -1
  52. package/dist/commands/start.cjs +3 -3
  53. package/dist/commands/start.cjs.map +1 -1
  54. package/dist/commands/start.d.ts +2 -2
  55. package/dist/commands/start.js +3 -3
  56. package/dist/commands/start.js.map +1 -1
  57. package/dist/commands/stop.cjs +4 -4
  58. package/dist/commands/stop.cjs.map +1 -1
  59. package/dist/commands/stop.d.ts +2 -2
  60. package/dist/commands/stop.js +4 -4
  61. package/dist/commands/stop.js.map +1 -1
  62. package/dist/commands/svc/create/arg-parser.cjs +13 -13
  63. package/dist/commands/svc/create/arg-parser.cjs.map +1 -1
  64. package/dist/commands/svc/create/arg-parser.d.ts +1 -1
  65. package/dist/commands/svc/create/arg-parser.js +13 -13
  66. package/dist/commands/svc/create/arg-parser.js.map +1 -1
  67. package/dist/commands/svc/create/docker/s3.cjs +27 -27
  68. package/dist/commands/svc/create/docker/s3.cjs.map +1 -1
  69. package/dist/commands/svc/create/docker/s3.d.ts +15 -15
  70. package/dist/commands/svc/create/docker/s3.d.ts.map +1 -1
  71. package/dist/commands/svc/create/docker/s3.js +27 -27
  72. package/dist/commands/svc/create/docker/s3.js.map +1 -1
  73. package/dist/commands/svc/create/docker.cjs +35 -35
  74. package/dist/commands/svc/create/docker.cjs.map +1 -1
  75. package/dist/commands/svc/create/docker.d.ts +16 -16
  76. package/dist/commands/svc/create/docker.js +35 -35
  77. package/dist/commands/svc/create/docker.js.map +1 -1
  78. package/dist/commands/svc/create/local/s3.cjs +37 -35
  79. package/dist/commands/svc/create/local/s3.cjs.map +1 -1
  80. package/dist/commands/svc/create/local/s3.d.ts +18 -18
  81. package/dist/commands/svc/create/local/s3.d.ts.map +1 -1
  82. package/dist/commands/svc/create/local/s3.js +37 -35
  83. package/dist/commands/svc/create/local/s3.js.map +1 -1
  84. package/dist/commands/svc/create/local.cjs +35 -35
  85. package/dist/commands/svc/create/local.cjs.map +1 -1
  86. package/dist/commands/svc/create/local.d.ts +16 -16
  87. package/dist/commands/svc/create/local.d.ts.map +1 -1
  88. package/dist/commands/svc/create/local.js +35 -35
  89. package/dist/commands/svc/create/local.js.map +1 -1
  90. package/dist/commands/svc/delete.cjs +4 -4
  91. package/dist/commands/svc/delete.cjs.map +1 -1
  92. package/dist/commands/svc/delete.d.ts +2 -2
  93. package/dist/commands/svc/delete.js +4 -4
  94. package/dist/commands/svc/delete.js.map +1 -1
  95. package/dist/commands/svc/down.cjs +3 -3
  96. package/dist/commands/svc/down.cjs.map +1 -1
  97. package/dist/commands/svc/down.d.ts +2 -2
  98. package/dist/commands/svc/down.js +3 -3
  99. package/dist/commands/svc/down.js.map +1 -1
  100. package/dist/commands/svc/list.cjs +5 -5
  101. package/dist/commands/svc/list.cjs.map +1 -1
  102. package/dist/commands/svc/list.d.ts +1 -1
  103. package/dist/commands/svc/list.d.ts.map +1 -1
  104. package/dist/commands/svc/list.js +5 -5
  105. package/dist/commands/svc/list.js.map +1 -1
  106. package/dist/commands/svc/up.cjs +5 -5
  107. package/dist/commands/svc/up.cjs.map +1 -1
  108. package/dist/commands/svc/up.d.ts +2 -2
  109. package/dist/commands/svc/up.d.ts.map +1 -1
  110. package/dist/commands/svc/up.js +5 -5
  111. package/dist/commands/svc/up.js.map +1 -1
  112. package/dist/core.cjs +261 -231
  113. package/dist/core.cjs.map +1 -1
  114. package/dist/core.d.ts +10 -10
  115. package/dist/core.d.ts.map +1 -1
  116. package/dist/core.js +261 -231
  117. package/dist/core.js.map +1 -1
  118. package/dist/index.cjs +16 -16
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.ts +29 -29
  121. package/dist/index.js +16 -16
  122. package/dist/index.js.map +1 -1
  123. package/dist/package.cjs +2 -2
  124. package/dist/package.cjs.map +1 -1
  125. package/dist/package.js +2 -2
  126. package/dist/package.js.map +1 -1
  127. package/dist/platforma.cjs +24 -24
  128. package/dist/platforma.cjs.map +1 -1
  129. package/dist/platforma.d.ts +1 -1
  130. package/dist/platforma.d.ts.map +1 -1
  131. package/dist/platforma.js +24 -24
  132. package/dist/platforma.js.map +1 -1
  133. package/dist/run.cjs +6 -6
  134. package/dist/run.cjs.map +1 -1
  135. package/dist/run.d.ts +3 -3
  136. package/dist/run.d.ts.map +1 -1
  137. package/dist/run.js +6 -6
  138. package/dist/run.js.map +1 -1
  139. package/dist/state.cjs +16 -14
  140. package/dist/state.cjs.map +1 -1
  141. package/dist/state.d.ts +5 -5
  142. package/dist/state.d.ts.map +1 -1
  143. package/dist/state.js +16 -14
  144. package/dist/state.js.map +1 -1
  145. package/dist/templates/compose.cjs +2 -2
  146. package/dist/templates/compose.cjs.map +1 -1
  147. package/dist/templates/compose.d.ts.map +1 -1
  148. package/dist/templates/compose.js +2 -2
  149. package/dist/templates/compose.js.map +1 -1
  150. package/dist/templates/pl-config.cjs +49 -49
  151. package/dist/templates/pl-config.cjs.map +1 -1
  152. package/dist/templates/pl-config.d.ts +2 -2
  153. package/dist/templates/pl-config.d.ts.map +1 -1
  154. package/dist/templates/pl-config.js +49 -49
  155. package/dist/templates/pl-config.js.map +1 -1
  156. package/dist/templates/types.cjs +12 -12
  157. package/dist/templates/types.cjs.map +1 -1
  158. package/dist/templates/types.d.ts +6 -6
  159. package/dist/templates/types.d.ts.map +1 -1
  160. package/dist/templates/types.js +12 -12
  161. package/dist/templates/types.js.map +1 -1
  162. package/dist/util.cjs +19 -17
  163. package/dist/util.cjs.map +1 -1
  164. package/dist/util.d.ts +2 -2
  165. package/dist/util.d.ts.map +1 -1
  166. package/dist/util.js +19 -17
  167. package/dist/util.js.map +1 -1
  168. package/package.json +23 -22
package/dist/core.js CHANGED
@@ -17,8 +17,8 @@ class Core {
17
17
  startLast() {
18
18
  const instance = state.currentInstance;
19
19
  if (!instance) {
20
- this.logger.error('failed to bring back Platforma Backend in the last started configuration: no last configuration found');
21
- throw new Error('no previous run info found');
20
+ this.logger.error("failed to bring back Platforma Backend in the last started configuration: no last configuration found");
21
+ throw new Error("no previous run info found");
22
22
  }
23
23
  return this.startInstance(instance);
24
24
  }
@@ -29,7 +29,7 @@ class Core {
29
29
  }
30
30
  const result = runCommands(this.logger, instance.upCommands);
31
31
  checkRunError(result.executed);
32
- if (result.spawned.length > 0 && instance.type === 'process') {
32
+ if (result.spawned.length > 0 && instance.type === "process") {
33
33
  instance.pid = result.spawned[result.spawned.length - 1].pid;
34
34
  state.setInstanceInfo(instance.name, instance);
35
35
  this.logger.info(`instance '${instance.name}' started`);
@@ -43,10 +43,10 @@ class Core {
43
43
  checkRunError(result.executed);
44
44
  const iType = instance.type;
45
45
  switch (iType) {
46
- case 'docker': {
46
+ case "docker": {
47
47
  return;
48
48
  }
49
- case 'process': {
49
+ case "process": {
50
50
  if (instance.pid && state.isInstanceActive(instance)) {
51
51
  process.kill(instance.pid);
52
52
  }
@@ -69,9 +69,9 @@ class Core {
69
69
  return this.startInstance(instance);
70
70
  }
71
71
  createLocal(instanceName, options) {
72
- let plBinaryPath = binaryPath(options?.version, 'binaries', 'platforma');
72
+ let plBinaryPath = binaryPath(options?.version, "binaries", "platforma");
73
73
  if (options?.sourcesPath) {
74
- plBinaryPath = path.join(os__default.tmpdir(), 'platforma-custom-build');
74
+ plBinaryPath = path.join(os__default.tmpdir(), "platforma-custom-build");
75
75
  }
76
76
  if (options?.binaryPath) {
77
77
  plBinaryPath = options.binaryPath;
@@ -104,17 +104,17 @@ class Core {
104
104
  `${configOptions.localRoot}/packages-local`,
105
105
  `${configOptions.localRoot}/blocks-local`,
106
106
  ];
107
- if (configOptions.storages.primary.type === 'FS') {
107
+ if (configOptions.storages.primary.type === "FS") {
108
108
  storageDirs.push(configOptions.storages.primary.rootPath);
109
109
  }
110
- if (configOptions.storages.library.type === 'FS') {
110
+ if (configOptions.storages.library.type === "FS") {
111
111
  storageDirs.push(configOptions.storages.library.rootPath);
112
112
  configOptions.hacks.libraryDownloadable = false;
113
113
  }
114
- if (configOptions.storages.work.type === 'FS') {
114
+ if (configOptions.storages.work.type === "FS") {
115
115
  storageDirs.push(configOptions.storages.work.rootPath);
116
116
  }
117
- this.logger.debug(' creating pl state directories...');
117
+ this.logger.debug(" creating pl state directories...");
118
118
  for (const dir of storageDirs) {
119
119
  if (!fs__default.existsSync(dir)) {
120
120
  this.logger.debug(` '${dir}'`);
@@ -122,36 +122,36 @@ class Core {
122
122
  }
123
123
  }
124
124
  for (const drv of configOptions.core.auth.drivers) {
125
- if (drv.driver === 'htpasswd') {
125
+ if (drv.driver === "htpasswd") {
126
126
  if (!fs__default.existsSync(drv.path)) {
127
127
  this.logger.debug(` installing default 'users.htpasswd' to ${drv.path}...`);
128
- fs__default.copyFileSync(assets('users.htpasswd'), drv.path);
128
+ fs__default.copyFileSync(assets("users.htpasswd"), drv.path);
129
129
  }
130
130
  }
131
131
  }
132
132
  if (!configPath) {
133
- configPath = path.join(configOptions.localRoot, 'config.yaml');
133
+ configPath = path.join(configOptions.localRoot, "config.yaml");
134
134
  this.logger.debug(` rendering configuration '${configPath}'...`);
135
135
  fs__default.writeFileSync(configPath, render(configOptions));
136
136
  }
137
137
  const upCommands = [];
138
138
  if (options?.sourcesPath) {
139
139
  upCommands.push({
140
- cmd: 'go',
141
- args: ['build', '-o', plBinaryPath, '.'],
142
- workdir: path.resolve(options.sourcesPath, 'cmd', 'platforma'),
140
+ cmd: "go",
141
+ args: ["build", "-o", plBinaryPath, "."],
142
+ workdir: path.resolve(options.sourcesPath, "cmd", "platforma"),
143
143
  runOpts: {
144
- stdio: 'inherit',
144
+ stdio: "inherit",
145
145
  },
146
146
  });
147
147
  }
148
148
  const runBinary = {
149
149
  async: true,
150
150
  cmd: plBinaryPath,
151
- args: ['--quiet', '--config', configPath],
151
+ args: ["--quiet", "--config", configPath],
152
152
  workdir: workdir,
153
153
  runOpts: {
154
- stdio: 'inherit',
154
+ stdio: "inherit",
155
155
  },
156
156
  };
157
157
  if (options?.configOptions?.numCpu) {
@@ -165,7 +165,7 @@ class Core {
165
165
  runBinary.runOpts.env = {};
166
166
  }
167
167
  for (const cmd of options.backendCommands) {
168
- const equalIndex = cmd.indexOf('=');
168
+ const equalIndex = cmd.indexOf("=");
169
169
  if (equalIndex > 0) {
170
170
  const key = cmd.substring(0, equalIndex);
171
171
  const value = cmd.substring(equalIndex + 1);
@@ -178,13 +178,13 @@ class Core {
178
178
  }
179
179
  // Process additional backend commands
180
180
  if (options?.backendCommands && options.backendCommands.length > 0) {
181
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
181
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
182
182
  // Add commands as arguments to the binary
183
183
  runBinary.args = [...runBinary.args, ...options.backendCommands];
184
184
  }
185
185
  upCommands.push(runBinary);
186
186
  state.setInstanceInfo(instanceName, {
187
- type: 'process',
187
+ type: "process",
188
188
  upCommands: upCommands,
189
189
  downCommands: [],
190
190
  cleanupCommands: [],
@@ -201,47 +201,38 @@ class Core {
201
201
  return state.getInstanceInfo(instanceName);
202
202
  }
203
203
  createLocalS3(instanceName, options) {
204
- this.logger.debug('creating platforma instance in \'local s3\' mode...');
204
+ this.logger.debug("creating platforma instance in 'local s3' mode...");
205
205
  const minioPort = options?.minioPort ?? 9000;
206
206
  const instance = this.createLocal(instanceName, {
207
207
  ...options,
208
- primaryURL: options?.primaryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
209
- libraryURL: options?.libraryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
208
+ primaryURL: options?.primaryURL ??
209
+ `s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
210
+ libraryURL: options?.libraryURL ??
211
+ `s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
210
212
  });
211
213
  const localRoot = options?.configOptions?.localRoot;
212
214
  const minioRunCmd = this.createMinio(instanceName, {
213
215
  minioPort: minioPort,
214
216
  minioConsolePort: options?.minioConsolePort,
215
- storage: localRoot ? path.join(localRoot, 'minio') : undefined,
217
+ storage: localRoot ? path.join(localRoot, "minio") : undefined,
216
218
  });
217
- instance.upCommands = [
218
- minioRunCmd.start,
219
- ...instance.upCommands,
220
- ];
221
- instance.downCommands = [
222
- minioRunCmd.stop,
223
- ...instance.downCommands,
224
- ];
225
- instance.cleanupCommands = [
226
- minioRunCmd.cleanup,
227
- ...instance.cleanupCommands,
228
- ];
219
+ instance.upCommands = [minioRunCmd.start, ...instance.upCommands];
220
+ instance.downCommands = [minioRunCmd.stop, ...instance.downCommands];
221
+ instance.cleanupCommands = [minioRunCmd.cleanup, ...instance.cleanupCommands];
229
222
  state.setInstanceInfo(instanceName, instance);
230
223
  return instance;
231
224
  }
232
225
  createMinio(instanceName, options) {
233
- this.logger.debug(' creating docker compose for minio service...');
234
- const composeSrc = assets('compose-backend.yaml');
235
- const composeMinio = state.instanceDir(instanceName, 'compose-minio.yaml');
236
- render$1(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([
237
- ['minio', {}],
238
- ]), { dropVolumes: true });
239
- const version = options?.version ? `:${options.version}` : '';
226
+ this.logger.debug(" creating docker compose for minio service...");
227
+ const composeSrc = assets("compose-backend.yaml");
228
+ const composeMinio = state.instanceDir(instanceName, "compose-minio.yaml");
229
+ render$1(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([["minio", {}]]), { dropVolumes: true });
230
+ const version = options?.version ? `:${options.version}` : "";
240
231
  this.logger.debug(` minio version: ${version}`);
241
232
  const image = options?.image ?? `quay.io/minio/minio${version}`;
242
233
  this.logger.debug(` minio image: ${image}`);
243
- const storage = options?.storage ?? state.instanceDir(instanceName, 'minio');
244
- ensureDir(storage, { mode: '0775' });
234
+ const storage = options?.storage ?? state.instanceDir(instanceName, "minio");
235
+ ensureDir(storage, { mode: "0775" });
245
236
  const minioPort = options?.minioPort ?? 9000;
246
237
  const minioConsolePort = options?.minioConsolePort ?? 9001;
247
238
  const envs = {
@@ -252,67 +243,74 @@ class Core {
252
243
  };
253
244
  return {
254
245
  start: {
255
- cmd: 'docker',
256
- args: ['compose', `--file=${composeMinio}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
246
+ cmd: "docker",
247
+ args: [
248
+ "compose",
249
+ `--file=${composeMinio}`,
250
+ "up",
251
+ "--detach",
252
+ "--remove-orphans",
253
+ "--pull=missing",
254
+ ],
257
255
  envs: envs,
258
256
  workdir: state.instanceDir(instanceName),
259
- runOpts: { stdio: 'inherit' },
257
+ runOpts: { stdio: "inherit" },
260
258
  },
261
259
  stop: {
262
- cmd: 'docker',
263
- args: ['compose', `--file=${composeMinio}`, 'down'],
260
+ cmd: "docker",
261
+ args: ["compose", `--file=${composeMinio}`, "down"],
264
262
  envs: envs,
265
263
  workdir: state.instanceDir(instanceName),
266
- runOpts: { stdio: 'inherit' },
264
+ runOpts: { stdio: "inherit" },
267
265
  },
268
266
  cleanup: {
269
- cmd: 'docker',
270
- args: ['compose', `--file=${composeMinio}`, 'down', '--volumes', '--remove-orphans'],
267
+ cmd: "docker",
268
+ args: ["compose", `--file=${composeMinio}`, "down", "--volumes", "--remove-orphans"],
271
269
  envs: envs,
272
270
  workdir: state.instanceDir(instanceName),
273
- runOpts: { stdio: 'inherit' },
271
+ runOpts: { stdio: "inherit" },
274
272
  },
275
273
  };
276
274
  }
277
275
  createDockerS3(instanceName, localRoot, options) {
278
- this.logger.debug('creating platforma instance in \'docker s3\' mode...');
279
- const composeS3Path = assets('compose-backend.yaml');
276
+ this.logger.debug("creating platforma instance in 'docker s3' mode...");
277
+ const composeS3Path = assets("compose-backend.yaml");
280
278
  const image = options?.image ?? plImageTag(options?.version);
281
279
  this.checkLicense(options?.license, options?.licenseFile);
282
280
  const storagePath = (...s) => path.join(localRoot, ...s);
283
281
  const storageDir = (s) => {
284
282
  const p = storagePath(s);
285
- ensureDir(p, { mode: '0775' });
283
+ ensureDir(p, { mode: "0775" });
286
284
  return p;
287
285
  };
288
- const logFilePath = storagePath('logs', 'platforma.log');
286
+ const logFilePath = storagePath("logs", "platforma.log");
289
287
  if (!fs__default.existsSync(logFilePath)) {
290
288
  fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
291
- fs__default.writeFileSync(logFilePath, '');
289
+ fs__default.writeFileSync(logFilePath, "");
292
290
  }
293
- const presignHost = options?.presignHost ?? 'localhost';
291
+ const presignHost = options?.presignHost ?? "localhost";
294
292
  const presignPort = options?.s3Port ?? 9000;
295
293
  const primary = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-primary-bucket`);
296
- if (primary.type !== 'S3') {
297
- throw new Error('primary storage must have \'S3\' type in \'docker s3\' configuration');
294
+ if (primary.type !== "S3") {
295
+ throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
298
296
  }
299
297
  else {
300
298
  primary.presignEndpoint = `http://${presignHost}:${presignPort}`;
301
299
  }
302
300
  const library = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-library-bucket`);
303
- if (library.type !== 'S3') {
301
+ if (library.type !== "S3") {
304
302
  throw new Error(`${library.type} storage type is not supported for library storage`);
305
303
  }
306
304
  else {
307
305
  library.presignEndpoint = `http://${presignHost}:${presignPort}`;
308
306
  }
309
- const dbFSPath = storageDir('db');
310
- const workFSPath = storageDir('work');
311
- const usersFSPath = storagePath('users.htpasswd');
307
+ const dbFSPath = storageDir("db");
308
+ const workFSPath = storageDir("work");
309
+ const usersFSPath = storagePath("users.htpasswd");
312
310
  if (!fs__default.existsSync(usersFSPath)) {
313
- fs__default.copyFileSync(assets('users.htpasswd'), usersFSPath);
311
+ fs__default.copyFileSync(assets("users.htpasswd"), usersFSPath);
314
312
  }
315
- const composeDstPath = storagePath('compose.yaml');
313
+ const composeDstPath = storagePath("compose.yaml");
316
314
  if (fs__default.existsSync(composeDstPath)) {
317
315
  this.logger.info(`replacing docker compose file ${composeDstPath}`);
318
316
  }
@@ -324,35 +322,38 @@ class Core {
324
322
  });
325
323
  }
326
324
  render$1(composeS3Path, composeDstPath, `pl-${instanceName}`, new Map([
327
- ['minio', {}],
328
- ['backend', {
325
+ ["minio", {}],
326
+ [
327
+ "backend",
328
+ {
329
329
  platform: options?.platformOverride,
330
330
  mounts: backendMounts,
331
331
  commands: options?.backendCommands,
332
- }],
332
+ },
333
+ ],
333
334
  ]));
334
335
  const envs = {
335
- MINIO_IMAGE: 'quay.io/minio/minio',
336
- MINIO_STORAGE: storageDir('minio'),
336
+ MINIO_IMAGE: "quay.io/minio/minio",
337
+ MINIO_STORAGE: storageDir("minio"),
337
338
  PL_IMAGE: image,
338
339
  PL_AUTH_HTPASSWD: usersFSPath,
339
340
  PL_LICENSE: options?.license,
340
341
  PL_LICENSE_FILE: options?.licenseFile,
341
- PL_LOG_LEVEL: options?.logLevel ?? 'info',
342
+ PL_LOG_LEVEL: options?.logLevel ?? "info",
342
343
  PL_LOG_DIR: path.dirname(logFilePath),
343
- PL_LOG_ROTATION_ENABLED: 'true',
344
- PL_RUNNER_WD_CACHE_ON_FAILURE: '1h',
344
+ PL_LOG_ROTATION_ENABLED: "true",
345
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
345
346
  PL_DATA_DB_ROOT: dbFSPath,
346
- PL_DATA_PRIMARY_ROOT: storageDir('primary'),
347
- PL_DATA_LIBRARY_ROOT: storageDir('library'),
347
+ PL_DATA_PRIMARY_ROOT: storageDir("primary"),
348
+ PL_DATA_LIBRARY_ROOT: storageDir("library"),
348
349
  PL_DATA_WORKDIR_ROOT: workFSPath,
349
350
  // Mount packages storage as volume, because APFS is case-insensitive on Mac OS X and this breaks some pl software installation.
350
351
  // PL_DATA_PACKAGE_ROOT: storageDir('packages'),
351
- ...this.configureDockerStorage('primary', primary),
352
- ...this.configureDockerStorage('library', library),
352
+ ...this.configureDockerStorage("primary", primary),
353
+ ...this.configureDockerStorage("library", library),
353
354
  };
354
355
  if (options?.grpcAddr) {
355
- const addrParts = options.grpcAddr.split(':');
356
+ const addrParts = options.grpcAddr.split(":");
356
357
  if (addrParts.length === 2) {
357
358
  envs.PL_LISTEN_ADDRESS = addrParts[0];
358
359
  envs.PL_LISTEN_PORT = addrParts[1];
@@ -365,7 +366,7 @@ class Core {
365
366
  envs.PL_LISTEN_PORT = options.grpcPort.toString();
366
367
  }
367
368
  if (options?.monitoringAddr) {
368
- const addrParts = options.monitoringAddr.split(':');
369
+ const addrParts = options.monitoringAddr.split(":");
369
370
  if (addrParts.length === 2) {
370
371
  envs.PL_MONITORING_IP = addrParts[0];
371
372
  envs.PL_MONITORING_PORT = addrParts[1];
@@ -378,7 +379,7 @@ class Core {
378
379
  envs.PL_MONITORING_PORT = options.monitoringPort.toString();
379
380
  }
380
381
  if (options?.debugAddr) {
381
- const addrParts = options.debugAddr.split(':');
382
+ const addrParts = options.debugAddr.split(":");
382
383
  if (addrParts.length === 2) {
383
384
  envs.PL_DEBUG_IP = addrParts[0];
384
385
  envs.PL_DEBUG_PORT = addrParts[1];
@@ -396,51 +397,64 @@ class Core {
396
397
  envs.MINIO_CONSOLE_PORT = options.s3ConsolePort.toString();
397
398
  if (options?.auth) {
398
399
  if (options.auth.enabled) {
399
- envs['PL_NO_AUTH'] = 'false';
400
+ envs["PL_NO_AUTH"] = "false";
400
401
  }
401
402
  else {
402
- envs['PL_NO_AUTH'] = 'true';
403
+ envs["PL_NO_AUTH"] = "true";
403
404
  }
404
405
  if (options.auth.drivers) {
405
406
  for (const drv of options.auth.drivers) {
406
- if (drv.driver === 'htpasswd') {
407
- envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
408
- drv.path = '/etc/platforma/users.htpasswd';
407
+ if (drv.driver === "htpasswd") {
408
+ envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
409
+ drv.path = "/etc/platforma/users.htpasswd";
409
410
  }
410
411
  }
411
- envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
412
+ envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
412
413
  }
413
414
  }
414
415
  // Process additional backend commands
415
416
  if (options?.backendCommands && options.backendCommands.length > 0) {
416
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
417
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
417
418
  }
418
419
  state.setInstanceInfo(instanceName, {
419
- type: 'docker',
420
- upCommands: [{
421
- cmd: 'docker',
422
- args: ['compose', `--file=${composeDstPath}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
420
+ type: "docker",
421
+ upCommands: [
422
+ {
423
+ cmd: "docker",
424
+ args: [
425
+ "compose",
426
+ `--file=${composeDstPath}`,
427
+ "up",
428
+ "--detach",
429
+ "--remove-orphans",
430
+ "--pull=missing",
431
+ ],
423
432
  envs: envs,
424
- runOpts: { stdio: 'inherit' },
425
- }],
426
- downCommands: [{
427
- cmd: 'docker',
428
- args: ['compose', `--file=${composeDstPath}`, 'down'],
433
+ runOpts: { stdio: "inherit" },
434
+ },
435
+ ],
436
+ downCommands: [
437
+ {
438
+ cmd: "docker",
439
+ args: ["compose", `--file=${composeDstPath}`, "down"],
429
440
  envs: envs,
430
- runOpts: { stdio: 'inherit' },
431
- }],
432
- cleanupCommands: [{
433
- cmd: 'docker',
434
- args: ['compose', `--file=${composeDstPath}`, 'down', '--volumes', '--remove-orphans'],
441
+ runOpts: { stdio: "inherit" },
442
+ },
443
+ ],
444
+ cleanupCommands: [
445
+ {
446
+ cmd: "docker",
447
+ args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
435
448
  envs: envs,
436
- runOpts: { stdio: 'inherit' },
437
- }],
449
+ runOpts: { stdio: "inherit" },
450
+ },
451
+ ],
438
452
  runInfo: {
439
453
  apiPort: options?.grpcPort,
440
454
  apiAddr: options?.grpcAddr,
441
455
  logPath: logFilePath,
442
456
  primary: primary,
443
- work: { type: 'FS', rootPath: workFSPath },
457
+ work: { type: "FS", rootPath: workFSPath },
444
458
  library: library,
445
459
  dbPath: dbFSPath,
446
460
  },
@@ -448,30 +462,30 @@ class Core {
448
462
  return state.getInstanceInfo(instanceName);
449
463
  }
450
464
  createDocker(instanceName, localRoot, options) {
451
- this.logger.debug('creating platforma instance in \'docker\' mode...');
452
- const composeFSPath = assets('compose-backend.yaml');
465
+ this.logger.debug("creating platforma instance in 'docker' mode...");
466
+ const composeFSPath = assets("compose-backend.yaml");
453
467
  const image = options?.image ?? plImageTag(options?.version);
454
468
  this.checkLicense(options?.license, options?.licenseFile);
455
469
  const storagePath = (...s) => path.join(localRoot, ...s);
456
470
  const storageDir = (s) => {
457
471
  const p = storagePath(s);
458
- ensureDir(p, { mode: '0775' });
472
+ ensureDir(p, { mode: "0775" });
459
473
  return p;
460
474
  };
461
- const logFilePath = storagePath('logs', 'platforma.log');
475
+ const logFilePath = storagePath("logs", "platforma.log");
462
476
  if (!fs__default.existsSync(logFilePath)) {
463
477
  fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
464
- fs__default.writeFileSync(logFilePath, '');
478
+ fs__default.writeFileSync(logFilePath, "");
465
479
  }
466
- const dbFSPath = storageDir('db');
467
- const primaryFSPath = storageDir('primary');
468
- const libraryFSPath = storageDir('library');
469
- const workFSPath = storageDir('work');
470
- const usersFSPath = storagePath('users.htpasswd');
480
+ const dbFSPath = storageDir("db");
481
+ const primaryFSPath = storageDir("primary");
482
+ const libraryFSPath = storageDir("library");
483
+ const workFSPath = storageDir("work");
484
+ const usersFSPath = storagePath("users.htpasswd");
471
485
  if (!fs__default.existsSync(usersFSPath)) {
472
- fs__default.copyFileSync(assets('users.htpasswd'), usersFSPath);
486
+ fs__default.copyFileSync(assets("users.htpasswd"), usersFSPath);
473
487
  }
474
- const composeDstPath = storagePath('compose.yaml');
488
+ const composeDstPath = storagePath("compose.yaml");
475
489
  if (fs__default.existsSync(composeDstPath)) {
476
490
  this.logger.info(`replacing docker compose file ${composeDstPath}`);
477
491
  }
@@ -484,33 +498,36 @@ class Core {
484
498
  }
485
499
  this.logger.debug(`Rendering docker compose file '${composeDstPath}' using '${composeFSPath}' as base template`);
486
500
  render$1(composeFSPath, composeDstPath, `pl-${instanceName}`, new Map([
487
- ['backend', {
501
+ [
502
+ "backend",
503
+ {
488
504
  platform: options?.platformOverride,
489
505
  mounts: backendMounts,
490
506
  commands: options?.backendCommands,
491
- }],
507
+ },
508
+ ],
492
509
  ]));
493
- const primary = storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, '.');
494
- const library = storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, '.');
510
+ const primary = storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, ".");
511
+ const library = storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, ".");
495
512
  const envs = {
496
513
  PL_IMAGE: image,
497
514
  PL_AUTH_HTPASSWD: usersFSPath,
498
515
  PL_LICENSE: options?.license,
499
516
  PL_LICENSE_FILE: options?.licenseFile,
500
- PL_LOG_LEVEL: options?.logLevel ?? 'info',
517
+ PL_LOG_LEVEL: options?.logLevel ?? "info",
501
518
  PL_LOG_DIR: path.dirname(logFilePath),
502
- PL_LOG_ROTATION_ENABLED: 'true',
503
- PL_RUNNER_WD_CACHE_ON_FAILURE: '1h',
519
+ PL_LOG_ROTATION_ENABLED: "true",
520
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
504
521
  PL_DATA_DB_ROOT: dbFSPath,
505
522
  PL_DATA_PRIMARY_ROOT: primaryFSPath,
506
523
  PL_DATA_LIBRARY_ROOT: libraryFSPath,
507
524
  PL_DATA_WORKDIR_ROOT: workFSPath,
508
- PL_DATA_PACKAGE_ROOT: storageDir('packages'),
509
- ...this.configureDockerStorage('primary', primary),
510
- ...this.configureDockerStorage('library', library),
525
+ PL_DATA_PACKAGE_ROOT: storageDir("packages"),
526
+ ...this.configureDockerStorage("primary", primary),
527
+ ...this.configureDockerStorage("library", library),
511
528
  };
512
529
  if (options?.grpcAddr) {
513
- const addrParts = options.grpcAddr.split(':');
530
+ const addrParts = options.grpcAddr.split(":");
514
531
  if (addrParts.length === 2) {
515
532
  envs.PL_LISTEN_ADDRESS = addrParts[0];
516
533
  envs.PL_LISTEN_PORT = addrParts[1];
@@ -523,7 +540,7 @@ class Core {
523
540
  envs.PL_LISTEN_PORT = options.grpcPort.toString();
524
541
  }
525
542
  if (options?.monitoringAddr) {
526
- const addrParts = options.monitoringAddr.split(':');
543
+ const addrParts = options.monitoringAddr.split(":");
527
544
  if (addrParts.length === 2) {
528
545
  envs.PL_MONITORING_IP = addrParts[0];
529
546
  envs.PL_MONITORING_PORT = addrParts[1];
@@ -536,7 +553,7 @@ class Core {
536
553
  envs.PL_MONITORING_PORT = options.monitoringPort.toString();
537
554
  }
538
555
  if (options?.debugAddr) {
539
- const addrParts = options.debugAddr.split(':');
556
+ const addrParts = options.debugAddr.split(":");
540
557
  if (addrParts.length === 2) {
541
558
  envs.PL_DEBUG_IP = addrParts[0];
542
559
  envs.PL_DEBUG_PORT = addrParts[1];
@@ -550,51 +567,64 @@ class Core {
550
567
  }
551
568
  if (options?.auth) {
552
569
  if (options.auth.enabled) {
553
- envs['PL_NO_AUTH'] = 'false';
570
+ envs["PL_NO_AUTH"] = "false";
554
571
  }
555
572
  else {
556
- envs['PL_NO_AUTH'] = 'true';
573
+ envs["PL_NO_AUTH"] = "true";
557
574
  }
558
575
  if (options.auth.drivers) {
559
576
  for (const drv of options.auth.drivers) {
560
- if (drv.driver === 'htpasswd') {
561
- envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
562
- drv.path = '/etc/platforma/users.htpasswd';
577
+ if (drv.driver === "htpasswd") {
578
+ envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
579
+ drv.path = "/etc/platforma/users.htpasswd";
563
580
  }
564
581
  }
565
- envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
582
+ envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
566
583
  }
567
584
  }
568
585
  // Process additional backend commands
569
586
  if (options?.backendCommands && options.backendCommands.length > 0) {
570
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
587
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
571
588
  }
572
589
  state.setInstanceInfo(instanceName, {
573
- type: 'docker',
574
- upCommands: [{
575
- cmd: 'docker',
576
- args: ['compose', `--file=${composeDstPath}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
590
+ type: "docker",
591
+ upCommands: [
592
+ {
593
+ cmd: "docker",
594
+ args: [
595
+ "compose",
596
+ `--file=${composeDstPath}`,
597
+ "up",
598
+ "--detach",
599
+ "--remove-orphans",
600
+ "--pull=missing",
601
+ ],
577
602
  envs: envs,
578
- runOpts: { stdio: 'inherit' },
579
- }],
580
- downCommands: [{
581
- cmd: 'docker',
582
- args: ['compose', `--file=${composeDstPath}`, 'down'],
603
+ runOpts: { stdio: "inherit" },
604
+ },
605
+ ],
606
+ downCommands: [
607
+ {
608
+ cmd: "docker",
609
+ args: ["compose", `--file=${composeDstPath}`, "down"],
583
610
  envs: envs,
584
- runOpts: { stdio: 'inherit' },
585
- }],
586
- cleanupCommands: [{
587
- cmd: 'docker',
588
- args: ['compose', `--file=${composeDstPath}`, 'down', '--volumes', '--remove-orphans'],
611
+ runOpts: { stdio: "inherit" },
612
+ },
613
+ ],
614
+ cleanupCommands: [
615
+ {
616
+ cmd: "docker",
617
+ args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
589
618
  envs: envs,
590
- runOpts: { stdio: 'inherit' },
591
- }],
619
+ runOpts: { stdio: "inherit" },
620
+ },
621
+ ],
592
622
  runInfo: {
593
623
  apiPort: options?.grpcPort,
594
624
  apiAddr: options?.grpcAddr,
595
625
  logPath: logFilePath,
596
626
  primary: primary,
597
- work: { type: 'FS', rootPath: workFSPath },
627
+ work: { type: "FS", rootPath: workFSPath },
598
628
  library: library,
599
629
  dbPath: dbFSPath,
600
630
  },
@@ -604,17 +634,17 @@ class Core {
604
634
  cleanupInstance(instanceName) {
605
635
  const removeWarns = [];
606
636
  const instancesToDrop = new Map();
607
- let warnMessage = '';
637
+ let warnMessage = "";
608
638
  if (instanceName) {
609
639
  const instance = state.getInstanceInfo(instanceName);
610
640
  instancesToDrop.set(instanceName, instance);
611
641
  const iType = instance.type;
612
642
  switch (iType) {
613
- case 'docker': {
643
+ case "docker": {
614
644
  removeWarns.push(`docker service 'pl-${instanceName}', including all its volumes and data in '${state.instanceDir(instanceName)}' will be destroyed`);
615
645
  break;
616
646
  }
617
- case 'process': {
647
+ case "process": {
618
648
  removeWarns.push(`directory '${state.instanceDir(instanceName)}' would be deleted`);
619
649
  if (instance.downCommands) {
620
650
  removeWarns.push(`associated docker service, including all volumes and data will be destroyed`);
@@ -625,26 +655,26 @@ class Core {
625
655
  assertNever();
626
656
  }
627
657
  if (instanceName === state.currentInstanceName) {
628
- removeWarns.push('last command run cache (\'pl-dev start\' shorthand will stop working until next full start command call)');
658
+ removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)");
629
659
  }
630
660
  warnMessage = `
631
661
  You are going to reset the state of platforma service '${instanceName}':
632
- - ${removeWarns.join('\n - ')}
662
+ - ${removeWarns.join("\n - ")}
633
663
  `;
634
664
  }
635
665
  else {
636
666
  for (const iName of state.instanceList) {
637
667
  instancesToDrop.set(iName, state.getInstanceInfo(iName));
638
668
  }
639
- removeWarns.push('last command run cache (\'pl-dev start\' shorthand will stop working until next full start command call)', `all service configurations stored in: ${state.instanceDir()} (including all associated docker containers and volumes)`);
669
+ removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)", `all service configurations stored in: ${state.instanceDir()} (including all associated docker containers and volumes)`);
640
670
  warnMessage = `
641
671
  You are going to reset the state of all platforma services configured with pl-bootstrap package.
642
- - ${removeWarns.join('\n - ')}
672
+ - ${removeWarns.join("\n - ")}
643
673
  `;
644
674
  }
645
675
  this.logger.warn(warnMessage);
646
- if (!askYN('Are you sure?')) {
647
- this.logger.info('Reset action was canceled');
676
+ if (!askYN("Are you sure?")) {
677
+ this.logger.info("Reset action was canceled");
648
678
  return;
649
679
  }
650
680
  for (const [name, instance] of instancesToDrop.entries()) {
@@ -664,62 +694,62 @@ You are going to reset the state of all platforma services configured with pl-bo
664
694
  }
665
695
  mergeLicenseEnvs(flags) {
666
696
  if (flags.license === undefined) {
667
- if ((process.env.MI_LICENSE ?? '') != '')
697
+ if ((process.env.MI_LICENSE ?? "") != "")
668
698
  flags.license = process.env.MI_LICENSE;
669
- else if ((process.env.PL_LICENSE ?? '') != '')
699
+ else if ((process.env.PL_LICENSE ?? "") != "")
670
700
  flags.license = process.env.PL_LICENSE;
671
701
  }
672
702
  // set 'license-file' only if license is still undefined
673
- if (flags['license-file'] === undefined && flags.license === undefined) {
674
- if ((process.env.MI_LICENSE_FILE ?? '') != '')
675
- flags['license-file'] = process.env.MI_LICENSE_FILE;
676
- else if ((process.env.PL_LICENSE_FILE ?? '') != '')
677
- flags['license-file'] = process.env.PL_LICENSE_FILE;
678
- else if (fs__default.existsSync(path.resolve(os__default.homedir(), '.pl.license')))
679
- flags['license-file'] = path.resolve(os__default.homedir(), '.pl.license');
703
+ if (flags["license-file"] === undefined && flags.license === undefined) {
704
+ if ((process.env.MI_LICENSE_FILE ?? "") != "")
705
+ flags["license-file"] = process.env.MI_LICENSE_FILE;
706
+ else if ((process.env.PL_LICENSE_FILE ?? "") != "")
707
+ flags["license-file"] = process.env.PL_LICENSE_FILE;
708
+ else if (fs__default.existsSync(path.resolve(os__default.homedir(), ".pl.license")))
709
+ flags["license-file"] = path.resolve(os__default.homedir(), ".pl.license");
680
710
  }
681
711
  }
682
712
  initAuthDriversList(flags, workdir) {
683
713
  const authDrivers = [];
684
- if (flags['auth-htpasswd-file']) {
714
+ if (flags["auth-htpasswd-file"]) {
685
715
  authDrivers.push({
686
- driver: 'htpasswd',
687
- path: path.resolve(workdir, flags['auth-htpasswd-file']),
716
+ driver: "htpasswd",
717
+ path: path.resolve(workdir, flags["auth-htpasswd-file"]),
688
718
  });
689
719
  }
690
- if (Boolean(flags['auth-ldap-server']) !== Boolean(flags['auth-ldap-default-dn'])) {
691
- throw new Error('LDAP auth settings require both \'server\' and \'default DN\' options to be set');
720
+ if (Boolean(flags["auth-ldap-server"]) !== Boolean(flags["auth-ldap-default-dn"])) {
721
+ throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");
692
722
  }
693
- if (flags['auth-ldap-server']) {
723
+ if (flags["auth-ldap-server"]) {
694
724
  authDrivers.push({
695
- driver: 'ldap',
696
- serverUrl: flags['auth-ldap-server'],
697
- defaultDN: flags['auth-ldap-default-dn'],
725
+ driver: "ldap",
726
+ serverUrl: flags["auth-ldap-server"],
727
+ defaultDN: flags["auth-ldap-default-dn"],
698
728
  });
699
729
  }
700
730
  if (authDrivers.length === 0) {
701
731
  return undefined;
702
732
  }
703
- return [{ driver: 'jwt', key: this.getLastJwt() }, ...authDrivers];
733
+ return [{ driver: "jwt", key: this.getLastJwt() }, ...authDrivers];
704
734
  }
705
735
  /** Gets the last stored JWT secret key or generates it and stores in a file. */
706
736
  getLastJwt() {
707
- const jwtFile = state.path('auth.jwt');
708
- const encoding = 'utf-8';
709
- let lastJwt = '';
737
+ const jwtFile = state.path("auth.jwt");
738
+ const encoding = "utf-8";
739
+ let lastJwt = "";
710
740
  if (fs__default.existsSync(jwtFile)) {
711
741
  lastJwt = fs__default.readFileSync(jwtFile, { encoding });
712
742
  }
713
- if (lastJwt == '') {
743
+ if (lastJwt == "") {
714
744
  lastJwt = randomStr(64);
715
745
  fs__default.writeFileSync(jwtFile, lastJwt, { encoding });
716
746
  }
717
747
  return lastJwt;
718
748
  }
719
749
  checkLicense(value, file) {
720
- if (value !== undefined && value != '')
750
+ if (value !== undefined && value != "")
721
751
  return;
722
- if (file !== undefined && file != '')
752
+ if (file !== undefined && file != "")
723
753
  return;
724
754
  this.logger.error(`A license for Platforma Backend must be set.
725
755
 
@@ -739,55 +769,55 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
739
769
  const sType = storage.type;
740
770
  storageID = storageID.toUpperCase();
741
771
  switch (sType) {
742
- case 'S3':
772
+ case "S3":
743
773
  switch (storageID) {
744
- case 'PRIMARY': {
774
+ case "PRIMARY": {
745
775
  // Construct the S3 URL for primary storage
746
776
  if (storage.endpoint && storage.bucketName) {
747
- envs['PL_PRIMARY_STORAGE_S3'] = `${storage.endpoint}${storage.bucketName}`;
777
+ envs["PL_PRIMARY_STORAGE_S3"] = `${storage.endpoint}${storage.bucketName}`;
748
778
  }
749
779
  if (storage.endpoint)
750
- envs['PL_PRIMARY_STORAGE_S3_ENDPOINT'] = storage.endpoint;
780
+ envs["PL_PRIMARY_STORAGE_S3_ENDPOINT"] = storage.endpoint;
751
781
  if (storage.presignEndpoint)
752
- envs['PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT'] = storage.presignEndpoint;
782
+ envs["PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT"] = storage.presignEndpoint;
753
783
  if (storage.region)
754
- envs['PL_PRIMARY_STORAGE_S3_REGION'] = storage.region;
784
+ envs["PL_PRIMARY_STORAGE_S3_REGION"] = storage.region;
755
785
  if (storage.key)
756
- envs['PL_PRIMARY_STORAGE_S3_KEY'] = storage.key;
786
+ envs["PL_PRIMARY_STORAGE_S3_KEY"] = storage.key;
757
787
  if (storage.secret)
758
- envs['PL_PRIMARY_STORAGE_S3_SECRET'] = storage.secret;
788
+ envs["PL_PRIMARY_STORAGE_S3_SECRET"] = storage.secret;
759
789
  break;
760
790
  }
761
- case 'LIBRARY': {
791
+ case "LIBRARY": {
762
792
  // Construct the S3 URL for library storage
763
793
  if (storage.endpoint && storage.bucketName) {
764
- envs['PL_DATA_LIBRARY_S3_URL'] = `library=${storage.endpoint}${storage.bucketName}`;
794
+ envs["PL_DATA_LIBRARY_S3_URL"] = `library=${storage.endpoint}${storage.bucketName}`;
765
795
  }
766
796
  if (storage.endpoint)
767
- envs['PL_DATA_LIBRARY_S3_ENDPOINT'] = `library=${storage.endpoint}`;
797
+ envs["PL_DATA_LIBRARY_S3_ENDPOINT"] = `library=${storage.endpoint}`;
768
798
  if (storage.presignEndpoint)
769
- envs['PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT'] = `library=${storage.presignEndpoint}`;
799
+ envs["PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT"] = `library=${storage.presignEndpoint}`;
770
800
  if (storage.region)
771
- envs['PL_DATA_LIBRARY_S3_REGION'] = `library=${storage.region}`;
801
+ envs["PL_DATA_LIBRARY_S3_REGION"] = `library=${storage.region}`;
772
802
  if (storage.key)
773
- envs['PL_DATA_LIBRARY_S3_KEY'] = `library=${storage.key}`;
803
+ envs["PL_DATA_LIBRARY_S3_KEY"] = `library=${storage.key}`;
774
804
  if (storage.secret)
775
- envs['PL_DATA_LIBRARY_S3_SECRET'] = `library=${storage.secret}`;
805
+ envs["PL_DATA_LIBRARY_S3_SECRET"] = `library=${storage.secret}`;
776
806
  break;
777
807
  }
778
808
  default:
779
809
  throw new Error(`Unknown storage ID: ${storageID}`);
780
810
  }
781
811
  return envs;
782
- case 'FS':
812
+ case "FS":
783
813
  switch (storageID) {
784
- case 'PRIMARY':
814
+ case "PRIMARY":
785
815
  if (storage.rootPath)
786
- envs['PL_PRIMARY_STORAGE_FS'] = storage.rootPath;
816
+ envs["PL_PRIMARY_STORAGE_FS"] = storage.rootPath;
787
817
  break;
788
- case 'LIBRARY':
818
+ case "LIBRARY":
789
819
  if (storage.rootPath)
790
- envs['PL_DATA_LIBRARY_FS_PATH'] = storage.rootPath;
820
+ envs["PL_DATA_LIBRARY_FS_PATH"] = storage.rootPath;
791
821
  break;
792
822
  default:
793
823
  throw new Error(`Unknown storage ID: ${storageID}`);
@@ -800,31 +830,31 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
800
830
  }
801
831
  renderRunInfo(runInfo, indent = 10) {
802
832
  const report = [];
803
- const column = (t) => t.padStart(indent, ' ');
833
+ const column = (t) => t.padStart(indent, " ");
804
834
  if (runInfo.configPath) {
805
- report.push(`${column('config')}: ${runInfo.configPath}`);
835
+ report.push(`${column("config")}: ${runInfo.configPath}`);
806
836
  }
807
837
  if (runInfo.apiAddr) {
808
- report.push(`${column('API')}: ${runInfo.apiAddr}`);
838
+ report.push(`${column("API")}: ${runInfo.apiAddr}`);
809
839
  }
810
840
  else if (runInfo.apiPort) {
811
- report.push(`${column('API')}: 127.0.0.1:${runInfo.apiPort.toString()}`);
841
+ report.push(`${column("API")}: 127.0.0.1:${runInfo.apiPort.toString()}`);
812
842
  }
813
843
  else {
814
- report.push(`${column('API')}: 127.0.0.1:6345`);
844
+ report.push(`${column("API")}: 127.0.0.1:6345`);
815
845
  }
816
846
  if (runInfo.logPath) {
817
- report.push(`${column('log')}: ${runInfo.logPath}`);
847
+ report.push(`${column("log")}: ${runInfo.logPath}`);
818
848
  }
819
849
  const primaryType = runInfo.primary?.type;
820
850
  switch (primaryType) {
821
851
  case undefined:
822
852
  break;
823
- case 'FS':
824
- report.push(`${column('primary')}: ${runInfo.primary.rootPath}`);
853
+ case "FS":
854
+ report.push(`${column("primary")}: ${runInfo.primary.rootPath}`);
825
855
  break;
826
- case 'S3':
827
- report.push(`${column('primary')}: S3 at '${runInfo.primary.endpoint ?? 'AWS'}', bucket '${runInfo.primary.bucketName}', prefix: '${runInfo.primary.keyPrefix ?? ''}'`);
856
+ case "S3":
857
+ report.push(`${column("primary")}: S3 at '${runInfo.primary.endpoint ?? "AWS"}', bucket '${runInfo.primary.bucketName}', prefix: '${runInfo.primary.keyPrefix ?? ""}'`);
828
858
  break;
829
859
  default:
830
860
  assertNever();
@@ -833,22 +863,22 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
833
863
  switch (libraryType) {
834
864
  case undefined:
835
865
  break;
836
- case 'FS':
837
- report.push(`${column('library')}: ${runInfo.library.rootPath}`);
866
+ case "FS":
867
+ report.push(`${column("library")}: ${runInfo.library.rootPath}`);
838
868
  break;
839
- case 'S3':
840
- report.push(`${column('library')}: S3 at '${runInfo.library.endpoint ?? 'AWS'}', bucket '${runInfo.library.bucketName}', prefix: '${runInfo.library.keyPrefix ?? ''}'`);
869
+ case "S3":
870
+ report.push(`${column("library")}: S3 at '${runInfo.library.endpoint ?? "AWS"}', bucket '${runInfo.library.bucketName}', prefix: '${runInfo.library.keyPrefix ?? ""}'`);
841
871
  break;
842
872
  default:
843
873
  assertNever();
844
874
  }
845
875
  if (runInfo.work) {
846
- report.push(`${column('workdirs')}: ${runInfo.work.rootPath}`);
876
+ report.push(`${column("workdirs")}: ${runInfo.work.rootPath}`);
847
877
  }
848
878
  if (runInfo.dbPath) {
849
- report.push(`${column('db')}: ${runInfo.dbPath}`);
879
+ report.push(`${column("db")}: ${runInfo.dbPath}`);
850
880
  }
851
- return report.join('\n');
881
+ return report.join("\n");
852
882
  }
853
883
  }
854
884
  function checkRunError(result, message) {
@@ -856,7 +886,7 @@ function checkRunError(result, message) {
856
886
  if (buffer.error) {
857
887
  throw buffer.error;
858
888
  }
859
- const msg = message ?? 'failed to run command';
889
+ const msg = message ?? "failed to run command";
860
890
  if (buffer.status !== 0) {
861
891
  throw new Error(`${msg}, process exited with code '${buffer.status}'`);
862
892
  }