@kumori/aurora-backend-handler 1.0.62 → 1.0.63

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.
@@ -217,12 +217,16 @@ const updateServiceWithRevision = (
217
217
  const existingRevisionIndex = existingService.revisions.findIndex(
218
218
  (rev) => String(rev.id) === String(entityId),
219
219
  );
220
- const existingRevision = existingRevisionIndex !== -1
221
- ? existingService.revisions[existingRevisionIndex]
222
- : null;
223
- const hasExistingSchema = existingRevision?.schema &&
224
- ("parameters" in existingRevision.schema || "resources" in existingRevision.schema);
225
- const hasNewSchema = newRevision.schema &&
220
+ const existingRevision =
221
+ existingRevisionIndex !== -1
222
+ ? existingService.revisions[existingRevisionIndex]
223
+ : null;
224
+ const hasExistingSchema =
225
+ existingRevision?.schema &&
226
+ ("parameters" in existingRevision.schema ||
227
+ "resources" in existingRevision.schema);
228
+ const hasNewSchema =
229
+ newRevision.schema &&
226
230
  ("parameters" in newRevision.schema || "resources" in newRevision.schema);
227
231
  if (hasExistingSchema && !hasNewSchema) {
228
232
  newRevision.schema = existingRevision!.schema;
@@ -238,9 +242,10 @@ const updateServiceWithRevision = (
238
242
  const updatedService: Service = {
239
243
  ...existingService,
240
244
  revisions: updatedRevisions,
241
- currentRevision: Number(entityId) >= Number(existingService.currentRevision ?? 0)
242
- ? entityId
243
- : existingService.currentRevision,
245
+ currentRevision:
246
+ Number(entityId) >= Number(existingService.currentRevision ?? 0)
247
+ ? entityId
248
+ : existingService.currentRevision,
244
249
  role: roles.length > 0 ? roles : existingService.role,
245
250
  usage: newRevision.usage,
246
251
  startedAt: newRevision.createdAt || existingService.startedAt,
@@ -276,10 +281,14 @@ const updateServiceWithRevision = (
276
281
  deploymentErrorEvent = updatedService;
277
282
  }
278
283
  }
284
+ const incomingRevisionId = Number(entityId);
285
+ const currentRevisionId = Number(existingService.currentRevision ?? 0);
286
+ if (incomingRevisionId >= currentRevisionId && !eventData.status.error) {
287
+ updatedService.error = undefined;
288
+ }
279
289
 
280
290
  return { updatedService, deploymentErrorEvent };
281
291
  };
282
-
283
292
  const updateEnvironmentConsumption = (
284
293
  environment: Environment,
285
294
  servicesMap: Map<string, Service>,
@@ -535,7 +544,8 @@ export const extractStructuredSchema = (
535
544
  if (!configSchema) return {};
536
545
  const deployedConfig = revisionData?.config?.config ?? {};
537
546
  const parameterValues: Record<string, any> = deployedConfig.parameter ?? {};
538
- const configResourceValues: Record<string, any> = deployedConfig.resource ?? {};
547
+ const configResourceValues: Record<string, any> =
548
+ deployedConfig.resource ?? {};
539
549
 
540
550
  const requiredParams: string[] =
541
551
  configSchema?.properties?.config?.required ?? [];
@@ -566,14 +576,22 @@ export const extractStructuredSchema = (
566
576
 
567
577
  const resolveResourceValue = (configValue: any): string => {
568
578
  if (!configValue || typeof configValue !== "object") return "";
569
- if (typeof configValue.secret === "string") return extractResourceName(configValue.secret);
570
- if (typeof configValue.domain === "string") return extractResourceName(configValue.domain);
571
- if (typeof configValue.port === "string") return extractResourceName(configValue.port);
572
- if (typeof configValue.certificate === "string") return extractResourceName(configValue.certificate);
573
- if (typeof configValue.ca === "string") return extractResourceName(configValue.ca);
579
+ if (typeof configValue.secret === "string")
580
+ return extractResourceName(configValue.secret);
581
+ if (typeof configValue.domain === "string")
582
+ return extractResourceName(configValue.domain);
583
+ if (typeof configValue.port === "string")
584
+ return extractResourceName(configValue.port);
585
+ if (typeof configValue.certificate === "string")
586
+ return extractResourceName(configValue.certificate);
587
+ if (typeof configValue.ca === "string")
588
+ return extractResourceName(configValue.ca);
574
589
  if (configValue.volume) {
575
590
  const vol = configValue.volume;
576
- return convertToGigabytes(vol.size, vol.unit)?.toString() ?? String(vol.size ?? "");
591
+ return (
592
+ convertToGigabytes(vol.size, vol.unit)?.toString() ??
593
+ String(vol.size ?? "")
594
+ );
577
595
  }
578
596
  return "";
579
597
  };
@@ -656,7 +674,9 @@ export const processRevisionData = (
656
674
  ): Service => {
657
675
  const { solution } = revisionData;
658
676
  const topLevelConfig = revisionData?.config?.config ?? {};
659
- const topLevelParameters = extractParametersFromConfig(topLevelConfig.parameter || {});
677
+ const topLevelParameters = extractParametersFromConfig(
678
+ topLevelConfig.parameter || {},
679
+ );
660
680
  const topLevelResources = extractResources(topLevelConfig.resource || {});
661
681
 
662
682
  const schemaResult = revisionData.revision
@@ -736,11 +756,21 @@ export const processRevisionData = (
736
756
  id: revisionId,
737
757
  schema,
738
758
  usage: svc.usage || {
739
- current: { cpu: 0, memory: 0, storage: 0, volatileStorage: 0, nonReplicatedStorage: 0, persistentStorage: 0 },
759
+ current: {
760
+ cpu: 0,
761
+ memory: 0,
762
+ storage: 0,
763
+ volatileStorage: 0,
764
+ nonReplicatedStorage: 0,
765
+ persistentStorage: 0,
766
+ },
740
767
  limit: {
741
- cpu: { max: 0, min: 0 }, memory: { max: 0, min: 0 },
742
- storage: { max: 0, min: 0 }, volatileStorage: { max: 0, min: 0 },
743
- nonReplicatedStorage: { max: 0, min: 0 }, persistentStorage: { max: 0, min: 0 },
768
+ cpu: { max: 0, min: 0 },
769
+ memory: { max: 0, min: 0 },
770
+ storage: { max: 0, min: 0 },
771
+ volatileStorage: { max: 0, min: 0 },
772
+ nonReplicatedStorage: { max: 0, min: 0 },
773
+ persistentStorage: { max: 0, min: 0 },
744
774
  },
745
775
  cost: 0,
746
776
  },
@@ -754,7 +784,10 @@ export const processRevisionData = (
754
784
  return {
755
785
  ...svc,
756
786
  revisions: updatedRevisions,
757
- currentRevision: Number(revisionId) >= Number(currentRevId) ? revisionId : svc.currentRevision,
787
+ currentRevision:
788
+ Number(revisionId) >= Number(currentRevId)
789
+ ? revisionId
790
+ : svc.currentRevision,
758
791
  };
759
792
  };
760
793
 
@@ -771,11 +804,21 @@ export const processRevisionData = (
771
804
  ),
772
805
  );
773
806
  }
774
- return applySchemaToService({ ...service, parameters: topLevelParameters, resources: topLevelResources });
807
+ return applySchemaToService({
808
+ ...service,
809
+ parameters: topLevelParameters,
810
+ resources: topLevelResources,
811
+ });
775
812
  }
776
813
 
777
814
  return applySchemaToService(
778
- processDeployment(service, deployment, revisionData, topLevelParameters, topLevelResources),
815
+ processDeployment(
816
+ service,
817
+ deployment,
818
+ revisionData,
819
+ topLevelParameters,
820
+ topLevelResources,
821
+ ),
779
822
  );
780
823
  };
781
824
 
@@ -796,13 +839,14 @@ export const processDeployment = (
796
839
  Object.entries(rolesDefinition).forEach(
797
840
  ([roleName, roleData]: [string, any]) => {
798
841
  const existingRole = service.role.find((r) => r.name === roleName);
799
- const roleArtifactConfig = roleData?.artifact?.description?.config ?? {};
842
+ const roleArtifactConfig =
843
+ roleData?.artifact?.description?.config ?? {};
800
844
 
801
845
  const roleParameters = extractParametersFromConfig(
802
- roleArtifactConfig.parameter ?? {}
846
+ roleArtifactConfig.parameter ?? {},
803
847
  );
804
848
  const roleResources = extractResources(
805
- roleArtifactConfig.resource ?? {}
849
+ roleArtifactConfig.resource ?? {},
806
850
  );
807
851
  const parameters = roleParameters;
808
852
  const resources = roleResources;
@@ -819,8 +863,7 @@ export const processDeployment = (
819
863
  roleArtifactConfig.resource || {},
820
864
  ).some((resourceData: any) => resourceData.volume);
821
865
 
822
- const artifactName: string =
823
- roleData.artifact?.ref?.name || "";
866
+ const artifactName: string = roleData.artifact?.ref?.name || "";
824
867
  const role: Role = {
825
868
  name: roleName,
826
869
  artifactName: artifactName || undefined,
@@ -868,7 +911,12 @@ export const processDeployment = (
868
911
  },
869
912
  ];
870
913
  }
871
- return { ...service, resources: fallbackResources, parameters: fallbackParameters, role: updatedRoles };
914
+ return {
915
+ ...service,
916
+ resources: fallbackResources,
917
+ parameters: fallbackParameters,
918
+ role: updatedRoles,
919
+ };
872
920
  };
873
921
 
874
922
  export const extractParametersFromConfig = (
@@ -1081,4 +1129,4 @@ const extractResourceName = (resourcePath: string): string => {
1081
1129
  return parts[1];
1082
1130
  }
1083
1131
  return resourcePath;
1084
- };
1132
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumori/aurora-backend-handler",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "description": "backend handler",
5
5
  "main": "backend-handler.ts",
6
6
  "scripts": {