Skip to content

Commit 823966e

Browse files
fix: resolve strictDirectoryName types in mdapi format (#601)
* fix: resolve strictDirectoryName types in mdapi format * chore: adding types for SDR * fix: add test for EmailServicesFunction Co-authored-by: Willie Ruemmele <[email protected]>
1 parent b34e3d2 commit 823966e

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

METADATA_SUPPORT.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ v55 introduces the following new types. Here's their current level of support
499499
|ExpressionSetDefinition|||
500500
|ExpressionSetDefinitionVersion|||
501501
|ExternalDataSrcDescriptor||Not supported, but support could be added|
502-
|ExternalDataTranField||Not supported, but support could be added|
503-
|ExternalDataTranObject||Not supported, but support could be added|
504502
|FlowTest|||
505503
|ForecastingFilter||Not supported, but support could be added|
506504
|ForecastingFilterCondition||Not supported, but support could be added|
@@ -511,10 +509,11 @@ v55 introduces the following new types. Here's their current level of support
511509
|MessagingChannel|undefined|undefined|
512510
|PaymentsManagementEnabledSettings|||
513511
|RegisteredExternalService||Not supported, but support could be added|
514-
|SchedulingObjective||Not supported, but support could be added|
512+
|SchedulingObjective|undefined|undefined|
515513
|StreamingAppDataConnector||Not supported, but support could be added|
516514
|SubscriptionManagementSettings|||
517515
|VoiceSettings|||
516+
|WarrantyLifecycleMgmtSettings|||
518517

519518
## Additional Types
520519

src/resolve/metadataResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ export class MetadataResolver {
174174
// any of the following 3 options is considered a good match
175175
// mixedContent and bundles don't have a suffix to match
176176
['mixedContent', 'bundle'].includes(type.strategies?.adapter) ||
177-
// the suffix matches the type we think it is
178-
(type.suffix && fsPath.endsWith(`${type.suffix}${META_XML_SUFFIX}`)) ||
177+
// the file suffix (in source or mdapi format) matches the type suffix we think it is
178+
(type.suffix && [type.suffix, `${type.suffix}${META_XML_SUFFIX}`].some((s) => fsPath.endsWith(s))) ||
179179
// the type has children and the path also includes THAT directory
180180
(type.children?.types &&
181181
Object.values(type.children?.types)

test/resolve/metadataResolver.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,61 @@ describe('MetadataResolver', () => {
142142
expect(access.getComponentsFromPath(path)).to.deep.equal([matchingContentFile.COMPONENT]);
143143
});
144144

145+
it('Should determine type for metadata file with known suffix and strictDirectoryName', () => {
146+
// CustomSite is an example. The conditions are:
147+
// 1. Type has "strictDirectoryName": true
148+
// 2. Type strategy adapter is neither "mixedContent" nor "bundle"
149+
// 3. Type doesn't have children
150+
// 4. mdapi format file path (E_Bikes.site)
151+
const path = join('unpackaged', 'sites', 'E_Bikes.site');
152+
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
153+
const mdResolver = new MetadataResolver(undefined, treeContainer);
154+
const expectedComponent = new SourceComponent(
155+
{
156+
name: 'E_Bikes',
157+
type: registry.types.customsite,
158+
xml: path,
159+
},
160+
treeContainer
161+
);
162+
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
163+
});
164+
165+
it('Should determine type for source file with known suffix and strictDirectoryName', () => {
166+
// CustomSite is an example. The conditions are:
167+
// 1. Type has "strictDirectoryName": true
168+
// 2. Type strategy adapter is neither "mixedContent" nor "bundle"
169+
// 3. Type doesn't have children
170+
// 4. source format file path (E_Bikes.site-meta.xml)
171+
const path = join('unpackaged', 'sites', 'E_Bikes.site-meta.xml');
172+
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
173+
const mdResolver = new MetadataResolver(undefined, treeContainer);
174+
const expectedComponent = new SourceComponent(
175+
{
176+
name: 'E_Bikes',
177+
type: registry.types.customsite,
178+
xml: path,
179+
},
180+
treeContainer
181+
);
182+
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
183+
});
184+
185+
it('Should determine type for EmailServicesFunction metadata file (mdapi format)', () => {
186+
const path = join('unpackaged', 'emailservices', 'MyEmailServices.xml');
187+
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
188+
const mdResolver = new MetadataResolver(undefined, treeContainer);
189+
const expectedComponent = new SourceComponent(
190+
{
191+
name: 'MyEmailServices',
192+
type: registry.types.emailservicesfunction,
193+
xml: path,
194+
},
195+
treeContainer
196+
);
197+
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
198+
});
199+
145200
it('Should determine type for path of mixed content type', () => {
146201
const path = mixedContentDirectory.MIXED_CONTENT_DIRECTORY_SOURCE_PATHS[1];
147202
const access = testUtil.createMetadataResolver([

0 commit comments

Comments
 (0)