Skip to content

Commit aba0d26

Browse files
committed
fix: FlexCards public properties were not getting exposed through the Meta XML causing deployment errors for components (flexi-pages) that would try to set public properties
1 parent 9318034 commit aba0d26

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

packages/vlocity-deploy/src/flexCard/flexCardLwcCompiler.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,18 @@ export class FlexCardLwcCompiler {
6161
compiler.isStdRuntime = !!options?.useStandardRuntime;
6262
compiler.defaultXmlConfig.api = Number(options?.apiVersion ?? this.salesforceService.getApiVersion());
6363
const name = options?.lwcName ?? this.getLwcName(card);
64-
const files = compiler.generateLWCFiles(name, card, 'card', null, null);
64+
const metaObject = this.getCardMeta(card);
65+
const files: Array<{filepath: string, source: string }> = compiler.generateLWCFiles(name, card, 'card', null, metaObject);
66+
67+
files.forEach(file => {
68+
// Prettify the XML files to make them more readable
69+
// By default the XML files generated by the compiler have inconsistent indentation
70+
// and this makes it hard to read them in the IDE
71+
if (/.(xml)$/i.test(file.filepath)) {
72+
file.source = XML.prettify(file.source, { indent: ' ' });
73+
}
74+
});
75+
6576
return {
6677
name: name,
6778
resources: files
@@ -74,6 +85,24 @@ export class FlexCardLwcCompiler {
7485
};
7586
}
7687

88+
private getCardMeta(card: FlexCardDefinition): any {
89+
const propertySet = typeof card.PropertySetConfig === 'string'
90+
? JSON.parse(card.PropertySetConfig)
91+
: card.PropertySetConfig;
92+
93+
const xmlTargets = XML.stringify(
94+
{ targetConfig: propertySet.xmlJson ?? [] },
95+
{ attributePrefix: '@attributes', headless: true }
96+
);
97+
98+
return {
99+
isExposed: true,
100+
description: `Autogenerated LWC by Vlocode for Omni FlexCard ${card.Name} (${DateTime.now().toString()})`,
101+
targets: propertySet.xmlObject?.targets ?? ['lightning__RecordPage', 'lightning__AppPage', 'lightning__HomePage'],
102+
targetConfigs: Buffer.from(xmlTargets, 'utf-8').toString('base64'),
103+
};
104+
}
105+
77106
/**
78107
* Compile an OmniScript into a deployable Salesforce Tooling record
79108
* @param scriptDefinition Definition of the OmniScript to compile
@@ -104,7 +133,7 @@ export class FlexCardLwcCompiler {
104133
capability: []
105134
},
106135
isExposed: componentDef.isExposed,
107-
description: componentDef.description ?? `Autogenerated LWC by Vlocode for Omni FlexCard ${card.Name} (${DateTime.now().toString()})`,
136+
description: componentDef.description,
108137
masterLabel: !card.IsActive ? `${card.Name} (disabled)` : `FlexCard: ${card.Name} (v${card.VersionNumber})`,
109138
runtimeNamespace: componentDef.runtimeNamespace ?? null,
110139
targets: componentDef.targets ?? null,

0 commit comments

Comments
 (0)