@kumori/aurora-backend-handler 1.0.39 → 1.0.40

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.
@@ -482,7 +482,7 @@ const collectNamedTypes = (schema: any): string[] => {
482
482
 
483
483
  const namedTypeToResourceKind = (
484
484
  namedTypes: string[],
485
- ): { type: string; kind?: string } => {
485
+ ): { type: string; kind?: string } | null => {
486
486
  for (const name of namedTypes) {
487
487
  switch (name) {
488
488
  case "Secret":
@@ -507,21 +507,30 @@ const namedTypeToResourceKind = (
507
507
  return { type: "volume" };
508
508
  }
509
509
  }
510
- return { type: "secret" };
510
+ return null;
511
511
  };
512
512
 
513
513
  export const extractStructuredSchema = (
514
514
  revisionData: any,
515
- ): {
516
- parameters: {
517
- name: string;
518
- type: string;
519
- required: boolean;
520
- defaultValue?: any;
521
- }[];
522
- resources: { name: string; type: string; kind?: string; required: boolean }[];
523
- } => {
515
+ ):
516
+ | {
517
+ parameters: {
518
+ name: string;
519
+ type: string;
520
+ required: boolean;
521
+ defaultValue?: any;
522
+ }[];
523
+ resources: {
524
+ name: string;
525
+ type: string;
526
+ kind?: string;
527
+ required: boolean;
528
+ }[];
529
+ }
530
+ | {} => {
524
531
  const configSchema = revisionData?.configSchema;
532
+ if (!configSchema) return {};
533
+
525
534
  const deploymentName = revisionData?.solution?.top;
526
535
  const deployment = deploymentName
527
536
  ? revisionData?.solution?.deployments?.[deploymentName]
@@ -529,14 +538,15 @@ export const extractStructuredSchema = (
529
538
 
530
539
  const parameterValues: Record<string, any> =
531
540
  (deployment as any)?.config?.parameter ?? {};
541
+ const configResourceValues: Record<string, any> =
542
+ (deployment as any)?.config?.resource ?? {};
543
+
532
544
  const requiredParams: string[] =
533
545
  configSchema?.properties?.config?.required ?? [];
534
546
  const requiredResources: string[] =
535
547
  configSchema?.properties?.resource?.required ?? [];
536
548
  const schemaConfigProps: Record<string, any> =
537
549
  configSchema?.properties?.config?.properties ?? {};
538
- const schemaResourceProps: Record<string, any> =
539
- configSchema?.properties?.resource?.properties ?? {};
540
550
 
541
551
  const parameters = Object.entries(schemaConfigProps).map(
542
552
  ([name, propSchema]) => {
@@ -558,10 +568,49 @@ export const extractStructuredSchema = (
558
568
  },
559
569
  );
560
570
 
561
- const resources = Object.entries(schemaResourceProps).map(
562
- ([name, propSchema]) => {
563
- const namedTypes = collectNamedTypes(propSchema);
564
- const resolved = namedTypeToResourceKind(namedTypes);
571
+ const resolveResourceType = (
572
+ configValue: any,
573
+ ): { type: string; kind?: string } | null => {
574
+ if (!configValue || typeof configValue !== "object") return null;
575
+ if ("secret" in configValue) return { type: "secret" };
576
+ if ("domain" in configValue) return { type: "domain" };
577
+ if ("port" in configValue) return { type: "port" };
578
+ if ("certificate" in configValue) return { type: "certificate" };
579
+ if ("ca" in configValue) return { type: "ca" };
580
+ if ("volume" in configValue) {
581
+ const volType = configValue.volume?.type;
582
+ if (volType === "persistent" || volType === "Persisted")
583
+ return { type: "volume", kind: "persistent" };
584
+ if (volType === "nonReplicated" || volType === "NonReplicated")
585
+ return { type: "volume", kind: "nonReplicated" };
586
+ if (
587
+ volType === "volatile" ||
588
+ volType === "Volatile" ||
589
+ volType === "ephemeral" ||
590
+ volType === "Ephemeral"
591
+ )
592
+ return { type: "volume", kind: "volatile" };
593
+ return { type: "volume" };
594
+ }
595
+ return null;
596
+ };
597
+
598
+ const allResourceNames = new Set<string>([
599
+ ...Object.keys(configResourceValues),
600
+ ...Object.keys(configSchema?.properties?.resource?.properties ?? {}),
601
+ ]);
602
+
603
+ const resources = Array.from(allResourceNames)
604
+ .map((name) => {
605
+ const configValue = configResourceValues[name];
606
+ const fromConfig = resolveResourceType(configValue);
607
+ const schemaProps =
608
+ configSchema?.properties?.resource?.properties?.[name];
609
+ const fromSchema = schemaProps
610
+ ? namedTypeToResourceKind(collectNamedTypes(schemaProps))
611
+ : null;
612
+ const resolved = fromConfig ?? fromSchema;
613
+ if (!resolved) return null;
565
614
  const entry: {
566
615
  name: string;
567
616
  type: string;
@@ -574,8 +623,13 @@ export const extractStructuredSchema = (
574
623
  };
575
624
  if (resolved.kind) entry.kind = resolved.kind;
576
625
  return entry;
577
- },
578
- );
626
+ })
627
+ .filter(Boolean) as {
628
+ name: string;
629
+ type: string;
630
+ kind?: string;
631
+ required: boolean;
632
+ }[];
579
633
 
580
634
  return { parameters, resources };
581
635
  };
@@ -592,12 +646,18 @@ export const processRevisionData = (
592
646
  const parameters = extractParametersFromConfig(config.parameter || {});
593
647
  const resources = extractResources(config.resource || {});
594
648
 
595
- let schema: any = {};
596
- if (revisionData.revision) {
597
- schema = extractStructuredSchema(revisionData);
598
- }
649
+ const schemaResult = revisionData.revision
650
+ ? extractStructuredSchema(revisionData)
651
+ : {};
652
+ const schema =
653
+ schemaResult && "parameters" in schemaResult ? schemaResult : {};
599
654
 
600
- if (revisionsMap && serviceId && revisionData.revision) {
655
+ if (
656
+ revisionsMap &&
657
+ serviceId &&
658
+ revisionData.revision &&
659
+ "parameters" in schema
660
+ ) {
601
661
  const revisionId: string = revisionData.revision;
602
662
  const revisionKey = `${serviceId}-${revisionId}`;
603
663
  const existing = revisionsMap.get(revisionKey);
@@ -650,7 +710,7 @@ export const processRevisionData = (
650
710
  const deployment = solution.deployments[deploymentName];
651
711
 
652
712
  const applySchemaToService = (svc: Service): Service => {
653
- if (!revisionData.revision || !schema) return svc;
713
+ if (!revisionData.revision || !("parameters" in schema)) return svc;
654
714
  const revisionId: string = revisionData.revision;
655
715
  return {
656
716
  ...svc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumori/aurora-backend-handler",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "backend handler",
5
5
  "main": "backend-handler.ts",
6
6
  "scripts": {