@kumori/aurora-backend-handler 1.0.54 → 1.0.56
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/helpers/revision-helper.ts +58 -9
- package/package.json +1 -1
|
@@ -215,13 +215,24 @@ const updateServiceWithRevision = (
|
|
|
215
215
|
roles: Role[],
|
|
216
216
|
): { updatedService: Service; deploymentErrorEvent: Service | null } => {
|
|
217
217
|
const existingRevisionIndex = existingService.revisions.findIndex(
|
|
218
|
-
(rev) => rev.id === entityId,
|
|
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 &&
|
|
226
|
+
("parameters" in newRevision.schema || "resources" in newRevision.schema);
|
|
227
|
+
if (hasExistingSchema && !hasNewSchema) {
|
|
228
|
+
newRevision.schema = existingRevision!.schema;
|
|
229
|
+
}
|
|
230
|
+
|
|
220
231
|
const updatedRevisions: Revision[] =
|
|
221
232
|
existingRevisionIndex === -1
|
|
222
233
|
? [...existingService.revisions, newRevision]
|
|
223
234
|
: existingService.revisions.map((rev) =>
|
|
224
|
-
rev.id === entityId ? newRevision : rev,
|
|
235
|
+
String(rev.id) === String(entityId) ? newRevision : rev,
|
|
225
236
|
);
|
|
226
237
|
|
|
227
238
|
const updatedService: Service = {
|
|
@@ -551,6 +562,20 @@ export const extractStructuredSchema = (
|
|
|
551
562
|
},
|
|
552
563
|
);
|
|
553
564
|
|
|
565
|
+
const resolveResourceValue = (configValue: any): string => {
|
|
566
|
+
if (!configValue || typeof configValue !== "object") return "";
|
|
567
|
+
if (typeof configValue.secret === "string") return extractResourceName(configValue.secret);
|
|
568
|
+
if (typeof configValue.domain === "string") return extractResourceName(configValue.domain);
|
|
569
|
+
if (typeof configValue.port === "string") return extractResourceName(configValue.port);
|
|
570
|
+
if (typeof configValue.certificate === "string") return extractResourceName(configValue.certificate);
|
|
571
|
+
if (typeof configValue.ca === "string") return extractResourceName(configValue.ca);
|
|
572
|
+
if (configValue.volume) {
|
|
573
|
+
const vol = configValue.volume;
|
|
574
|
+
return convertToGigabytes(vol.size, vol.unit)?.toString() ?? String(vol.size ?? "");
|
|
575
|
+
}
|
|
576
|
+
return "";
|
|
577
|
+
};
|
|
578
|
+
|
|
554
579
|
const resolveResourceType = (
|
|
555
580
|
configValue: any,
|
|
556
581
|
): { type: string; kind?: string } | null => {
|
|
@@ -599,12 +624,15 @@ export const extractStructuredSchema = (
|
|
|
599
624
|
type: string;
|
|
600
625
|
kind?: string;
|
|
601
626
|
required: boolean;
|
|
627
|
+
value?: string;
|
|
602
628
|
} = {
|
|
603
629
|
name,
|
|
604
630
|
type: resolved.type,
|
|
605
631
|
required: requiredResources.includes(name),
|
|
606
632
|
};
|
|
607
633
|
if (resolved.kind) entry.kind = resolved.kind;
|
|
634
|
+
const value = resolveResourceValue(configValue);
|
|
635
|
+
if (value) entry.value = value;
|
|
608
636
|
return entry;
|
|
609
637
|
})
|
|
610
638
|
.filter(Boolean) as {
|
|
@@ -612,6 +640,7 @@ export const extractStructuredSchema = (
|
|
|
612
640
|
type: string;
|
|
613
641
|
kind?: string;
|
|
614
642
|
required: boolean;
|
|
643
|
+
value?: string;
|
|
615
644
|
}[];
|
|
616
645
|
|
|
617
646
|
return { parameters, resources };
|
|
@@ -693,13 +722,33 @@ export const processRevisionData = (
|
|
|
693
722
|
|
|
694
723
|
const applySchemaToService = (svc: Service): Service => {
|
|
695
724
|
if (!revisionData.revision || !("parameters" in schema)) return svc;
|
|
696
|
-
const revisionId: string = revisionData.revision;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
725
|
+
const revisionId: string = String(revisionData.revision);
|
|
726
|
+
const found = svc.revisions.some((rev) => String(rev.id) === revisionId);
|
|
727
|
+
const updatedRevisions = found
|
|
728
|
+
? svc.revisions.map((rev) =>
|
|
729
|
+
String(rev.id) === revisionId ? { ...rev, schema } : rev,
|
|
730
|
+
)
|
|
731
|
+
: [
|
|
732
|
+
...svc.revisions,
|
|
733
|
+
{
|
|
734
|
+
id: revisionId,
|
|
735
|
+
schema,
|
|
736
|
+
usage: svc.usage || {
|
|
737
|
+
current: { cpu: 0, memory: 0, storage: 0, volatileStorage: 0, nonReplicatedStorage: 0, persistentStorage: 0 },
|
|
738
|
+
limit: {
|
|
739
|
+
cpu: { max: 0, min: 0 }, memory: { max: 0, min: 0 },
|
|
740
|
+
storage: { max: 0, min: 0 }, volatileStorage: { max: 0, min: 0 },
|
|
741
|
+
nonReplicatedStorage: { max: 0, min: 0 }, persistentStorage: { max: 0, min: 0 },
|
|
742
|
+
},
|
|
743
|
+
cost: 0,
|
|
744
|
+
},
|
|
745
|
+
status: { code: "", message: "", timestamp: "", args: [] },
|
|
746
|
+
errorCode: "",
|
|
747
|
+
errorMsg: "",
|
|
748
|
+
createdAt: "",
|
|
749
|
+
},
|
|
750
|
+
];
|
|
751
|
+
return { ...svc, revisions: updatedRevisions, currentRevision: revisionId };
|
|
703
752
|
};
|
|
704
753
|
|
|
705
754
|
if (!deployment) {
|