@kumori/aurora-backend-handler 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/account-api-service.ts +1 -1
- package/api/deploy-service-helper.ts +1 -1
- package/api/environment-api-service.ts +1 -1
- package/api/marketplace-api-service.ts +1 -1
- package/api/reporting-api-service.ts +1 -1
- package/api/resources-api-service.ts +1 -1
- package/api/service-api-service.ts +1 -1
- package/api/tenant-api-service.ts +1 -1
- package/api/user-api-service.ts +1 -1
- package/backend-handler.ts +1 -1
- package/event-helper.ts +1 -1
- package/helpers/account-helper.ts +1 -1
- package/helpers/environment-helper.ts +1 -1
- package/helpers/link-helper.ts +1 -1
- package/helpers/plan-helper.ts +1 -1
- package/helpers/registry-helper.ts +1 -1
- package/helpers/resource-helper.ts +1 -1
- package/helpers/revision-helper.ts +73 -22
- package/helpers/service-helper.ts +1 -1
- package/helpers/tenant-helper.ts +1 -1
- package/helpers/token-helper.ts +1 -1
- package/helpers/user-helper.ts +1 -1
- package/package.json +2 -2
- package/test/backend-handler.test.ts +1 -1
- package/test/deploy-service-helper.test.ts +1 -1
- package/websocket-manager.ts +1 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ComponentSpec as ComponentSpecDSL,
|
|
11
11
|
ServiceSpec as ServiceSpecDSL,
|
|
12
12
|
} from "@kumori/kumori-dsl-generator";
|
|
13
|
-
import { MarketplaceService, Resource, Service } from "@
|
|
13
|
+
import { MarketplaceService, Resource, Service } from "@kumori/aurora-interfaces";
|
|
14
14
|
|
|
15
15
|
export type ResourceBundle =
|
|
16
16
|
| { secret: { name: string; configResource: string } }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Link, MarketplaceItem, MarketplaceService, Notification, Service } from "@
|
|
1
|
+
import { Link, MarketplaceItem, MarketplaceService, Notification, Service } from "@kumori/aurora-interfaces";
|
|
2
2
|
import { eventHelper } from "../backend-handler";
|
|
3
3
|
import { environment } from "../environment";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getWebSocketStatus,
|
|
7
7
|
makeGlobalWebSocketRequest,
|
|
8
8
|
} from "../websocket-manager";
|
|
9
|
-
import { Link, Notification, Service } from "@
|
|
9
|
+
import { Link, Notification, Service } from "@kumori/aurora-interfaces";
|
|
10
10
|
let pendingLinks = new Map<string, Link[]>();
|
|
11
11
|
/**
|
|
12
12
|
* Function to deploy a service
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Notification, Registry, Tenant, tenantRole } from "@
|
|
1
|
+
import { Notification, Registry, Tenant, tenantRole } from "@kumori/aurora-interfaces";
|
|
2
2
|
import { eventHelper } from "../backend-handler";
|
|
3
3
|
import { environment } from "../environment";
|
|
4
4
|
import {
|
package/api/user-api-service.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
makeGlobalWebSocketRequest,
|
|
5
5
|
} from "../websocket-manager.ts";
|
|
6
6
|
import { environment } from "../environment.ts";
|
|
7
|
-
import { Account, Container, Environment, Instance, MarketplaceItem, Notification, Organization, Platform, Registry, Resource, Service, Tenant, User, UserData } from "@
|
|
7
|
+
import { Account, Container, Environment, Instance, MarketplaceItem, Notification, Organization, Platform, Registry, Resource, Service, Tenant, User, UserData } from "@kumori/aurora-interfaces";
|
|
8
8
|
|
|
9
9
|
type Security = string;
|
|
10
10
|
|
package/backend-handler.ts
CHANGED
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
updateResource,
|
|
53
53
|
} from "./api/resources-api-service";
|
|
54
54
|
import { getPlanProviders } from './api/planProvider-api-service';
|
|
55
|
-
import { Account, Environment, Link, MarketplaceService, Notification, Organization, Resource, Service, Tenant, tenantRole, UserData } from "@
|
|
55
|
+
import { Account, Environment, Link, MarketplaceService, Notification, Organization, Resource, Service, Tenant, tenantRole, UserData } from "@kumori/aurora-interfaces";
|
|
56
56
|
|
|
57
57
|
export let eventHelper: EventHelper;
|
|
58
58
|
const token =
|
package/event-helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, Environment, Link, MarketplaceItem, MarketplaceService, Organization, PlanProvider, Registry, Tenant, tenantRole, User, Service, Notification, Resource } from "@
|
|
1
|
+
import { Account, Environment, Link, MarketplaceItem, MarketplaceService, Organization, PlanProvider, Registry, Tenant, tenantRole, User, Service, Notification, Resource } from "@kumori/aurora-interfaces";
|
|
2
2
|
import { EventNames } from "./event-names";
|
|
3
3
|
export interface RegistryUpdatePayload {
|
|
4
4
|
tenant: Tenant;
|
package/helpers/link-helper.ts
CHANGED
package/helpers/plan-helper.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Account,
|
|
3
|
+
Container,
|
|
4
|
+
Environment,
|
|
5
|
+
Instance,
|
|
6
|
+
Resource,
|
|
7
|
+
Service,
|
|
8
|
+
Usage,
|
|
9
|
+
} from "@kumori/aurora-interfaces";
|
|
3
10
|
import { convertToGigabytes, getTimestamp } from "../utils/utils";
|
|
4
11
|
|
|
5
12
|
interface Role {
|
|
@@ -73,8 +80,13 @@ const MAX_HISTORY = 100;
|
|
|
73
80
|
const processRolesAndInstances = (
|
|
74
81
|
eventData: any,
|
|
75
82
|
serviceId: string,
|
|
76
|
-
roleMap: Map<string, Role[]
|
|
77
|
-
): {
|
|
83
|
+
roleMap: Map<string, Role[]>,
|
|
84
|
+
): {
|
|
85
|
+
roles: Role[];
|
|
86
|
+
instances: Instance[];
|
|
87
|
+
usedCpu: number;
|
|
88
|
+
usedMemory: number;
|
|
89
|
+
} => {
|
|
78
90
|
const roles: Role[] = [];
|
|
79
91
|
const instances: Instance[] = [];
|
|
80
92
|
let usedCpu = 0;
|
|
@@ -86,7 +98,7 @@ const processRolesAndInstances = (
|
|
|
86
98
|
|
|
87
99
|
for (const [roleName, roleData] of roleEntries) {
|
|
88
100
|
const instanceEntries = Object.entries(
|
|
89
|
-
(roleData as { instances: Record<string, any> }).instances
|
|
101
|
+
(roleData as { instances: Record<string, any> }).instances,
|
|
90
102
|
);
|
|
91
103
|
const roleInstances: Instance[] = [];
|
|
92
104
|
const existingRoles = roleMap.get(serviceId) || [];
|
|
@@ -172,7 +184,7 @@ const createRevision = (
|
|
|
172
184
|
parentParts: { [entity: string]: string },
|
|
173
185
|
eventData: any,
|
|
174
186
|
usedCpu: number,
|
|
175
|
-
usedMemory: number
|
|
187
|
+
usedMemory: number,
|
|
176
188
|
): Revision => {
|
|
177
189
|
return {
|
|
178
190
|
service: parentParts.service,
|
|
@@ -236,10 +248,10 @@ const updateServiceWithRevision = (
|
|
|
236
248
|
entityId: string,
|
|
237
249
|
eventData: any,
|
|
238
250
|
newRevision: Revision,
|
|
239
|
-
roles: Role[]
|
|
251
|
+
roles: Role[],
|
|
240
252
|
): { updatedService: Service; deploymentErrorEvent: Service | null } => {
|
|
241
253
|
const existingRevisionIndex = existingService.revisions.findIndex(
|
|
242
|
-
(rev) => rev === entityId
|
|
254
|
+
(rev) => rev === entityId,
|
|
243
255
|
);
|
|
244
256
|
const shouldIncludeInList =
|
|
245
257
|
newRevision.errorCode !== "COMPUTE_ERROR" &&
|
|
@@ -253,7 +265,7 @@ const updateServiceWithRevision = (
|
|
|
253
265
|
: existingService.revisions;
|
|
254
266
|
} else {
|
|
255
267
|
updatedRevisions = existingService.revisions.filter(
|
|
256
|
-
(rev) => rev !== entityId
|
|
268
|
+
(rev) => rev !== entityId,
|
|
257
269
|
);
|
|
258
270
|
}
|
|
259
271
|
|
|
@@ -308,7 +320,7 @@ const updateEnvironmentConsumption = (
|
|
|
308
320
|
environment: Environment,
|
|
309
321
|
servicesMap: Map<string, Service>,
|
|
310
322
|
revisionsMap: Map<string, Revision>,
|
|
311
|
-
serviceEnvironmentId: string
|
|
323
|
+
serviceEnvironmentId: string,
|
|
312
324
|
): Environment => {
|
|
313
325
|
let totalEnvCpu = 0;
|
|
314
326
|
let totalEnvMemory = 0;
|
|
@@ -353,7 +365,7 @@ const updateAccountConsumption = (
|
|
|
353
365
|
account: Account,
|
|
354
366
|
servicesMap: Map<string, Service>,
|
|
355
367
|
revisionsMap: Map<string, Revision>,
|
|
356
|
-
serviceAccountId: string
|
|
368
|
+
serviceAccountId: string,
|
|
357
369
|
): Account => {
|
|
358
370
|
let totalAccountCpu = 0;
|
|
359
371
|
let totalAccountMemory = 0;
|
|
@@ -416,7 +428,7 @@ export const handleRevisionEvent = ({
|
|
|
416
428
|
const { roles, instances, usedCpu, usedMemory } = processRolesAndInstances(
|
|
417
429
|
eventData,
|
|
418
430
|
serviceId,
|
|
419
|
-
roleMap
|
|
431
|
+
roleMap,
|
|
420
432
|
);
|
|
421
433
|
|
|
422
434
|
// Create new revision
|
|
@@ -425,14 +437,15 @@ export const handleRevisionEvent = ({
|
|
|
425
437
|
parentParts,
|
|
426
438
|
eventData,
|
|
427
439
|
usedCpu,
|
|
428
|
-
usedMemory
|
|
440
|
+
usedMemory,
|
|
429
441
|
);
|
|
430
442
|
|
|
431
443
|
// Initialize result
|
|
432
444
|
let updatedService: Service | null = null;
|
|
433
445
|
let updatedEnvironment: Environment | null = null;
|
|
434
446
|
let updatedAccount: Account | null = null;
|
|
435
|
-
let pendingRevisionError: { service: string; revision: Revision } | null =
|
|
447
|
+
let pendingRevisionError: { service: string; revision: Revision } | null =
|
|
448
|
+
null;
|
|
436
449
|
let serviceDeployedEvent: Service | null = null;
|
|
437
450
|
let serviceDeploymentErrorEvent: Service | null = null;
|
|
438
451
|
let shouldFetchChannels = false;
|
|
@@ -446,7 +459,7 @@ export const handleRevisionEvent = ({
|
|
|
446
459
|
entityId,
|
|
447
460
|
eventData,
|
|
448
461
|
newRevision,
|
|
449
|
-
roles
|
|
462
|
+
roles,
|
|
450
463
|
);
|
|
451
464
|
|
|
452
465
|
updatedService = serviceUpdateResult.updatedService;
|
|
@@ -464,7 +477,7 @@ export const handleRevisionEvent = ({
|
|
|
464
477
|
{ ...environment },
|
|
465
478
|
tempServicesMap,
|
|
466
479
|
tempRevisionsMap,
|
|
467
|
-
serviceEnvironmentId
|
|
480
|
+
serviceEnvironmentId,
|
|
468
481
|
);
|
|
469
482
|
}
|
|
470
483
|
}
|
|
@@ -474,7 +487,7 @@ export const handleRevisionEvent = ({
|
|
|
474
487
|
if (account) {
|
|
475
488
|
const tempServicesMap = new Map(servicesMap);
|
|
476
489
|
tempServicesMap.set(serviceId, updatedService);
|
|
477
|
-
|
|
490
|
+
|
|
478
491
|
const tempRevisionsMap = new Map(revisionsMap);
|
|
479
492
|
tempRevisionsMap.set(revisionKey, newRevision);
|
|
480
493
|
|
|
@@ -482,7 +495,7 @@ export const handleRevisionEvent = ({
|
|
|
482
495
|
{ ...account },
|
|
483
496
|
tempServicesMap,
|
|
484
497
|
tempRevisionsMap,
|
|
485
|
-
serviceAccountId
|
|
498
|
+
serviceAccountId,
|
|
486
499
|
);
|
|
487
500
|
}
|
|
488
501
|
}
|
|
@@ -494,7 +507,11 @@ export const handleRevisionEvent = ({
|
|
|
494
507
|
revision: newRevision,
|
|
495
508
|
};
|
|
496
509
|
}
|
|
497
|
-
if (
|
|
510
|
+
if (
|
|
511
|
+
!eventData.meta.deleted &&
|
|
512
|
+
eventData.status &&
|
|
513
|
+
eventData.status.deployed
|
|
514
|
+
) {
|
|
498
515
|
shouldFetchChannels = true;
|
|
499
516
|
channelsFetchInfo = {
|
|
500
517
|
serviceId: parentParts.service,
|
|
@@ -517,7 +534,10 @@ export const handleRevisionEvent = ({
|
|
|
517
534
|
serviceDeploymentErrorEvent,
|
|
518
535
|
};
|
|
519
536
|
};
|
|
520
|
-
export const processRevisionData = (
|
|
537
|
+
export const processRevisionData = (
|
|
538
|
+
service: Service,
|
|
539
|
+
revisionData: any,
|
|
540
|
+
): Service => {
|
|
521
541
|
const { solution } = revisionData;
|
|
522
542
|
const deploymentName = solution.top || service.name;
|
|
523
543
|
const deployment = solution.deployments[deploymentName];
|
|
@@ -560,6 +580,11 @@ export const processDeployment = (
|
|
|
560
580
|
if (hasRoles) {
|
|
561
581
|
Object.entries(rolesDefinition).forEach(
|
|
562
582
|
([roleName, roleData]: [string, any]) => {
|
|
583
|
+
const fileSystemParameters = extractParametersFromFilesystem(
|
|
584
|
+
roleData.artifact.description?.mapping.filesystem || [],
|
|
585
|
+
allServiceParameters,
|
|
586
|
+
);
|
|
587
|
+
allServiceParameters.push(...fileSystemParameters);
|
|
563
588
|
const roleResources = extractResources(roleData.config?.resource || {});
|
|
564
589
|
const existingRole = service.role.find((r) => r.name === roleName);
|
|
565
590
|
let hsize = 1;
|
|
@@ -647,7 +672,7 @@ export const extractParametersFromConfig = (
|
|
|
647
672
|
|
|
648
673
|
if (typeof paramValue === "object" && paramValue !== null) {
|
|
649
674
|
if (paramValue.value !== undefined) {
|
|
650
|
-
value =
|
|
675
|
+
value = paramValue.value;
|
|
651
676
|
} else if (paramValue.default !== undefined) {
|
|
652
677
|
value = String(paramValue.default);
|
|
653
678
|
} else {
|
|
@@ -678,6 +703,32 @@ export const extractParametersFromConfig = (
|
|
|
678
703
|
|
|
679
704
|
return parameters;
|
|
680
705
|
};
|
|
706
|
+
export const extractParametersFromFilesystem = (
|
|
707
|
+
filesystem: any,
|
|
708
|
+
currentParameters: { [key: string]: string }[],
|
|
709
|
+
): { [key: string]: string }[] => {
|
|
710
|
+
const parameters: { [key: string]: string }[] = [];
|
|
711
|
+
filesystem.forEach((file: any) => {
|
|
712
|
+
Object.entries(file).forEach(([key, value]: [string, any]) => {
|
|
713
|
+
if (value.data) {
|
|
714
|
+
const existingParam = currentParameters.find(
|
|
715
|
+
(param) => param.value === value.data.value,
|
|
716
|
+
);
|
|
717
|
+
parameters.push({
|
|
718
|
+
name: existingParam?.name || key,
|
|
719
|
+
path: value.path,
|
|
720
|
+
value: value.data.value,
|
|
721
|
+
type: "file",
|
|
722
|
+
});
|
|
723
|
+
if (existingParam) {
|
|
724
|
+
currentParameters.splice(currentParameters.indexOf(existingParam), 1);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
return parameters;
|
|
731
|
+
};
|
|
681
732
|
export const extractResources = (resourceConfig: any): Resource[] => {
|
|
682
733
|
const resources: Resource[] = [];
|
|
683
734
|
|
|
@@ -896,4 +947,4 @@ const extractParameters = (
|
|
|
896
947
|
}
|
|
897
948
|
|
|
898
949
|
return parameters;
|
|
899
|
-
};
|
|
950
|
+
};
|
package/helpers/tenant-helper.ts
CHANGED
package/helpers/token-helper.ts
CHANGED
package/helpers/user-helper.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"test": "jest --config jest.config.ts"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@hestekumori/aurora-interfaces": "^1.0.17",
|
|
7
6
|
"@jest/globals": "^29.7.0",
|
|
7
|
+
"@kumori/aurora-interfaces": "^1.0.0",
|
|
8
8
|
"@kumori/kumori-dsl-generator": "^1.0.3",
|
|
9
9
|
"@kumori/kumori-module-generator": "^1.1.6",
|
|
10
10
|
"jest": "^29.7.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ws": "^8.18.2"
|
|
24
24
|
},
|
|
25
25
|
"name": "@kumori/aurora-backend-handler",
|
|
26
|
-
"version": "1.0.
|
|
26
|
+
"version": "1.0.2",
|
|
27
27
|
"description": "backend handler",
|
|
28
28
|
"main": "backend-handler.ts",
|
|
29
29
|
"repository": {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getMarketplaceItems,
|
|
13
13
|
} from "../api/marketplace-api-service";
|
|
14
14
|
import { BackendHandler } from "../backend-handler";
|
|
15
|
-
import { Account, Tenant, UserData, Environment, Service, MarketplaceService } from "@
|
|
15
|
+
import { Account, Tenant, UserData, Environment, Service, MarketplaceService } from "@kumori/aurora-interfaces";
|
|
16
16
|
|
|
17
17
|
jest.mock("../event-helper", () => {
|
|
18
18
|
return jest.fn().mockImplementation((globalEventHandler) => {
|
package/websocket-manager.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v7 as uuidv7 } from "uuid";
|
|
2
2
|
import { environment } from "./environment";
|
|
3
|
-
import { Account, Channel, ClusterToken, Environment, Instance, Link, MarketplaceService, Notification, Organization, Plan, PlanProvider, Platform, Registry, Resource, Service, Tenant, tenantRole, Token, Usage, User, UserData } from "@
|
|
3
|
+
import { Account, Channel, ClusterToken, Environment, Instance, Link, MarketplaceService, Notification, Organization, Plan, PlanProvider, Platform, Registry, Resource, Service, Tenant, tenantRole, Token, Usage, User, UserData } from "@kumori/aurora-interfaces";
|
|
4
4
|
import { loadMarketplaceItemsForTenant } from "./api/marketplace-api-service";
|
|
5
5
|
import { getReporting } from "./api/reporting-api-service";
|
|
6
6
|
import { parseKeyPath } from "./utils/utils";
|