Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sm/no-adapter-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 1, 2024
2 parents 5a0ff3c + 8e14cd8 commit 1727cd3
Show file tree
Hide file tree
Showing 29 changed files with 810 additions and 553 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [12.1.10](https://github.com/forcedotcom/source-deploy-retrieve/compare/12.1.9...12.1.10) (2024-08-01)

### Bug Fixes

- manifests for custom object can omit parent ([#1375](https://github.com/forcedotcom/source-deploy-retrieve/issues/1375)) ([8fd9c9e](https://github.com/forcedotcom/source-deploy-retrieve/commit/8fd9c9ec57a8502234c9c2abe0cd528e5107844b))

## [12.1.9](https://github.com/forcedotcom/source-deploy-retrieve/compare/12.1.8...12.1.9) (2024-07-31)

### Bug Fixes

- use jsforce's `cancelDeploy` method ([#1380](https://github.com/forcedotcom/source-deploy-retrieve/issues/1380)) ([7d644f2](https://github.com/forcedotcom/source-deploy-retrieve/commit/7d644f215d7c0bcfe413d1fcfafc10122b17a412))

## [12.1.8](https://github.com/forcedotcom/source-deploy-retrieve/compare/12.1.7...12.1.8) (2024-07-19)

### Bug Fixes
Expand Down
7 changes: 2 additions & 5 deletions METADATA_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This list compares metadata types found in Salesforce v61 with the [metadata reg

This repository is used by both the Salesforce CLIs and Salesforce's VSCode Extensions.

Currently, there are 576/610 supported metadata types.
Currently, there are 577/608 supported metadata types.
For status on any existing gaps, please search or file an issue in the [Salesforce CLI issues only repo](https://github.com/forcedotcom/cli/issues).
To contribute a new metadata type, please see the [Contributing Metadata Types to the Registry](./contributing/metadata.md)

Expand Down Expand Up @@ -167,11 +167,11 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
| DashboardFolder || |
| DataCalcInsightTemplate || |
| DataCategoryGroup || |
| DataConnectionParamTmpl || Not supported, but support could be added |
| DataConnectorIngestApi || |
| DataConnectorS3 || |
| DataDotComSettings || |
| DataImportManagementSettings || |
| DataKitObjectDependency || |
| DataKitObjectTemplate || |
| DataPackageKitDefinition || |
| DataPackageKitObject || |
Expand Down Expand Up @@ -393,8 +393,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
| MilestoneType || |
| MktCalcInsightObjectDef || |
| MktDataConnection || Not supported, but support could be added |
| MktDataConnectionCred || Not supported, but support could be added |
| MktDataConnectionParam || Not supported, but support could be added |
| MktDataConnectionSrcParam || Not supported, but support could be added |
| MktDataTranObject || |
| MlDomain || |
Expand Down Expand Up @@ -632,7 +630,6 @@ v62 introduces the following new types. Here's their current level of support
| ChannelRevMgmtSettings || |
| ChoiceList || Not supported, but support could be added (but not for tracking) |
| ConversationMessageDefinition || |
| DataKitObjectDependency || |
| EnblProgramTaskSubCategory || |
| ExtlClntAppPushConfigurablePolicies || Not supported, but support could be added (but not for tracking) |
| ExtlClntAppPushSettings || |
Expand Down
13 changes: 13 additions & 0 deletions messages/sdr.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,16 @@ If the type is available via Metadata API but not in the registry

- Open an issue <https://github.com/forcedotcom/cli/issues>
- Add the type via PR. Instructions: <https://github.com/forcedotcom/source-deploy-retrieve/blob/main/contributing/metadata.md>

# type_name_suggestions

Confirm the metadata type name is correct. Validate against the registry at:
<https://github.com/forcedotcom/source-deploy-retrieve/blob/main/src/registry/metadataRegistry.json>

If the type is not listed in the registry, check that it has Metadata API support via the Metadata Coverage Report:
<https://developer.salesforce.com/docs/metadata-coverage>

If the type is available via Metadata API but not in the registry

- Open an issue <https://github.com/forcedotcom/cli/issues>
- Add the type via PR. Instructions: <https://github.com/forcedotcom/source-deploy-retrieve/blob/main/contributing/metadata.md>
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/source-deploy-retrieve",
"version": "12.1.8",
"version": "12.1.10",
"description": "JavaScript library to run Salesforce metadata deploys and retrieves",
"main": "lib/src/index.js",
"author": "Salesforce",
Expand All @@ -25,9 +25,9 @@
"node": ">=18.0.0"
},
"dependencies": {
"@salesforce/core": "^8.2.1",
"@salesforce/core": "^8.2.8",
"@salesforce/kit": "^3.1.6",
"@salesforce/ts-types": "^2.0.10",
"@salesforce/ts-types": "^2.0.12",
"fast-levenshtein": "^3.0.0",
"fast-xml-parser": "^4.3.6",
"got": "^11.8.6",
Expand All @@ -39,22 +39,22 @@
"proxy-agent": "^6.4.0"
},
"devDependencies": {
"@jsforce/jsforce-node": "^3.2.4",
"@salesforce/cli-plugins-testkit": "^5.3.18",
"@salesforce/dev-scripts": "^10.2.2",
"@jsforce/jsforce-node": "^3.4.0",
"@salesforce/cli-plugins-testkit": "^5.3.20",
"@salesforce/dev-scripts": "^10.2.8",
"@types/deep-equal-in-any-order": "^1.0.1",
"@types/fast-levenshtein": "^0.0.4",
"@types/graceful-fs": "^4.1.9",
"@types/mime": "2.0.3",
"@types/minimatch": "^5.1.2",
"deep-equal-in-any-order": "^1.1.19",
"deepmerge": "^4.3.1",
"eslint-plugin-sf-plugin": "^1.18.12",
"eslint-plugin-sf-plugin": "^1.20.1",
"mocha-junit-reporter": "^1.23.3",
"mocha-snap": "^5.0.0",
"ts-node": "^10.9.2",
"ts-patch": "^3.2.1",
"typescript": "^5.5.3"
"typescript": "^5.5.4"
},
"scripts": {
"build": "wireit",
Expand Down
4 changes: 1 addition & 3 deletions src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ export class MetadataApiDeploy extends MetadataTransfer<

const connection = await this.getConnection();

// jsforce has an <any> on this
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,no-underscore-dangle
await connection.metadata._invoke('cancelDeploy', { id: this.id });
await connection.metadata.cancelDeploy(this.id);
}

protected async pre(): Promise<AsyncResult> {
Expand Down
112 changes: 62 additions & 50 deletions src/collections/componentSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
SfProject,
} from '@salesforce/core';
import { isString } from '@salesforce/ts-types';
import { objectHasSomeRealValues } from '../utils/decomposed';
import { MetadataApiDeploy, MetadataApiDeployOptions } from '../client/metadataApiDeploy';
import { MetadataApiRetrieve } from '../client/metadataApiRetrieve';
import type { MetadataApiRetrieveOptions } from '../client/types';
Expand Down Expand Up @@ -406,74 +407,60 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
* @returns Object representation of a package manifest
*/
public async getObject(destructiveType?: DestructiveChangesType): Promise<PackageManifestObject> {
const version = await this.getApiVersion();

// If this ComponentSet has components marked for delete, we need to
// only include those components in a destructiveChanges.xml and
// all other components in the regular manifest.
let components = this.components;
if (this.getTypesOfDestructiveChanges().length) {
components = destructiveType ? this.destructiveComponents[destructiveType] : this.manifestComponents;
}
const components = this.getTypesOfDestructiveChanges().length
? destructiveType
? this.destructiveComponents[destructiveType]
: this.manifestComponents
: this.components;

const typeMap = new Map<string, string[]>();
const typeMap = new Map<string, Set<string>>();

const addToTypeMap = (type: MetadataType, fullName: string): void => {
if (type.isAddressable !== false) {
const typeName = type.name;
if (!typeMap.has(typeName)) {
typeMap.set(typeName, []);
}
const typeEntry = typeMap.get(typeName);
if (fullName === ComponentSet.WILDCARD && !type.supportsWildcardAndName && !destructiveType) {
// if the type doesn't support mixed wildcards and specific names, overwrite the names to be a wildcard
typeMap.set(typeName, [fullName]);
} else if (
typeEntry &&
!typeEntry.includes(fullName) &&
(!typeEntry.includes(ComponentSet.WILDCARD) || type.supportsWildcardAndName)
) {
// if the type supports both wildcards and names, add them regardless
typeMap.get(typeName)?.push(fullName);
}
}
};

for (const key of components.keys()) {
[...components.entries()].map(([key, cmpMap]) => {
const [typeId, fullName] = splitOnFirstDelimiter(key);
let type = this.registry.getTypeByName(typeId);

if (type.folderContentType) {
type = this.registry.getTypeByName(type.folderContentType);
}
addToTypeMap(
type,
// they're reassembled like CustomLabels.MyLabel
this.registry.getParentType(type.name)?.strategies?.recomposition === 'startEmpty' && fullName.includes('.')
? fullName.split('.')[1]
: fullName
);
const type = this.registry.getTypeByName(typeId);

// Add children
const componentMap = components.get(key);
if (componentMap) {
for (const comp of componentMap.values()) {
for (const child of comp.getChildren()) {
addToTypeMap(child.type, child.fullName);
}
[...(cmpMap?.values() ?? [])]
.flatMap((c) => c.getChildren())
.map((child) => addToTypeMap({ typeMap, type: child.type, fullName: child.fullName, destructiveType }));

// logic: if this is a decomposed type, skip its inclusion in the manifest if the parent is "empty"
if (
type.strategies?.transformer === 'decomposed' &&
// exclude (ex: CustomObjectTranslation) where there are no addressable children
Object.values(type.children?.types ?? {}).some((t) => t.unaddressableWithoutParent !== true) &&
Object.values(type.children?.types ?? {}).some((t) => t.isAddressable !== false)
) {
const parentComp = [...(cmpMap?.values() ?? [])].find((c) => c.fullName === fullName);
if (parentComp?.xml && !objectHasSomeRealValues(type)(parentComp.parseXmlSync())) {
return;
}
}
}

addToTypeMap({
typeMap,
type: type.folderContentType ? this.registry.getTypeByName(type.folderContentType) : type,
fullName:
this.registry.getParentType(type.name)?.strategies?.recomposition === 'startEmpty' && fullName.includes('.')
? // they're reassembled like CustomLabels.MyLabel
fullName.split('.')[1]
: fullName,
destructiveType,
});
});

const typeMembers = Array.from(typeMap.entries())
.map(([typeName, members]) => ({ members: members.sort(), name: typeName }))
.map(([typeName, members]) => ({ members: [...members].sort(), name: typeName }))
.sort((a, b) => (a.name > b.name ? 1 : -1));

return {
Package: {
...{
types: typeMembers,
version,
version: await this.getApiVersion(),
},
...(this.fullName ? { fullName: this.fullName } : {}),
},
Expand Down Expand Up @@ -750,3 +737,28 @@ const splitOnFirstDelimiter = (input: string): [string, string] => {
const indexOfSplitChar = input.indexOf(KEY_DELIMITER);
return [input.substring(0, indexOfSplitChar), input.substring(indexOfSplitChar + 1)];
};

/** side effect: mutates the typeMap property */
const addToTypeMap = ({
typeMap,
type,
fullName,
destructiveType,
}: {
typeMap: Map<string, Set<string>>;
type: MetadataType;
fullName: string;
destructiveType?: DestructiveChangesType;
}): void => {
if (type.isAddressable === false) return;
if (fullName === ComponentSet.WILDCARD && !type.supportsWildcardAndName && !destructiveType) {
// if the type doesn't support mixed wildcards and specific names, overwrite the names to be a wildcard
typeMap.set(type.name, new Set([fullName]));
return;
}
const existing = typeMap.get(type.name) ?? new Set<string>();
if (!existing.has(ComponentSet.WILDCARD) || type.supportsWildcardAndName) {
// if the type supports both wildcards and names, add them regardless
typeMap.set(type.name, existing.add(fullName));
}
};
Loading

0 comments on commit 1727cd3

Please sign in to comment.