|
7 | 7 | import { RemoteSyncInput } from './types';
|
8 | 8 | import { getMetadataKey } from './remoteSourceTrackingService';
|
9 | 9 |
|
| 10 | +// LWC can have child folders (ex: dynamic templates like /templates/noDataIllustration.html |
| 11 | +const pathAfterFullName = (fileResponse: RemoteSyncInput): string => |
| 12 | + fileResponse && fileResponse.filePath |
| 13 | + ? fileResponse.filePath.substr(fileResponse.filePath.indexOf(fileResponse.fullName)) |
| 14 | + : ''; |
| 15 | + |
10 | 16 | // handle all "weird" type/name translation between SourceMember and SDR FileResponse
|
| 17 | +// These get de-duplicated in a set later |
11 | 18 | export const getMetadataKeyFromFileResponse = (fileResponse: RemoteSyncInput): string[] => {
|
12 |
| - // LWC can have child folders (ex: dynamic templates like LightningComponentResource__errorPanel/templates/noDataIllustration.html |
13 |
| - const pathAfterFullName = (): string => |
14 |
| - fileResponse && fileResponse.filePath |
15 |
| - ? fileResponse.filePath.substr(fileResponse.filePath.indexOf(fileResponse.fullName)) |
16 |
| - : ''; |
17 |
| - |
| 19 | + // also create an element for the parent object |
| 20 | + if (fileResponse.type === 'CustomField' && fileResponse.filePath) { |
| 21 | + const splits = fileResponse.filePath.split('/'); |
| 22 | + const objectFolderIndex = splits.indexOf('objects'); |
| 23 | + return [ |
| 24 | + getMetadataKey('CustomObject', splits[objectFolderIndex + 1]), |
| 25 | + getMetadataKey(fileResponse.type, fileResponse.fullName), |
| 26 | + ]; |
| 27 | + } |
18 | 28 | // Aura/LWC need to have both the bundle level and file level keys
|
19 |
| - // These get de-duplicated in a set later |
20 | 29 | if (fileResponse.type === 'LightningComponentBundle' && fileResponse.filePath) {
|
21 | 30 | return [
|
22 |
| - `LightningComponentResource__${pathAfterFullName()}`, |
| 31 | + `LightningComponentResource__${pathAfterFullName(fileResponse)}`, |
23 | 32 | getMetadataKey(fileResponse.type, fileResponse.fullName),
|
24 | 33 | ];
|
25 | 34 | }
|
26 | 35 | if (fileResponse.type === 'AuraDefinitionBundle' && fileResponse.filePath) {
|
27 |
| - return [`AuraDefinition__${pathAfterFullName()}`, getMetadataKey(fileResponse.type, fileResponse.fullName)]; |
| 36 | + return [ |
| 37 | + `AuraDefinition__${pathAfterFullName(fileResponse)}`, |
| 38 | + getMetadataKey(fileResponse.type, fileResponse.fullName), |
| 39 | + ]; |
28 | 40 | }
|
29 |
| - |
30 | 41 | // standard key
|
31 | 42 | return [getMetadataKey(fileResponse.type, fileResponse.fullName)];
|
32 | 43 | };
|
0 commit comments