@kumori/aurora-backend-handler 1.0.100 → 1.0.111

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.
@@ -1,4 +1,11 @@
1
- import { createUser, loadUser, isUserLogged, updateUser, deleteUSer } from "./api/user-api-service";
1
+ import {
2
+ createUser,
3
+ loadUser,
4
+ isUserLogged,
5
+ updateUser,
6
+ deleteUSer,
7
+ getUserHTTP,
8
+ } from "./api/user-api-service";
2
9
  import {
3
10
  changeRevision,
4
11
  deleteService,
@@ -13,6 +20,7 @@ import {
13
20
  import {
14
21
  deployMarketplaceItem,
15
22
  getMarketplaceItems,
23
+ getMarketplaceSchema,
16
24
  } from "./api/marketplace-api-service";
17
25
  import {
18
26
  clearAccount,
@@ -46,48 +54,68 @@ import {
46
54
  } from "./api/environment-api-service";
47
55
  import EventHelper, { RegistryUpdatePayload } from "./event-helper";
48
56
  import { environment } from "./environment";
49
- import { initializeGlobalWebSocketClient, updateUserComplete } from "./websocket-manager";
57
+ import {
58
+ fetchAndStoreMarketplaceSchema,
59
+ initializeGlobalWebSocketClient,
60
+ updateUserComplete,
61
+ } from "./websocket-manager";
50
62
  import {
51
63
  createResource,
52
64
  deleteResource,
53
65
  updateResource,
54
66
  } from "./api/resources-api-service";
55
- import { getPlanProviders } from './api/planProvider-api-service';
56
- import { Account, Environment, Link, MarketplaceService, Notification, Organization, Resource, Service, Tenant, tenantRole, UserData } from "@kumori/aurora-interfaces";
67
+ import { getPlanProviders } from "./api/planProvider-api-service";
68
+ import {
69
+ Account,
70
+ Environment,
71
+ errors,
72
+ Link,
73
+ MarketplaceItem,
74
+ MarketplaceService,
75
+ Notification,
76
+ Organization,
77
+ Resource,
78
+ Service,
79
+ Tenant,
80
+ tenantRole,
81
+ User,
82
+ UserData,
83
+ } from "@kumori/aurora-interfaces";
57
84
 
58
85
  export let eventHelper: EventHelper;
59
- const token =
60
- "";
86
+ const token = "";
61
87
  export class BackendHandler {
62
88
  private unsubscribeFunctions: (() => void)[] = [];
63
89
  constructor(
64
90
  route: string,
65
91
  globalEventHandler: any,
66
92
  baseUrl: string,
67
- apiVersion: string
93
+ apiVersion: string,
68
94
  ) {
69
95
  if (
70
96
  !globalEventHandler ||
71
97
  typeof globalEventHandler.subscribe !== "function"
72
98
  ) {
73
99
  throw new Error(
74
- "globalEventHandler inválido. Asegúrate de pasar una instancia correcta de EventHandler."
100
+ "globalEventHandler inválido. Asegúrate de pasar una instancia correcta de EventHandler.",
75
101
  );
76
102
  }
77
103
  eventHelper = new EventHelper(globalEventHandler);
78
- eventHelper.user.subscribe.load((data: UserData) => {
79
- initializeGlobalWebSocketClient(token, "", "", data);
80
- });
81
- const loadedCb = (data: UserData) => {
82
- updateUserComplete(data);
83
- };
84
- eventHelper.user.subscribe.loaded(loadedCb);
85
-
86
- this.changeRoute(route);
87
104
  environment.apiServer.baseUrl = baseUrl;
88
105
  environment.apiServer.apiVersion = apiVersion;
106
+ getUserHTTP().then(() => {
107
+ eventHelper.user.subscribe.load((data: UserData) => {
108
+ initializeGlobalWebSocketClient(token, "", "", data);
109
+ });
110
+ const loadedCb = (data: UserData) => {
111
+ updateUserComplete(data);
112
+ };
113
+ eventHelper.user.subscribe.loaded(loadedCb);
114
+ this.changeRoute(route);
115
+ eventHelper.user.publish.load({} as UserData);
116
+ })
89
117
  }
90
-
118
+
91
119
  /**
92
120
  * Function to change the route and subscribe to the new route events
93
121
  * @param newRoute string with the new route
@@ -135,7 +163,6 @@ export class BackendHandler {
135
163
  this.subscribeMarketplaceEvents();
136
164
  this.subscribeResourceEvents();
137
165
  this.subscribeOrganizationEvents();
138
-
139
166
  }
140
167
  public async isUserLoggedIn(): Promise<boolean> {
141
168
  const loggedIn = await isUserLogged(token);
@@ -157,21 +184,19 @@ export class BackendHandler {
157
184
  };
158
185
  eventHelper.tenant.subscribe.creation(creationCb);
159
186
  this.unsubscribeFunctions.push(() =>
160
- eventHelper.tenant.unsubscribe.creation(creationCb)
187
+ eventHelper.tenant.unsubscribe.creation(creationCb),
161
188
  );
162
189
 
163
- const createdCb = (data: Tenant) => {
164
- };
190
+ const createdCb = (data: Tenant) => {};
165
191
  eventHelper.tenant.subscribe.created(createdCb);
166
192
  this.unsubscribeFunctions.push(() =>
167
- eventHelper.tenant.unsubscribe.created(createdCb)
193
+ eventHelper.tenant.unsubscribe.created(createdCb),
168
194
  );
169
195
 
170
- const creationErrorCb = (data: Tenant) => {
171
- };
196
+ const creationErrorCb = (data: Tenant) => {};
172
197
  eventHelper.tenant.subscribe.creationError(creationErrorCb);
173
198
  this.unsubscribeFunctions.push(() =>
174
- eventHelper.tenant.unsubscribe.creationError(creationErrorCb)
199
+ eventHelper.tenant.unsubscribe.creationError(creationErrorCb),
175
200
  );
176
201
 
177
202
  const updateCb = (data: Tenant) => {
@@ -179,21 +204,19 @@ export class BackendHandler {
179
204
  };
180
205
  eventHelper.tenant.subscribe.update(updateCb);
181
206
  this.unsubscribeFunctions.push(() =>
182
- eventHelper.tenant.unsubscribe.update(updateCb)
207
+ eventHelper.tenant.unsubscribe.update(updateCb),
183
208
  );
184
209
 
185
- const updatedCb = (data: Tenant) => {
186
- };
210
+ const updatedCb = (data: Tenant) => {};
187
211
  eventHelper.tenant.subscribe.updated(updatedCb);
188
212
  this.unsubscribeFunctions.push(() =>
189
- eventHelper.tenant.unsubscribe.updated(updatedCb)
213
+ eventHelper.tenant.unsubscribe.updated(updatedCb),
190
214
  );
191
215
 
192
- const updateErrorCb = (data: Tenant) => {
193
- };
216
+ const updateErrorCb = (data: Tenant) => {};
194
217
  eventHelper.tenant.subscribe.updateError(updateErrorCb);
195
218
  this.unsubscribeFunctions.push(() =>
196
- eventHelper.tenant.unsubscribe.updateError(updateErrorCb)
219
+ eventHelper.tenant.unsubscribe.updateError(updateErrorCb),
197
220
  );
198
221
 
199
222
  const deleteCb = (data: Tenant) => {
@@ -202,196 +225,221 @@ export class BackendHandler {
202
225
  };
203
226
  eventHelper.tenant.subscribe.delete(deleteCb);
204
227
  this.unsubscribeFunctions.push(() =>
205
- eventHelper.tenant.unsubscribe.delete(deleteCb)
228
+ eventHelper.tenant.unsubscribe.delete(deleteCb),
206
229
  );
207
230
 
208
- const deletedCb = (data: Tenant) => {
209
- };
231
+ const deletedCb = (data: Tenant) => {};
210
232
  eventHelper.tenant.subscribe.deleted(deletedCb);
211
233
  this.unsubscribeFunctions.push(() =>
212
- eventHelper.tenant.unsubscribe.deleted(deletedCb)
234
+ eventHelper.tenant.unsubscribe.deleted(deletedCb),
213
235
  );
214
236
 
215
- const deletionErrorCb = (data: Tenant) => {
216
- };
237
+ const deletionErrorCb = (data: Tenant) => {};
217
238
  eventHelper.tenant.subscribe.deletionError(deletionErrorCb);
218
239
  this.unsubscribeFunctions.push(() =>
219
- eventHelper.tenant.unsubscribe.deletionError(deletionErrorCb)
240
+ eventHelper.tenant.unsubscribe.deletionError(deletionErrorCb),
220
241
  );
221
242
  const createRegistryCb = (payload: RegistryUpdatePayload) => {
222
243
  createRegistry(payload.tenant, token, payload.registry);
223
- }
244
+ };
224
245
  eventHelper.tenant.subscribe.createRegistry(createRegistryCb);
225
246
  this.unsubscribeFunctions.push(() =>
226
- eventHelper.tenant.unsubscribe.createRegistry(createRegistryCb)
247
+ eventHelper.tenant.unsubscribe.createRegistry(createRegistryCb),
227
248
  );
228
- const registryCreatedCb = (payload: RegistryUpdatePayload) => {
229
- }
249
+ const registryCreatedCb = (payload: RegistryUpdatePayload) => {};
230
250
  eventHelper.tenant.subscribe.registryCreated(registryCreatedCb);
231
251
  this.unsubscribeFunctions.push(() =>
232
- eventHelper.tenant.unsubscribe.registryCreated(registryCreatedCb)
252
+ eventHelper.tenant.unsubscribe.registryCreated(registryCreatedCb),
233
253
  );
234
- const registryCreationErrorCb = (payload: RegistryUpdatePayload) => {
235
- }
254
+ const registryCreationErrorCb = (payload: RegistryUpdatePayload) => {};
236
255
  eventHelper.tenant.subscribe.registryCreationError(registryCreationErrorCb);
237
256
  this.unsubscribeFunctions.push(() =>
238
- eventHelper.tenant.unsubscribe.registryCreationError(registryCreationErrorCb)
257
+ eventHelper.tenant.unsubscribe.registryCreationError(
258
+ registryCreationErrorCb,
259
+ ),
239
260
  );
240
261
  const updateRegistryCb = (payload: RegistryUpdatePayload) => {
241
262
  updateRegistry(payload.tenant, payload.registry, token);
242
- }
263
+ };
243
264
  eventHelper.tenant.subscribe.updateRegistry(updateRegistryCb);
244
265
  this.unsubscribeFunctions.push(() =>
245
- eventHelper.tenant.unsubscribe.updateRegistry(updateRegistryCb)
266
+ eventHelper.tenant.unsubscribe.updateRegistry(updateRegistryCb),
246
267
  );
247
- const registryUpdatedCb = (payload: RegistryUpdatePayload) => {
248
- }
268
+ const registryUpdatedCb = (payload: RegistryUpdatePayload) => {};
249
269
  eventHelper.tenant.subscribe.registryUpdated(registryUpdatedCb);
250
270
  this.unsubscribeFunctions.push(() =>
251
- eventHelper.tenant.unsubscribe.registryUpdated(registryUpdatedCb)
271
+ eventHelper.tenant.unsubscribe.registryUpdated(registryUpdatedCb),
252
272
  );
253
- const registryUpdateErrorCb = (payload: RegistryUpdatePayload) => {
254
- }
273
+ const registryUpdateErrorCb = (payload: RegistryUpdatePayload) => {};
255
274
  eventHelper.tenant.subscribe.registryUpdateError(registryUpdateErrorCb);
256
275
  this.unsubscribeFunctions.push(() =>
257
- eventHelper.tenant.unsubscribe.registryUpdateError(registryUpdateErrorCb)
276
+ eventHelper.tenant.unsubscribe.registryUpdateError(registryUpdateErrorCb),
258
277
  );
259
278
  const deleteRegistryCb = (payload: RegistryUpdatePayload) => {
260
279
  deleteRegistry(payload.tenant, payload.registry, token);
261
- }
280
+ };
262
281
  eventHelper.tenant.subscribe.deleteRegistry(deleteRegistryCb);
263
282
  this.unsubscribeFunctions.push(() =>
264
- eventHelper.tenant.unsubscribe.deleteRegistry(deleteRegistryCb)
283
+ eventHelper.tenant.unsubscribe.deleteRegistry(deleteRegistryCb),
265
284
  );
266
- const registryDeletedCb = (payload: RegistryUpdatePayload) => {
267
- }
285
+ const registryDeletedCb = (payload: RegistryUpdatePayload) => {};
268
286
  eventHelper.tenant.subscribe.registryDeleted(registryDeletedCb);
269
287
  this.unsubscribeFunctions.push(() =>
270
- eventHelper.tenant.unsubscribe.registryDeleted(registryDeletedCb)
288
+ eventHelper.tenant.unsubscribe.registryDeleted(registryDeletedCb),
271
289
  );
272
- const registryDeletionErrorCb = (payload: RegistryUpdatePayload) => {
273
- }
290
+ const registryDeletionErrorCb = (payload: RegistryUpdatePayload) => {};
274
291
  eventHelper.tenant.subscribe.registryDeletionError(registryDeletionErrorCb);
275
292
  this.unsubscribeFunctions.push(() =>
276
- eventHelper.tenant.unsubscribe.registryDeletionError(registryDeletionErrorCb)
293
+ eventHelper.tenant.unsubscribe.registryDeletionError(
294
+ registryDeletionErrorCb,
295
+ ),
277
296
  );
278
- const inviteUserCb = (payload: { user: string; tenant: string; role: tenantRole }) => {
297
+ const inviteUserCb = (payload: {
298
+ user: string;
299
+ tenant: string;
300
+ role: tenantRole;
301
+ }) => {
279
302
  inviteUser(payload.tenant, payload.user, payload.role, token);
280
303
  };
281
304
  eventHelper.tenant.subscribe.inviteUser(inviteUserCb);
282
305
  this.unsubscribeFunctions.push(() =>
283
- eventHelper.tenant.unsubscribe.inviteUser(inviteUserCb)
306
+ eventHelper.tenant.unsubscribe.inviteUser(inviteUserCb),
284
307
  );
285
- const userInvitedCb = (payload: { user: string; tenant: string; role: tenantRole }) => {
308
+ const userInvitedCb = (payload: {
309
+ user: string;
310
+ tenant: string;
311
+ role: tenantRole;
312
+ }) => {
286
313
  updateUserRole(payload.user, payload.tenant, payload.role, token);
287
314
  };
288
315
  eventHelper.tenant.subscribe.userInvited(userInvitedCb);
289
316
  this.unsubscribeFunctions.push(() =>
290
- eventHelper.tenant.unsubscribe.userInvited(userInvitedCb)
317
+ eventHelper.tenant.unsubscribe.userInvited(userInvitedCb),
291
318
  );
292
- const userInviteErrorCb = (payload: { user: string; tenant: string; role: tenantRole }) => {
293
- };
319
+ const userInviteErrorCb = (payload: {
320
+ user: string;
321
+ tenant: string;
322
+ role: tenantRole;
323
+ }) => {};
294
324
  eventHelper.tenant.subscribe.inviteError(userInviteErrorCb);
295
325
  this.unsubscribeFunctions.push(() =>
296
- eventHelper.tenant.unsubscribe.inviteError(userInviteErrorCb)
326
+ eventHelper.tenant.unsubscribe.inviteError(userInviteErrorCb),
297
327
  );
298
- const removeUserFromTenantCb = (payload: { user: string; tenant: string }) => {
299
- removeUser(payload.tenant,payload.user, token)
300
- }
328
+ const removeUserFromTenantCb = (payload: {
329
+ user: string;
330
+ tenant: string;
331
+ }) => {
332
+ removeUser(payload.tenant, payload.user, token);
333
+ };
301
334
  eventHelper.tenant.subscribe.removeUser(removeUserFromTenantCb);
302
335
  this.unsubscribeFunctions.push(() =>
303
- eventHelper.tenant.unsubscribe.removeUser(removeUserFromTenantCb)
336
+ eventHelper.tenant.unsubscribe.removeUser(removeUserFromTenantCb),
304
337
  );
305
- const userRemovedFromTenantCb = (payload: { user: string; tenant: string }) => {
306
- }
338
+ const userRemovedFromTenantCb = (payload: {
339
+ user: string;
340
+ tenant: string;
341
+ }) => {};
307
342
  eventHelper.tenant.subscribe.userRemoved(userRemovedFromTenantCb);
308
343
  this.unsubscribeFunctions.push(() =>
309
- eventHelper.tenant.unsubscribe.userRemoved(userRemovedFromTenantCb)
344
+ eventHelper.tenant.unsubscribe.userRemoved(userRemovedFromTenantCb),
310
345
  );
311
- const userRemoveErrorCb = (payload: { user: string; tenant: string }) => {
312
- }
346
+ const userRemoveErrorCb = (payload: { user: string; tenant: string }) => {};
313
347
  eventHelper.tenant.subscribe.removeUserError(userRemoveErrorCb);
314
348
  this.unsubscribeFunctions.push(() =>
315
- eventHelper.tenant.unsubscribe.removeUserError(userRemoveErrorCb)
349
+ eventHelper.tenant.unsubscribe.removeUserError(userRemoveErrorCb),
316
350
  );
317
- const updateInviteCb = (payload: { user: string; role: tenantRole; tenant: string }) => {
318
- updateUserRole(payload.tenant, payload.user, payload.role, token)
319
- }
351
+ const updateInviteCb = (payload: {
352
+ user: string;
353
+ role: tenantRole;
354
+ tenant: string;
355
+ }) => {
356
+ updateUserRole(payload.tenant, payload.user, payload.role, token);
357
+ };
320
358
  eventHelper.tenant.subscribe.updateInvite(updateInviteCb);
321
359
  this.unsubscribeFunctions.push(() =>
322
- eventHelper.tenant.unsubscribe.updateInvite(updateInviteCb)
360
+ eventHelper.tenant.unsubscribe.updateInvite(updateInviteCb),
323
361
  );
324
- const inviteUpdatedCb = (payload: { user: string; role: string; tenant: string }) => {
325
- }
362
+ const inviteUpdatedCb = (payload: {
363
+ user: string;
364
+ role: string;
365
+ tenant: string;
366
+ }) => {};
326
367
  eventHelper.tenant.subscribe.inviteUpdated(inviteUpdatedCb);
327
368
  this.unsubscribeFunctions.push(() =>
328
- eventHelper.tenant.unsubscribe.inviteUpdated(inviteUpdatedCb)
369
+ eventHelper.tenant.unsubscribe.inviteUpdated(inviteUpdatedCb),
329
370
  );
330
- const inviteUpdateErrorCb = (payload: { user: string; role: string; tenant: string }) => {
331
- }
371
+ const inviteUpdateErrorCb = (payload: {
372
+ user: string;
373
+ role: string;
374
+ tenant: string;
375
+ }) => {};
332
376
  eventHelper.tenant.subscribe.inviteUpdateError(inviteUpdateErrorCb);
333
377
  this.unsubscribeFunctions.push(() =>
334
- eventHelper.tenant.unsubscribe.inviteUpdateError(inviteUpdateErrorCb)
378
+ eventHelper.tenant.unsubscribe.inviteUpdateError(inviteUpdateErrorCb),
335
379
  );
336
380
  const acceptInviteCb = (payload: { tenant: string }) => {
337
381
  acceptInvite(payload.tenant, token);
338
- }
382
+ };
339
383
  eventHelper.tenant.subscribe.acceptInvite(acceptInviteCb);
340
384
  this.unsubscribeFunctions.push(() =>
341
- eventHelper.tenant.unsubscribe.acceptInvite(acceptInviteCb)
385
+ eventHelper.tenant.unsubscribe.acceptInvite(acceptInviteCb),
342
386
  );
343
- const inviteAcceptedCb = (payload: { tenant: string}) => {
344
- }
387
+ const inviteAcceptedCb = (payload: { tenant: string }) => {};
345
388
  eventHelper.tenant.subscribe.inviteAccepted(inviteAcceptedCb);
346
389
  this.unsubscribeFunctions.push(() =>
347
- eventHelper.tenant.unsubscribe.inviteAccepted(inviteAcceptedCb)
390
+ eventHelper.tenant.unsubscribe.inviteAccepted(inviteAcceptedCb),
348
391
  );
349
- const inviteAcceptErrorCb = (payload: { tenant: string }) => {
350
- }
392
+ const inviteAcceptErrorCb = (payload: { tenant: string }) => {};
351
393
  eventHelper.tenant.subscribe.acceptInviteError(inviteAcceptErrorCb);
352
394
  this.unsubscribeFunctions.push(() =>
353
- eventHelper.tenant.unsubscribe.acceptInviteError(inviteAcceptErrorCb)
395
+ eventHelper.tenant.unsubscribe.acceptInviteError(inviteAcceptErrorCb),
354
396
  );
355
- const rejectInviteCb = (payload: { tenant: string }) => {
356
- rejectInvite(payload.tenant, token);
357
- }
397
+ const rejectInviteCb = (payload: { tenant: string; leave: boolean }) => {
398
+ rejectInvite(payload.tenant, token, payload.leave);
399
+ };
358
400
  eventHelper.tenant.subscribe.rejectInvite(rejectInviteCb);
359
401
  this.unsubscribeFunctions.push(() =>
360
- eventHelper.tenant.unsubscribe.rejectInvite(rejectInviteCb)
402
+ eventHelper.tenant.unsubscribe.rejectInvite(rejectInviteCb),
361
403
  );
362
- const inviteRejectedCb = (payload: { user: string; tenant: string }) => {
363
- }
404
+ const inviteRejectedCb = (payload: { user: string; tenant: string }) => {};
364
405
  eventHelper.tenant.subscribe.inviteRejected(inviteRejectedCb);
365
406
  this.unsubscribeFunctions.push(() =>
366
- eventHelper.tenant.unsubscribe.inviteRejected(inviteRejectedCb)
407
+ eventHelper.tenant.unsubscribe.inviteRejected(inviteRejectedCb),
367
408
  );
368
- const inviteRejectErrorCb = (payload: { tenant: string }) => {
369
- }
409
+ const inviteRejectErrorCb = (payload: { tenant: string }) => {};
370
410
  eventHelper.tenant.subscribe.inviteRejectError(inviteRejectErrorCb);
371
411
  this.unsubscribeFunctions.push(() =>
372
- eventHelper.tenant.unsubscribe.inviteRejectError(inviteRejectErrorCb)
412
+ eventHelper.tenant.unsubscribe.inviteRejectError(inviteRejectErrorCb),
373
413
  );
374
414
  const getPlanProvidersCb = () => {
375
415
  getPlanProviders(token);
376
- }
416
+ };
377
417
  eventHelper.planProviders.subscribe.loadPlans(getPlanProvidersCb);
378
418
  this.unsubscribeFunctions.push(() =>
379
- eventHelper.planProviders.unsubscribe.loadPlans(getPlanProvidersCb)
380
- );
381
- const crateTokenCb = (payload: { tenant: string; expiration: string; description: string }) => {
382
- createToken(payload.tenant, payload.description, payload.expiration, token);
383
-
384
- }
419
+ eventHelper.planProviders.unsubscribe.loadPlans(getPlanProvidersCb),
420
+ );
421
+ const crateTokenCb = (payload: {
422
+ tenant: string;
423
+ expiration: string;
424
+ description: string;
425
+ }) => {
426
+ createToken(
427
+ payload.tenant,
428
+ payload.description,
429
+ payload.expiration,
430
+ token,
431
+ );
432
+ };
385
433
  eventHelper.tenant.subscribe.createToken(crateTokenCb);
386
434
  this.unsubscribeFunctions.push(() =>
387
- eventHelper.tenant.unsubscribe.createToken(crateTokenCb)
435
+ eventHelper.tenant.unsubscribe.createToken(crateTokenCb),
388
436
  );
389
437
  const deleteTokenCb = (payload: { tenant: string; token: string }) => {
390
438
  deleteToken(payload.tenant, payload.token, token);
391
- }
439
+ };
392
440
  eventHelper.tenant.subscribe.deleteToken(deleteTokenCb);
393
441
  this.unsubscribeFunctions.push(() =>
394
- eventHelper.tenant.unsubscribe.deleteToken(deleteTokenCb)
442
+ eventHelper.tenant.unsubscribe.deleteToken(deleteTokenCb),
395
443
  );
396
444
  }
397
445
  /**
@@ -403,21 +451,19 @@ export class BackendHandler {
403
451
  };
404
452
  eventHelper.user.subscribe.creation(creationCb);
405
453
  this.unsubscribeFunctions.push(() =>
406
- eventHelper.user.unsubscribe.creation(creationCb)
454
+ eventHelper.user.unsubscribe.creation(creationCb),
407
455
  );
408
456
 
409
- const createdCb = (data: UserData) => {
410
- };
457
+ const createdCb = (data: UserData) => {};
411
458
  eventHelper.user.subscribe.created(createdCb);
412
459
  this.unsubscribeFunctions.push(() =>
413
- eventHelper.user.unsubscribe.created(createdCb)
460
+ eventHelper.user.unsubscribe.created(createdCb),
414
461
  );
415
462
 
416
- const creationErrorCb = (data: UserData) => {
417
- };
463
+ const creationErrorCb = (data: UserData) => {};
418
464
  eventHelper.user.subscribe.creationError(creationErrorCb);
419
465
  this.unsubscribeFunctions.push(() =>
420
- eventHelper.user.unsubscribe.creationError(creationErrorCb)
466
+ eventHelper.user.unsubscribe.creationError(creationErrorCb),
421
467
  );
422
468
 
423
469
  const updateCb = (data: UserData) => {
@@ -425,21 +471,19 @@ export class BackendHandler {
425
471
  };
426
472
  eventHelper.user.subscribe.update(updateCb);
427
473
  this.unsubscribeFunctions.push(() =>
428
- eventHelper.user.unsubscribe.update(updateCb)
474
+ eventHelper.user.unsubscribe.update(updateCb),
429
475
  );
430
476
 
431
- const updatedCb = (data: UserData) => {
432
- };
477
+ const updatedCb = (data: UserData) => {};
433
478
  eventHelper.user.subscribe.updated(updatedCb);
434
479
  this.unsubscribeFunctions.push(() =>
435
- eventHelper.user.unsubscribe.updated(updatedCb)
480
+ eventHelper.user.unsubscribe.updated(updatedCb),
436
481
  );
437
482
 
438
- const updateErrorCb = (data: UserData) => {
439
- };
483
+ const updateErrorCb = (data: UserData) => {};
440
484
  eventHelper.user.subscribe.updateError(updateErrorCb);
441
485
  this.unsubscribeFunctions.push(() =>
442
- eventHelper.user.unsubscribe.updateError(updateErrorCb)
486
+ eventHelper.user.unsubscribe.updateError(updateErrorCb),
443
487
  );
444
488
 
445
489
  const loadCb = (data: UserData) => {
@@ -447,7 +491,7 @@ export class BackendHandler {
447
491
  };
448
492
  eventHelper.user.subscribe.load(loadCb);
449
493
  this.unsubscribeFunctions.push(() =>
450
- eventHelper.user.unsubscribe.load(loadCb)
494
+ eventHelper.user.unsubscribe.load(loadCb),
451
495
  );
452
496
 
453
497
  // const loadedCb = (data: UserData) => {
@@ -458,11 +502,10 @@ export class BackendHandler {
458
502
  // eventHelper.user.unsubscribe.loaded(loadedCb)
459
503
  // );
460
504
 
461
- const loadErrorCb = (data: UserData) => {
462
- };
505
+ const loadErrorCb = (data: UserData) => {};
463
506
  eventHelper.user.subscribe.loadError(loadErrorCb);
464
507
  this.unsubscribeFunctions.push(() =>
465
- eventHelper.user.unsubscribe.loadError(loadErrorCb)
508
+ eventHelper.user.unsubscribe.loadError(loadErrorCb),
466
509
  );
467
510
 
468
511
  const deleteCb = (data: UserData) => {
@@ -470,21 +513,19 @@ export class BackendHandler {
470
513
  };
471
514
  eventHelper.user.subscribe.delete(deleteCb);
472
515
  this.unsubscribeFunctions.push(() =>
473
- eventHelper.user.unsubscribe.delete(deleteCb)
516
+ eventHelper.user.unsubscribe.delete(deleteCb),
474
517
  );
475
518
 
476
- const deletedCb = (data: UserData) => {
477
- };
519
+ const deletedCb = (data: UserData) => {};
478
520
  eventHelper.user.subscribe.deleted(deletedCb);
479
521
  this.unsubscribeFunctions.push(() =>
480
- eventHelper.user.unsubscribe.deleted(deletedCb)
522
+ eventHelper.user.unsubscribe.deleted(deletedCb),
481
523
  );
482
524
 
483
- const deletionErrorCb = (data: UserData) => {
484
- };
525
+ const deletionErrorCb = (data: UserData) => {};
485
526
  eventHelper.user.subscribe.deletionError(deletionErrorCb);
486
527
  this.unsubscribeFunctions.push(() =>
487
- eventHelper.user.unsubscribe.deletionError(deletionErrorCb)
528
+ eventHelper.user.unsubscribe.deletionError(deletionErrorCb),
488
529
  );
489
530
  }
490
531
  /**
@@ -496,21 +537,19 @@ export class BackendHandler {
496
537
  };
497
538
  eventHelper.account.subscribe.creation(creationCb);
498
539
  this.unsubscribeFunctions.push(() =>
499
- eventHelper.account.unsubscribe.creation(creationCb)
540
+ eventHelper.account.unsubscribe.creation(creationCb),
500
541
  );
501
542
 
502
- const createdCb = (data: Account) => {
503
- };
543
+ const createdCb = (data: Account) => {};
504
544
  eventHelper.account.subscribe.created(createdCb);
505
545
  this.unsubscribeFunctions.push(() =>
506
- eventHelper.account.unsubscribe.created(createdCb)
546
+ eventHelper.account.unsubscribe.created(createdCb),
507
547
  );
508
548
 
509
- const creationErrorCb = (data: Account) => {
510
- };
549
+ const creationErrorCb = (data: Account) => {};
511
550
  eventHelper.account.subscribe.creationError(creationErrorCb);
512
551
  this.unsubscribeFunctions.push(() =>
513
- eventHelper.account.unsubscribe.creationError(creationErrorCb)
552
+ eventHelper.account.unsubscribe.creationError(creationErrorCb),
514
553
  );
515
554
 
516
555
  const updateCb = (data: Account) => {
@@ -518,21 +557,19 @@ export class BackendHandler {
518
557
  };
519
558
  eventHelper.account.subscribe.update(updateCb);
520
559
  this.unsubscribeFunctions.push(() =>
521
- eventHelper.account.unsubscribe.update(updateCb)
560
+ eventHelper.account.unsubscribe.update(updateCb),
522
561
  );
523
562
 
524
- const updatedCb = (data: Account) => {
525
- };
563
+ const updatedCb = (data: Account) => {};
526
564
  eventHelper.account.subscribe.updated(updatedCb);
527
565
  this.unsubscribeFunctions.push(() =>
528
- eventHelper.account.unsubscribe.updated(updatedCb)
566
+ eventHelper.account.unsubscribe.updated(updatedCb),
529
567
  );
530
568
 
531
- const updateErrorCb = (data: Account) => {
532
- };
569
+ const updateErrorCb = (data: Account) => {};
533
570
  eventHelper.account.subscribe.updateError(updateErrorCb);
534
571
  this.unsubscribeFunctions.push(() =>
535
- eventHelper.account.unsubscribe.updateError(updateErrorCb)
572
+ eventHelper.account.unsubscribe.updateError(updateErrorCb),
536
573
  );
537
574
 
538
575
  const deleteCb = (data: Account) => {
@@ -540,96 +577,90 @@ export class BackendHandler {
540
577
  };
541
578
  eventHelper.account.subscribe.delete(deleteCb);
542
579
  this.unsubscribeFunctions.push(() =>
543
- eventHelper.account.unsubscribe.delete(deleteCb)
580
+ eventHelper.account.unsubscribe.delete(deleteCb),
544
581
  );
545
582
 
546
- const deletedCb = (data: Account) => {
547
- };
583
+ const deletedCb = (data: Account) => {};
548
584
  eventHelper.account.subscribe.deleted(deletedCb);
549
585
  this.unsubscribeFunctions.push(() =>
550
- eventHelper.account.unsubscribe.deleted(deletedCb)
586
+ eventHelper.account.unsubscribe.deleted(deletedCb),
551
587
  );
552
588
 
553
- const deletionErrorCb = (data: Account) => {
554
- };
589
+ const deletionErrorCb = (data: Account) => {};
555
590
  eventHelper.account.subscribe.deletionError(deletionErrorCb);
556
591
  this.unsubscribeFunctions.push(() =>
557
- eventHelper.account.unsubscribe.deletionError(deletionErrorCb)
592
+ eventHelper.account.unsubscribe.deletionError(deletionErrorCb),
558
593
  );
559
594
  const cleanCb = (data: Account) => {
560
595
  clearAccount(data, token);
561
596
  };
562
597
  eventHelper.account.subscribe.clean(cleanCb);
563
598
  this.unsubscribeFunctions.push(() =>
564
- eventHelper.account.unsubscribe.clean(cleanCb)
599
+ eventHelper.account.unsubscribe.clean(cleanCb),
565
600
  );
566
601
  }
567
602
  /**
568
603
  * Function to subscribe to the plan events
569
604
  */
570
605
  private subscribePlanEvents(): void {
571
- const updateCb = (data: string) => {
572
- };
606
+ const updateCb = (data: string) => {};
573
607
  eventHelper.plan.subscribe.upgrade(updateCb);
574
608
  this.unsubscribeFunctions.push(() =>
575
- eventHelper.plan.unsubscribe.upgrade(updateCb)
609
+ eventHelper.plan.unsubscribe.upgrade(updateCb),
576
610
  );
577
611
 
578
612
  const updatedCb = (data: string) => {
579
613
  const upgradeNotification: Notification = {
580
614
  type: "success",
581
- subtype: "plan-upgrade",
615
+ subtype: errors.user.planUpgraded.subtype,
582
616
  date: Date.now().toString(),
583
617
  status: "unread",
584
618
  callToAction: false,
585
619
  data: {
586
- plan: data
587
- }
620
+ plan: data,
621
+ },
588
622
  };
589
623
  eventHelper.notification.publish.creation(upgradeNotification);
590
624
  };
591
625
  eventHelper.plan.subscribe.upgraded(updatedCb);
592
626
  this.unsubscribeFunctions.push(() =>
593
- eventHelper.plan.unsubscribe.upgraded(updatedCb)
627
+ eventHelper.plan.unsubscribe.upgraded(updatedCb),
594
628
  );
595
629
 
596
- const updateErrorCb = (data: string) => {
597
- };
630
+ const updateErrorCb = (data: string) => {};
598
631
  eventHelper.plan.subscribe.upgradeError(updateErrorCb);
599
632
  this.unsubscribeFunctions.push(() =>
600
- eventHelper.plan.unsubscribe.upgradeError(updateErrorCb)
633
+ eventHelper.plan.unsubscribe.upgradeError(updateErrorCb),
601
634
  );
602
635
 
603
- const downgradeCb = (data: string) => {
604
- };
636
+ const downgradeCb = (data: string) => {};
605
637
  eventHelper.plan.subscribe.downgrade(downgradeCb);
606
638
  this.unsubscribeFunctions.push(() =>
607
- eventHelper.plan.unsubscribe.downgrade(downgradeCb)
639
+ eventHelper.plan.unsubscribe.downgrade(downgradeCb),
608
640
  );
609
641
 
610
642
  const downgradedCb = (data: string) => {
611
643
  const downgradeNotification: Notification = {
612
644
  type: "success",
613
- subtype: "plan-downgrade",
645
+ subtype: errors.user.planDowngraded.subtype,
614
646
  date: Date.now().toString(),
615
647
  status: "unread",
616
648
  callToAction: false,
617
649
  data: {
618
- plan: data
619
- }
650
+ plan: data,
651
+ },
620
652
  };
621
653
  eventHelper.notification.publish.creation(downgradeNotification);
622
654
  };
623
655
  eventHelper.plan.subscribe.downgraded(downgradedCb);
624
656
  this.unsubscribeFunctions.push(() =>
625
- eventHelper.plan.unsubscribe.downgraded(downgradedCb)
657
+ eventHelper.plan.unsubscribe.downgraded(downgradedCb),
626
658
  );
627
659
 
628
- const downgradeErrorCb = (data: string) => {
629
- };
660
+ const downgradeErrorCb = (data: string) => {};
630
661
  eventHelper.plan.subscribe.downgradeError(downgradeErrorCb);
631
662
  this.unsubscribeFunctions.push(() =>
632
- eventHelper.plan.unsubscribe.downgradeError(downgradeErrorCb)
663
+ eventHelper.plan.unsubscribe.downgradeError(downgradeErrorCb),
633
664
  );
634
665
  }
635
666
  /**
@@ -641,34 +672,33 @@ export class BackendHandler {
641
672
  };
642
673
  eventHelper.environment.subscribe.creation(creationCb);
643
674
  this.unsubscribeFunctions.push(() =>
644
- eventHelper.environment.unsubscribe.creation(creationCb)
675
+ eventHelper.environment.unsubscribe.creation(creationCb),
645
676
  );
646
677
 
647
678
  const createdCb = (data: Environment) => {
648
679
  const envNotification: Notification = {
649
680
  type: "success",
650
- subtype: "environment-created",
681
+ subtype: errors.environment.created.subtype,
651
682
  date: Date.now().toString(),
652
683
  status: "unread",
653
684
  callToAction: false,
654
- data : {
685
+ data: {
655
686
  environment: data.name,
656
687
  account: data.account,
657
- tenant: data.tenant
658
- }
688
+ tenant: data.tenant,
689
+ },
659
690
  };
660
691
  eventHelper.notification.publish.creation(envNotification);
661
692
  };
662
693
  eventHelper.environment.subscribe.created(createdCb);
663
694
  this.unsubscribeFunctions.push(() =>
664
- eventHelper.environment.unsubscribe.created(createdCb)
695
+ eventHelper.environment.unsubscribe.created(createdCb),
665
696
  );
666
697
 
667
- const creationErrorCb = (data: Environment) => {
668
- };
698
+ const creationErrorCb = (data: Environment) => {};
669
699
  eventHelper.environment.subscribe.creationError(creationErrorCb);
670
700
  this.unsubscribeFunctions.push(() =>
671
- eventHelper.environment.unsubscribe.creationError(creationErrorCb)
701
+ eventHelper.environment.unsubscribe.creationError(creationErrorCb),
672
702
  );
673
703
 
674
704
  const updateCb = (data: Environment) => {
@@ -676,21 +706,19 @@ export class BackendHandler {
676
706
  };
677
707
  eventHelper.environment.subscribe.update(updateCb);
678
708
  this.unsubscribeFunctions.push(() =>
679
- eventHelper.environment.unsubscribe.update(updateCb)
709
+ eventHelper.environment.unsubscribe.update(updateCb),
680
710
  );
681
711
 
682
- const updatedCb = (data: Environment) => {
683
- };
712
+ const updatedCb = (data: Environment) => {};
684
713
  eventHelper.environment.subscribe.updated(updatedCb);
685
714
  this.unsubscribeFunctions.push(() =>
686
- eventHelper.environment.unsubscribe.updated(updatedCb)
715
+ eventHelper.environment.unsubscribe.updated(updatedCb),
687
716
  );
688
717
 
689
- const updateErrorCb = (data: Environment) => {
690
- };
718
+ const updateErrorCb = (data: Environment) => {};
691
719
  eventHelper.environment.subscribe.updateError(updateErrorCb);
692
720
  this.unsubscribeFunctions.push(() =>
693
- eventHelper.environment.unsubscribe.updateError(updateErrorCb)
721
+ eventHelper.environment.unsubscribe.updateError(updateErrorCb),
694
722
  );
695
723
 
696
724
  const deleteCb = (data: Environment) => {
@@ -698,37 +726,34 @@ export class BackendHandler {
698
726
  };
699
727
  eventHelper.environment.subscribe.delete(deleteCb);
700
728
  this.unsubscribeFunctions.push(() =>
701
- eventHelper.environment.unsubscribe.delete(deleteCb)
729
+ eventHelper.environment.unsubscribe.delete(deleteCb),
702
730
  );
703
731
 
704
- const deletedCb = (data: Environment) => {
705
- };
732
+ const deletedCb = (data: Environment) => {};
706
733
  eventHelper.environment.subscribe.deleted(deletedCb);
707
734
  this.unsubscribeFunctions.push(() =>
708
- eventHelper.environment.unsubscribe.deleted(deletedCb)
735
+ eventHelper.environment.unsubscribe.deleted(deletedCb),
709
736
  );
710
737
 
711
- const deletionErrorCb = (data: Environment) => {
712
- };
738
+ const deletionErrorCb = (data: Environment) => {};
713
739
  eventHelper.environment.subscribe.deletionError(deletionErrorCb);
714
740
  this.unsubscribeFunctions.push(() =>
715
- eventHelper.environment.unsubscribe.deletionError(deletionErrorCb)
741
+ eventHelper.environment.unsubscribe.deletionError(deletionErrorCb),
716
742
  );
717
743
  const cleanCb = (data: Environment) => {
718
744
  clearEnvironment(data, token);
719
745
  };
720
746
  eventHelper.environment.subscribe.clean(cleanCb);
721
747
  this.unsubscribeFunctions.push(() =>
722
- eventHelper.environment.unsubscribe.clean(cleanCb)
748
+ eventHelper.environment.unsubscribe.clean(cleanCb),
723
749
  );
724
750
  const scaleCb = (data: Environment) => {
725
- console.log('Scale called', data)
726
751
  scaleEnvironment(data, token);
727
- }
752
+ };
728
753
  eventHelper.environment.subscribe.scale(scaleCb);
729
- this.unsubscribeFunctions.push(() =>
730
- eventHelper.environment.unsubscribe.scale(scaleCb)
731
- )
754
+ this.unsubscribeFunctions.push(() =>
755
+ eventHelper.environment.unsubscribe.scale(scaleCb),
756
+ );
732
757
  }
733
758
  /**
734
759
  * Function to subscribe to the service events
@@ -737,14 +762,14 @@ export class BackendHandler {
737
762
  const deployedCb = (data: Service) => {
738
763
  const deploymentSuccessNotification: Notification = {
739
764
  type: "success",
740
- subtype: "deployment-success",
765
+ subtype: errors.deployment.success.subtype,
741
766
  date: Date.now().toString(),
742
767
  status: "unread",
743
768
  callToAction: false,
744
769
  data: {
745
770
  service: data.name,
746
- tenant: data.tenant
747
- }
771
+ tenant: data.tenant,
772
+ },
748
773
  };
749
774
  eventHelper.notification.publish.creation(deploymentSuccessNotification);
750
775
  };
@@ -752,19 +777,19 @@ export class BackendHandler {
752
777
  const deploymentErrorCb = (data: Service) => {
753
778
  const deploymentErrorNotification: Notification = {
754
779
  type: "error",
755
- subtype: "deployment-error",
780
+ subtype: errors.deployment.error.subtype,
756
781
  date: Date.now().toString(),
757
782
  status: "unread",
758
783
  info_content: {
759
- code: data.error?.code || '',
760
- message: data.error?.message || '',
761
- timestamp: data.error?.timestamp || '',
784
+ code: data.error?.code || "",
785
+ message: data.error?.message || "",
786
+ timestamp: data.error?.timestamp || "",
762
787
  },
763
788
  callToAction: false,
764
789
  data: {
765
790
  service: data.name,
766
- tenant: data.tenant
767
- }
791
+ tenant: data.tenant,
792
+ },
768
793
  };
769
794
  eventHelper.notification.publish.creation(deploymentErrorNotification);
770
795
  };
@@ -773,143 +798,152 @@ export class BackendHandler {
773
798
  deployService(data, token);
774
799
  const deploymentSuccessNotification: Notification = {
775
800
  type: "info",
776
- subtype: "deployment-in-progress",
801
+ subtype: errors.deployment.inProgress.subtype,
777
802
  date: Date.now().toString(),
778
803
  status: "unread",
779
804
  callToAction: false,
780
805
  data: {
781
806
  service: data.name,
782
- tenant: data.tenant
783
- }
807
+ tenant: data.tenant,
808
+ },
784
809
  };
785
- data.download ? '' : eventHelper.notification.publish.creation(deploymentSuccessNotification);
810
+ data.download
811
+ ? ""
812
+ : eventHelper.notification.publish.creation(
813
+ deploymentSuccessNotification,
814
+ );
786
815
  };
787
816
  eventHelper.service.subscribe.deploy(deployCb);
788
817
  this.unsubscribeFunctions.push(() =>
789
- eventHelper.service.unsubscribe.deploy(deployCb)
818
+ eventHelper.service.unsubscribe.deploy(deployCb),
790
819
  );
791
820
 
792
-
793
821
  const updateCb = (data: Service) => {
794
822
  updateService(data, token);
795
823
  };
796
824
  eventHelper.service.subscribe.update(updateCb);
797
825
  this.unsubscribeFunctions.push(() =>
798
- eventHelper.service.unsubscribe.update(updateCb)
826
+ eventHelper.service.unsubscribe.update(updateCb),
799
827
  );
800
828
 
801
829
  const updatedCb = (data: Service) => {
802
830
  const deploymentNotification: Notification = {
803
831
  type: "success",
804
- subtype: "deployment-updated",
832
+ subtype: errors.deployment.updated.subtype,
805
833
  date: Date.now().toString(),
806
834
  status: "unread",
807
835
  callToAction: false,
808
836
  data: {
809
837
  service: data.name,
810
- tenant: data.tenant
811
- }
838
+ tenant: data.tenant,
839
+ },
812
840
  };
813
841
  eventHelper.notification.publish.creation(deploymentNotification);
814
842
  };
815
843
  eventHelper.service.subscribe.updated(updatedCb);
816
844
  this.unsubscribeFunctions.push(() =>
817
- eventHelper.service.unsubscribe.updated(updatedCb)
845
+ eventHelper.service.unsubscribe.updated(updatedCb),
818
846
  );
819
847
 
820
- const updateErrorCb = (data: Service) => {
821
- };
848
+ const updateErrorCb = (data: Service) => {};
822
849
  eventHelper.service.subscribe.updateError(updateErrorCb);
823
850
  this.unsubscribeFunctions.push(() =>
824
- eventHelper.service.unsubscribe.updateError(updateErrorCb)
851
+ eventHelper.service.unsubscribe.updateError(updateErrorCb),
825
852
  );
826
853
 
827
854
  const deleteCb = (data: Service) => {
828
855
  const deploymentNotification: Notification = {
829
856
  type: "info",
830
- subtype: "deployment-deleting",
857
+ subtype: errors.deployment.deleting.subtype,
831
858
  date: Date.now().toString(),
832
859
  status: "unread",
833
860
  callToAction: false,
834
861
  data: {
835
862
  service: data.name,
836
- tenant: data.tenant
837
- }
863
+ tenant: data.tenant,
864
+ },
838
865
  };
839
866
  eventHelper.notification.publish.creation(deploymentNotification);
840
867
  deleteService(data, token);
841
868
  };
842
869
  eventHelper.service.subscribe.delete(deleteCb);
843
870
  this.unsubscribeFunctions.push(() =>
844
- eventHelper.service.unsubscribe.delete(deleteCb)
871
+ eventHelper.service.unsubscribe.delete(deleteCb),
845
872
  );
846
873
 
847
874
  const deletedCb = (data: Service) => {
848
875
  const deploymentNotification: Notification = {
849
876
  type: "success",
850
- subtype: "deployment-deleted",
877
+ subtype: errors.deployment.deleted.subtype,
851
878
  date: Date.now().toString(),
852
879
  status: "unread",
853
880
  callToAction: false,
854
881
  data: {
855
882
  service: data.name,
856
- tenant: data.tenant
857
- }
883
+ tenant: data.tenant,
884
+ },
858
885
  };
859
886
  eventHelper.notification.publish.creation(deploymentNotification);
860
887
  };
861
888
  eventHelper.service.subscribe.deleted(deletedCb);
862
889
  this.unsubscribeFunctions.push(() =>
863
- eventHelper.service.unsubscribe.deleted(deletedCb)
890
+ eventHelper.service.unsubscribe.deleted(deletedCb),
864
891
  );
865
892
 
866
- const deletionErrorCb = (data: Service) => {
867
- };
893
+ const deletionErrorCb = (data: Service) => {};
868
894
  eventHelper.service.subscribe.deletionError(deletionErrorCb);
869
895
  this.unsubscribeFunctions.push(() =>
870
- eventHelper.service.unsubscribe.deletionError(deletionErrorCb)
896
+ eventHelper.service.unsubscribe.deletionError(deletionErrorCb),
871
897
  );
872
898
 
873
- const requestLogsCb = (data: Service) => {
874
- };
899
+ const requestLogsCb = (data: Service) => {};
875
900
  eventHelper.service.subscribe.requestLogs(requestLogsCb);
876
901
  this.unsubscribeFunctions.push(() =>
877
- eventHelper.service.unsubscribe.requestLogs(requestLogsCb)
902
+ eventHelper.service.unsubscribe.requestLogs(requestLogsCb),
878
903
  );
879
904
  const restartCb = (data: Service) => {
880
905
  restartService(data, token);
881
906
  };
882
907
  eventHelper.service.subscribe.restart(restartCb);
883
908
  this.unsubscribeFunctions.push(() =>
884
- eventHelper.service.unsubscribe.restart(restartCb)
909
+ eventHelper.service.unsubscribe.restart(restartCb),
885
910
  );
886
911
  const requestRevisionCb = (data: Service) => {
887
912
  requestRevisionData(data, token);
888
- }
913
+ };
889
914
  eventHelper.service.subscribe.requestRevisionData(requestRevisionCb);
890
915
  this.unsubscribeFunctions.push(() =>
891
- eventHelper.service.unsubscribe.requestRevisionData(requestRevisionCb)
916
+ eventHelper.service.unsubscribe.requestRevisionData(requestRevisionCb),
892
917
  );
893
918
  const updateServiceLinksCb = (data: Link) => {
894
919
  updateServiceLinks(data, token);
895
- }
920
+ };
896
921
  eventHelper.service.subscribe.updateServiceLinks(updateServiceLinksCb);
897
922
  this.unsubscribeFunctions.push(() =>
898
- eventHelper.service.unsubscribe.updateServiceLinks(updateServiceLinksCb)
923
+ eventHelper.service.unsubscribe.updateServiceLinks(updateServiceLinksCb),
899
924
  );
900
925
  const changeRevisionCb = (data: Service) => {
901
926
  changeRevision(data, token);
902
- }
927
+ };
903
928
  eventHelper.service.subscribe.changeRevision(changeRevisionCb);
904
929
  this.unsubscribeFunctions.push(() => {
905
930
  eventHelper.service.unsubscribe.changeRevision(changeRevisionCb);
906
- })
907
- const restartInstanceCb = (payload: { service: Service; roleId: string; instanceId: string; }) => {
908
- restartInstance(payload.service, payload.roleId, payload.instanceId, token);
909
- }
931
+ });
932
+ const restartInstanceCb = (payload: {
933
+ service: Service;
934
+ roleId: string;
935
+ instanceId: string;
936
+ }) => {
937
+ restartInstance(
938
+ payload.service,
939
+ payload.roleId,
940
+ payload.instanceId,
941
+ token,
942
+ );
943
+ };
910
944
  eventHelper.service.subscribe.restartInstance(restartInstanceCb);
911
945
  this.unsubscribeFunctions.push(() =>
912
- eventHelper.service.unsubscribe.restartInstance(restartInstanceCb)
946
+ eventHelper.service.unsubscribe.restartInstance(restartInstanceCb),
913
947
  );
914
948
  }
915
949
  /**
@@ -921,69 +955,60 @@ export class BackendHandler {
921
955
  };
922
956
  eventHelper.marketplace.subscribe.deployItem(deployItemCb);
923
957
  this.unsubscribeFunctions.push(() =>
924
- eventHelper.marketplace.unsubscribe.deployItem(deployItemCb)
958
+ eventHelper.marketplace.unsubscribe.deployItem(deployItemCb),
925
959
  );
926
960
 
927
- const itemDeployedCb = (data: Service) => {
928
- };
961
+ const itemDeployedCb = (data: Service) => {};
929
962
  eventHelper.marketplace.subscribe.itemDeployed(itemDeployedCb);
930
963
  this.unsubscribeFunctions.push(() =>
931
- eventHelper.marketplace.unsubscribe.itemDeployed(itemDeployedCb)
964
+ eventHelper.marketplace.unsubscribe.itemDeployed(itemDeployedCb),
932
965
  );
933
966
 
934
- const deploymentErrorCb = (data: Service) => {
935
- };
967
+ const deploymentErrorCb = (data: Service) => {};
936
968
  eventHelper.marketplace.subscribe.deploymentError(deploymentErrorCb);
937
969
  this.unsubscribeFunctions.push(() =>
938
- eventHelper.marketplace.unsubscribe.deploymentError(deploymentErrorCb)
970
+ eventHelper.marketplace.unsubscribe.deploymentError(deploymentErrorCb),
939
971
  );
940
972
 
941
- const updateItemCb = (data: Service) => {
942
- };
973
+ const updateItemCb = (data: Service) => {};
943
974
  eventHelper.marketplace.subscribe.updateItem(updateItemCb);
944
975
  this.unsubscribeFunctions.push(() =>
945
- eventHelper.marketplace.unsubscribe.updateItem(updateItemCb)
976
+ eventHelper.marketplace.unsubscribe.updateItem(updateItemCb),
946
977
  );
947
978
 
948
- const itemUpdatedCb = (data: Service) => {
949
- };
979
+ const itemUpdatedCb = (data: Service) => {};
950
980
  eventHelper.marketplace.subscribe.itemUpdated(itemUpdatedCb);
951
981
  this.unsubscribeFunctions.push(() =>
952
- eventHelper.marketplace.unsubscribe.itemUpdated(itemUpdatedCb)
982
+ eventHelper.marketplace.unsubscribe.itemUpdated(itemUpdatedCb),
953
983
  );
954
984
 
955
- const updateErrorCb = (data: Service) => {
956
- };
985
+ const updateErrorCb = (data: Service) => {};
957
986
  eventHelper.marketplace.subscribe.updateError(updateErrorCb);
958
987
  this.unsubscribeFunctions.push(() =>
959
- eventHelper.marketplace.unsubscribe.updateError(updateErrorCb)
988
+ eventHelper.marketplace.unsubscribe.updateError(updateErrorCb),
960
989
  );
961
990
 
962
- const deleteItemCb = (data: Service) => {
963
- };
991
+ const deleteItemCb = (data: Service) => {};
964
992
  eventHelper.marketplace.subscribe.deleteItem(deleteItemCb);
965
993
  this.unsubscribeFunctions.push(() =>
966
- eventHelper.marketplace.unsubscribe.deleteItem(deleteItemCb)
994
+ eventHelper.marketplace.unsubscribe.deleteItem(deleteItemCb),
967
995
  );
968
996
 
969
- const itemDeletedCb = (data: Service) => {
970
- };
997
+ const itemDeletedCb = (data: Service) => {};
971
998
  eventHelper.marketplace.subscribe.itemDeleted(itemDeletedCb);
972
999
  this.unsubscribeFunctions.push(() =>
973
- eventHelper.marketplace.unsubscribe.itemDeleted(itemDeletedCb)
1000
+ eventHelper.marketplace.unsubscribe.itemDeleted(itemDeletedCb),
974
1001
  );
975
1002
 
976
- const deletionErrorCb = (data: Service) => {
977
- };
1003
+ const deletionErrorCb = (data: Service) => {};
978
1004
  eventHelper.marketplace.subscribe.deletionError(deletionErrorCb);
979
1005
  this.unsubscribeFunctions.push(() =>
980
- eventHelper.marketplace.unsubscribe.deletionError(deletionErrorCb)
1006
+ eventHelper.marketplace.unsubscribe.deletionError(deletionErrorCb),
981
1007
  );
982
1008
 
983
1009
  const loadItemsCb = (data: string[]) => {
984
1010
  // getMarketplaceItems(data, token)
985
1011
  // .then((result) => {
986
-
987
1012
  // eventHelper.marketplace.publish.itemsLoaded(result.items);
988
1013
  // })
989
1014
  // .catch((err) => {
@@ -992,7 +1017,22 @@ export class BackendHandler {
992
1017
  };
993
1018
  eventHelper.marketplace.subscribe.loadItems(loadItemsCb);
994
1019
  this.unsubscribeFunctions.push(() =>
995
- eventHelper.marketplace.unsubscribe.loadItems(loadItemsCb)
1020
+ eventHelper.marketplace.unsubscribe.loadItems(loadItemsCb),
1021
+ );
1022
+ const loadSchemaCb = async (payload: string) => {
1023
+ try {
1024
+ const { item } = JSON.parse(payload) as { item: MarketplaceItem };
1025
+ await fetchAndStoreMarketplaceSchema(item);
1026
+ eventHelper.marketplace.publish.schemaLoaded(item);
1027
+ } catch (error) {
1028
+ console.error(`Error loading schema for marketplace item:`, error);
1029
+ eventHelper.marketplace.publish.schemaLoadError(payload);
1030
+ }
1031
+ };
1032
+
1033
+ eventHelper.marketplace.subscribe.loadSchema(loadSchemaCb);
1034
+ this.unsubscribeFunctions.push(() =>
1035
+ eventHelper.marketplace.unsubscribe.loadSchema(loadSchemaCb),
996
1036
  );
997
1037
  }
998
1038
  /**
@@ -1004,21 +1044,19 @@ export class BackendHandler {
1004
1044
  };
1005
1045
  eventHelper.resource.subscribe.creation(creationCb);
1006
1046
  this.unsubscribeFunctions.push(() =>
1007
- eventHelper.resource.unsubscribe.creation(creationCb)
1047
+ eventHelper.resource.unsubscribe.creation(creationCb),
1008
1048
  );
1009
1049
 
1010
- const createdCb = (data: Resource) => {
1011
- };
1050
+ const createdCb = (data: Resource) => {};
1012
1051
  eventHelper.resource.subscribe.created(createdCb);
1013
1052
  this.unsubscribeFunctions.push(() =>
1014
- eventHelper.resource.unsubscribe.created(createdCb)
1053
+ eventHelper.resource.unsubscribe.created(createdCb),
1015
1054
  );
1016
1055
 
1017
- const creationErrorCb = (data: Resource) => {
1018
- };
1056
+ const creationErrorCb = (data: Resource) => {};
1019
1057
  eventHelper.resource.subscribe.creationError(creationErrorCb);
1020
1058
  this.unsubscribeFunctions.push(() =>
1021
- eventHelper.resource.unsubscribe.creationError(creationErrorCb)
1059
+ eventHelper.resource.unsubscribe.creationError(creationErrorCb),
1022
1060
  );
1023
1061
 
1024
1062
  const updateCb = (data: Resource) => {
@@ -1026,21 +1064,19 @@ export class BackendHandler {
1026
1064
  };
1027
1065
  eventHelper.resource.subscribe.update(updateCb);
1028
1066
  this.unsubscribeFunctions.push(() =>
1029
- eventHelper.resource.unsubscribe.update(updateCb)
1067
+ eventHelper.resource.unsubscribe.update(updateCb),
1030
1068
  );
1031
1069
 
1032
- const updatedCb = (data: Resource) => {
1033
- };
1070
+ const updatedCb = (data: Resource) => {};
1034
1071
  eventHelper.resource.subscribe.updated(updatedCb);
1035
1072
  this.unsubscribeFunctions.push(() =>
1036
- eventHelper.resource.unsubscribe.updated(updatedCb)
1073
+ eventHelper.resource.unsubscribe.updated(updatedCb),
1037
1074
  );
1038
1075
 
1039
- const updateErrorCb = (data: Resource) => {
1040
- };
1076
+ const updateErrorCb = (data: Resource) => {};
1041
1077
  eventHelper.resource.subscribe.updateError(updateErrorCb);
1042
1078
  this.unsubscribeFunctions.push(() =>
1043
- eventHelper.resource.unsubscribe.updateError(updateErrorCb)
1079
+ eventHelper.resource.unsubscribe.updateError(updateErrorCb),
1044
1080
  );
1045
1081
 
1046
1082
  const deleteCb = (data: Resource) => {
@@ -1048,101 +1084,91 @@ export class BackendHandler {
1048
1084
  };
1049
1085
  eventHelper.resource.subscribe.delete(deleteCb);
1050
1086
  this.unsubscribeFunctions.push(() =>
1051
- eventHelper.resource.unsubscribe.delete(deleteCb)
1087
+ eventHelper.resource.unsubscribe.delete(deleteCb),
1052
1088
  );
1053
1089
 
1054
1090
  const deletedCb = (data: Resource) => {
1055
1091
  const resourceNotification: Notification = {
1056
- type: "success",
1057
- subtype: "resource-deleted",
1058
- date: Date.now().toString(),
1059
- status: "unread",
1060
- callToAction: false,
1061
- data: {
1062
- resource: data.name,
1063
- type: data.type,
1064
- tenant: data.tenant
1065
- }
1066
- };
1067
- eventHelper.notification.publish.creation(resourceNotification);
1092
+ type: "success",
1093
+ subtype: errors.resource.deleted.subtype,
1094
+ date: Date.now().toString(),
1095
+ status: "unread",
1096
+ callToAction: false,
1097
+ data: {
1098
+ resource: data.name,
1099
+ type: data.type,
1100
+ tenant: data.tenant,
1101
+ },
1102
+ };
1103
+ eventHelper.notification.publish.creation(resourceNotification);
1068
1104
  };
1069
1105
  eventHelper.resource.subscribe.deleted(deletedCb);
1070
1106
  this.unsubscribeFunctions.push(() =>
1071
- eventHelper.resource.unsubscribe.deleted(deletedCb)
1107
+ eventHelper.resource.unsubscribe.deleted(deletedCb),
1072
1108
  );
1073
1109
 
1074
- const deletionErrorCb = (data: Resource) => {
1075
- };
1110
+ const deletionErrorCb = (data: Resource) => {};
1076
1111
  eventHelper.resource.subscribe.deletionError(deletionErrorCb);
1077
1112
  this.unsubscribeFunctions.push(() =>
1078
- eventHelper.resource.unsubscribe.deletionError(deletionErrorCb)
1113
+ eventHelper.resource.unsubscribe.deletionError(deletionErrorCb),
1079
1114
  );
1080
1115
  }
1081
1116
  /**
1082
1117
  * Function to subscribe to the organization events
1083
1118
  */
1084
1119
  private subscribeOrganizationEvents(): void {
1085
- const creationCb = (data: Organization) => {
1086
- };
1120
+ const creationCb = (data: Organization) => {};
1087
1121
  eventHelper.organization.subscribe.creation(creationCb);
1088
1122
  this.unsubscribeFunctions.push(() =>
1089
- eventHelper.organization.unsubscribe.creation(creationCb)
1123
+ eventHelper.organization.unsubscribe.creation(creationCb),
1090
1124
  );
1091
1125
 
1092
- const createdCb = (data: Organization) => {
1093
- };
1126
+ const createdCb = (data: Organization) => {};
1094
1127
  eventHelper.organization.subscribe.created(createdCb);
1095
1128
  this.unsubscribeFunctions.push(() =>
1096
- eventHelper.organization.unsubscribe.created(createdCb)
1129
+ eventHelper.organization.unsubscribe.created(createdCb),
1097
1130
  );
1098
1131
 
1099
- const creationErrorCb = (data: Organization) => {
1100
- };
1132
+ const creationErrorCb = (data: Organization) => {};
1101
1133
  eventHelper.organization.subscribe.creationError(creationErrorCb);
1102
1134
  this.unsubscribeFunctions.push(() =>
1103
- eventHelper.organization.unsubscribe.creationError(creationErrorCb)
1135
+ eventHelper.organization.unsubscribe.creationError(creationErrorCb),
1104
1136
  );
1105
1137
 
1106
- const updateCb = (data: Organization) => {
1107
- };
1138
+ const updateCb = (data: Organization) => {};
1108
1139
  eventHelper.organization.subscribe.update(updateCb);
1109
1140
  this.unsubscribeFunctions.push(() =>
1110
- eventHelper.organization.unsubscribe.update(updateCb)
1141
+ eventHelper.organization.unsubscribe.update(updateCb),
1111
1142
  );
1112
1143
 
1113
- const updatedCb = (data: Organization) => {
1114
- };
1144
+ const updatedCb = (data: Organization) => {};
1115
1145
  eventHelper.organization.subscribe.updated(updatedCb);
1116
1146
  this.unsubscribeFunctions.push(() =>
1117
- eventHelper.organization.unsubscribe.updated(updatedCb)
1147
+ eventHelper.organization.unsubscribe.updated(updatedCb),
1118
1148
  );
1119
1149
 
1120
- const updateErrorCb = (data: Organization) => {
1121
- };
1150
+ const updateErrorCb = (data: Organization) => {};
1122
1151
  eventHelper.organization.subscribe.updateError(updateErrorCb);
1123
1152
  this.unsubscribeFunctions.push(() =>
1124
- eventHelper.organization.unsubscribe.updateError(updateErrorCb)
1153
+ eventHelper.organization.unsubscribe.updateError(updateErrorCb),
1125
1154
  );
1126
1155
 
1127
- const deleteCb = (data: Organization) => {
1128
- };
1156
+ const deleteCb = (data: Organization) => {};
1129
1157
  eventHelper.organization.subscribe.delete(deleteCb);
1130
1158
  this.unsubscribeFunctions.push(() =>
1131
- eventHelper.organization.unsubscribe.delete(deleteCb)
1159
+ eventHelper.organization.unsubscribe.delete(deleteCb),
1132
1160
  );
1133
1161
 
1134
- const deletedCb = (data: Organization) => {
1135
- };
1162
+ const deletedCb = (data: Organization) => {};
1136
1163
  eventHelper.organization.subscribe.deleted(deletedCb);
1137
1164
  this.unsubscribeFunctions.push(() =>
1138
- eventHelper.organization.unsubscribe.deleted(deletedCb)
1165
+ eventHelper.organization.unsubscribe.deleted(deletedCb),
1139
1166
  );
1140
1167
 
1141
- const deletionErrorCb = (data: Organization) => {
1142
- };
1168
+ const deletionErrorCb = (data: Organization) => {};
1143
1169
  eventHelper.organization.subscribe.deletionError(deletionErrorCb);
1144
1170
  this.unsubscribeFunctions.push(() =>
1145
- eventHelper.organization.unsubscribe.deletionError(deletionErrorCb)
1171
+ eventHelper.organization.unsubscribe.deletionError(deletionErrorCb),
1146
1172
  );
1147
1173
  }
1148
1174
  }