@uniformdev/transformer 1.1.0 → 1.1.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.
- package/dist/cli/index.js +40 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/errors.ts","../src/core/services/file-system.service.ts","../src/core/services/component.service.ts","../src/core/services/composition.service.ts","../src/core/services/property-propagator.service.ts","../src/core/services/slot-renamer.service.ts","../src/core/services/component-renamer.service.ts","../src/core/services/component-adder.service.ts","../src/cli/logger.ts"],"sourcesContent":["export class TransformError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TransformError';\n }\n}\n\nexport class ComponentNotFoundError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component not found: ${componentType}${pathInfo}`);\n this.name = 'ComponentNotFoundError';\n }\n}\n\nexport class PropertyNotFoundError extends TransformError {\n constructor(propertyName: string, componentType: string) {\n super(`Property \"${propertyName}\" not found on component \"${componentType}\"`);\n this.name = 'PropertyNotFoundError';\n }\n}\n\nexport class InvalidYamlError extends TransformError {\n constructor(filePath: string, details?: string) {\n const detailsInfo = details ? `: ${details}` : '';\n super(`Invalid YAML file: ${filePath}${detailsInfo}`);\n this.name = 'InvalidYamlError';\n }\n}\n\nexport class FileNotFoundError extends TransformError {\n constructor(filePath: string) {\n super(`File not found: ${filePath}`);\n this.name = 'FileNotFoundError';\n }\n}\n\nexport class DuplicateIdError extends TransformError {\n constructor(id: string, arrayProperty: string, filePath: string) {\n super(`Duplicate id \"${id}\" in array \"${arrayProperty}\" of file: ${filePath}`);\n this.name = 'DuplicateIdError';\n }\n}\n\nexport class ComponentAlreadyExistsError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component type \"${componentType}\" already exists${pathInfo}`);\n this.name = 'ComponentAlreadyExistsError';\n }\n}\n\nexport class SlotNotFoundError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" does not exist on component \"${componentType}\"`);\n this.name = 'SlotNotFoundError';\n }\n}\n\nexport class SlotAlreadyExistsError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" already exists on component \"${componentType}\"`);\n this.name = 'SlotAlreadyExistsError';\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as YAML from 'yaml';\nimport { InvalidYamlError, FileNotFoundError } from '../errors.js';\n\nexport class FileSystemService {\n private isJsonFile(filePath: string): boolean {\n return filePath.toLowerCase().endsWith('.json');\n }\n\n async readFile<T>(filePath: string): Promise<T> {\n if (!fs.existsSync(filePath)) {\n throw new FileNotFoundError(filePath);\n }\n\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n if (this.isJsonFile(filePath)) {\n return JSON.parse(content) as T;\n }\n return YAML.parse(content) as T;\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n throw new InvalidYamlError(filePath, message);\n }\n }\n\n async writeFile<T>(filePath: string, data: T): Promise<void> {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n let content: string;\n if (this.isJsonFile(filePath)) {\n content = JSON.stringify(data, null, 2);\n } else {\n content = YAML.stringify(data, {\n lineWidth: 0,\n defaultKeyType: 'PLAIN',\n defaultStringType: 'QUOTE_DOUBLE',\n });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n }\n\n async readYamlFile<T>(filePath: string): Promise<T> {\n return this.readFile<T>(filePath);\n }\n\n async writeYamlFile<T>(filePath: string, data: T): Promise<void> {\n return this.writeFile(filePath, data);\n }\n\n async findFiles(directory: string, pattern: string): Promise<string[]> {\n const fullPattern = path.join(directory, pattern).replace(/\\\\/g, '/');\n return glob(fullPattern);\n }\n\n async fileExists(filePath: string): Promise<boolean> {\n return fs.existsSync(filePath);\n }\n\n resolvePath(...segments: string[]): string {\n return path.resolve(...segments);\n }\n\n joinPath(...segments: string[]): string {\n return path.join(...segments);\n }\n\n getBasename(filePath: string, ext?: string): string {\n return path.basename(filePath, ext);\n }\n\n async renameFile(oldPath: string, newPath: string): Promise<void> {\n fs.renameSync(oldPath, newPath);\n }\n\n deleteFile(filePath: string): void {\n fs.unlinkSync(filePath);\n }\n\n getExtension(filePath: string): string {\n return path.extname(filePath);\n }\n\n getDirname(filePath: string): string {\n return path.dirname(filePath);\n }\n}\n","import { ComponentDefinition, Parameter, SlotDefinition } from '../types/index.js';\nimport { ComponentNotFoundError, PropertyNotFoundError } from '../errors.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport class ComponentService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async loadComponent(\n componentsDir: string,\n componentType: string,\n options: FindOptions = {}\n ): Promise<{ component: ComponentDefinition; filePath: string }> {\n const { strict = false } = options;\n\n // First try exact match\n const jsonPath = this.fileSystem.joinPath(componentsDir, `${componentType}.json`);\n const yamlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(jsonPath);\n return { component, filePath: jsonPath };\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(yamlPath);\n return { component, filePath: yamlPath };\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(ymlPath);\n return { component, filePath: ymlPath };\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === componentType.toLowerCase()) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n return { component, filePath };\n }\n }\n }\n\n throw new ComponentNotFoundError(componentType, componentsDir);\n }\n\n async saveComponent(filePath: string, component: ComponentDefinition): Promise<void> {\n await this.fileSystem.writeFile(filePath, component);\n }\n\n findParameter(\n component: ComponentDefinition,\n parameterName: string,\n options: FindOptions = {}\n ): Parameter | undefined {\n const { strict = false } = options;\n return component.parameters?.find((p) => this.compareIds(p.id, parameterName, strict));\n }\n\n isGroupParameter(parameter: Parameter): boolean {\n return parameter.type === 'group';\n }\n\n resolveGroupParameters(\n component: ComponentDefinition,\n groupParameter: Parameter,\n options: FindOptions = {}\n ): Parameter[] {\n if (!this.isGroupParameter(groupParameter)) {\n return [groupParameter];\n }\n\n const childrenIds = groupParameter.typeConfig?.childrenParams ?? [];\n const resolved: Parameter[] = [];\n\n for (const childId of childrenIds) {\n const childParam = this.findParameter(component, childId, options);\n if (childParam) {\n resolved.push(childParam);\n }\n }\n\n return resolved;\n }\n\n resolveProperties(\n component: ComponentDefinition,\n propertyNames: string[],\n options: FindOptions = {}\n ): { parameters: Parameter[]; notFound: string[] } {\n const parameters: Parameter[] = [];\n const notFound: string[] = [];\n const seenIds = new Set<string>();\n\n for (const name of propertyNames) {\n const param = this.findParameter(component, name, options);\n if (!param) {\n notFound.push(name);\n continue;\n }\n\n if (this.isGroupParameter(param)) {\n const groupParams = this.resolveGroupParameters(component, param, options);\n for (const gp of groupParams) {\n if (!seenIds.has(gp.id)) {\n seenIds.add(gp.id);\n parameters.push(gp);\n }\n }\n } else {\n if (!seenIds.has(param.id)) {\n seenIds.add(param.id);\n parameters.push(param);\n }\n }\n }\n\n return { parameters, notFound };\n }\n\n addParameterToComponent(\n component: ComponentDefinition,\n parameter: Parameter,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existingIndex = component.parameters.findIndex((p) =>\n this.compareIds(p.id, parameter.id, strict)\n );\n if (existingIndex >= 0) {\n component.parameters[existingIndex] = { ...parameter };\n } else {\n component.parameters.push({ ...parameter });\n }\n\n return component;\n }\n\n ensureGroupExists(\n component: ComponentDefinition,\n groupId: string,\n groupName?: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existing = component.parameters.find((p) => this.compareIds(p.id, groupId, strict));\n if (existing) {\n return component;\n }\n\n const groupParam: Parameter = {\n id: groupId,\n name: groupName ?? groupId,\n type: 'group',\n typeConfig: {\n childrenParams: [],\n },\n };\n\n component.parameters.push(groupParam);\n return component;\n }\n\n addParameterToGroup(\n component: ComponentDefinition,\n groupId: string,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const group = component.parameters?.find((p) => this.compareIds(p.id, groupId, strict));\n if (!group || !this.isGroupParameter(group)) {\n throw new PropertyNotFoundError(groupId, component.id);\n }\n\n if (!group.typeConfig) {\n group.typeConfig = { childrenParams: [] };\n }\n if (!group.typeConfig.childrenParams) {\n group.typeConfig.childrenParams = [];\n }\n\n // Check if already exists (case-insensitive if not strict)\n const alreadyExists = group.typeConfig.childrenParams.some((id) =>\n this.compareIds(id, parameterId, strict)\n );\n\n if (!alreadyExists) {\n group.typeConfig.childrenParams.push(parameterId);\n }\n\n return component;\n }\n\n removeParameter(\n component: ComponentDefinition,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter(\n (p) => !this.compareIds(p.id, parameterId, strict)\n );\n\n // Also remove from any groups that reference this parameter\n for (const param of component.parameters) {\n if (this.isGroupParameter(param) && param.typeConfig?.childrenParams) {\n param.typeConfig.childrenParams = param.typeConfig.childrenParams.filter(\n (id) => !this.compareIds(id, parameterId, strict)\n );\n }\n }\n\n return component;\n }\n\n removeEmptyGroups(component: ComponentDefinition): ComponentDefinition {\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter((p) => {\n if (!this.isGroupParameter(p)) {\n return true;\n }\n const children = p.typeConfig?.childrenParams ?? [];\n return children.length > 0;\n });\n\n return component;\n }\n\n // Slot methods\n\n findSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): SlotDefinition | undefined {\n const { strict = false } = options;\n return component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n }\n\n addSlot(component: ComponentDefinition, slot: SlotDefinition): ComponentDefinition {\n if (!component.slots) {\n component.slots = [];\n }\n component.slots.push({ ...slot });\n return component;\n }\n\n updateSlotAllowedComponents(\n component: ComponentDefinition,\n slotId: string,\n allowedComponents: string[],\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const slot = component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n if (slot) {\n slot.allowedComponents = allowedComponents;\n }\n return component;\n }\n\n removeSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.slots) {\n return component;\n }\n component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));\n return component;\n }\n}\n","import { Composition, ComponentInstance, ParameterValue } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport interface FoundComponentInstance {\n instance: ComponentInstance;\n instanceId: string;\n path: string[];\n}\n\nexport class CompositionService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareTypes(type1: string, type2: string, strict: boolean): boolean {\n if (strict) {\n return type1 === type2;\n }\n return type1.toLowerCase() === type2.toLowerCase();\n }\n\n async loadComposition(filePath: string): Promise<Composition> {\n return this.fileSystem.readFile<Composition>(filePath);\n }\n\n async saveComposition(filePath: string, composition: Composition): Promise<void> {\n await this.fileSystem.writeFile(filePath, composition);\n }\n\n async findCompositionsByType(\n compositionsDir: string,\n compositionType: string,\n options: FindOptions = {}\n ): Promise<{ composition: Composition; filePath: string }[]> {\n const { strict = false } = options;\n const files = await this.fileSystem.findFiles(compositionsDir, '**/*.{json,yaml,yml}');\n const results: { composition: Composition; filePath: string }[] = [];\n\n for (const filePath of files) {\n try {\n const composition = await this.loadComposition(filePath);\n if (\n composition.composition?.type &&\n this.compareTypes(composition.composition.type, compositionType, strict)\n ) {\n results.push({ composition, filePath });\n }\n } catch {\n // Skip invalid files\n }\n }\n\n return results;\n }\n\n findComponentInstances(\n composition: Composition,\n componentType: string,\n options: FindOptions = {}\n ): FoundComponentInstance[] {\n const { strict = false } = options;\n const results: FoundComponentInstance[] = [];\n this.searchSlots(composition.composition.slots ?? {}, componentType, [], results, strict);\n return results;\n }\n\n private searchSlots(\n slots: Record<string, ComponentInstance[]>,\n componentType: string,\n currentPath: string[],\n results: FoundComponentInstance[],\n strict: boolean\n ): void {\n for (const [slotName, instances] of Object.entries(slots)) {\n if (!Array.isArray(instances)) continue;\n\n for (let i = 0; i < instances.length; i++) {\n const instance = instances[i];\n const instancePath = [...currentPath, slotName, String(i)];\n\n if (this.compareTypes(instance.type, componentType, strict)) {\n const instanceId = instance._id ?? `${componentType}-${results.length}`;\n results.push({\n instance,\n instanceId,\n path: instancePath,\n });\n }\n\n if (instance.slots) {\n this.searchSlots(instance.slots, componentType, instancePath, results, strict);\n }\n }\n }\n }\n\n getRootOverrides(composition: Composition): Record<string, ParameterValue> {\n const rootId = composition.composition._id;\n // Check _overrides first (newer format), then fall back to direct parameters (older format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides && Object.keys(overrides).length > 0) {\n return overrides;\n }\n // Fall back to direct parameters on the composition root\n return (composition.composition as { parameters?: Record<string, ParameterValue> }).parameters ?? {};\n }\n\n getInstanceOverrides(\n composition: Composition,\n instanceId: string\n ): Record<string, ParameterValue> {\n return composition.composition._overrides?.[instanceId]?.parameters ?? {};\n }\n\n setInstanceOverride(\n composition: Composition,\n instanceId: string,\n parameterId: string,\n value: ParameterValue\n ): Composition {\n if (!composition.composition._overrides) {\n composition.composition._overrides = {};\n }\n if (!composition.composition._overrides[instanceId]) {\n composition.composition._overrides[instanceId] = {};\n }\n if (!composition.composition._overrides[instanceId].parameters) {\n composition.composition._overrides[instanceId].parameters = {};\n }\n\n composition.composition._overrides[instanceId].parameters![parameterId] = value;\n return composition;\n }\n\n setInstanceOverrides(\n composition: Composition,\n instanceId: string,\n parameters: Record<string, ParameterValue>\n ): Composition {\n for (const [paramId, value] of Object.entries(parameters)) {\n this.setInstanceOverride(composition, instanceId, paramId, value);\n }\n return composition;\n }\n\n /**\n * Sets parameters directly on a component instance (preferred approach).\n * This modifies the instance object in-place.\n */\n setInstanceParameters(\n instance: ComponentInstance,\n parameters: Record<string, ParameterValue>\n ): void {\n if (!instance.parameters) {\n instance.parameters = {};\n }\n for (const [paramId, value] of Object.entries(parameters)) {\n instance.parameters[paramId] = value;\n }\n }\n\n /**\n * Deletes parameters from root overrides.\n * Returns true if any parameters were deleted.\n */\n deleteRootOverrides(\n composition: Composition,\n parameterIds: string[],\n options: FindOptions = {}\n ): boolean {\n const { strict = false } = options;\n const rootId = composition.composition._id;\n let deleted = false;\n\n // Check _overrides first (newer format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(overrides)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete overrides[key];\n deleted = true;\n }\n }\n }\n }\n\n // Also check direct parameters on root (older format)\n const rootParams = (composition.composition as { parameters?: Record<string, ParameterValue> })\n .parameters;\n if (rootParams) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(rootParams)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete rootParams[key];\n deleted = true;\n }\n }\n }\n }\n\n return deleted;\n }\n}\n","import { ParameterValue } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface PropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n property: string;\n targetComponentType: string;\n targetGroup: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceParameter: boolean;\n}\n\nexport interface PropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class PropertyPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: PropagateOptions): Promise<PropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n property,\n targetComponentType,\n targetGroup,\n whatIf,\n strict,\n deleteSourceParameter,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve properties\n const propertyNames = property.split('|').map((p) => p.trim());\n const { parameters: resolvedParams, notFound } = this.componentService.resolveProperties(\n sourceComponent,\n propertyNames,\n findOptions\n );\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(notFound.join(', '), compositionType);\n }\n\n const resolvedNames = resolvedParams.map((p) => p.id);\n const groupSources = propertyNames.filter((name) => {\n const param = this.componentService.findParameter(sourceComponent, name, findOptions);\n return param && this.componentService.isGroupParameter(param);\n });\n\n if (groupSources.length > 0) {\n this.logger.info(\n `Resolved properties: ${resolvedNames.join(', ')} (from ${groupSources.join(', ')})`\n );\n } else {\n this.logger.info(`Resolved properties: ${resolvedNames.join(', ')}`);\n }\n\n // Step 4: Modify target component\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n // Ensure target group exists\n const existingGroup = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (!existingGroup) {\n this.logger.action(whatIf, 'CREATE', `Group \"${targetGroup}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.ensureGroupExists(\n modifiedComponent,\n targetGroup,\n undefined,\n findOptions\n );\n componentModified = true;\n }\n\n // Copy parameter definitions to target\n for (const param of resolvedParams) {\n const existingParam = this.componentService.findParameter(\n modifiedComponent,\n param.id,\n findOptions\n );\n if (!existingParam) {\n this.logger.action(\n whatIf,\n 'COPY',\n `Parameter \"${param.id}\" → ${targetComponentType}.${targetGroup}`\n );\n modifiedComponent = this.componentService.addParameterToComponent(\n modifiedComponent,\n param,\n findOptions\n );\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Parameter \"${param.id}\" already exists on ${targetComponentType}`);\n // Ensure it's in the group\n const group = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (group && this.componentService.isGroupParameter(group)) {\n // Check if param is already in group (case-insensitive if not strict)\n const isInGroup = group.typeConfig?.childrenParams?.some((id) =>\n strict ? id === param.id : id.toLowerCase() === param.id.toLowerCase()\n );\n if (!isInGroup) {\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n }\n }\n }\n }\n\n // Save modified component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate values in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootOverrides = this.compositionService.getRootOverrides(composition);\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Build the values to propagate\n const valuesToPropagate: Record<string, ParameterValue> = {};\n for (const param of resolvedParams) {\n if (rootOverrides[param.id]) {\n valuesToPropagate[param.id] = rootOverrides[param.id];\n }\n }\n\n if (Object.keys(valuesToPropagate).length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Set parameters directly on the instance (preferred over _overrides)\n this.compositionService.setInstanceParameters(instance, valuesToPropagate);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${Object.keys(valuesToPropagate).join(', ')}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source parameters if requested\n let sourceComponentModified = false;\n if (deleteSourceParameter) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved parameters from source component\n for (const param of resolvedParams) {\n this.logger.action(whatIf, 'DELETE', `Parameter \"${param.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeParameter(modifiedSource, param.id, findOptions);\n sourceComponentModified = true;\n }\n\n // Also delete any groups that are now empty\n const beforeGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n modifiedSource = this.componentService.removeEmptyGroups(modifiedSource);\n const afterGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n if (afterGroupCount < beforeGroupCount) {\n const removedCount = beforeGroupCount - afterGroupCount;\n this.logger.action(\n whatIf,\n 'DELETE',\n `${removedCount} empty group(s) from ${compositionType}`\n );\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Delete parameter values from root overrides in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const deleted = this.compositionService.deleteRootOverrides(\n composition,\n resolvedNames,\n findOptions\n );\n if (deleted) {\n this.logger.action(whatIf, 'DELETE', `Root overrides from composition/${relativePath}`);\n this.logger.detail(`→ Removed: ${resolvedNames.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n}\n","import { ComponentInstance, Composition } from '../types/index.js';\nimport { SlotNotFoundError, SlotAlreadyExistsError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameSlotInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n slotId: string;\n newSlotId: string;\n newSlotName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameSlotResult {\n componentDefinitionUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class SlotRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameSlotInternalOptions): Promise<RenameSlotResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n newSlotName,\n whatIf,\n strict,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n\n // Validate: newSlotId must differ from slotId\n if (this.compareIds(slotId, newSlotId, strict)) {\n throw new TransformError('New slot ID is the same as the current slot ID');\n }\n\n // Step 1: Load and validate component definition\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n if (!component.slots || component.slots.length === 0) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const slotIndex = component.slots.findIndex((s) =>\n this.compareIds(s.id, slotId, strict)\n );\n if (slotIndex === -1) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const existingNewSlot = component.slots.find((s) =>\n this.compareIds(s.id, newSlotId, strict)\n );\n if (existingNewSlot) {\n throw new SlotAlreadyExistsError(newSlotId, componentType);\n }\n\n // Step 2: Rename the slot in the component definition\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${slotId}\" → \"${newSlotId}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n\n component.slots[slotIndex].id = newSlotId;\n if (newSlotName !== undefined) {\n component.slots[slotIndex].name = newSlotName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 3: Rename slot keys in compositions\n const compositionsResult = await this.renameSlotInDirectory(\n fullCompositionsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 4: Rename slot keys in composition patterns\n const compositionPatternsResult = await this.renameSlotInDirectory(\n fullCompositionPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 5: Rename slot keys in component patterns\n const componentPatternsResult = await this.renameSlotInDirectory(\n fullComponentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component definition, ${totalFiles} file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentDefinitionUpdated: true,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async renameSlotInDirectory(\n directory: string,\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n // Directory may not exist\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n const count = this.renameSlotInTree(\n composition.composition,\n componentType,\n oldSlotId,\n newSlotId,\n strict\n );\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s) of ${componentType})`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameSlotInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check if this node's type matches the target component type\n if (this.compareIds(node.type, componentType, strict) && node.slots) {\n const result = this.renameSlotKey(node.slots, oldSlotId, newSlotId, strict);\n if (result.renamed) {\n node.slots = result.slots;\n count++;\n }\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameSlotInTree(instance, componentType, oldSlotId, newSlotId, strict);\n }\n }\n }\n\n return count;\n }\n\n private renameSlotKey(\n slots: Record<string, ComponentInstance[]>,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): { renamed: boolean; slots: Record<string, ComponentInstance[]> } {\n const matchingKey = Object.keys(slots).find((key) =>\n this.compareIds(key, oldSlotId, strict)\n );\n\n if (!matchingKey) {\n return { renamed: false, slots };\n }\n\n // Rebuild object preserving key order, replacing the old key with the new one\n const newSlots: Record<string, ComponentInstance[]> = {};\n for (const key of Object.keys(slots)) {\n if (key === matchingKey) {\n newSlots[newSlotId] = slots[key];\n } else {\n newSlots[key] = slots[key];\n }\n }\n\n return { renamed: true, slots: newSlots };\n }\n}\n","import { ComponentDefinition, ComponentInstance, Composition } from '../types/index.js';\nimport { ComponentAlreadyExistsError, ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n newComponentType: string;\n newComponentName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameComponentResult {\n componentRenamed: boolean;\n fileRenamed: boolean;\n allowedComponentsUpdated: number;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class ComponentRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameComponentInternalOptions): Promise<RenameComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n newComponentType,\n newComponentName,\n whatIf,\n strict,\n } = options;\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Validate: newComponentType must differ from componentType\n if (this.compareIds(componentType, newComponentType, strict)) {\n throw new TransformError('New component type is the same as the current component type');\n }\n\n // Step 1: Load and validate source component\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n // Step 2: Check target does not already exist\n let targetExists = false;\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n targetExists = true;\n } catch (error) {\n if (!(error instanceof ComponentNotFoundError)) {\n throw error;\n }\n }\n if (targetExists) {\n throw new ComponentAlreadyExistsError(newComponentType, fullComponentsDir);\n }\n\n // Step 3: Update the component definition id (and optionally name)\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Component ID \"${componentType}\" → \"${newComponentType}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n component.id = newComponentType;\n if (newComponentName !== undefined) {\n component.name = newComponentName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 4: Rename the component file\n const ext = this.fileSystem.getExtension(componentFilePath);\n const dir = this.fileSystem.getDirname(componentFilePath);\n const newFilePath = this.fileSystem.joinPath(dir, `${newComponentType}${ext}`);\n let fileRenamed = false;\n\n if (componentFilePath !== newFilePath) {\n this.logger.action(\n whatIf,\n 'RENAME',\n `component/${this.fileSystem.getBasename(componentFilePath)} → component/${this.fileSystem.getBasename(newFilePath)}`\n );\n if (!whatIf) {\n await this.fileSystem.renameFile(componentFilePath, newFilePath);\n }\n fileRenamed = true;\n }\n\n // Step 5: Update allowedComponents on other component definitions\n const allowedComponentsUpdated = await this.updateAllowedComponents(\n fullComponentsDir,\n componentType,\n newComponentType,\n componentFilePath,\n whatIf,\n strict\n );\n\n // Step 6: Update type fields in compositions\n const compositionsResult = await this.renameTypeInDirectory(\n fullCompositionsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 7: Update type fields in composition patterns\n const compositionPatternsResult = await this.renameTypeInDirectory(\n fullCompositionPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 8: Update type fields in component patterns\n const componentPatternsResult = await this.renameTypeInDirectory(\n fullComponentPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalCompositionFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component renamed, ${allowedComponentsUpdated} component(s) with allowedComponents updated, ` +\n `${totalCompositionFiles} composition file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentRenamed: true,\n fileRenamed,\n allowedComponentsUpdated,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async updateAllowedComponents(\n componentsDir: string,\n oldType: string,\n newType: string,\n sourceFilePath: string,\n whatIf: boolean,\n strict: boolean\n ): Promise<number> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n } catch {\n return 0;\n }\n\n let updatedCount = 0;\n\n for (const filePath of files) {\n // Skip the source component file itself (it was already saved with the new id)\n if (filePath === sourceFilePath) continue;\n\n let comp: ComponentDefinition;\n try {\n comp = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n } catch {\n continue;\n }\n\n if (!comp.slots || comp.slots.length === 0) continue;\n\n let fileModified = false;\n for (const slot of comp.slots) {\n if (!slot.allowedComponents) continue;\n\n for (let i = 0; i < slot.allowedComponents.length; i++) {\n if (this.compareIds(slot.allowedComponents[i], oldType, strict)) {\n slot.allowedComponents[i] = newType;\n fileModified = true;\n }\n }\n }\n\n if (fileModified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `allowedComponents in component/${this.fileSystem.getBasename(filePath)}: ${oldType} → ${newType}`\n );\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, comp);\n }\n updatedCount++;\n }\n }\n\n return updatedCount;\n }\n\n private async renameTypeInDirectory(\n directory: string,\n oldType: string,\n newType: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) continue;\n\n const count = this.renameTypeInTree(composition.composition, oldType, newType, strict);\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s))`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameTypeInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n oldType: string,\n newType: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check this node's type\n if (this.compareIds(node.type, oldType, strict)) {\n node.type = newType;\n count++;\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameTypeInTree(instance, oldType, newType, strict);\n }\n }\n }\n\n return count;\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport {\n ComponentInstance,\n Composition,\n} from '../types/index.js';\nimport { ComponentNotFoundError, SlotNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface AddComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n parentComponentType: string;\n slot: string;\n newComponentType?: string;\n componentPatternId?: string;\n parameters?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface AddComponentResult {\n allowedComponentsUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesAdded: number;\n}\n\ninterface ComponentPattern {\n componentPatternId: string;\n definition: ComponentInstance;\n [key: string]: unknown;\n}\n\ninterface ParsedParameters {\n [key: string]: string;\n}\n\nexport class ComponentAdderService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n private parseParameters(parameterString?: string): ParsedParameters {\n const result: ParsedParameters = {};\n if (!parameterString) return result;\n\n const pairs = parameterString.split('|');\n for (const pair of pairs) {\n const [key, ...valueParts] = pair.split(':');\n if (key && valueParts.length > 0) {\n result[key.trim()] = valueParts.join(':').trim();\n }\n }\n return result;\n }\n\n private generateId(baseName: string): string {\n return `${baseName}-${randomUUID().slice(0, 8)}`;\n }\n\n private cloneComponentInstance(instance: ComponentInstance): ComponentInstance {\n const clone = JSON.parse(JSON.stringify(instance)) as ComponentInstance;\n\n // Regenerate _id for the root\n if (clone._id) {\n clone._id = this.generateId(clone.type);\n }\n\n // Recursively regenerate _id for nested instances\n if (clone.slots) {\n for (const slotInstances of Object.values(clone.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n\n return clone;\n }\n\n private regenerateInstanceIds(instance: ComponentInstance): void {\n if (instance._id) {\n instance._id = this.generateId(instance.type);\n }\n\n if (instance.slots) {\n for (const slotInstances of Object.values(instance.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n }\n\n private createComponentInstance(\n componentType: string,\n parameters: ParsedParameters\n ): ComponentInstance {\n const instance: ComponentInstance = {\n type: componentType,\n _id: this.generateId(componentType),\n };\n\n if (Object.keys(parameters).length > 0) {\n instance.parameters = {};\n for (const [key, value] of Object.entries(parameters)) {\n instance.parameters[key] = {\n type: 'text',\n value,\n };\n }\n }\n\n return instance;\n }\n\n private addComponentToSlot(slots: Record<string, ComponentInstance[]>, slotId: string, instance: ComponentInstance): void {\n if (!slots[slotId]) {\n slots[slotId] = [];\n }\n slots[slotId].push(instance);\n }\n\n async addComponent(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n newComponentType,\n parameters: paramString,\n whatIf,\n strict,\n } = options;\n\n if (!newComponentType) {\n throw new TransformError('newComponentType is required for add-component');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent, filePath: parentComponentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Validate slot exists on parent\n const slotDef = parentComponent.slots?.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n throw new SlotNotFoundError(slot, parentComponentType);\n }\n\n // Step 3: Validate new component type exists\n this.logger.info(`Validating new component: ${newComponentType}`);\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n } catch (error) {\n if (error instanceof ComponentNotFoundError) {\n throw new TransformError(\n `Component type \"${newComponentType}\" not found in ${fullComponentsDir}`\n );\n }\n throw error;\n }\n\n // Step 4: Update allowedComponents if needed\n let allowedComponentsUpdated = false;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, newComponentType, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newComponentType}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(newComponentType);\n if (!whatIf) {\n await this.componentService.saveComponent(parentComponentFilePath, parentComponent);\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 5: Parse parameters\n const parsedParams = this.parseParameters(paramString);\n\n // Step 6: Create the new component instance\n const newInstance = this.createComponentInstance(newComponentType, parsedParams);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n async addComponentPattern(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n componentPatternId,\n whatIf,\n strict,\n } = options;\n\n if (!componentPatternId) {\n throw new TransformError('componentPatternId is required for add-component-pattern');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Validate slot exists on parent\n const slotDef = parentComponent.slots?.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n throw new SlotNotFoundError(slot, parentComponentType);\n }\n\n // Step 3: Load and validate component pattern\n this.logger.info(`Loading component pattern: ${componentPatternId}`);\n const pattern = await this.loadComponentPattern(\n fullComponentPatternsDir,\n componentPatternId,\n strict\n );\n\n // Step 4: Get the definition from the pattern\n const patternDefinition = pattern.definition;\n if (!patternDefinition || !patternDefinition.type) {\n throw new TransformError(\n `Component pattern \"${componentPatternId}\" has no valid definition or missing type`\n );\n }\n\n // Step 5: Update allowedComponents if needed (using the pattern's definition type)\n let allowedComponentsUpdated = false;\n const componentTypeInPattern = patternDefinition.type;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, componentTypeInPattern, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${componentTypeInPattern}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(componentTypeInPattern);\n if (!whatIf) {\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions)\n .then(({ filePath }) =>\n this.componentService.saveComponent(filePath, parentComponent)\n );\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 6: Create the new component instance from the pattern (with cloned definition)\n const newInstance = this.cloneComponentInstance(patternDefinition);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n private async loadComponentPattern(\n componentPatternsDir: string,\n patternId: string,\n strict: boolean\n ): Promise<ComponentPattern> {\n // Try exact match first\n const jsonPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.json`);\n const yamlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n return this.fileSystem.readFile<ComponentPattern>(jsonPath);\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n return this.fileSystem.readFile<ComponentPattern>(yamlPath);\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n return this.fileSystem.readFile<ComponentPattern>(ymlPath);\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentPatternsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === patternId.toLowerCase()) {\n return this.fileSystem.readFile<ComponentPattern>(filePath);\n }\n }\n }\n\n throw new TransformError(`Component pattern \"${patternId}\" not found in ${componentPatternsDir}`);\n }\n\n private async addComponentToDirectory(\n directory: string,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n whatIf: boolean,\n strict: boolean,\n dirType: 'composition' | 'compositionPattern' | 'componentPattern'\n ): Promise<number> {\n const exists = await this.fileSystem.fileExists(directory);\n if (!exists) {\n this.logger.detail(`${dirType} directory does not exist, skipping`);\n return 0;\n }\n\n const files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n let filesModified = 0;\n\n for (const filePath of files) {\n try {\n // Handle both composition and componentPattern formats\n const content = await this.fileSystem.readFile<unknown>(filePath);\n\n // For component patterns, the structure might be different\n let composition: Composition | null = null;\n let isComponentPattern = false;\n\n if (dirType === 'componentPattern' && content && typeof content === 'object' && 'definition' in content) {\n // This is a component pattern\n isComponentPattern = true;\n const pattern = content as ComponentPattern;\n if (pattern.definition && pattern.definition.slots) {\n composition = {\n composition: {\n _id: 'pattern-root',\n type: pattern.definition.type,\n slots: pattern.definition.slots,\n } as any,\n };\n }\n } else {\n // This is a normal composition\n composition = content as Composition;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n // Find and add to parent component instances\n const rootInstance = composition.composition as any;\n let modified = false;\n\n // Check root instance\n if (this.compareIds(rootInstance.type, parentComponentType, strict)) {\n if (!rootInstance.slots) {\n rootInstance.slots = {};\n }\n\n // Clone the new instance to avoid mutations\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Check nested instances\n if (rootInstance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n rootInstance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n\n if (modified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newInstance.type}\" to slot \"${slot}\" in ${dirType}/${this.fileSystem.getBasename(filePath)}`\n );\n\n if (!whatIf) {\n if (isComponentPattern && content && typeof content === 'object' && 'definition' in content) {\n // For component patterns, update the definition\n const pattern = content as ComponentPattern;\n if (rootInstance.slots) {\n pattern.definition.slots = rootInstance.slots;\n }\n }\n await this.fileSystem.writeFile(filePath, content);\n }\n\n filesModified++;\n }\n } catch (error) {\n // Skip files that can't be parsed\n if (error instanceof Error && !error.message.includes('skipping')) {\n this.logger.detail(`Skipping ${filePath}: ${error.message}`);\n }\n }\n }\n\n return filesModified;\n }\n\n private addComponentToNestedSlots(\n slots: Record<string, ComponentInstance[]>,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n strict: boolean\n ): boolean {\n let modified = false;\n\n for (const slotInstances of Object.values(slots)) {\n if (!Array.isArray(slotInstances)) continue;\n\n for (const instance of slotInstances) {\n if (this.compareIds(instance.type, parentComponentType, strict)) {\n if (!instance.slots) {\n instance.slots = {};\n }\n\n // Clone the new instance to avoid mutations across multiple matches\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(instance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Recurse into nested slots\n if (instance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n instance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n }\n }\n\n return modified;\n }\n}\n","import chalk from 'chalk';\n\nexport class Logger {\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${message}`);\n }\n\n success(message: string): void {\n console.log(`${chalk.green('[DONE]')} ${message}`);\n }\n\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${message}`);\n }\n\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${message}`);\n }\n\n action(whatIf: boolean, actionType: string, message: string): void {\n const prefix = whatIf ? chalk.yellow('[WOULD]') : chalk.green(`[${actionType}]`);\n console.log(`${prefix} ${message}`);\n }\n\n detail(message: string): void {\n console.log(` ${chalk.gray(message)}`);\n }\n}\n"],"mappings":";AAAO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,yBAAN,cAAqC,eAAe;AAAA,EACzD,YAAY,eAAuBA,OAAe;AAChD,UAAM,WAAWA,QAAO,eAAeA,KAAI,MAAM;AACjD,UAAM,wBAAwB,aAAa,GAAG,QAAQ,EAAE;AACxD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EACxD,YAAY,cAAsB,eAAuB;AACvD,UAAM,aAAa,YAAY,6BAA6B,aAAa,GAAG;AAC5E,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EACnD,YAAY,UAAkB,SAAkB;AAC9C,UAAM,cAAc,UAAU,KAAK,OAAO,KAAK;AAC/C,UAAM,sBAAsB,QAAQ,GAAG,WAAW,EA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A,EACnD;AAAA,EAEA,MAAM,SAAuB;AAC3B,YAAQ,IAAI,GAAG,MAAM,IAAI,SAAS,CAAC,IAAI,OAAO,EAAE;AAAA,EAClD;AAAA,EAEA,KAAK,SAAuB;AAC1B,YAAQ,IAAI,GAAG,MAAM,OAAO,QAAQ,CAAC,IAAI,OAAO,EAAE;AAAA,EACpD;AAAA,EAEA,OAAO,QAAiB,YAAoB,SAAuB;AACjE,UAAM,SAAS,SAAS,MAAM,OAAO,SAAS,IAAI,MAAM,MAAM,IAAI,UAAU,GAAG;AAC/E,YAAQ,IAAI,GAAG,MAAM,IAAI,OAAO,EAAE;AAAA,EACpC;AAAA,EAEA,OAAO,SAAuB;AAC5B,YAAQ,IAAI,KAAK,MAAM,KAAK,OAAO,CAAC,EAAE;AAAA,EACxC;AACF;","names":["path","basename","basename"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.ts","../src/core/services/file-system.service.ts","../src/core/services/component.service.ts","../src/core/services/composition.service.ts","../src/core/services/property-propagator.service.ts","../src/core/services/slot-renamer.service.ts","../src/core/services/component-renamer.service.ts","../src/core/services/component-adder.service.ts","../src/cli/logger.ts"],"sourcesContent":["export class TransformError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TransformError';\n }\n}\n\nexport class ComponentNotFoundError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component not found: ${componentType}${pathInfo}`);\n this.name = 'ComponentNotFoundError';\n }\n}\n\nexport class PropertyNotFoundError extends TransformError {\n constructor(propertyName: string, componentType: string) {\n super(`Property \"${propertyName}\" not found on component \"${componentType}\"`);\n this.name = 'PropertyNotFoundError';\n }\n}\n\nexport class InvalidYamlError extends TransformError {\n constructor(filePath: string, details?: string) {\n const detailsInfo = details ? `: ${details}` : '';\n super(`Invalid YAML file: ${filePath}${detailsInfo}`);\n this.name = 'InvalidYamlError';\n }\n}\n\nexport class FileNotFoundError extends TransformError {\n constructor(filePath: string) {\n super(`File not found: ${filePath}`);\n this.name = 'FileNotFoundError';\n }\n}\n\nexport class DuplicateIdError extends TransformError {\n constructor(id: string, arrayProperty: string, filePath: string) {\n super(`Duplicate id \"${id}\" in array \"${arrayProperty}\" of file: ${filePath}`);\n this.name = 'DuplicateIdError';\n }\n}\n\nexport class ComponentAlreadyExistsError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component type \"${componentType}\" already exists${pathInfo}`);\n this.name = 'ComponentAlreadyExistsError';\n }\n}\n\nexport class SlotNotFoundError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" does not exist on component \"${componentType}\"`);\n this.name = 'SlotNotFoundError';\n }\n}\n\nexport class SlotAlreadyExistsError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" already exists on component \"${componentType}\"`);\n this.name = 'SlotAlreadyExistsError';\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as YAML from 'yaml';\nimport { InvalidYamlError, FileNotFoundError } from '../errors.js';\n\nexport class FileSystemService {\n private isJsonFile(filePath: string): boolean {\n return filePath.toLowerCase().endsWith('.json');\n }\n\n async readFile<T>(filePath: string): Promise<T> {\n if (!fs.existsSync(filePath)) {\n throw new FileNotFoundError(filePath);\n }\n\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n if (this.isJsonFile(filePath)) {\n return JSON.parse(content) as T;\n }\n return YAML.parse(content) as T;\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n throw new InvalidYamlError(filePath, message);\n }\n }\n\n async writeFile<T>(filePath: string, data: T): Promise<void> {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n let content: string;\n if (this.isJsonFile(filePath)) {\n content = JSON.stringify(data, null, 2);\n } else {\n content = YAML.stringify(data, {\n lineWidth: 0,\n defaultKeyType: 'PLAIN',\n defaultStringType: 'QUOTE_DOUBLE',\n });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n }\n\n async readYamlFile<T>(filePath: string): Promise<T> {\n return this.readFile<T>(filePath);\n }\n\n async writeYamlFile<T>(filePath: string, data: T): Promise<void> {\n return this.writeFile(filePath, data);\n }\n\n async findFiles(directory: string, pattern: string): Promise<string[]> {\n const fullPattern = path.join(directory, pattern).replace(/\\\\/g, '/');\n return glob(fullPattern);\n }\n\n async fileExists(filePath: string): Promise<boolean> {\n return fs.existsSync(filePath);\n }\n\n resolvePath(...segments: string[]): string {\n return path.resolve(...segments);\n }\n\n joinPath(...segments: string[]): string {\n return path.join(...segments);\n }\n\n getBasename(filePath: string, ext?: string): string {\n return path.basename(filePath, ext);\n }\n\n async renameFile(oldPath: string, newPath: string): Promise<void> {\n fs.renameSync(oldPath, newPath);\n }\n\n deleteFile(filePath: string): void {\n fs.unlinkSync(filePath);\n }\n\n getExtension(filePath: string): string {\n return path.extname(filePath);\n }\n\n getDirname(filePath: string): string {\n return path.dirname(filePath);\n }\n}\n","import { ComponentDefinition, Parameter, SlotDefinition } from '../types/index.js';\nimport { ComponentNotFoundError, PropertyNotFoundError } from '../errors.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport class ComponentService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async loadComponent(\n componentsDir: string,\n componentType: string,\n options: FindOptions = {}\n ): Promise<{ component: ComponentDefinition; filePath: string }> {\n const { strict = false } = options;\n\n // First try exact match\n const jsonPath = this.fileSystem.joinPath(componentsDir, `${componentType}.json`);\n const yamlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(jsonPath);\n return { component, filePath: jsonPath };\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(yamlPath);\n return { component, filePath: yamlPath };\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(ymlPath);\n return { component, filePath: ymlPath };\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === componentType.toLowerCase()) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n return { component, filePath };\n }\n }\n }\n\n throw new ComponentNotFoundError(componentType, componentsDir);\n }\n\n async saveComponent(filePath: string, component: ComponentDefinition): Promise<void> {\n await this.fileSystem.writeFile(filePath, component);\n }\n\n findParameter(\n component: ComponentDefinition,\n parameterName: string,\n options: FindOptions = {}\n ): Parameter | undefined {\n const { strict = false } = options;\n return component.parameters?.find((p) => this.compareIds(p.id, parameterName, strict));\n }\n\n isGroupParameter(parameter: Parameter): boolean {\n return parameter.type === 'group';\n }\n\n resolveGroupParameters(\n component: ComponentDefinition,\n groupParameter: Parameter,\n options: FindOptions = {}\n ): Parameter[] {\n if (!this.isGroupParameter(groupParameter)) {\n return [groupParameter];\n }\n\n const childrenIds = groupParameter.typeConfig?.childrenParams ?? [];\n const resolved: Parameter[] = [];\n\n for (const childId of childrenIds) {\n const childParam = this.findParameter(component, childId, options);\n if (childParam) {\n resolved.push(childParam);\n }\n }\n\n return resolved;\n }\n\n resolveProperties(\n component: ComponentDefinition,\n propertyNames: string[],\n options: FindOptions = {}\n ): { parameters: Parameter[]; notFound: string[] } {\n const parameters: Parameter[] = [];\n const notFound: string[] = [];\n const seenIds = new Set<string>();\n\n for (const name of propertyNames) {\n const param = this.findParameter(component, name, options);\n if (!param) {\n notFound.push(name);\n continue;\n }\n\n if (this.isGroupParameter(param)) {\n const groupParams = this.resolveGroupParameters(component, param, options);\n for (const gp of groupParams) {\n if (!seenIds.has(gp.id)) {\n seenIds.add(gp.id);\n parameters.push(gp);\n }\n }\n } else {\n if (!seenIds.has(param.id)) {\n seenIds.add(param.id);\n parameters.push(param);\n }\n }\n }\n\n return { parameters, notFound };\n }\n\n addParameterToComponent(\n component: ComponentDefinition,\n parameter: Parameter,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existingIndex = component.parameters.findIndex((p) =>\n this.compareIds(p.id, parameter.id, strict)\n );\n if (existingIndex >= 0) {\n component.parameters[existingIndex] = { ...parameter };\n } else {\n component.parameters.push({ ...parameter });\n }\n\n return component;\n }\n\n ensureGroupExists(\n component: ComponentDefinition,\n groupId: string,\n groupName?: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existing = component.parameters.find((p) => this.compareIds(p.id, groupId, strict));\n if (existing) {\n return component;\n }\n\n const groupParam: Parameter = {\n id: groupId,\n name: groupName ?? groupId,\n type: 'group',\n typeConfig: {\n childrenParams: [],\n },\n };\n\n component.parameters.push(groupParam);\n return component;\n }\n\n addParameterToGroup(\n component: ComponentDefinition,\n groupId: string,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const group = component.parameters?.find((p) => this.compareIds(p.id, groupId, strict));\n if (!group || !this.isGroupParameter(group)) {\n throw new PropertyNotFoundError(groupId, component.id);\n }\n\n if (!group.typeConfig) {\n group.typeConfig = { childrenParams: [] };\n }\n if (!group.typeConfig.childrenParams) {\n group.typeConfig.childrenParams = [];\n }\n\n // Check if already exists (case-insensitive if not strict)\n const alreadyExists = group.typeConfig.childrenParams.some((id) =>\n this.compareIds(id, parameterId, strict)\n );\n\n if (!alreadyExists) {\n group.typeConfig.childrenParams.push(parameterId);\n }\n\n return component;\n }\n\n removeParameter(\n component: ComponentDefinition,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter(\n (p) => !this.compareIds(p.id, parameterId, strict)\n );\n\n // Also remove from any groups that reference this parameter\n for (const param of component.parameters) {\n if (this.isGroupParameter(param) && param.typeConfig?.childrenParams) {\n param.typeConfig.childrenParams = param.typeConfig.childrenParams.filter(\n (id) => !this.compareIds(id, parameterId, strict)\n );\n }\n }\n\n return component;\n }\n\n removeEmptyGroups(component: ComponentDefinition): ComponentDefinition {\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter((p) => {\n if (!this.isGroupParameter(p)) {\n return true;\n }\n const children = p.typeConfig?.childrenParams ?? [];\n return children.length > 0;\n });\n\n return component;\n }\n\n // Slot methods\n\n findSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): SlotDefinition | undefined {\n const { strict = false } = options;\n return component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n }\n\n addSlot(component: ComponentDefinition, slot: SlotDefinition): ComponentDefinition {\n if (!component.slots) {\n component.slots = [];\n }\n component.slots.push({ ...slot });\n return component;\n }\n\n updateSlotAllowedComponents(\n component: ComponentDefinition,\n slotId: string,\n allowedComponents: string[],\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const slot = component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n if (slot) {\n slot.allowedComponents = allowedComponents;\n }\n return component;\n }\n\n removeSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.slots) {\n return component;\n }\n component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));\n return component;\n }\n}\n","import { Composition, ComponentInstance, ParameterValue } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport interface FoundComponentInstance {\n instance: ComponentInstance;\n instanceId: string;\n path: string[];\n}\n\nexport class CompositionService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareTypes(type1: string, type2: string, strict: boolean): boolean {\n if (strict) {\n return type1 === type2;\n }\n return type1.toLowerCase() === type2.toLowerCase();\n }\n\n async loadComposition(filePath: string): Promise<Composition> {\n return this.fileSystem.readFile<Composition>(filePath);\n }\n\n async saveComposition(filePath: string, composition: Composition): Promise<void> {\n await this.fileSystem.writeFile(filePath, composition);\n }\n\n async findCompositionsByType(\n compositionsDir: string,\n compositionType: string,\n options: FindOptions = {}\n ): Promise<{ composition: Composition; filePath: string }[]> {\n const { strict = false } = options;\n const files = await this.fileSystem.findFiles(compositionsDir, '**/*.{json,yaml,yml}');\n const results: { composition: Composition; filePath: string }[] = [];\n\n for (const filePath of files) {\n try {\n const composition = await this.loadComposition(filePath);\n if (\n composition.composition?.type &&\n this.compareTypes(composition.composition.type, compositionType, strict)\n ) {\n results.push({ composition, filePath });\n }\n } catch {\n // Skip invalid files\n }\n }\n\n return results;\n }\n\n findComponentInstances(\n composition: Composition,\n componentType: string,\n options: FindOptions = {}\n ): FoundComponentInstance[] {\n const { strict = false } = options;\n const results: FoundComponentInstance[] = [];\n this.searchSlots(composition.composition.slots ?? {}, componentType, [], results, strict);\n return results;\n }\n\n private searchSlots(\n slots: Record<string, ComponentInstance[]>,\n componentType: string,\n currentPath: string[],\n results: FoundComponentInstance[],\n strict: boolean\n ): void {\n for (const [slotName, instances] of Object.entries(slots)) {\n if (!Array.isArray(instances)) continue;\n\n for (let i = 0; i < instances.length; i++) {\n const instance = instances[i];\n const instancePath = [...currentPath, slotName, String(i)];\n\n if (this.compareTypes(instance.type, componentType, strict)) {\n const instanceId = instance._id ?? `${componentType}-${results.length}`;\n results.push({\n instance,\n instanceId,\n path: instancePath,\n });\n }\n\n if (instance.slots) {\n this.searchSlots(instance.slots, componentType, instancePath, results, strict);\n }\n }\n }\n }\n\n getRootOverrides(composition: Composition): Record<string, ParameterValue> {\n const rootId = composition.composition._id;\n // Check _overrides first (newer format), then fall back to direct parameters (older format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides && Object.keys(overrides).length > 0) {\n return overrides;\n }\n // Fall back to direct parameters on the composition root\n return (composition.composition as { parameters?: Record<string, ParameterValue> }).parameters ?? {};\n }\n\n getInstanceOverrides(\n composition: Composition,\n instanceId: string\n ): Record<string, ParameterValue> {\n return composition.composition._overrides?.[instanceId]?.parameters ?? {};\n }\n\n setInstanceOverride(\n composition: Composition,\n instanceId: string,\n parameterId: string,\n value: ParameterValue\n ): Composition {\n if (!composition.composition._overrides) {\n composition.composition._overrides = {};\n }\n if (!composition.composition._overrides[instanceId]) {\n composition.composition._overrides[instanceId] = {};\n }\n if (!composition.composition._overrides[instanceId].parameters) {\n composition.composition._overrides[instanceId].parameters = {};\n }\n\n composition.composition._overrides[instanceId].parameters![parameterId] = value;\n return composition;\n }\n\n setInstanceOverrides(\n composition: Composition,\n instanceId: string,\n parameters: Record<string, ParameterValue>\n ): Composition {\n for (const [paramId, value] of Object.entries(parameters)) {\n this.setInstanceOverride(composition, instanceId, paramId, value);\n }\n return composition;\n }\n\n /**\n * Sets parameters directly on a component instance (preferred approach).\n * This modifies the instance object in-place.\n */\n setInstanceParameters(\n instance: ComponentInstance,\n parameters: Record<string, ParameterValue>\n ): void {\n if (!instance.parameters) {\n instance.parameters = {};\n }\n for (const [paramId, value] of Object.entries(parameters)) {\n instance.parameters[paramId] = value;\n }\n }\n\n /**\n * Deletes parameters from root overrides.\n * Returns true if any parameters were deleted.\n */\n deleteRootOverrides(\n composition: Composition,\n parameterIds: string[],\n options: FindOptions = {}\n ): boolean {\n const { strict = false } = options;\n const rootId = composition.composition._id;\n let deleted = false;\n\n // Check _overrides first (newer format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(overrides)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete overrides[key];\n deleted = true;\n }\n }\n }\n }\n\n // Also check direct parameters on root (older format)\n const rootParams = (composition.composition as { parameters?: Record<string, ParameterValue> })\n .parameters;\n if (rootParams) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(rootParams)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete rootParams[key];\n deleted = true;\n }\n }\n }\n }\n\n return deleted;\n }\n}\n","import { ParameterValue } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface PropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n property: string;\n targetComponentType: string;\n targetGroup: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceParameter: boolean;\n}\n\nexport interface PropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class PropertyPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: PropagateOptions): Promise<PropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n property,\n targetComponentType,\n targetGroup,\n whatIf,\n strict,\n deleteSourceParameter,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve properties\n const propertyNames = property.split('|').map((p) => p.trim());\n const { parameters: resolvedParams, notFound } = this.componentService.resolveProperties(\n sourceComponent,\n propertyNames,\n findOptions\n );\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(notFound.join(', '), compositionType);\n }\n\n const resolvedNames = resolvedParams.map((p) => p.id);\n const groupSources = propertyNames.filter((name) => {\n const param = this.componentService.findParameter(sourceComponent, name, findOptions);\n return param && this.componentService.isGroupParameter(param);\n });\n\n if (groupSources.length > 0) {\n this.logger.info(\n `Resolved properties: ${resolvedNames.join(', ')} (from ${groupSources.join(', ')})`\n );\n } else {\n this.logger.info(`Resolved properties: ${resolvedNames.join(', ')}`);\n }\n\n // Step 4: Modify target component\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n // Ensure target group exists\n const existingGroup = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (!existingGroup) {\n this.logger.action(whatIf, 'CREATE', `Group \"${targetGroup}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.ensureGroupExists(\n modifiedComponent,\n targetGroup,\n undefined,\n findOptions\n );\n componentModified = true;\n }\n\n // Copy parameter definitions to target\n for (const param of resolvedParams) {\n const existingParam = this.componentService.findParameter(\n modifiedComponent,\n param.id,\n findOptions\n );\n if (!existingParam) {\n this.logger.action(\n whatIf,\n 'COPY',\n `Parameter \"${param.id}\" → ${targetComponentType}.${targetGroup}`\n );\n modifiedComponent = this.componentService.addParameterToComponent(\n modifiedComponent,\n param,\n findOptions\n );\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Parameter \"${param.id}\" already exists on ${targetComponentType}`);\n // Ensure it's in the group\n const group = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (group && this.componentService.isGroupParameter(group)) {\n // Check if param is already in group (case-insensitive if not strict)\n const isInGroup = group.typeConfig?.childrenParams?.some((id) =>\n strict ? id === param.id : id.toLowerCase() === param.id.toLowerCase()\n );\n if (!isInGroup) {\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n }\n }\n }\n }\n\n // Save modified component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate values in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootOverrides = this.compositionService.getRootOverrides(composition);\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Build the values to propagate\n const valuesToPropagate: Record<string, ParameterValue> = {};\n for (const param of resolvedParams) {\n if (rootOverrides[param.id]) {\n valuesToPropagate[param.id] = rootOverrides[param.id];\n }\n }\n\n if (Object.keys(valuesToPropagate).length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Set parameters directly on the instance (preferred over _overrides)\n this.compositionService.setInstanceParameters(instance, valuesToPropagate);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${Object.keys(valuesToPropagate).join(', ')}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source parameters if requested\n let sourceComponentModified = false;\n if (deleteSourceParameter) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved parameters from source component\n for (const param of resolvedParams) {\n this.logger.action(whatIf, 'DELETE', `Parameter \"${param.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeParameter(modifiedSource, param.id, findOptions);\n sourceComponentModified = true;\n }\n\n // Also delete any groups that are now empty\n const beforeGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n modifiedSource = this.componentService.removeEmptyGroups(modifiedSource);\n const afterGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n if (afterGroupCount < beforeGroupCount) {\n const removedCount = beforeGroupCount - afterGroupCount;\n this.logger.action(\n whatIf,\n 'DELETE',\n `${removedCount} empty group(s) from ${compositionType}`\n );\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Delete parameter values from root overrides in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const deleted = this.compositionService.deleteRootOverrides(\n composition,\n resolvedNames,\n findOptions\n );\n if (deleted) {\n this.logger.action(whatIf, 'DELETE', `Root overrides from composition/${relativePath}`);\n this.logger.detail(`→ Removed: ${resolvedNames.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n}\n","import { ComponentInstance, Composition } from '../types/index.js';\nimport { SlotNotFoundError, SlotAlreadyExistsError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameSlotInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n slotId: string;\n newSlotId: string;\n newSlotName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameSlotResult {\n componentDefinitionUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class SlotRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameSlotInternalOptions): Promise<RenameSlotResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n newSlotName,\n whatIf,\n strict,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n\n // Validate: newSlotId must differ from slotId\n if (this.compareIds(slotId, newSlotId, strict)) {\n throw new TransformError('New slot ID is the same as the current slot ID');\n }\n\n // Step 1: Load and validate component definition\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n if (!component.slots || component.slots.length === 0) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const slotIndex = component.slots.findIndex((s) =>\n this.compareIds(s.id, slotId, strict)\n );\n if (slotIndex === -1) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const existingNewSlot = component.slots.find((s) =>\n this.compareIds(s.id, newSlotId, strict)\n );\n if (existingNewSlot) {\n throw new SlotAlreadyExistsError(newSlotId, componentType);\n }\n\n // Step 2: Rename the slot in the component definition\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${slotId}\" → \"${newSlotId}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n\n component.slots[slotIndex].id = newSlotId;\n if (newSlotName !== undefined) {\n component.slots[slotIndex].name = newSlotName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 3: Rename slot keys in compositions\n const compositionsResult = await this.renameSlotInDirectory(\n fullCompositionsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 4: Rename slot keys in composition patterns\n const compositionPatternsResult = await this.renameSlotInDirectory(\n fullCompositionPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 5: Rename slot keys in component patterns\n const componentPatternsResult = await this.renameSlotInDirectory(\n fullComponentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component definition, ${totalFiles} file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentDefinitionUpdated: true,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async renameSlotInDirectory(\n directory: string,\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n // Directory may not exist\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n const count = this.renameSlotInTree(\n composition.composition,\n componentType,\n oldSlotId,\n newSlotId,\n strict\n );\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s) of ${componentType})`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameSlotInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check if this node's type matches the target component type\n if (this.compareIds(node.type, componentType, strict) && node.slots) {\n const result = this.renameSlotKey(node.slots, oldSlotId, newSlotId, strict);\n if (result.renamed) {\n node.slots = result.slots;\n count++;\n }\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameSlotInTree(instance, componentType, oldSlotId, newSlotId, strict);\n }\n }\n }\n\n return count;\n }\n\n private renameSlotKey(\n slots: Record<string, ComponentInstance[]>,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): { renamed: boolean; slots: Record<string, ComponentInstance[]> } {\n const matchingKey = Object.keys(slots).find((key) =>\n this.compareIds(key, oldSlotId, strict)\n );\n\n if (!matchingKey) {\n return { renamed: false, slots };\n }\n\n // Rebuild object preserving key order, replacing the old key with the new one\n const newSlots: Record<string, ComponentInstance[]> = {};\n for (const key of Object.keys(slots)) {\n if (key === matchingKey) {\n newSlots[newSlotId] = slots[key];\n } else {\n newSlots[key] = slots[key];\n }\n }\n\n return { renamed: true, slots: newSlots };\n }\n}\n","import { ComponentDefinition, ComponentInstance, Composition } from '../types/index.js';\nimport { ComponentAlreadyExistsError, ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n newComponentType: string;\n newComponentName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameComponentResult {\n componentRenamed: boolean;\n fileRenamed: boolean;\n allowedComponentsUpdated: number;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class ComponentRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameComponentInternalOptions): Promise<RenameComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n newComponentType,\n newComponentName,\n whatIf,\n strict,\n } = options;\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Validate: newComponentType must differ from componentType\n if (this.compareIds(componentType, newComponentType, strict)) {\n throw new TransformError('New component type is the same as the current component type');\n }\n\n // Step 1: Load and validate source component\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n // Step 2: Check target does not already exist\n let targetExists = false;\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n targetExists = true;\n } catch (error) {\n if (!(error instanceof ComponentNotFoundError)) {\n throw error;\n }\n }\n if (targetExists) {\n throw new ComponentAlreadyExistsError(newComponentType, fullComponentsDir);\n }\n\n // Step 3: Update the component definition id (and optionally name)\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Component ID \"${componentType}\" → \"${newComponentType}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n component.id = newComponentType;\n if (newComponentName !== undefined) {\n component.name = newComponentName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 4: Rename the component file\n const ext = this.fileSystem.getExtension(componentFilePath);\n const dir = this.fileSystem.getDirname(componentFilePath);\n const newFilePath = this.fileSystem.joinPath(dir, `${newComponentType}${ext}`);\n let fileRenamed = false;\n\n if (componentFilePath !== newFilePath) {\n this.logger.action(\n whatIf,\n 'RENAME',\n `component/${this.fileSystem.getBasename(componentFilePath)} → component/${this.fileSystem.getBasename(newFilePath)}`\n );\n if (!whatIf) {\n await this.fileSystem.renameFile(componentFilePath, newFilePath);\n }\n fileRenamed = true;\n }\n\n // Step 5: Update allowedComponents on other component definitions\n const allowedComponentsUpdated = await this.updateAllowedComponents(\n fullComponentsDir,\n componentType,\n newComponentType,\n componentFilePath,\n whatIf,\n strict\n );\n\n // Step 6: Update type fields in compositions\n const compositionsResult = await this.renameTypeInDirectory(\n fullCompositionsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 7: Update type fields in composition patterns\n const compositionPatternsResult = await this.renameTypeInDirectory(\n fullCompositionPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 8: Update type fields in component patterns\n const componentPatternsResult = await this.renameTypeInDirectory(\n fullComponentPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalCompositionFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component renamed, ${allowedComponentsUpdated} component(s) with allowedComponents updated, ` +\n `${totalCompositionFiles} composition file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentRenamed: true,\n fileRenamed,\n allowedComponentsUpdated,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async updateAllowedComponents(\n componentsDir: string,\n oldType: string,\n newType: string,\n sourceFilePath: string,\n whatIf: boolean,\n strict: boolean\n ): Promise<number> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n } catch {\n return 0;\n }\n\n let updatedCount = 0;\n\n for (const filePath of files) {\n // Skip the source component file itself (it was already saved with the new id)\n if (filePath === sourceFilePath) continue;\n\n let comp: ComponentDefinition;\n try {\n comp = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n } catch {\n continue;\n }\n\n if (!comp.slots || comp.slots.length === 0) continue;\n\n let fileModified = false;\n for (const slot of comp.slots) {\n if (!slot.allowedComponents) continue;\n\n for (let i = 0; i < slot.allowedComponents.length; i++) {\n if (this.compareIds(slot.allowedComponents[i], oldType, strict)) {\n slot.allowedComponents[i] = newType;\n fileModified = true;\n }\n }\n }\n\n if (fileModified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `allowedComponents in component/${this.fileSystem.getBasename(filePath)}: ${oldType} → ${newType}`\n );\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, comp);\n }\n updatedCount++;\n }\n }\n\n return updatedCount;\n }\n\n private async renameTypeInDirectory(\n directory: string,\n oldType: string,\n newType: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) continue;\n\n const count = this.renameTypeInTree(composition.composition, oldType, newType, strict);\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s))`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameTypeInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n oldType: string,\n newType: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check this node's type\n if (this.compareIds(node.type, oldType, strict)) {\n node.type = newType;\n count++;\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameTypeInTree(instance, oldType, newType, strict);\n }\n }\n }\n\n return count;\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport {\n ComponentInstance,\n Composition,\n} from '../types/index.js';\nimport { ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface AddComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n parentComponentType: string;\n slot: string;\n newComponentType?: string;\n componentPatternId?: string;\n parameters?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface AddComponentResult {\n allowedComponentsUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesAdded: number;\n}\n\ninterface ComponentPattern {\n componentPatternId: string;\n definition: ComponentInstance;\n [key: string]: unknown;\n}\n\ninterface ParsedParameters {\n [key: string]: string;\n}\n\nexport class ComponentAdderService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n private parseParameters(parameterString?: string): ParsedParameters {\n const result: ParsedParameters = {};\n if (!parameterString) return result;\n\n const pairs = parameterString.split('|');\n for (const pair of pairs) {\n const [key, ...valueParts] = pair.split(':');\n if (key && valueParts.length > 0) {\n result[key.trim()] = valueParts.join(':').trim();\n }\n }\n return result;\n }\n\n private generateId(baseName: string): string {\n return `${baseName}-${randomUUID().slice(0, 8)}`;\n }\n\n private cloneComponentInstance(instance: ComponentInstance): ComponentInstance {\n const clone = JSON.parse(JSON.stringify(instance)) as ComponentInstance;\n\n // Regenerate _id for the root\n if (clone._id) {\n clone._id = this.generateId(clone.type);\n }\n\n // Recursively regenerate _id for nested instances\n if (clone.slots) {\n for (const slotInstances of Object.values(clone.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n\n return clone;\n }\n\n private regenerateInstanceIds(instance: ComponentInstance): void {\n if (instance._id) {\n instance._id = this.generateId(instance.type);\n }\n\n if (instance.slots) {\n for (const slotInstances of Object.values(instance.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n }\n\n private createComponentInstance(\n componentType: string,\n parameters: ParsedParameters\n ): ComponentInstance {\n const instance: ComponentInstance = {\n type: componentType,\n _id: this.generateId(componentType),\n };\n\n if (Object.keys(parameters).length > 0) {\n instance.parameters = {};\n for (const [key, value] of Object.entries(parameters)) {\n instance.parameters[key] = {\n type: 'text',\n value,\n };\n }\n }\n\n return instance;\n }\n\n private addComponentToSlot(slots: Record<string, ComponentInstance[]>, slotId: string, instance: ComponentInstance): void {\n if (!slots[slotId]) {\n slots[slotId] = [];\n }\n slots[slotId].push(instance);\n }\n\n async addComponent(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n newComponentType,\n parameters: paramString,\n whatIf,\n strict,\n } = options;\n\n if (!newComponentType) {\n throw new TransformError('newComponentType is required for add-component');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent, filePath: parentComponentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Validate new component type exists\n this.logger.info(`Validating new component: ${newComponentType}`);\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n } catch (error) {\n if (error instanceof ComponentNotFoundError) {\n throw new TransformError(\n `Component type \"${newComponentType}\" not found in ${fullComponentsDir}`\n );\n }\n throw error;\n }\n\n // Step 4: Update allowedComponents if needed\n let allowedComponentsUpdated = false;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, newComponentType, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newComponentType}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(newComponentType);\n if (!whatIf) {\n await this.componentService.saveComponent(parentComponentFilePath, parentComponent);\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 5: Parse parameters\n const parsedParams = this.parseParameters(paramString);\n\n // Step 6: Create the new component instance\n const newInstance = this.createComponentInstance(newComponentType, parsedParams);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n async addComponentPattern(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n componentPatternId,\n whatIf,\n strict,\n } = options;\n\n if (!componentPatternId) {\n throw new TransformError('componentPatternId is required for add-component-pattern');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Load and validate component pattern\n this.logger.info(`Loading component pattern: ${componentPatternId}`);\n const pattern = await this.loadComponentPattern(\n fullComponentPatternsDir,\n componentPatternId,\n strict\n );\n\n // Step 4: Get the definition from the pattern\n const patternDefinition = pattern.definition;\n if (!patternDefinition || !patternDefinition.type) {\n throw new TransformError(\n `Component pattern \"${componentPatternId}\" has no valid definition or missing type`\n );\n }\n\n // Step 5: Update allowedComponents if needed (using the pattern's definition type)\n let allowedComponentsUpdated = false;\n const componentTypeInPattern = patternDefinition.type;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, componentTypeInPattern, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${componentTypeInPattern}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(componentTypeInPattern);\n if (!whatIf) {\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions)\n .then(({ filePath }) =>\n this.componentService.saveComponent(filePath, parentComponent)\n );\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 6: Create the new component instance from the pattern (with cloned definition)\n const newInstance = this.cloneComponentInstance(patternDefinition);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n private async loadComponentPattern(\n componentPatternsDir: string,\n patternId: string,\n strict: boolean\n ): Promise<ComponentPattern> {\n // Try exact match first\n const jsonPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.json`);\n const yamlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yml`);\n\n let raw: Record<string, unknown> | undefined;\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(jsonPath);\n } else if (await this.fileSystem.fileExists(yamlPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(yamlPath);\n } else if (await this.fileSystem.fileExists(ymlPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(ymlPath);\n }\n\n // If not strict, try case-insensitive search\n if (!raw && !strict) {\n const files = await this.fileSystem.findFiles(componentPatternsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === patternId.toLowerCase()) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(filePath);\n break;\n }\n }\n }\n\n if (!raw) {\n throw new TransformError(`Component pattern \"${patternId}\" not found in ${componentPatternsDir}`);\n }\n\n return this.normalizeComponentPattern(raw, patternId);\n }\n\n private normalizeComponentPattern(\n raw: Record<string, unknown>,\n patternId: string\n ): ComponentPattern {\n // Native format: { componentPatternId, definition: { type, ... } }\n if (raw.definition && typeof raw.definition === 'object' && (raw.definition as ComponentInstance).type) {\n return raw as unknown as ComponentPattern;\n }\n\n // Uniform export format: { composition: { type, _id, ... }, pattern: true }\n if (raw.composition && typeof raw.composition === 'object' && (raw.composition as ComponentInstance).type) {\n const composition = raw.composition as ComponentInstance;\n return {\n componentPatternId: patternId,\n definition: composition,\n };\n }\n\n return raw as unknown as ComponentPattern;\n }\n\n private async addComponentToDirectory(\n directory: string,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n whatIf: boolean,\n strict: boolean,\n dirType: 'composition' | 'compositionPattern' | 'componentPattern'\n ): Promise<number> {\n const exists = await this.fileSystem.fileExists(directory);\n if (!exists) {\n this.logger.detail(`${dirType} directory does not exist, skipping`);\n return 0;\n }\n\n const files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n let filesModified = 0;\n\n for (const filePath of files) {\n try {\n // Handle both composition and componentPattern formats\n const content = await this.fileSystem.readFile<unknown>(filePath);\n\n // For component patterns, the structure might be different\n let composition: Composition | null = null;\n let isComponentPattern = false;\n\n if (dirType === 'componentPattern' && content && typeof content === 'object' && 'definition' in content) {\n // This is a component pattern\n isComponentPattern = true;\n const pattern = content as ComponentPattern;\n if (pattern.definition && pattern.definition.slots) {\n composition = {\n composition: {\n _id: 'pattern-root',\n type: pattern.definition.type,\n slots: pattern.definition.slots,\n } as any,\n };\n }\n } else {\n // This is a normal composition\n composition = content as Composition;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n // Find and add to parent component instances\n const rootInstance = composition.composition as any;\n let modified = false;\n\n // Check root instance\n if (this.compareIds(rootInstance.type, parentComponentType, strict)) {\n if (!rootInstance.slots) {\n rootInstance.slots = {};\n }\n\n // Clone the new instance to avoid mutations\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Check nested instances\n if (rootInstance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n rootInstance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n\n if (modified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newInstance.type}\" to slot \"${slot}\" in ${dirType}/${this.fileSystem.getBasename(filePath)}`\n );\n\n if (!whatIf) {\n if (isComponentPattern && content && typeof content === 'object' && 'definition' in content) {\n // For component patterns, update the definition\n const pattern = content as ComponentPattern;\n if (rootInstance.slots) {\n pattern.definition.slots = rootInstance.slots;\n }\n }\n await this.fileSystem.writeFile(filePath, content);\n }\n\n filesModified++;\n }\n } catch (error) {\n // Skip files that can't be parsed\n if (error instanceof Error && !error.message.includes('skipping')) {\n this.logger.detail(`Skipping ${filePath}: ${error.message}`);\n }\n }\n }\n\n return filesModified;\n }\n\n private addComponentToNestedSlots(\n slots: Record<string, ComponentInstance[]>,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n strict: boolean\n ): boolean {\n let modified = false;\n\n for (const slotInstances of Object.values(slots)) {\n if (!Array.isArray(slotInstances)) continue;\n\n for (const instance of slotInstances) {\n if (this.compareIds(instance.type, parentComponentType, strict)) {\n if (!instance.slots) {\n instance.slots = {};\n }\n\n // Clone the new instance to avoid mutations across multiple matches\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(instance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Recurse into nested slots\n if (instance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n instance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n }\n }\n\n return modified;\n }\n}\n","import chalk from 'chalk';\n\nexport class Logger {\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${message}`);\n }\n\n success(message: string): void {\n console.log(`${chalk.green('[DONE]')} ${message}`);\n }\n\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${message}`);\n }\n\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${message}`);\n }\n\n action(whatIf: boolean, actionType: string, message: string): void {\n const prefix = whatIf ? chalk.yellow('[WOULD]') : chalk.green(`[${actionType}]`);\n console.log(`${prefix} ${message}`);\n }\n\n detail(message: string): void {\n console.log(` ${chalk.gray(message)}`);\n }\n}\n"],"mappings":";AAAO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,yBAAN,cAAqC,eAAe;AAAA,EACzD,YAAY,eAAuBA,OAAe;AAChD,UAAM,WAAWA,QAAO,eAAeA,KAAI,MAAM;AACjD,UAAM,wBAAwB,aAAa,GAAG,QAAQ,EAAE;AACxD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EACxD,YAAY,cAAsB,eAAuB;AACvD,UAAM,aAAa,YAAY,6BAA6B,aAAa,GAAG;AAC5E,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EACnD,YAAY,UAAkB,SAAkB;AAC9C,UAAM,cAAc,UAAU,KAAK,OAAO,KAAK;AAC/C,UAAM,sBAAsB,QAAQ,GAAG,WAAW,EAAE;AACpD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,oBAAN,cAAgC,eAAe;AAAA,EACpD,YAAY,UAAkB;AAC5B,UAAM,mBAAmB,QAAQ,EAAE;AACnC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EACnD,YAAY,IAAY,eAAuB,UAAkB;AAC/D,UAAM,iBAAiB,EAAE,eAAe,aAAa,cAAc,QAAQ,EAAE;AAC7E,SAAK,OAAO;AAAA,EACd;AACF;AA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