Skip to content

Commit

Permalink
actiondata
Browse files Browse the repository at this point in the history
  • Loading branch information
daveads committed Jan 5, 2025
1 parent b2a591c commit ebd8172
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions source/commands/env/export/generators/ResourceGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@ import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

interface ResourceData {
key: string;
name: string;
description?: string;
urn?: string;
actions: Record<string, ActionData>;
attributes?: Record<string, AttributeData>;
}

interface ActionData {
name: string;
description?: string;
}

// Define a type for attributes
interface AttributeData {
type: string;
required?: boolean;
}

interface ResourceData {
key: string;
name: string;
description?: string;
urn?: string;
actions: Record<string, ActionData>;
attributes?: Record<string, AttributeData>;
}

interface ActionBlockRead {
name?: string;
description?: string;
Expand Down Expand Up @@ -62,8 +61,8 @@ export class ResourceGenerator implements HCLGenerator {
name: resource.name,
description: resource.description,
urn: resource.urn,
actions: this.transformActions(resource.actions || {}),
attributes: this.transformAttributes(resource.attributes),
actions: this.transformActions(resource.actions || {}), // Transform actions
attributes: this.transformAttributes(resource.attributes), // Transform attributes
}));

if (validResources.length === 0) return '';
Expand All @@ -82,7 +81,7 @@ export class ResourceGenerator implements HCLGenerator {
const transformedActions: Record<string, ActionData> = {};
for (const [key, action] of Object.entries(actions)) {
transformedActions[key] = {
name: action.name || key,
name: action.name || key, // Use the key as a fallback if `name` is undefined
description: action.description,
};
}
Expand Down

0 comments on commit ebd8172

Please sign in to comment.