Skip to content

Commit cc8bcfb

Browse files
feat: @w-22893150 - add support for FragmentBundle metadata
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dffedd3 commit cc8bcfb

6 files changed

Lines changed: 43 additions & 2 deletions

File tree

METADATA_SUPPORT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
387387
|FlowSettings|||
388388
|FlowTest|||
389389
|FlowValueMap|||
390+
|FragmentBundle|||
390391
|ForecastingFilter|||
391392
|ForecastingFilterCondition|||
392393
|ForecastingGroup|||

src/registry/metadataRegistry.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"waveTemplates": "wavetemplatebundle",
7272
"appTemplates": "appframeworktemplatebundle",
7373
"lightningTypes": "lightningtypebundle",
74-
"uiBundles": "uibundle"
74+
"uiBundles": "uibundle",
75+
"fragments": "fragmentbundle"
7576
},
7677
"suffixes": {
7778
"Canvas": "canvasmetadata",
@@ -5371,6 +5372,18 @@
53715372
"directoryName": "policyRuleDefinitionSets",
53725373
"inFolder": false,
53735374
"strictDirectoryName": false
5375+
},
5376+
"fragmentbundle": {
5377+
"id": "fragmentbundle",
5378+
"name": "FragmentBundle",
5379+
"directoryName": "fragments",
5380+
"inFolder": false,
5381+
"strictDirectoryName": true,
5382+
"strategies": {
5383+
"adapter": "bundle"
5384+
},
5385+
"supportsPartialDelete": true,
5386+
"metaFileSuffix": "fragment.json"
53745387
}
53755388
}
53765389
}

src/resolve/metadataResolver.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ const parseAsMetadata =
400400
if (tree.isDirectory(fsPath)) {
401401
return;
402402
}
403-
return ['DigitalExperience', 'ExperiencePropertyTypeBundle', 'LightningTypeBundle', 'ContentTypeBundle']
403+
return [
404+
'DigitalExperience',
405+
'ExperiencePropertyTypeBundle',
406+
'LightningTypeBundle',
407+
'ContentTypeBundle',
408+
'FragmentBundle',
409+
]
404410
.map((type) => registry.getTypeByName(type))
405411
.find((type) => fsPath.split(sep).includes(type.directoryName))?.name;
406412
};

src/utils/filePathGenerator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const filePathsFromMetadataComponent = (
125125
['ExperiencePropertyTypeBundle', [join(packageDirWithTypeDir, `${fullName}${sep}schema.json`)]],
126126
['LightningTypeBundle', [join(packageDirWithTypeDir, `${fullName}${sep}schema.json`)]],
127127
['ContentTypeBundle', [join(packageDirWithTypeDir, `${fullName}${sep}schema.json`)]],
128+
['FragmentBundle', [join(packageDirWithTypeDir, `${fullName}${sep}fragment.json`)]],
128129
['WaveTemplateBundle', [join(packageDirWithTypeDir, `${fullName}${sep}template-info.json`)]],
129130
// ui-bundle.json is optional, so only the meta XML is a guaranteed file path.
130131
['UIBundle', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.uibundle${META_XML_SUFFIX}`)]],

test/resolve/metadataResolver.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ describe('MetadataResolver', () => {
266266
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
267267
});
268268

269+
it('Should determine type for FragmentBundle content file', () => {
270+
const fragmentPath = join('unpackaged', 'fragments', 'myFragment', 'fragment.json');
271+
const treeContainer = VirtualTreeContainer.fromFilePaths([fragmentPath]);
272+
const mdResolver = new MetadataResolver(undefined, treeContainer);
273+
const components = mdResolver.getComponentsFromPath(fragmentPath);
274+
expect(components).to.have.lengthOf(1);
275+
expect(components[0].type.name).to.equal('FragmentBundle');
276+
expect(components[0].name).to.equal('myFragment');
277+
});
278+
269279
it('Should determine type for path of mixed content type', () => {
270280
const path = mixedContentDirectory.MIXED_CONTENT_DIRECTORY_SOURCE_PATHS[1];
271281
const access = testUtil.createMetadataResolver([

test/utils/filePathGenerator.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ const testData = {
182182
},
183183
],
184184
},
185+
bundleFragment: {
186+
fullName: 'myFragment',
187+
typeName: 'FragmentBundle',
188+
expectedFilePaths: [getFilePath('fragments/myFragment/fragment.json')],
189+
expectedComponents: [
190+
{
191+
content: getFilePath('fragments/myFragment'),
192+
},
193+
],
194+
},
185195
nonDecomposedExplicit: {
186196
fullName: 'CustomLabels',
187197
typeName: 'CustomLabels',

0 commit comments

Comments
 (0)