@kapeta/local-cluster-service 0.15.2 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.15.3](https://github.com/kapetacom/local-cluster-service/compare/v0.15.2...v0.15.3) (2023-08-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Use fresh API every time ([05851db](https://github.com/kapetacom/local-cluster-service/commit/05851dbf8c2a690c790a2ba93b7c0a8d24a93b06))
7
+
1
8
  ## [0.15.2](https://github.com/kapetacom/local-cluster-service/compare/v0.15.1...v0.15.2) (2023-08-09)
2
9
 
3
10
 
@@ -158,7 +158,7 @@ class AssetManager {
158
158
  throw new Error('File not found: ' + filePath);
159
159
  }
160
160
  const assetInfos = yaml_1.default.parseAllDocuments(node_fs_1.default.readFileSync(filePath).toString()).map((doc) => doc.toJSON());
161
- await nodejs_registry_utils_1.Actions.link(progressListener_1.progressListener, node_path_1.default.dirname(filePath));
161
+ await nodejs_registry_utils_1.Actions.link(new progressListener_1.ProgressListener(), node_path_1.default.dirname(filePath));
162
162
  const version = 'local';
163
163
  const refs = assetInfos.map((assetInfo) => `kapeta://${assetInfo.metadata.name}:${version}`);
164
164
  this.cache.flushAll();
@@ -170,7 +170,7 @@ class AssetManager {
170
170
  throw new Error('Asset does not exists: ' + ref);
171
171
  }
172
172
  this.cache.flushAll();
173
- await nodejs_registry_utils_1.Actions.uninstall(progressListener_1.progressListener, [asset.ref]);
173
+ await nodejs_registry_utils_1.Actions.uninstall(new progressListener_1.ProgressListener(), [asset.ref]);
174
174
  }
175
175
  async installAsset(ref) {
176
176
  const asset = await this.getAsset(ref, true, false);
@@ -17,7 +17,6 @@ const md5_1 = __importDefault(require("md5"));
17
17
  const utils_1 = require("./utils/utils");
18
18
  const nodejs_api_client_1 = require("@kapeta/nodejs-api-client");
19
19
  const taskManager_1 = require("./taskManager");
20
- const EVENT_IMAGE_PULL = 'docker-image-pull';
21
20
  exports.CONTAINER_LABEL_PORT_PREFIX = 'kapeta_port-';
22
21
  const NANO_SECOND = 1000000;
23
22
  const HEALTH_CHECK_INTERVAL = 3000;
@@ -7,10 +7,10 @@ const express_promise_router_1 = __importDefault(require("express-promise-router
7
7
  const nodejs_api_client_1 = require("@kapeta/nodejs-api-client");
8
8
  const cors_1 = require("../middleware/cors");
9
9
  const router = (0, express_promise_router_1.default)();
10
- const api = new nodejs_api_client_1.KapetaAPI();
11
10
  router.use('/', cors_1.corsHandler);
12
11
  router.get('/current', async (req, res) => {
13
12
  try {
13
+ const api = new nodejs_api_client_1.KapetaAPI();
14
14
  if (api.hasToken()) {
15
15
  res.send(await api.getCurrentIdentity());
16
16
  }
@@ -24,6 +24,7 @@ router.get('/current', async (req, res) => {
24
24
  });
25
25
  router.get('/:identityId/memberships', async (req, res) => {
26
26
  try {
27
+ const api = new nodejs_api_client_1.KapetaAPI();
27
28
  if (api.hasToken()) {
28
29
  res.send(await api.getMemberships(req.params.identityId));
29
30
  }
@@ -38,7 +38,5 @@ export declare class InstanceManager {
38
38
  private checkInstances;
39
39
  private getExternalStatus;
40
40
  private requestInstanceStatus;
41
- private emitSystemEvent;
42
- private emitInstanceEvent;
43
41
  }
44
42
  export declare const instanceManager: InstanceManager;
@@ -22,10 +22,6 @@ const definitionsManager_1 = require("./definitionsManager");
22
22
  const taskManager_1 = require("./taskManager");
23
23
  const CHECK_INTERVAL = 5000;
24
24
  const DEFAULT_HEALTH_PORT_TYPE = 'rest';
25
- const EVENT_STATUS_CHANGED = 'status-changed';
26
- const EVENT_INSTANCE_CREATED = 'instance-created';
27
- const EVENT_INSTANCE_EXITED = 'instance-exited';
28
- const EVENT_INSTANCE_LOG = 'instance-log';
29
25
  const MIN_TIME_RUNNING = 30000; //If something didnt run for more than 30 secs - it failed
30
26
  class InstanceManager {
31
27
  _interval = undefined;
@@ -121,11 +117,11 @@ class InstanceManager {
121
117
  if (existingInstance) {
122
118
  const ix = this._instances.indexOf(existingInstance);
123
119
  this._instances.splice(ix, 1, instance);
124
- this.emitSystemEvent(instance.systemId, EVENT_STATUS_CHANGED, instance);
120
+ socketManager_1.socketManager.emitSystemEvent(instance.systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
125
121
  }
126
122
  else {
127
123
  this._instances.push(instance);
128
- this.emitSystemEvent(instance.systemId, EVENT_INSTANCE_CREATED, instance);
124
+ socketManager_1.socketManager.emitSystemEvent(instance.systemId, socketManager_1.EVENT_INSTANCE_CREATED, instance);
129
125
  }
130
126
  this.save();
131
127
  return instance;
@@ -168,7 +164,7 @@ class InstanceManager {
168
164
  if (healthUrl) {
169
165
  instance.health = healthUrl;
170
166
  }
171
- this.emitSystemEvent(systemId, EVENT_STATUS_CHANGED, instance);
167
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
172
168
  }
173
169
  else {
174
170
  //If instance was not found - then we're receiving an externally started instance
@@ -184,7 +180,7 @@ class InstanceManager {
184
180
  address,
185
181
  };
186
182
  this._instances.push(instance);
187
- this.emitSystemEvent(systemId, EVENT_INSTANCE_CREATED, instance);
183
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_INSTANCE_CREATED, instance);
188
184
  }
189
185
  this.save();
190
186
  return instance;
@@ -209,7 +205,7 @@ class InstanceManager {
209
205
  instance.status = types_1.InstanceStatus.STOPPED;
210
206
  instance.pid = null;
211
207
  instance.health = null;
212
- this.emitSystemEvent(systemId, EVENT_STATUS_CHANGED, instance);
208
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
213
209
  this.save();
214
210
  }
215
211
  });
@@ -267,7 +263,7 @@ class InstanceManager {
267
263
  instance.desiredStatus = types_1.DesiredInstanceStatus.STOP;
268
264
  }
269
265
  instance.status = types_1.InstanceStatus.STOPPING;
270
- this.emitSystemEvent(systemId, EVENT_STATUS_CHANGED, instance);
266
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
271
267
  console.log('Stopping instance: %s::%s [desired: %s]', systemId, instanceId, instance.desiredStatus);
272
268
  this.save();
273
269
  try {
@@ -278,7 +274,7 @@ class InstanceManager {
278
274
  try {
279
275
  await container.stop();
280
276
  instance.status = types_1.InstanceStatus.STOPPED;
281
- this.emitSystemEvent(systemId, EVENT_STATUS_CHANGED, instance);
277
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
282
278
  this.save();
283
279
  }
284
280
  catch (e) {
@@ -297,7 +293,7 @@ class InstanceManager {
297
293
  }
298
294
  process.kill(instance.pid, 'SIGTERM');
299
295
  instance.status = types_1.InstanceStatus.STOPPED;
300
- this.emitSystemEvent(systemId, EVENT_STATUS_CHANGED, instance);
296
+ socketManager_1.socketManager.emitSystemEvent(systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
301
297
  this.save();
302
298
  }
303
299
  catch (e) {
@@ -422,10 +418,10 @@ class InstanceManager {
422
418
  status: types_1.InstanceStatus.FAILED,
423
419
  errorMessage: e.message ?? 'Failed to start - Check logs for details.',
424
420
  });
425
- this.emitInstanceEvent(systemId, instanceId, EVENT_INSTANCE_LOG, logs[0]);
426
- this.emitInstanceEvent(systemId, blockInstance.id, EVENT_INSTANCE_EXITED, {
421
+ socketManager_1.socketManager.emitInstanceLog(systemId, instanceId, logs[0]);
422
+ socketManager_1.socketManager.emitInstanceEvent(systemId, blockInstance.id, socketManager_1.EVENT_INSTANCE_EXITED, {
427
423
  error: `Failed to start instance: ${e.message}`,
428
- status: EVENT_INSTANCE_EXITED,
424
+ status: socketManager_1.EVENT_INSTANCE_EXITED,
429
425
  instanceId: blockInstance.id,
430
426
  });
431
427
  return out;
@@ -512,7 +508,7 @@ class InstanceManager {
512
508
  const oldStatus = instance.status;
513
509
  instance.status = newStatus;
514
510
  console.log('Instance status changed: %s %s: %s -> %s', instance.systemId, instance.instanceId, oldStatus, instance.status);
515
- this.emitSystemEvent(instance.systemId, EVENT_STATUS_CHANGED, instance);
511
+ socketManager_1.socketManager.emitSystemEvent(instance.systemId, socketManager_1.EVENT_STATUS_CHANGED, instance);
516
512
  changed = true;
517
513
  }
518
514
  }
@@ -644,24 +640,6 @@ class InstanceManager {
644
640
  });
645
641
  });
646
642
  }
647
- emitSystemEvent(systemId, type, payload) {
648
- systemId = (0, utils_1.normalizeKapetaUri)(systemId);
649
- try {
650
- socketManager_1.socketManager.emit(`${systemId}/instances`, type, payload);
651
- }
652
- catch (e) {
653
- console.warn('Failed to emit instance event: %s', e.message);
654
- }
655
- }
656
- emitInstanceEvent(systemId, instanceId, type, payload) {
657
- systemId = (0, utils_1.normalizeKapetaUri)(systemId);
658
- try {
659
- socketManager_1.socketManager.emit(`${systemId}/instances/${instanceId}`, type, payload);
660
- }
661
- catch (e) {
662
- console.warn('Failed to emit instance event: %s', e.message);
663
- }
664
- }
665
643
  }
666
644
  exports.InstanceManager = InstanceManager;
667
645
  exports.instanceManager = new InstanceManager();
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { SocketManager } from './socketManager';
3
- declare class ProgressListener {
4
- private socketManager;
5
- constructor(socketManager: SocketManager);
2
+ export declare class ProgressListener {
3
+ private readonly systemId;
4
+ private readonly instanceId;
5
+ constructor(systemId?: string, instanceId?: string);
6
+ private emitLog;
6
7
  run(command: string, directory?: string): Promise<{
7
8
  exit: number;
8
9
  signal: NodeJS.Signals | null;
@@ -17,5 +18,3 @@ declare class ProgressListener {
17
18
  info(msg: string, ...args: any[]): void;
18
19
  debug(msg: string, ...args: any[]): void;
19
20
  }
20
- export declare const progressListener: ProgressListener;
21
- export {};
@@ -1,19 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.progressListener = void 0;
3
+ exports.ProgressListener = void 0;
4
4
  const nodejs_process_1 = require("@kapeta/nodejs-process");
5
5
  const socketManager_1 = require("./socketManager");
6
+ const node_util_1 = require("node:util");
6
7
  class ProgressListener {
7
- socketManager;
8
- constructor(socketManager) {
9
- this.socketManager = socketManager;
8
+ systemId;
9
+ instanceId;
10
+ constructor(systemId, instanceId) {
11
+ this.systemId = systemId;
12
+ this.instanceId = instanceId;
13
+ }
14
+ emitLog(payload) {
15
+ const logEntry = {
16
+ ...payload,
17
+ source: 'stdout',
18
+ time: Date.now(),
19
+ };
20
+ if (this.systemId && this.instanceId) {
21
+ socketManager_1.socketManager.emitInstanceLog(this.systemId, this.instanceId, logEntry);
22
+ return;
23
+ }
24
+ if (this.systemId) {
25
+ socketManager_1.socketManager.emitSystemLog(this.systemId, logEntry);
26
+ return;
27
+ }
28
+ socketManager_1.socketManager.emitGlobalLog(logEntry);
10
29
  }
11
30
  run(command, directory) {
12
- this.socketManager.emit(`install`, 'install:log', {
13
- type: 'info',
14
- message: `Running command "${command}"`,
15
- });
16
- const firstCommand = command.split(' ')[0];
31
+ this.info(`Running command "${command}"`);
17
32
  return new Promise(async (resolve, reject) => {
18
33
  try {
19
34
  const chunks = [];
@@ -23,7 +38,10 @@ class ProgressListener {
23
38
  shell: true,
24
39
  });
25
40
  child.onData((data) => {
26
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: data.line });
41
+ this.emitLog({
42
+ level: data.type === 'stdout' ? 'INFO' : 'WARN',
43
+ message: data.line,
44
+ });
27
45
  });
28
46
  if (child.process.stdout) {
29
47
  child.process.stdout.on('data', (data) => {
@@ -32,25 +50,16 @@ class ProgressListener {
32
50
  }
33
51
  child.process.on('exit', (exit, signal) => {
34
52
  if (exit !== 0) {
35
- this.socketManager.emit(`install`, 'install:log', {
36
- type: 'info',
37
- message: `"${command}" failed: "${exit}"`,
38
- });
53
+ this.warn(`Command "${command}" failed: ${exit}`);
39
54
  reject(new Error(`Command "${command}" exited with code ${exit}`));
40
55
  }
41
56
  else {
42
- this.socketManager.emit(`install`, 'install:log', {
43
- type: 'info',
44
- message: `Command OK: "${command}"`,
45
- });
57
+ this.info(`Command OK: "${command}"`);
46
58
  resolve({ exit, signal, output: Buffer.concat(chunks).toString() });
47
59
  }
48
60
  });
49
61
  child.process.on('error', (err) => {
50
- this.socketManager.emit(`install`, 'install:log', {
51
- type: 'info',
52
- message: `"${command}" failed: "${err.message}"`,
53
- });
62
+ this.warn(`"${command}" failed: "${err.message}"`);
54
63
  reject(err);
55
64
  });
56
65
  await child.wait();
@@ -61,41 +70,50 @@ class ProgressListener {
61
70
  });
62
71
  }
63
72
  async progress(label, callback) {
64
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: `${label}: started` });
73
+ this.info(`${label}: started`);
65
74
  try {
66
75
  const result = await callback();
67
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: `${label}: done` });
76
+ this.info(`${label}: done`);
68
77
  return result;
69
78
  }
70
79
  catch (e) {
71
- this.socketManager.emit(`install`, 'install:log', {
72
- type: 'info',
73
- message: `${label}: failed. ${e.message}`,
74
- });
80
+ this.warn(`${label}: failed. ${e.message}`);
75
81
  throw e;
76
82
  }
77
83
  }
78
84
  async check(message, ok) {
79
85
  const wasOk = await ok;
80
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: `${message}: ${wasOk}` });
86
+ this.info(`${message}: ${wasOk}`);
81
87
  }
82
88
  start(label) {
83
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: label });
89
+ this.info(label);
84
90
  }
85
91
  showValue(label, value) {
86
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: `${label}: ${value}` });
92
+ this.info(`${label}: ${value}`);
87
93
  }
88
94
  error(msg, ...args) {
89
- this.socketManager.emit(`install`, 'install:log', { type: 'error', message: msg });
95
+ this.emitLog({
96
+ message: (0, node_util_1.format)(msg, args),
97
+ level: 'ERROR',
98
+ });
90
99
  }
91
100
  warn(msg, ...args) {
92
- this.socketManager.emit(`install`, 'install:log', { type: 'warn', message: msg });
101
+ this.emitLog({
102
+ message: (0, node_util_1.format)(msg, args),
103
+ level: 'WARN',
104
+ });
93
105
  }
94
106
  info(msg, ...args) {
95
- this.socketManager.emit(`install`, 'install:log', { type: 'info', message: msg });
107
+ this.emitLog({
108
+ message: (0, node_util_1.format)(msg, args),
109
+ level: 'INFO',
110
+ });
96
111
  }
97
112
  debug(msg, ...args) {
98
- this.socketManager.emit(`install`, 'install:log', { type: 'debug', message: msg });
113
+ this.emitLog({
114
+ message: (0, node_util_1.format)(msg, args),
115
+ level: 'DEBUG',
116
+ });
99
117
  }
100
118
  }
101
- exports.progressListener = new ProgressListener(socketManager_1.socketManager);
119
+ exports.ProgressListener = ProgressListener;
@@ -12,12 +12,12 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
12
12
  const local_cluster_config_1 = __importDefault(require("@kapeta/local-cluster-config"));
13
13
  const nodejs_utils_1 = require("@kapeta/nodejs-utils");
14
14
  const socketManager_1 = require("./socketManager");
15
- const progressListener_1 = require("./progressListener");
16
15
  const nodejs_registry_utils_1 = require("@kapeta/nodejs-registry-utils");
17
16
  const definitionsManager_1 = require("./definitionsManager");
18
17
  const taskManager_1 = require("./taskManager");
19
18
  const utils_1 = require("./utils/utils");
20
19
  const assetManager_1 = require("./assetManager");
20
+ const progressListener_1 = require("./progressListener");
21
21
  const EVENT_DEFAULT_PROVIDERS_START = 'default-providers-start';
22
22
  const EVENT_DEFAULT_PROVIDERS_END = 'default-providers-end';
23
23
  const DEFAULT_PROVIDERS = [
@@ -126,7 +126,7 @@ class RepositoryManager {
126
126
  ensureDefaultProviders() {
127
127
  socketManager_1.socketManager.emitGlobal(EVENT_DEFAULT_PROVIDERS_START, { providers: DEFAULT_PROVIDERS });
128
128
  const tasks = this._install(DEFAULT_PROVIDERS);
129
- Promise.allSettled(tasks.map(t => t.wait())).then(() => {
129
+ Promise.allSettled(tasks.map((t) => t.wait())).then(() => {
130
130
  socketManager_1.socketManager.emitGlobal(EVENT_DEFAULT_PROVIDERS_END, {});
131
131
  });
132
132
  }
@@ -148,7 +148,7 @@ class RepositoryManager {
148
148
  process.chdir(node_os_1.default.tmpdir());
149
149
  //Disable change events while installing
150
150
  this.setChangeEventsEnabled(false);
151
- await nodejs_registry_utils_1.Actions.install(progressListener_1.progressListener, [ref], {});
151
+ await nodejs_registry_utils_1.Actions.install(new progressListener_1.ProgressListener(), [ref], {});
152
152
  }
153
153
  catch (e) {
154
154
  console.error(`Failed to install asset: ${ref}`, e);
@@ -1,16 +1,28 @@
1
- import { Socket, Server } from 'socket.io';
1
+ import { Server } from 'socket.io';
2
+ import { LogEntry } from './types';
3
+ export declare const EVENT_STATUS_CHANGED = "status-changed";
4
+ export declare const EVENT_INSTANCE_CREATED = "instance-created";
5
+ export declare const EVENT_INSTANCE_EXITED = "instance-exited";
6
+ export declare const EVENT_INSTANCE_LOG = "instance-log";
7
+ export declare const EVENT_SYSTEM_LOG = "system-log";
8
+ export declare const EVENT_LOG = "log";
2
9
  export declare class SocketManager {
3
10
  private _io;
4
- private _sockets;
11
+ private readonly _sockets;
5
12
  constructor();
6
13
  setIo(io: Server): void;
7
14
  isAlive(): boolean;
8
15
  private get io();
9
16
  emit(context: string, type: string, payload: any): void;
10
17
  emitGlobal(type: string, payload: any): void;
11
- _bindIO(): void;
12
- _handleSocketCreated(socket: Socket): void;
13
- _bindSocket(socket: Socket): void;
14
- _handleSocketDestroyed(socket: Socket): void;
18
+ emitSystemEvent(systemId: string, type: string, payload: any): void;
19
+ emitInstanceLog(systemId: string, instanceId: string, payload: LogEntry): void;
20
+ emitSystemLog(systemId: string, payload: LogEntry): void;
21
+ emitGlobalLog(payload: LogEntry): void;
22
+ emitInstanceEvent(systemId: string, instanceId: string, type: string, payload: any): void;
23
+ private _bindIO;
24
+ private _handleSocketCreated;
25
+ private _bindSocket;
26
+ private _handleSocketDestroyed;
15
27
  }
16
28
  export declare const socketManager: SocketManager;
@@ -3,8 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.socketManager = exports.SocketManager = void 0;
6
+ exports.socketManager = exports.SocketManager = exports.EVENT_LOG = exports.EVENT_SYSTEM_LOG = exports.EVENT_INSTANCE_LOG = exports.EVENT_INSTANCE_EXITED = exports.EVENT_INSTANCE_CREATED = exports.EVENT_STATUS_CHANGED = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
+ const utils_1 = require("./utils/utils");
9
+ exports.EVENT_STATUS_CHANGED = 'status-changed';
10
+ exports.EVENT_INSTANCE_CREATED = 'instance-created';
11
+ exports.EVENT_INSTANCE_EXITED = 'instance-exited';
12
+ exports.EVENT_INSTANCE_LOG = 'instance-log';
13
+ exports.EVENT_SYSTEM_LOG = 'system-log';
14
+ exports.EVENT_LOG = 'log';
8
15
  class SocketManager {
9
16
  _io;
10
17
  _sockets;
@@ -32,6 +39,33 @@ class SocketManager {
32
39
  emitGlobal(type, payload) {
33
40
  this.io.emit(type, payload);
34
41
  }
42
+ emitSystemEvent(systemId, type, payload) {
43
+ systemId = (0, utils_1.normalizeKapetaUri)(systemId);
44
+ try {
45
+ exports.socketManager.emit(`${systemId}/instances`, type, payload);
46
+ }
47
+ catch (e) {
48
+ console.warn('Failed to emit instance event: %s', e.message);
49
+ }
50
+ }
51
+ emitInstanceLog(systemId, instanceId, payload) {
52
+ this.emitInstanceEvent(systemId, instanceId, exports.EVENT_INSTANCE_LOG, payload);
53
+ }
54
+ emitSystemLog(systemId, payload) {
55
+ this.emitSystemEvent(systemId, exports.EVENT_SYSTEM_LOG, payload);
56
+ }
57
+ emitGlobalLog(payload) {
58
+ this.emitGlobal(exports.EVENT_LOG, payload);
59
+ }
60
+ emitInstanceEvent(systemId, instanceId, type, payload) {
61
+ systemId = (0, utils_1.normalizeKapetaUri)(systemId);
62
+ try {
63
+ exports.socketManager.emit(`${systemId}/instances/${instanceId}`, type, payload);
64
+ }
65
+ catch (e) {
66
+ console.warn('Failed to emit instance event: %s', e.message);
67
+ }
68
+ }
35
69
  _bindIO() {
36
70
  this.io.on('connection', (socket) => this._handleSocketCreated(socket));
37
71
  }
@@ -4,7 +4,7 @@ import FSExtra from 'fs-extra';
4
4
  import YAML from 'yaml';
5
5
  import NodeCache from 'node-cache';
6
6
  import { codeGeneratorManager } from './codeGeneratorManager';
7
- import { progressListener } from './progressListener';
7
+ import { ProgressListener } from './progressListener';
8
8
  import { parseKapetaUri } from '@kapeta/nodejs-utils';
9
9
  import { repositoryManager } from './repositoryManager';
10
10
  import { Actions } from '@kapeta/nodejs-registry-utils';
@@ -152,7 +152,7 @@ class AssetManager {
152
152
  throw new Error('File not found: ' + filePath);
153
153
  }
154
154
  const assetInfos = YAML.parseAllDocuments(FS.readFileSync(filePath).toString()).map((doc) => doc.toJSON());
155
- await Actions.link(progressListener, Path.dirname(filePath));
155
+ await Actions.link(new ProgressListener(), Path.dirname(filePath));
156
156
  const version = 'local';
157
157
  const refs = assetInfos.map((assetInfo) => `kapeta://${assetInfo.metadata.name}:${version}`);
158
158
  this.cache.flushAll();
@@ -164,7 +164,7 @@ class AssetManager {
164
164
  throw new Error('Asset does not exists: ' + ref);
165
165
  }
166
166
  this.cache.flushAll();
167
- await Actions.uninstall(progressListener, [asset.ref]);
167
+ await Actions.uninstall(new ProgressListener(), [asset.ref]);
168
168
  }
169
169
  async installAsset(ref) {
170
170
  const asset = await this.getAsset(ref, true, false);
@@ -11,7 +11,6 @@ import md5 from 'md5';
11
11
  import { getBlockInstanceContainerName } from './utils/utils';
12
12
  import { KapetaAPI } from '@kapeta/nodejs-api-client';
13
13
  import { taskManager } from './taskManager';
14
- const EVENT_IMAGE_PULL = 'docker-image-pull';
15
14
  export const CONTAINER_LABEL_PORT_PREFIX = 'kapeta_port-';
16
15
  const NANO_SECOND = 1000000;
17
16
  const HEALTH_CHECK_INTERVAL = 3000;
@@ -2,10 +2,10 @@ import Router from 'express-promise-router';
2
2
  import { KapetaAPI } from '@kapeta/nodejs-api-client';
3
3
  import { corsHandler } from '../middleware/cors';
4
4
  const router = Router();
5
- const api = new KapetaAPI();
6
5
  router.use('/', corsHandler);
7
6
  router.get('/current', async (req, res) => {
8
7
  try {
8
+ const api = new KapetaAPI();
9
9
  if (api.hasToken()) {
10
10
  res.send(await api.getCurrentIdentity());
11
11
  }
@@ -19,6 +19,7 @@ router.get('/current', async (req, res) => {
19
19
  });
20
20
  router.get('/:identityId/memberships', async (req, res) => {
21
21
  try {
22
+ const api = new KapetaAPI();
22
23
  if (api.hasToken()) {
23
24
  res.send(await api.getMemberships(req.params.identityId));
24
25
  }
@@ -38,7 +38,5 @@ export declare class InstanceManager {
38
38
  private checkInstances;
39
39
  private getExternalStatus;
40
40
  private requestInstanceStatus;
41
- private emitSystemEvent;
42
- private emitInstanceEvent;
43
41
  }
44
42
  export declare const instanceManager: InstanceManager;