@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.
@@ -1,5 +1,5 @@
1
1
 
2
- import { Account, Notification } from "@hestekumori/aurora-interfaces";
2
+ import { Account, Notification } from "@kumori/aurora-interfaces";
3
3
  import {
4
4
  initializeGlobalWebSocketClient,
5
5
  getWebSocketStatus,
@@ -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 "@hestekumori/aurora-interfaces";
13
+ import { MarketplaceService, Resource, Service } from "@kumori/aurora-interfaces";
14
14
 
15
15
  export type ResourceBundle =
16
16
  | { secret: { name: string; configResource: string } }
@@ -1,5 +1,5 @@
1
1
 
2
- import { Environment, Notification } from "@hestekumori/aurora-interfaces";
2
+ import { Environment, Notification } from "@kumori/aurora-interfaces";
3
3
  import { eventHelper } from "../backend-handler";
4
4
  import {
5
5
  initializeGlobalWebSocketClient,
@@ -1,4 +1,4 @@
1
- import { Link, MarketplaceItem, MarketplaceService, Notification, Service } from "@hestekumori/aurora-interfaces";
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
 
@@ -1,4 +1,4 @@
1
- import { Environment } from "@hestekumori/aurora-interfaces";
1
+ import { Environment } from "@kumori/aurora-interfaces";
2
2
  import { makeGlobalWebSocketRequest } from "../websocket-manager";
3
3
 
4
4
  export const getReporting = async (env: Environment) => {
@@ -1,4 +1,4 @@
1
- import { Notification, Resource } from "@hestekumori/aurora-interfaces";
1
+ import { Notification, Resource } from "@kumori/aurora-interfaces";
2
2
  import { eventHelper } from "../backend-handler";
3
3
 
4
4
  import {
@@ -6,7 +6,7 @@ import {
6
6
  getWebSocketStatus,
7
7
  makeGlobalWebSocketRequest,
8
8
  } from "../websocket-manager";
9
- import { Link, Notification, Service } from "@hestekumori/aurora-interfaces";
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 "@hestekumori/aurora-interfaces";
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 {
@@ -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 "@hestekumori/aurora-interfaces";
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
 
@@ -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 "@hestekumori/aurora-interfaces";
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 "@hestekumori/aurora-interfaces";
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;
@@ -1,4 +1,4 @@
1
- import { Account, Notification } from "@hestekumori/aurora-interfaces";
1
+ import { Account, Notification } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
  interface HandleAccountEventParams {
@@ -1,4 +1,4 @@
1
- import { Account, Environment, Notification } from "@hestekumori/aurora-interfaces";
1
+ import { Account, Environment, Notification } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- import { Link, Service } from "@hestekumori/aurora-interfaces";
1
+ import { Link, Service } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
  interface HandleLinkEventParams {
@@ -1,4 +1,4 @@
1
- import { Plan, UserData } from "@hestekumori/aurora-interfaces";
1
+ import { Plan, UserData } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
  interface HandlePlanInstanceEventParams {
@@ -1,5 +1,5 @@
1
1
 
2
- import { Registry, Tenant } from "@hestekumori/aurora-interfaces";
2
+ import { Registry, Tenant } from "@kumori/aurora-interfaces";
3
3
  import { decodeRegistryAuth } from "../utils/utils";
4
4
 
5
5
 
@@ -1,5 +1,5 @@
1
1
 
2
- import { Resource, Tenant } from "@hestekumori/aurora-interfaces";
2
+ import { Resource, Tenant } from "@kumori/aurora-interfaces";
3
3
  import { decodeRegistryAuth } from "../utils/utils";
4
4
 
5
5
 
@@ -1,5 +1,12 @@
1
-
2
- import { Account, Container, Environment, Instance, Resource, Service, Usage } from "@hestekumori/aurora-interfaces";
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
- ): { roles: Role[]; instances: Instance[]; usedCpu: number; usedMemory: number } => {
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 = 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 (!eventData.meta.deleted && eventData.status && eventData.status.deployed) {
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 = (service: Service, revisionData: any): Service => {
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 = String(paramValue.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
+ };
@@ -1,5 +1,5 @@
1
1
 
2
- import { Channel, Service, Tenant, Usage } from "@hestekumori/aurora-interfaces";
2
+ import { Channel, Service, Tenant, Usage } from "@kumori/aurora-interfaces";
3
3
  import { getTimestamp } from "../utils/utils";
4
4
 
5
5
  interface Role {
@@ -1,5 +1,5 @@
1
1
 
2
- import { Tenant, tenantRole, User, UserData } from "@hestekumori/aurora-interfaces";
2
+ import { Tenant, tenantRole, User, UserData } from "@kumori/aurora-interfaces";
3
3
  import { parseKeyPath } from "../utils/utils";
4
4
 
5
5
  export const handleTenantEvent: (
@@ -1,4 +1,4 @@
1
- import { ClusterToken, Token, UserData } from "@hestekumori/aurora-interfaces";
1
+ import { ClusterToken, Token, UserData } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
  interface HandleTokenEventParams {
@@ -1,4 +1,4 @@
1
- import { Notification, Plan, Tenant, UserData } from "@hestekumori/aurora-interfaces";
1
+ import { Notification, Plan, Tenant, UserData } from "@kumori/aurora-interfaces";
2
2
 
3
3
 
4
4
 
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.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 "@hestekumori/aurora-interfaces";
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) => {
@@ -1,4 +1,4 @@
1
- import { Service } from "@hestekumori/aurora-interfaces";
1
+ import { Service } from "@kumori/aurora-interfaces";
2
2
  import {
3
3
  withDefaultValue,
4
4
  handleParametersToGenerateData,
@@ -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 "@hestekumori/aurora-interfaces";
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";