@kumori/aurora-backend-handler 1.0.49 → 1.0.51
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/api/account-api-service.ts +0 -6
- package/api/service-api-service.ts +215 -234
- package/api/user-api-service.ts +233 -203
- package/helpers/revision-helper.ts +270 -318
- package/helpers/service-helper.ts +189 -80
- package/package.json +2 -2
- package/websocket-manager.ts +12 -5
package/api/user-api-service.ts
CHANGED
|
@@ -4,23 +4,7 @@ import {
|
|
|
4
4
|
makeGlobalWebSocketRequest,
|
|
5
5
|
} from "../websocket-manager.ts";
|
|
6
6
|
import { environment } from "../environment.ts";
|
|
7
|
-
import {
|
|
8
|
-
Account,
|
|
9
|
-
Container,
|
|
10
|
-
Environment,
|
|
11
|
-
Instance,
|
|
12
|
-
MarketplaceItem,
|
|
13
|
-
Notification,
|
|
14
|
-
Organization,
|
|
15
|
-
Platform,
|
|
16
|
-
Registry,
|
|
17
|
-
Resource,
|
|
18
|
-
Service,
|
|
19
|
-
Tenant,
|
|
20
|
-
User,
|
|
21
|
-
UserData,
|
|
22
|
-
} from "@kumori/aurora-interfaces";
|
|
23
|
-
import { Revision } from "@kumori/aurora-interfaces/interfaces/revision-interface.ts";
|
|
7
|
+
import { Account, Container, Environment, Instance, MarketplaceItem, Notification, Organization, Platform, Registry, Resource, Service, Tenant, User, UserData } from "@kumori/aurora-interfaces";
|
|
24
8
|
|
|
25
9
|
type Security = string;
|
|
26
10
|
|
|
@@ -46,7 +30,7 @@ export const isUserLogged = async (security: Security) => {
|
|
|
46
30
|
{},
|
|
47
31
|
30000,
|
|
48
32
|
"GET",
|
|
49
|
-
"USER_INFO"
|
|
33
|
+
"USER_INFO"
|
|
50
34
|
);
|
|
51
35
|
userLogged = true;
|
|
52
36
|
} catch (error) {
|
|
@@ -70,9 +54,9 @@ export const createUser = async (user: User) => {
|
|
|
70
54
|
{
|
|
71
55
|
method: "POST",
|
|
72
56
|
body: JSON.stringify(userBody),
|
|
73
|
-
}
|
|
57
|
+
}
|
|
74
58
|
);
|
|
75
|
-
if
|
|
59
|
+
if(response.ok){
|
|
76
60
|
eventHelper.user.publish.created(user);
|
|
77
61
|
}
|
|
78
62
|
if (!response.ok) {
|
|
@@ -80,11 +64,10 @@ export const createUser = async (user: User) => {
|
|
|
80
64
|
user.name = error.code;
|
|
81
65
|
eventHelper.user.publish.creationError(user);
|
|
82
66
|
throw new Error(
|
|
83
|
-
`HTTP Error ${response.status}: ${error.message || "Unknown error"}
|
|
67
|
+
`HTTP Error ${response.status}: ${error.message || "Unknown error"}`
|
|
84
68
|
);
|
|
85
69
|
}
|
|
86
70
|
};
|
|
87
|
-
|
|
88
71
|
export const loadUserData = async () => {
|
|
89
72
|
try {
|
|
90
73
|
const response = await makeGlobalWebSocketRequest("user:user_info", {});
|
|
@@ -96,7 +79,13 @@ export const loadUserData = async () => {
|
|
|
96
79
|
id: userResponse.userRecord.id.name,
|
|
97
80
|
name: userResponse.userRecord.spec.userinfo.name,
|
|
98
81
|
surname: userResponse.userRecord.spec.userinfo.surname,
|
|
99
|
-
provider: [
|
|
82
|
+
provider: [
|
|
83
|
+
{
|
|
84
|
+
name: provider,
|
|
85
|
+
email: email || "",
|
|
86
|
+
password: "",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
100
89
|
notificationsEnabled: "true",
|
|
101
90
|
organizations: [],
|
|
102
91
|
clusterTokens: [],
|
|
@@ -113,12 +102,11 @@ export const loadUserData = async () => {
|
|
|
113
102
|
{ strict: true },
|
|
114
103
|
30000,
|
|
115
104
|
"GET",
|
|
116
|
-
"ALL_TENANTS"
|
|
105
|
+
"ALL_TENANTS"
|
|
117
106
|
);
|
|
118
107
|
const tenantsData = tenantsResponse.data;
|
|
119
108
|
const userTenants: Tenant[] = [];
|
|
120
109
|
const userOrganizations: Organization[] = [];
|
|
121
|
-
|
|
122
110
|
for (const [_, value] of Object.entries(tenantsData)) {
|
|
123
111
|
const parts = (value as any).toString().split(",");
|
|
124
112
|
userTenants.push({
|
|
@@ -133,18 +121,26 @@ export const loadUserData = async () => {
|
|
|
133
121
|
role: parts[1],
|
|
134
122
|
status: "healthy",
|
|
135
123
|
users: [],
|
|
136
|
-
registry: [
|
|
124
|
+
registry: [
|
|
125
|
+
{
|
|
126
|
+
name: "",
|
|
127
|
+
public: false,
|
|
128
|
+
credentials: "",
|
|
129
|
+
domain: "",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
137
132
|
});
|
|
138
133
|
}
|
|
139
|
-
|
|
140
134
|
for (const tenant of userTenants) {
|
|
141
135
|
try {
|
|
142
136
|
const tenantResponse = await makeGlobalWebSocketRequest(
|
|
143
137
|
"tenant:tenant_info",
|
|
144
|
-
{
|
|
138
|
+
{
|
|
139
|
+
tenant: tenant.name,
|
|
140
|
+
},
|
|
145
141
|
30000,
|
|
146
142
|
"GET",
|
|
147
|
-
tenant.name
|
|
143
|
+
tenant.name
|
|
148
144
|
);
|
|
149
145
|
const tenantData = tenantResponse.data;
|
|
150
146
|
const registries = tenantData?.registries?.registries;
|
|
@@ -161,18 +157,22 @@ export const loadUserData = async () => {
|
|
|
161
157
|
extra: {},
|
|
162
158
|
password: "",
|
|
163
159
|
};
|
|
164
|
-
if (tenantOptions?.endpoint)
|
|
160
|
+
if (tenantOptions?.endpoint) {
|
|
165
161
|
registry.domain = tenantOptions.endpoint;
|
|
166
|
-
|
|
162
|
+
}
|
|
163
|
+
if (tenantOptions?.credentials) {
|
|
167
164
|
registry.credentials = tenantOptions.credentials;
|
|
168
|
-
|
|
165
|
+
}
|
|
166
|
+
if (typeof tenantOptions?.public === "boolean") {
|
|
169
167
|
registry.public = tenantOptions.public;
|
|
170
|
-
|
|
168
|
+
}
|
|
169
|
+
if (tenantData?.domains && Object.keys(tenantData.domains)[0]) {
|
|
171
170
|
registry.name = Object.keys(tenantData.domains)[0];
|
|
171
|
+
}
|
|
172
172
|
tenant.registry.push(registry);
|
|
173
173
|
} else {
|
|
174
174
|
console.warn(
|
|
175
|
-
`No se encontró información de registry para el tenant ${tenant.name}
|
|
175
|
+
`No se encontró información de registry para el tenant ${tenant.name}`
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -193,7 +193,10 @@ export const loadUserData = async () => {
|
|
|
193
193
|
name: env.id.name,
|
|
194
194
|
account: `${account.account.id.parent.name}-${account.account.id.name}`,
|
|
195
195
|
tenant: account.account.id.parent.name.split("tenant/")[1],
|
|
196
|
-
logo: `${
|
|
196
|
+
logo: `${
|
|
197
|
+
env.logo ||
|
|
198
|
+
"https://kumori.systems/wp-content/uploads/2023/07/cropped-favicon-kumori.png"
|
|
199
|
+
}`,
|
|
197
200
|
services: [],
|
|
198
201
|
domains: [],
|
|
199
202
|
status: {
|
|
@@ -252,7 +255,7 @@ export const loadUserData = async () => {
|
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
const cloudProviderInfo = extractCloudProviderInfo(
|
|
255
|
-
account.account.spec
|
|
258
|
+
account.account.spec
|
|
256
259
|
);
|
|
257
260
|
const newAccount: Account = {
|
|
258
261
|
id: `${account.account.id.parent.name}-${account.account.id.name}`,
|
|
@@ -262,7 +265,10 @@ export const loadUserData = async () => {
|
|
|
262
265
|
name: account.account.spec.api,
|
|
263
266
|
...cloudProviderInfo,
|
|
264
267
|
},
|
|
265
|
-
logo: `${
|
|
268
|
+
logo: `${
|
|
269
|
+
account.account.spec.api ||
|
|
270
|
+
"https://kumori.systems/wp-content/uploads/2023/07/cropped-favicon-kumori.png"
|
|
271
|
+
}`,
|
|
266
272
|
environments: environmentsIds,
|
|
267
273
|
services: [],
|
|
268
274
|
domains: [],
|
|
@@ -271,9 +277,9 @@ export const loadUserData = async () => {
|
|
|
271
277
|
"InvalidCredentials"
|
|
272
278
|
? "InvalidCredentials"
|
|
273
279
|
: !account.account.status.validCredentials?.status &&
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
account.account.id !== "kumori"
|
|
281
|
+
? "pending"
|
|
282
|
+
: "healthy"
|
|
277
283
|
: "",
|
|
278
284
|
usage: {
|
|
279
285
|
current: {
|
|
@@ -329,7 +335,6 @@ export const loadUserData = async () => {
|
|
|
329
335
|
|
|
330
336
|
tenantAccounts.push(newAccount);
|
|
331
337
|
}
|
|
332
|
-
|
|
333
338
|
const kinds = [
|
|
334
339
|
"ca",
|
|
335
340
|
"certificate",
|
|
@@ -338,14 +343,18 @@ export const loadUserData = async () => {
|
|
|
338
343
|
"secret",
|
|
339
344
|
"volume",
|
|
340
345
|
];
|
|
346
|
+
|
|
341
347
|
for (const kind of kinds) {
|
|
342
348
|
try {
|
|
343
349
|
const resourcesResponse = await makeGlobalWebSocketRequest(
|
|
344
350
|
"resource:list_resources",
|
|
345
|
-
{
|
|
351
|
+
{
|
|
352
|
+
tenant: tenant.name,
|
|
353
|
+
kind: kind,
|
|
354
|
+
},
|
|
346
355
|
30000,
|
|
347
356
|
"GET",
|
|
348
|
-
"ALL_RESOURCES"
|
|
357
|
+
"ALL_RESOURCES"
|
|
349
358
|
);
|
|
350
359
|
const resourcesData = resourcesResponse.data;
|
|
351
360
|
if (
|
|
@@ -353,7 +362,7 @@ export const loadUserData = async () => {
|
|
|
353
362
|
!Array.isArray(resourcesData[kind])
|
|
354
363
|
) {
|
|
355
364
|
console.warn(
|
|
356
|
-
`No se encontraron recursos de tipo ${kind} o no es un array
|
|
365
|
+
`No se encontraron recursos de tipo ${kind} o no es un array`
|
|
357
366
|
);
|
|
358
367
|
continue;
|
|
359
368
|
}
|
|
@@ -363,21 +372,28 @@ export const loadUserData = async () => {
|
|
|
363
372
|
const resourceName = resource.id.name;
|
|
364
373
|
const resourceResponse = await makeGlobalWebSocketRequest(
|
|
365
374
|
"resource:resource_info",
|
|
366
|
-
{
|
|
375
|
+
{
|
|
376
|
+
tenant: tenant.name,
|
|
377
|
+
kind: kind,
|
|
378
|
+
resource: resourceName,
|
|
379
|
+
},
|
|
367
380
|
30000,
|
|
368
381
|
"GET",
|
|
369
|
-
resourceName
|
|
382
|
+
resourceName
|
|
370
383
|
);
|
|
371
384
|
const resourceDataJson = resourceResponse.data;
|
|
372
385
|
const resourceType = resourceDataJson.id.kind;
|
|
373
386
|
let resourceStatus: "used" | "available" | "error" =
|
|
374
387
|
"available";
|
|
375
388
|
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
389
|
+
if (
|
|
390
|
+
resourceDataJson.status &&
|
|
391
|
+
resourceDataJson.status.requested
|
|
392
|
+
) {
|
|
393
|
+
const requestedKeys = Object.keys(
|
|
394
|
+
resourceDataJson.status.requested
|
|
395
|
+
);
|
|
396
|
+
if (requestedKeys.length > 0) {
|
|
381
397
|
resourceStatus = "used";
|
|
382
398
|
}
|
|
383
399
|
}
|
|
@@ -401,7 +417,10 @@ export const loadUserData = async () => {
|
|
|
401
417
|
status: resourceStatus,
|
|
402
418
|
} as Resource);
|
|
403
419
|
} else if (
|
|
404
|
-
|
|
420
|
+
resourceType === "domain" ||
|
|
421
|
+
resourceType === "port" ||
|
|
422
|
+
resourceType === "ca" ||
|
|
423
|
+
resourceType === "secret"
|
|
405
424
|
) {
|
|
406
425
|
tenant.resources.push({
|
|
407
426
|
type: kind,
|
|
@@ -413,25 +432,26 @@ export const loadUserData = async () => {
|
|
|
413
432
|
} catch (resourceError) {
|
|
414
433
|
console.error(
|
|
415
434
|
`Error procesando recurso individual de tipo ${kind}:`,
|
|
416
|
-
resourceError
|
|
435
|
+
resourceError
|
|
417
436
|
);
|
|
418
437
|
}
|
|
419
438
|
}
|
|
420
439
|
} catch (error) {
|
|
421
440
|
console.error(
|
|
422
441
|
`Error procesando recursos de tipo ${kind}:`,
|
|
423
|
-
error
|
|
442
|
+
error
|
|
424
443
|
);
|
|
425
444
|
}
|
|
426
445
|
}
|
|
427
446
|
}
|
|
428
|
-
|
|
429
447
|
const servicesResponse = await makeGlobalWebSocketRequest(
|
|
430
448
|
"service:list_services",
|
|
431
|
-
{
|
|
449
|
+
{
|
|
450
|
+
tenant: tenant.name,
|
|
451
|
+
},
|
|
432
452
|
30000,
|
|
433
453
|
"GET",
|
|
434
|
-
"ALL_SERVICES"
|
|
454
|
+
"ALL_SERVICES"
|
|
435
455
|
);
|
|
436
456
|
const servicesData = servicesResponse.data;
|
|
437
457
|
const serviceEntries = Object.entries(servicesData);
|
|
@@ -444,7 +464,6 @@ export const loadUserData = async () => {
|
|
|
444
464
|
timestamp: "",
|
|
445
465
|
args: [],
|
|
446
466
|
};
|
|
447
|
-
|
|
448
467
|
const serviceResponse = await makeGlobalWebSocketRequest(
|
|
449
468
|
"service:describe_service",
|
|
450
469
|
{
|
|
@@ -454,11 +473,10 @@ export const loadUserData = async () => {
|
|
|
454
473
|
},
|
|
455
474
|
30000,
|
|
456
475
|
"GET",
|
|
457
|
-
(serviceValue as any).name
|
|
476
|
+
(serviceValue as any).name
|
|
458
477
|
);
|
|
459
478
|
const serviceData = serviceResponse.data;
|
|
460
|
-
|
|
461
|
-
let revisionData: any;
|
|
479
|
+
let revisionData;
|
|
462
480
|
try {
|
|
463
481
|
const revisionResponse = await makeGlobalWebSocketRequest(
|
|
464
482
|
"revision:revision_info",
|
|
@@ -469,7 +487,7 @@ export const loadUserData = async () => {
|
|
|
469
487
|
},
|
|
470
488
|
30000,
|
|
471
489
|
"GET_REVISION",
|
|
472
|
-
(serviceValue as any).name
|
|
490
|
+
(serviceValue as any).name
|
|
473
491
|
);
|
|
474
492
|
revisionData = revisionResponse.data;
|
|
475
493
|
} catch (revisionError) {
|
|
@@ -478,76 +496,48 @@ export const loadUserData = async () => {
|
|
|
478
496
|
message: "",
|
|
479
497
|
timestamp: "",
|
|
480
498
|
args: [],
|
|
481
|
-
}
|
|
499
|
+
},
|
|
482
500
|
console.warn(
|
|
483
|
-
`No se pudo obtener la revisión para el servicio ${
|
|
484
|
-
|
|
501
|
+
`No se pudo obtener la revisión para el servicio ${
|
|
502
|
+
(serviceValue as any).name
|
|
503
|
+
}:`,
|
|
504
|
+
revisionError
|
|
485
505
|
);
|
|
486
506
|
continue;
|
|
487
507
|
}
|
|
488
508
|
|
|
489
509
|
const serviceName = revisionData.solution.top;
|
|
490
|
-
|
|
491
|
-
// revisionData.revision is a string ID, revisionData.intensives has the resource limits
|
|
492
|
-
const revisionId: string = revisionData.revision;
|
|
493
|
-
const intensives = revisionData.intensives ?? {};
|
|
494
|
-
|
|
495
|
-
let rawHistoryData: any[] = [];
|
|
510
|
+
let revisionsData;
|
|
496
511
|
try {
|
|
497
512
|
const revisionsResponse = await makeGlobalWebSocketRequest(
|
|
498
513
|
"service:report_history_service",
|
|
499
|
-
{
|
|
514
|
+
{
|
|
515
|
+
tenant: tenant.name,
|
|
516
|
+
service: serviceName,
|
|
517
|
+
},
|
|
500
518
|
30000,
|
|
501
519
|
"GET_HISTORY",
|
|
502
|
-
serviceName
|
|
520
|
+
serviceName
|
|
503
521
|
);
|
|
504
|
-
|
|
522
|
+
revisionsData = revisionsResponse.data;
|
|
505
523
|
} catch (historyError) {
|
|
506
524
|
serviceStatus = {
|
|
507
525
|
code: "PENDING",
|
|
508
526
|
message: "",
|
|
509
527
|
timestamp: "",
|
|
510
528
|
args: [],
|
|
511
|
-
}
|
|
529
|
+
},
|
|
512
530
|
console.warn(
|
|
513
531
|
`No se pudo obtener el historial para el servicio ${serviceName}:`,
|
|
514
|
-
historyError
|
|
532
|
+
historyError
|
|
515
533
|
);
|
|
516
534
|
continue;
|
|
517
535
|
}
|
|
518
536
|
|
|
519
|
-
const revisions:
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
usage: {
|
|
524
|
-
current: {
|
|
525
|
-
cpu: 0,
|
|
526
|
-
memory: 0,
|
|
527
|
-
storage: 0,
|
|
528
|
-
volatileStorage: 0,
|
|
529
|
-
nonReplicatedStorage: 0,
|
|
530
|
-
persistentStorage: 0,
|
|
531
|
-
},
|
|
532
|
-
limit: {
|
|
533
|
-
cpu: { max: 0, min: 0 },
|
|
534
|
-
memory: { max: 0, min: 0 },
|
|
535
|
-
storage: { max: 0, min: 0 },
|
|
536
|
-
volatileStorage: { max: 0, min: 0 },
|
|
537
|
-
nonReplicatedStorage: { max: 0, min: 0 },
|
|
538
|
-
persistentStorage: { max: 0, min: 0 },
|
|
539
|
-
},
|
|
540
|
-
cost: 0,
|
|
541
|
-
},
|
|
542
|
-
status: entry.status ?? {
|
|
543
|
-
code: "",
|
|
544
|
-
message: "",
|
|
545
|
-
timestamp: "",
|
|
546
|
-
args: [],
|
|
547
|
-
},
|
|
548
|
-
createdAt: entry.createdAt ?? "",
|
|
549
|
-
}),
|
|
550
|
-
);
|
|
537
|
+
const revisions: string[] = [];
|
|
538
|
+
for (const revision of revisionsData) {
|
|
539
|
+
revisions.push(revision.revision);
|
|
540
|
+
}
|
|
551
541
|
|
|
552
542
|
const serviceRoles: { name: string; instances: Instance[] }[] =
|
|
553
543
|
[];
|
|
@@ -568,13 +558,13 @@ export const loadUserData = async () => {
|
|
|
568
558
|
},
|
|
569
559
|
30000,
|
|
570
560
|
"GET_ROLE",
|
|
571
|
-
|
|
561
|
+
serviceName + "_" + roleName
|
|
572
562
|
);
|
|
573
563
|
const instancesData = instancesResponse.data;
|
|
574
564
|
const instances: Instance[] = [];
|
|
575
565
|
|
|
576
566
|
for (const [instanceName, instanceValue] of Object.entries(
|
|
577
|
-
instancesData.instances
|
|
567
|
+
instancesData.instances
|
|
578
568
|
)) {
|
|
579
569
|
const containers: Container[] = [];
|
|
580
570
|
for (const [
|
|
@@ -630,15 +620,27 @@ export const loadUserData = async () => {
|
|
|
630
620
|
.artifact.description.code[roleName]?.size
|
|
631
621
|
?.memory?.size / 1000,
|
|
632
622
|
},
|
|
633
|
-
storage: {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
623
|
+
storage: {
|
|
624
|
+
max: 0,
|
|
625
|
+
min: 0,
|
|
626
|
+
},
|
|
627
|
+
volatileStorage: {
|
|
628
|
+
max: 0,
|
|
629
|
+
min: 0,
|
|
630
|
+
},
|
|
631
|
+
nonReplicatedStorage: {
|
|
632
|
+
max: 0,
|
|
633
|
+
min: 0,
|
|
634
|
+
},
|
|
635
|
+
persistentStorage: {
|
|
636
|
+
max: 0,
|
|
637
|
+
min: 0,
|
|
638
|
+
},
|
|
637
639
|
},
|
|
638
640
|
cost: 0,
|
|
639
641
|
},
|
|
640
642
|
logs: [],
|
|
641
|
-
containers,
|
|
643
|
+
containers: containers,
|
|
642
644
|
});
|
|
643
645
|
}
|
|
644
646
|
serviceRoles.push({ name: roleName, instances });
|
|
@@ -648,10 +650,10 @@ export const loadUserData = async () => {
|
|
|
648
650
|
message: "",
|
|
649
651
|
timestamp: "",
|
|
650
652
|
args: [],
|
|
651
|
-
}
|
|
653
|
+
},
|
|
652
654
|
console.warn(
|
|
653
655
|
`Error obteniendo instancias para el rol ${roleName}:`,
|
|
654
|
-
instanceError
|
|
656
|
+
instanceError
|
|
655
657
|
);
|
|
656
658
|
}
|
|
657
659
|
}
|
|
@@ -674,7 +676,7 @@ export const loadUserData = async () => {
|
|
|
674
676
|
name: (serviceValue as any).name,
|
|
675
677
|
logo: "",
|
|
676
678
|
description: "",
|
|
677
|
-
revisions,
|
|
679
|
+
revisions: revisions,
|
|
678
680
|
status: serviceStatus,
|
|
679
681
|
role: serviceRoles,
|
|
680
682
|
links: [],
|
|
@@ -691,53 +693,57 @@ export const loadUserData = async () => {
|
|
|
691
693
|
},
|
|
692
694
|
limit: {
|
|
693
695
|
cpu: {
|
|
694
|
-
max: intensives.vcpu / 1000,
|
|
695
|
-
min: intensives.vcpu / 1000,
|
|
696
|
+
max: revisionData.revision.spec.intensives.vcpu / 1000,
|
|
697
|
+
min: revisionData.revision.spec.intensives.vcpu / 1000,
|
|
696
698
|
},
|
|
697
699
|
memory: {
|
|
698
|
-
max: intensives.ram / 1000,
|
|
699
|
-
min: intensives.ram / 1000,
|
|
700
|
+
max: revisionData.revision.spec.intensives.ram / 1000,
|
|
701
|
+
min: revisionData.revision.spec.intensives.ram / 1000,
|
|
700
702
|
},
|
|
701
703
|
storage: {
|
|
702
|
-
max: intensives.shared_disk,
|
|
703
|
-
min: intensives.shared_disk,
|
|
704
|
+
max: revisionData.revision.spec.intensives.shared_disk,
|
|
705
|
+
min: revisionData.revision.spec.intensives.shared_disk,
|
|
704
706
|
},
|
|
705
707
|
volatileStorage: {
|
|
706
|
-
max: intensives.volatile_disk,
|
|
707
|
-
min: intensives.volatile_disk,
|
|
708
|
+
max: revisionData.revision.spec.intensives.volatile_disk,
|
|
709
|
+
min: revisionData.revision.spec.intensives.volatile_disk,
|
|
708
710
|
},
|
|
709
711
|
nonReplicatedStorage: {
|
|
710
|
-
max: intensives
|
|
711
|
-
|
|
712
|
+
max: revisionData.revision.spec.intensives
|
|
713
|
+
.nrpersistent_disk,
|
|
714
|
+
min: revisionData.revision.spec.intensives
|
|
715
|
+
.nrpersistent_disk,
|
|
712
716
|
},
|
|
713
717
|
persistentStorage: {
|
|
714
|
-
max: intensives
|
|
715
|
-
|
|
718
|
+
max: revisionData.revision.spec.intensives
|
|
719
|
+
.persistent_disk,
|
|
720
|
+
min: revisionData.revision.spec.intensives
|
|
721
|
+
.persistent_disk,
|
|
716
722
|
},
|
|
717
723
|
},
|
|
718
724
|
cost: 0,
|
|
719
725
|
},
|
|
720
726
|
minReplicas: 0,
|
|
721
727
|
maxReplicas: 0,
|
|
722
|
-
lastDeployed: `${revisionData.tstamp
|
|
728
|
+
lastDeployed: `${revisionData.revision.spec.tstamp}`,
|
|
723
729
|
project: "",
|
|
724
730
|
registry:
|
|
725
731
|
roles[firstRoleName].artifact.description.code[containerName]
|
|
726
|
-
|
|
732
|
+
.image.hub.name,
|
|
727
733
|
imageName:
|
|
728
734
|
roles[firstRoleName].artifact.description.code[containerName]
|
|
729
|
-
|
|
735
|
+
.image.tag,
|
|
730
736
|
entrypoint:
|
|
731
737
|
roles[firstRoleName].artifact.description.code[containerName]
|
|
732
|
-
|
|
733
|
-
cmd:
|
|
734
|
-
|
|
735
|
-
|
|
738
|
+
.entrypoint,
|
|
739
|
+
cmd: roles[firstRoleName].artifact.description.code[
|
|
740
|
+
containerName
|
|
741
|
+
].cmd,
|
|
736
742
|
serverChannels: [],
|
|
737
743
|
clientChannels: [],
|
|
738
744
|
duplexChannels: [],
|
|
739
745
|
cloudProvider: "",
|
|
740
|
-
currentRevision:
|
|
746
|
+
currentRevision: revisionData.revision.id.name,
|
|
741
747
|
};
|
|
742
748
|
|
|
743
749
|
userServices.push(newService);
|
|
@@ -745,25 +751,27 @@ export const loadUserData = async () => {
|
|
|
745
751
|
console.error("Error al obtener los datos del servicio:", error);
|
|
746
752
|
}
|
|
747
753
|
}
|
|
748
|
-
|
|
749
754
|
for (const account of tenantAccounts) {
|
|
750
755
|
account.services = userServices
|
|
751
756
|
.filter((service) => service.account === account.name)
|
|
752
757
|
.map((service) => service.name);
|
|
753
758
|
}
|
|
754
|
-
for (const
|
|
755
|
-
|
|
756
|
-
.filter((service) => service.environment ===
|
|
759
|
+
for (const environment of tenantEnvironments) {
|
|
760
|
+
environment.services = userServices
|
|
761
|
+
.filter((service) => service.environment === environment.name)
|
|
757
762
|
.map((service) => service.name);
|
|
758
763
|
}
|
|
759
764
|
|
|
760
765
|
try {
|
|
761
766
|
const marketplaceResponse = await makeGlobalWebSocketRequest(
|
|
762
767
|
"marketplace:search_marketplace",
|
|
763
|
-
{
|
|
768
|
+
{
|
|
769
|
+
tenant: tenant.name,
|
|
770
|
+
name: "",
|
|
771
|
+
},
|
|
764
772
|
30000,
|
|
765
773
|
"GET",
|
|
766
|
-
"MARKETPLACE"
|
|
774
|
+
"MARKETPLACE"
|
|
767
775
|
);
|
|
768
776
|
const marketplaceData = marketplaceResponse.data;
|
|
769
777
|
const tenantItems: MarketplaceItem[] = [];
|
|
@@ -771,31 +779,36 @@ export const loadUserData = async () => {
|
|
|
771
779
|
let cpu = 0;
|
|
772
780
|
let memory = 0;
|
|
773
781
|
(value as any).tags.forEach((tag: string) => {
|
|
774
|
-
if (tag.includes("cpu"))
|
|
782
|
+
if (tag.includes("cpu")) {
|
|
775
783
|
cpu = Number(tag.split("::")[1].split("vCPU")[0]);
|
|
776
|
-
else if (tag.includes("memory"))
|
|
784
|
+
} else if (tag.includes("memory")) {
|
|
777
785
|
memory = Number(tag.split("::")[1].split("MB")[0]);
|
|
786
|
+
}
|
|
778
787
|
});
|
|
779
|
-
|
|
788
|
+
const item: MarketplaceItem = {
|
|
780
789
|
tenant: tenant.toString(),
|
|
781
790
|
name: (value as any).name,
|
|
782
791
|
logo: (value as any).icon,
|
|
783
792
|
description: (value as any).name,
|
|
784
793
|
version: (value as any).version,
|
|
785
|
-
requirements: {
|
|
794
|
+
requirements: {
|
|
795
|
+
cpu: cpu,
|
|
796
|
+
memory: memory,
|
|
797
|
+
},
|
|
786
798
|
status: "",
|
|
787
799
|
instances: [],
|
|
788
800
|
links: [],
|
|
789
801
|
resources: [],
|
|
790
802
|
domain: (value as any).domain,
|
|
791
803
|
type: (value as any).artifactTypes[0],
|
|
792
|
-
}
|
|
804
|
+
};
|
|
805
|
+
tenantItems.push(item);
|
|
793
806
|
});
|
|
794
807
|
tenant.marketplaceItems = tenantItems;
|
|
795
808
|
} catch (marketplaceError) {
|
|
796
809
|
console.error(
|
|
797
810
|
`Error obteniendo marketplace para tenant ${tenant.name}:`,
|
|
798
|
-
marketplaceError
|
|
811
|
+
marketplaceError
|
|
799
812
|
);
|
|
800
813
|
tenant.marketplaceItems = [];
|
|
801
814
|
}
|
|
@@ -811,14 +824,17 @@ export const loadUserData = async () => {
|
|
|
811
824
|
try {
|
|
812
825
|
const organizationsResponse = await makeGlobalWebSocketRequest(
|
|
813
826
|
"organization:list_organizations",
|
|
814
|
-
{
|
|
827
|
+
{
|
|
828
|
+
strict: true,
|
|
829
|
+
},
|
|
815
830
|
30000,
|
|
816
831
|
"GET",
|
|
817
|
-
"ORGANIZATIONS"
|
|
832
|
+
"ORGANIZATIONS"
|
|
818
833
|
);
|
|
819
834
|
const organizationsData = organizationsResponse.data;
|
|
820
|
-
|
|
821
|
-
|
|
835
|
+
const organizationsEntries = Object.entries(organizationsData);
|
|
836
|
+
for (const [, organizationValue] of organizationsEntries) {
|
|
837
|
+
const newOrg = {
|
|
822
838
|
id: (organizationValue as any).spec.companyName,
|
|
823
839
|
name: (organizationValue as any).id.name,
|
|
824
840
|
usersIds: Object.keys((organizationValue as any).spec.users),
|
|
@@ -835,7 +851,8 @@ export const loadUserData = async () => {
|
|
|
835
851
|
zipcode: (organizationValue as any).spec.billing.zip,
|
|
836
852
|
},
|
|
837
853
|
invoices: [],
|
|
838
|
-
}
|
|
854
|
+
};
|
|
855
|
+
userOrganizations.push(newOrg);
|
|
839
856
|
}
|
|
840
857
|
} catch (organizationError) {
|
|
841
858
|
console.error("Error obteniendo organizaciones:", organizationError);
|
|
@@ -847,8 +864,9 @@ export const loadUserData = async () => {
|
|
|
847
864
|
{},
|
|
848
865
|
30000,
|
|
849
866
|
"GET",
|
|
850
|
-
"PLATFORM"
|
|
867
|
+
"PLATFORM"
|
|
851
868
|
);
|
|
869
|
+
|
|
852
870
|
const platformData: Platform = {
|
|
853
871
|
instanceName: String(platformResponse.instanceName),
|
|
854
872
|
platformVersion: String(platformResponse.platformVersion),
|
|
@@ -867,72 +885,72 @@ export const loadUserData = async () => {
|
|
|
867
885
|
freemiumAdvancedLimits: {
|
|
868
886
|
vcpu: {
|
|
869
887
|
lowmark: Number(
|
|
870
|
-
platformResponse.freemiumAdvancedLimits.vcpu.lowmark
|
|
888
|
+
platformResponse.freemiumAdvancedLimits.vcpu.lowmark
|
|
871
889
|
),
|
|
872
890
|
highmark: Number(
|
|
873
|
-
platformResponse.freemiumAdvancedLimits.vcpu.highmark
|
|
891
|
+
platformResponse.freemiumAdvancedLimits.vcpu.highmark
|
|
874
892
|
),
|
|
875
893
|
unit: String(platformResponse.freemiumAdvancedLimits.vcpu.unit),
|
|
876
894
|
},
|
|
877
895
|
memory: {
|
|
878
896
|
lowmark: Number(
|
|
879
|
-
platformResponse.freemiumAdvancedLimits.memory.lowmark
|
|
897
|
+
platformResponse.freemiumAdvancedLimits.memory.lowmark
|
|
880
898
|
),
|
|
881
899
|
highmark: Number(
|
|
882
|
-
platformResponse.freemiumAdvancedLimits.memory.highmark
|
|
900
|
+
platformResponse.freemiumAdvancedLimits.memory.highmark
|
|
883
901
|
),
|
|
884
902
|
unit: String(platformResponse.freemiumAdvancedLimits.memory.unit),
|
|
885
903
|
},
|
|
886
904
|
vstorage: {
|
|
887
905
|
lowmark: Number(
|
|
888
|
-
platformResponse.freemiumAdvancedLimits.vstorage.lowmark
|
|
906
|
+
platformResponse.freemiumAdvancedLimits.vstorage.lowmark
|
|
889
907
|
),
|
|
890
908
|
highmark: Number(
|
|
891
|
-
platformResponse.freemiumAdvancedLimits.vstorage.highmark
|
|
909
|
+
platformResponse.freemiumAdvancedLimits.vstorage.highmark
|
|
892
910
|
),
|
|
893
911
|
unit: String(
|
|
894
|
-
platformResponse.freemiumAdvancedLimits.vstorage.unit
|
|
912
|
+
platformResponse.freemiumAdvancedLimits.vstorage.unit
|
|
895
913
|
),
|
|
896
914
|
},
|
|
897
915
|
nrstorage: {
|
|
898
916
|
lowmark: Number(
|
|
899
|
-
platformResponse.freemiumAdvancedLimits.nrstorage.lowmark
|
|
917
|
+
platformResponse.freemiumAdvancedLimits.nrstorage.lowmark
|
|
900
918
|
),
|
|
901
919
|
highmark: Number(
|
|
902
|
-
platformResponse.freemiumAdvancedLimits.nrstorage.highmark
|
|
920
|
+
platformResponse.freemiumAdvancedLimits.nrstorage.highmark
|
|
903
921
|
),
|
|
904
922
|
unit: String(
|
|
905
|
-
platformResponse.freemiumAdvancedLimits.nrstorage.unit
|
|
923
|
+
platformResponse.freemiumAdvancedLimits.nrstorage.unit
|
|
906
924
|
),
|
|
907
925
|
},
|
|
908
926
|
rstorage: {
|
|
909
927
|
lowmark: Number(
|
|
910
|
-
platformResponse.freemiumAdvancedLimits.rstorage.lowmark
|
|
928
|
+
platformResponse.freemiumAdvancedLimits.rstorage.lowmark
|
|
911
929
|
),
|
|
912
930
|
highmark: Number(
|
|
913
|
-
platformResponse.freemiumAdvancedLimits.rstorage.highmark
|
|
931
|
+
platformResponse.freemiumAdvancedLimits.rstorage.highmark
|
|
914
932
|
),
|
|
915
933
|
unit: String(
|
|
916
|
-
platformResponse.freemiumAdvancedLimits.rstorage.unit
|
|
934
|
+
platformResponse.freemiumAdvancedLimits.rstorage.unit
|
|
917
935
|
),
|
|
918
936
|
},
|
|
919
937
|
storage: {
|
|
920
938
|
lowmark: Number(
|
|
921
|
-
platformResponse.freemiumAdvancedLimits.storage.lowmark
|
|
939
|
+
platformResponse.freemiumAdvancedLimits.storage.lowmark
|
|
922
940
|
),
|
|
923
941
|
highmark: Number(
|
|
924
|
-
platformResponse.freemiumAdvancedLimits.storage.highmark
|
|
942
|
+
platformResponse.freemiumAdvancedLimits.storage.highmark
|
|
925
943
|
),
|
|
926
944
|
unit: String(
|
|
927
|
-
platformResponse.freemiumAdvancedLimits.storage.unit
|
|
945
|
+
platformResponse.freemiumAdvancedLimits.storage.unit
|
|
928
946
|
),
|
|
929
947
|
},
|
|
930
948
|
cost: {
|
|
931
949
|
lowmark: Number(
|
|
932
|
-
platformResponse.freemiumAdvancedLimits.cost.lowmark
|
|
950
|
+
platformResponse.freemiumAdvancedLimits.cost.lowmark
|
|
933
951
|
),
|
|
934
952
|
highmark: Number(
|
|
935
|
-
platformResponse.freemiumAdvancedLimits.cost.highmark
|
|
953
|
+
platformResponse.freemiumAdvancedLimits.cost.highmark
|
|
936
954
|
),
|
|
937
955
|
unit: String(platformResponse.freemiumAdvancedLimits.cost.unit),
|
|
938
956
|
},
|
|
@@ -951,30 +969,30 @@ export const loadUserData = async () => {
|
|
|
951
969
|
vstorage: {
|
|
952
970
|
lowmark: Number(platformResponse.freemiumLimits.vstorage.lowmark),
|
|
953
971
|
highmark: Number(
|
|
954
|
-
platformResponse.freemiumLimits.vstorage.highmark
|
|
972
|
+
platformResponse.freemiumLimits.vstorage.highmark
|
|
955
973
|
),
|
|
956
974
|
unit: String(platformResponse.freemiumLimits.vstorage.unit),
|
|
957
975
|
},
|
|
958
976
|
nrstorage: {
|
|
959
977
|
lowmark: Number(
|
|
960
|
-
platformResponse.freemiumLimits.nrstorage.lowmark
|
|
978
|
+
platformResponse.freemiumLimits.nrstorage.lowmark
|
|
961
979
|
),
|
|
962
980
|
highmark: Number(
|
|
963
|
-
platformResponse.freemiumLimits.nrstorage.highmark
|
|
981
|
+
platformResponse.freemiumLimits.nrstorage.highmark
|
|
964
982
|
),
|
|
965
983
|
unit: String(platformResponse.freemiumLimits.nrstorage.unit),
|
|
966
984
|
},
|
|
967
985
|
rstorage: {
|
|
968
986
|
lowmark: Number(platformResponse.freemiumLimits.rstorage.lowmark),
|
|
969
987
|
highmark: Number(
|
|
970
|
-
platformResponse.freemiumLimits.rstorage.highmark
|
|
988
|
+
platformResponse.freemiumLimits.rstorage.highmark
|
|
971
989
|
),
|
|
972
990
|
unit: String(platformResponse.freemiumLimits.rstorage.unit),
|
|
973
991
|
},
|
|
974
992
|
storage: {
|
|
975
993
|
lowmark: Number(platformResponse.freemiumLimits.storage.lowmark),
|
|
976
994
|
highmark: Number(
|
|
977
|
-
platformResponse.freemiumLimits.storage.highmark
|
|
995
|
+
platformResponse.freemiumLimits.storage.highmark
|
|
978
996
|
),
|
|
979
997
|
unit: String(platformResponse.freemiumLimits.storage.unit),
|
|
980
998
|
},
|
|
@@ -990,8 +1008,9 @@ export const loadUserData = async () => {
|
|
|
990
1008
|
};
|
|
991
1009
|
if (eventHelper.user) {
|
|
992
1010
|
eventHelper.user.publish.loaded(
|
|
993
|
-
new User(userData, userTenants, userOrganizations, platformData)
|
|
1011
|
+
new User(userData, userTenants, userOrganizations, platformData)
|
|
994
1012
|
);
|
|
1013
|
+
} else {
|
|
995
1014
|
}
|
|
996
1015
|
} catch (error) {
|
|
997
1016
|
console.error("Error al obtener los datos del tenant:", error);
|
|
@@ -1045,7 +1064,6 @@ const extractCloudProviderInfo = (accountSpec: any) => {
|
|
|
1045
1064
|
credentialSecret: "",
|
|
1046
1065
|
};
|
|
1047
1066
|
};
|
|
1048
|
-
|
|
1049
1067
|
export const updateUser = async (user: User) => {
|
|
1050
1068
|
try {
|
|
1051
1069
|
const userBody = {
|
|
@@ -1057,22 +1075,25 @@ export const updateUser = async (user: User) => {
|
|
|
1057
1075
|
companyRole: user.rol,
|
|
1058
1076
|
},
|
|
1059
1077
|
};
|
|
1060
|
-
await makeGlobalWebSocketRequest(
|
|
1078
|
+
const response = await makeGlobalWebSocketRequest(
|
|
1061
1079
|
"user:modify_user_info",
|
|
1062
1080
|
userBody,
|
|
1063
1081
|
30000,
|
|
1064
1082
|
"PUT",
|
|
1065
|
-
"UPDATE_USER"
|
|
1083
|
+
"UPDATE_USER"
|
|
1066
1084
|
);
|
|
1067
1085
|
eventHelper.user.publish.updated(user);
|
|
1068
|
-
|
|
1086
|
+
const userUpdatedNotification: Notification = {
|
|
1069
1087
|
type: "success",
|
|
1070
1088
|
subtype: "user-updated",
|
|
1071
1089
|
date: Date.now().toString(),
|
|
1072
1090
|
status: "unread",
|
|
1073
1091
|
callToAction: false,
|
|
1074
|
-
data: {
|
|
1075
|
-
|
|
1092
|
+
data: {
|
|
1093
|
+
user: user.name
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
eventHelper.notification.publish.creation(userUpdatedNotification);
|
|
1076
1097
|
} catch (error) {
|
|
1077
1098
|
console.error("Error updating user:", {
|
|
1078
1099
|
error,
|
|
@@ -1080,56 +1101,65 @@ export const updateUser = async (user: User) => {
|
|
|
1080
1101
|
stack: error instanceof Error ? error.stack : undefined,
|
|
1081
1102
|
});
|
|
1082
1103
|
eventHelper.user.publish.updateError(user);
|
|
1083
|
-
|
|
1104
|
+
const userUpdatedNotificationError: Notification = {
|
|
1084
1105
|
type: "error",
|
|
1085
1106
|
subtype: "tenant-update-error",
|
|
1086
1107
|
date: Date.now().toString(),
|
|
1087
1108
|
status: "unread",
|
|
1088
1109
|
callToAction: false,
|
|
1089
|
-
info_content:
|
|
1110
|
+
info_content:{
|
|
1090
1111
|
code: (error as any).error.code,
|
|
1091
|
-
message: (error as any).error.content
|
|
1112
|
+
message: (error as any).error.content
|
|
1092
1113
|
},
|
|
1093
|
-
data: {
|
|
1094
|
-
|
|
1114
|
+
data: {
|
|
1115
|
+
user: user.name
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
eventHelper.notification.publish.creation(userUpdatedNotificationError);
|
|
1095
1119
|
throw error;
|
|
1096
1120
|
}
|
|
1097
1121
|
};
|
|
1098
|
-
|
|
1099
1122
|
export const deleteUSer = async (user: User, security: string) => {
|
|
1100
1123
|
try {
|
|
1101
1124
|
await initializeGlobalWebSocketClient(security);
|
|
1102
1125
|
const response = await makeGlobalWebSocketRequest(
|
|
1103
1126
|
"user:delete_user",
|
|
1104
1127
|
{},
|
|
1105
|
-
30000,
|
|
1128
|
+
30000,
|
|
1106
1129
|
"DELETE",
|
|
1107
1130
|
"DELETE_USER",
|
|
1108
|
-
"user"
|
|
1131
|
+
"user"
|
|
1109
1132
|
);
|
|
1110
|
-
|
|
1133
|
+
|
|
1134
|
+
const userDeletedNotification: Notification = {
|
|
1111
1135
|
type: "success",
|
|
1112
1136
|
subtype: "user-deleted",
|
|
1113
1137
|
date: Date.now().toString(),
|
|
1114
1138
|
status: "unread",
|
|
1115
1139
|
callToAction: false,
|
|
1116
|
-
data: {
|
|
1117
|
-
|
|
1140
|
+
data: {
|
|
1141
|
+
user: user.name
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
eventHelper.notification.publish.creation(userDeletedNotification);
|
|
1118
1145
|
return response;
|
|
1119
1146
|
} catch (error) {
|
|
1120
1147
|
console.error("Error deleting user:", error);
|
|
1121
|
-
|
|
1148
|
+
const userDeletedNotificationError: Notification = {
|
|
1122
1149
|
type: "error",
|
|
1123
1150
|
subtype: "user-delete-error",
|
|
1124
1151
|
date: Date.now().toString(),
|
|
1125
1152
|
status: "unread",
|
|
1126
1153
|
callToAction: false,
|
|
1127
|
-
info_content:
|
|
1154
|
+
info_content:{
|
|
1128
1155
|
code: (error as any).error.code,
|
|
1129
|
-
message: (error as any).error.content
|
|
1156
|
+
message: (error as any).error.content
|
|
1130
1157
|
},
|
|
1131
|
-
data: {
|
|
1132
|
-
|
|
1158
|
+
data: {
|
|
1159
|
+
user: user.name
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
eventHelper.notification.publish.creation(userDeletedNotificationError);
|
|
1133
1163
|
throw error;
|
|
1134
1164
|
}
|
|
1135
|
-
};
|
|
1165
|
+
};
|