Skip to content

Commit 352e15b

Browse files
committed
feat: use xmlElementName for decomposition
1 parent 083b7c5 commit 352e15b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/convert/transformers/decomposedMetadataTransformer.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { WriteInfo } from '../types';
1414
import { META_XML_SUFFIX, SourcePath, XML_NS_KEY, XML_NS_URL } from '../../common';
1515
import { ComponentSet } from '../../collections';
1616
import { DecompositionStateValue } from '../convertContext';
17-
import { DecompositionStrategy } from '../../registry';
17+
import { DecompositionStrategy, MetadataType } from '../../registry';
1818
import { BaseMetadataTransformer } from './baseMetadataTransformer';
1919

2020
Messages.importMessagesDirectory(__dirname);
@@ -64,7 +64,7 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer {
6464
const composedMetadata = await getComposedMetadataEntries(component);
6565

6666
for (const [tagKey, tagValue] of composedMetadata) {
67-
const childTypeId = type.children?.directories?.[tagKey];
67+
const childTypeId = tagToChildTypeId({ tagKey, type });
6868
if (childTypeId) {
6969
const childType = type.children?.types[childTypeId];
7070
if (!childType) {
@@ -240,3 +240,8 @@ const extractUniqueElementValue = (xml: JsonMap, elementName?: string): string |
240240

241241
const getStandardElements = (xml: JsonMap): string | undefined =>
242242
getString(xml, 'fullName') ?? getString(xml, 'name') ?? undefined;
243+
244+
/** use the given xmlElementName name if it exists, otherwise use see if one matches the directories */
245+
const tagToChildTypeId = ({ tagKey, type }: { tagKey: string; type: MetadataType }): string | undefined =>
246+
Object.values(type.children?.types ?? {}).find((c) => c.xmlElementName === tagKey)?.id ??
247+
type.children?.directories?.[tagKey];

0 commit comments

Comments
 (0)