Skip to content

Commit f5d552b

Browse files
committed
chore: update md xml to include xml header
1 parent 35ad23a commit f5d552b

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

src/convert/transformers/decomposeExternalServiceRegistrationTransformer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type ESR = JsonMap & {
2020
ExternalServiceRegistration: ExternalServiceRegistration;
2121
};
2222

23+
const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8"?>\n';
24+
2325
export class DecomposeExternalServiceRegistrationTransformer extends BaseMetadataTransformer {
2426
// eslint-disable-next-line @typescript-eslint/require-await,class-methods-use-this,@typescript-eslint/no-unused-vars
2527
public async toSourceFormat(input: {
@@ -59,12 +61,14 @@ export class DecomposeExternalServiceRegistrationTransformer extends BaseMetadat
5961
format: true,
6062
ignoreAttributes: false,
6163
suppressUnpairedNode: true,
62-
processEntities: false,
64+
processEntities: true,
6365
indentBy: ' ',
6466
});
67+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
68+
const source = xmlBuilder.build({ ExternalServiceRegistration: xmlContent });
6569
writeInfos.push({
6670
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
67-
source: xmlBuilder.build({ ExternalServiceRegistration: xmlContent }),
71+
source: Readable.from(Buffer.from(xmlDeclaration + source)),
6872
output: esrFilePath,
6973
});
7074

@@ -104,7 +108,7 @@ export class DecomposeExternalServiceRegistrationTransformer extends BaseMetadat
104108
// Write combined content back to md format
105109
writeInfos.push({
106110
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment
107-
source: Readable.from(Buffer.from(source)),
111+
source: Readable.from(Buffer.from(xmlDeclaration + source)),
108112
output: path.resolve(esrMdApiFilePath),
109113
});
110114
this.context.decomposedExternalServiceRegistration.transactionState.esrRecords.push({ component, writeInfos });

test/snapshot/sampleProjects/preset-decomposedESR/__snapshots__/verify-md-files.expected/externalServiceRegistrations/OpenAPIChallenge.externalServiceRegistration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<ExternalServiceRegistration xmlns="http://soap.sforce.com/2006/04/metadata">
23
<label>BankService</label>
34
<namedCredential>ntest</namedCredential>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<ExternalServiceRegistration xmlns="http://soap.sforce.com/2006/04/metadata">
23
<label>BankService</label>
34
<namedCredential>ntest</namedCredential>
45
<registrationProviderType>Custom</registrationProviderType>
56
<schemaType>OpenApi3</schemaType>
67
<schemaUrl>/accounts/schema</schemaUrl>
7-
<serviceBinding>{"host":"","basePath":"/","allowedSchemes":[],"requestMediaTypes":[],"responseMediaTypes":[],"compatibleMediaTypes":{}}</serviceBinding>
8+
<serviceBinding>{&quot;host&quot;:&quot;&quot;,&quot;basePath&quot;:&quot;/&quot;,&quot;allowedSchemes&quot;:[],&quot;requestMediaTypes&quot;:[],&quot;responseMediaTypes&quot;:[],&quot;compatibleMediaTypes&quot;:{}}</serviceBinding>
89
<status>Complete</status>
910
<systemVersion>3</systemVersion>
1011
</ExternalServiceRegistration>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<ExternalServiceRegistration xmlns="http://soap.sforce.com/2006/04/metadata">
23
<label>BankService</label>
34
<namedCredential>ntest</namedCredential>
45
<registrationProviderType>Custom</registrationProviderType>
56
<schemaType>OpenApi3</schemaType>
67
<schemaUrl>/accounts/schema</schemaUrl>
7-
<serviceBinding>{"host":"","basePath":"/","allowedSchemes":[],"requestMediaTypes":[],"responseMediaTypes":[],"compatibleMediaTypes":{}}</serviceBinding>
8+
<serviceBinding>{&quot;host&quot;:&quot;&quot;,&quot;basePath&quot;:&quot;/&quot;,&quot;allowedSchemes&quot;:[],&quot;requestMediaTypes&quot;:[],&quot;responseMediaTypes&quot;:[],&quot;compatibleMediaTypes&quot;:{}}</serviceBinding>
89
<status>Complete</status>
910
<systemVersion>3</systemVersion>
1011
</ExternalServiceRegistration>

test/snapshot/sampleProjects/preset-decomposedESR/mdapiOutput/externalServiceRegistrations/OpenAPIChallenge.externalServiceRegistration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<ExternalServiceRegistration xmlns="http://soap.sforce.com/2006/04/metadata">
23
<label>BankService</label>
34
<namedCredential>ntest</namedCredential>

0 commit comments

Comments
 (0)