@@ -61,7 +61,18 @@ export class FlexCardLwcCompiler {
61
61
compiler . isStdRuntime = ! ! options ?. useStandardRuntime ;
62
62
compiler . defaultXmlConfig . api = Number ( options ?. apiVersion ?? this . salesforceService . getApiVersion ( ) ) ;
63
63
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 ( / .( x m l ) $ / i. test ( file . filepath ) ) {
72
+ file . source = XML . prettify ( file . source , { indent : ' ' } ) ;
73
+ }
74
+ } ) ;
75
+
65
76
return {
66
77
name : name ,
67
78
resources : files
@@ -74,6 +85,24 @@ export class FlexCardLwcCompiler {
74
85
} ;
75
86
}
76
87
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
+
77
106
/**
78
107
* Compile an OmniScript into a deployable Salesforce Tooling record
79
108
* @param scriptDefinition Definition of the OmniScript to compile
@@ -104,7 +133,7 @@ export class FlexCardLwcCompiler {
104
133
capability : [ ]
105
134
} ,
106
135
isExposed : componentDef . isExposed ,
107
- description : componentDef . description ?? `Autogenerated LWC by Vlocode for Omni FlexCard ${ card . Name } ( ${ DateTime . now ( ) . toString ( ) } )` ,
136
+ description : componentDef . description ,
108
137
masterLabel : ! card . IsActive ? `${ card . Name } (disabled)` : `FlexCard: ${ card . Name } (v${ card . VersionNumber } )` ,
109
138
runtimeNamespace : componentDef . runtimeNamespace ?? null ,
110
139
targets : componentDef . targets ?? null ,
0 commit comments