Skip to content

Commit

Permalink
Sm/max-api-version-on-deploys (#684)
Browse files Browse the repository at this point in the history
* fix: set max api version from connection if not provided

* feat: cap and warn on connections higher than org supports

* chore: auto-update metadata coverage in METADATA_SUPPORT.md
  • Loading branch information
mshanemc authored Aug 8, 2022
1 parent d036a6b commit 8d81800
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 42 deletions.
82 changes: 41 additions & 41 deletions METADATA_SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Supported CLI Metadata Types

This list compares metadata types found in Salesforce v55 with the [metadata registry file](./src/registry/metadataRegistry.json) included in this repository.
This list compares metadata types found in Salesforce v56 with the [metadata registry file](./src/registry/metadataRegistry.json) included in this repository.

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

Currently, there are 462/491 supported metadata types.
Currently, there are 465/510 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 All @@ -13,11 +13,15 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|AIApplication|||
|AIApplicationConfig|||
|AIReplyRecommendationsSettings|||
|AIUsecaseDefinition|⚠️|Supports deploy/retrieve but not source tracking|
|AccountForecastSettings|||
|AccountInsightsSettings|||
|AccountIntelligenceSettings|||
|AccountRelationshipShareRule|||
|AccountSettings|||
|AccountingFieldMapping||Not supported, but support could be added|
|AccountingModelConfig||Not supported, but support could be added|
|AccountingSettings|||
|AcctMgrTargetSettings|||
|ActionLinkGroupTemplate|||
|ActionPlanTemplate|||
Expand All @@ -29,7 +33,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|AdvAcctForecastDimSource|||
|AdvAcctForecastPeriodGroup|||
|AnalyticSnapshot|||
|AnalyticsDataServicesSettings|||
|AnalyticsSettings|||
|AnimationRule|||
|ApexClass|||
Expand Down Expand Up @@ -70,6 +73,8 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|BldgEnrgyIntensityCnfg|||
|BlockchainSettings|||
|Bot|||
|BotBlock||Not supported, but support could be added|
|BotBlockVersion||Not supported, but support could be added|
|BotSettings|||
|BotTemplate|||
|BotVersion|||
Expand Down Expand Up @@ -103,6 +108,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|ChatterExtension|||
|ChatterSettings|||
|CleanDataService|||
|CollectionsDashboardSettings|||
|CommandAction|||
|CommerceSettings|||
|CommunitiesSettings|||
Expand All @@ -113,7 +119,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|CompanySettings|||
|ConnectedApp|||
|ConnectedAppSettings|||
|ConnectedSystem|||
|ContentAsset|||
|ContentSettings|||
|ContractSettings|||
Expand Down Expand Up @@ -141,28 +146,33 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|CustomTab|||
|CustomValue||Not supported, but support could be added|
|CustomerDataPlatformSettings|||
|CustomizablePropensityScoringSettings|||
|Dashboard|||
|DashboardFolder|||
|DataCategoryGroup|||
|DataConnectorIngestApi|||
|DataConnectorS3|||
|DataDotComSettings|||
|DataImportManagementSettings|||
|DataMapping|||
|DataMappingFieldDefinition|||
|DataMappingObjectDefinition|||
|DataMappingSchema|||
|DataPackageKitDefinition|||
|DataPackageKitObject|||
|DataSource|||
|DataSourceBundleDefinition|||
|DataSourceObject|||
|DataSourceTenant|||
|DataSrcDataModelFieldMap|||
|DataStreamDefinition|||
|DataStreamTemplate|||
|DecisionMatrixDefinition|||
|DecisionMatrixDefinitionVersion|||
|DecisionTable|||
|DecisionTableDatasetLink|||
|DelegateGroup|||
|DeploymentSettings|||
|DevHubSettings|||
|DigitalExperience||Not supported, but support could be added (but not for tracking)|
|DigitalExperienceBundle||Not supported, but support could be added (but not for tracking)|
|DigitalExperienceConfig||Not supported, but support could be added (but not for tracking)|
|DiscoveryAIModel|||
|DiscoveryGoal|||
|DiscoverySettings|||
Expand Down Expand Up @@ -208,8 +218,10 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|ExperienceBundleSettings|||
|ExplainabilityActionDefinition|||
|ExplainabilityActionVersion|||
|ExplainabilityMsgTemplate||Not supported, but support could be added|
|ExpressionSetDefinition|||
|ExpressionSetDefinitionVersion|||
|ExpressionSetObjectAlias||Not supported, but support could be added|
|ExternalAIModel||Not supported, but support could be added|
|ExternalCredential||Not supported, but support could be added|
|ExternalDataConnector|||
Expand All @@ -218,11 +230,9 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|ExternalDataTranField||Not supported, but support could be added|
|ExternalDataTranObject||Not supported, but support could be added|
|ExternalServiceRegistration|||
|ExternalServicesSettings|||
|FeatureParameterBoolean|||
|FeatureParameterDate|||
|FeatureParameterInteger|||
|FederationDataMappingUsage|||
|FieldRestrictionRule|||
|FieldServiceMobileExtension|||
|FieldServiceSettings|||
Expand All @@ -244,6 +254,8 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|ForecastingType|||
|ForecastingTypeSource|||
|FormulaSettings|||
|FuelType||Not supported, but support could be added|
|FuelTypeSustnUom||Not supported, but support could be added|
|FunctionReference|⚠️|Supports deploy/retrieve but not source tracking|
|GatewayProviderPaymentMethodType|||
|GlobalValueSet|||
Expand All @@ -261,6 +273,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|InboundCertificate|||
|InboundNetworkConnection|||
|IncidentMgmtSettings|||
|IncludeEstTaxInQuoteSettings|||
|Index|⚠️|Supports deploy/retrieve but not source tracking|
|IndustriesAutomotiveSettings|||
|IndustriesLoyaltySettings|||
Expand Down Expand Up @@ -310,6 +323,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|MeetingsSettings|||
|MessagingChannel||Not supported, but support could be added (but not for tracking)|
|MfgProgramTemplate||Not supported, but support could be added|
|MfgServiceConsoleSettings|||
|MilestoneType|||
|MktCalcInsightObjectDef|||
|MktDataTranObject|||
Expand All @@ -318,7 +332,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|MobileApplicationDetail|||
|MobileSecurityAssignment|||
|MobileSecurityPolicy|||
|MobileSecurityPolicySet|||
|MobileSettings|||
|ModerationRule|||
|MutingPermissionSet|||
Expand All @@ -332,6 +345,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|NotificationTypeConfig|||
|NotificationsSettings|||
|OauthCustomScope|||
|OauthOidcSettings|||
|ObjectHierarchyRelationship|||
|ObjectLinkingSettings|||
|ObjectSourceTargetMap|||
Expand Down Expand Up @@ -370,6 +384,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|PlatformEventChannelMember|||
|PlatformEventSubscriberConfig|||
|PlatformSlackSettings|||
|PortalDelegablePermissionSet||Not supported, but support could be added|
|PortalsSettings|||
|PostTemplate|||
|PredictionBuilderSettings|||
Expand Down Expand Up @@ -403,6 +418,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|Report|||
|ReportFolder|||
|ReportType|||
|ReportingTypeConfig||Not supported, but support could be added|
|RestrictionRule|||
|RetailExecutionSettings|||
|Role|||
Expand Down Expand Up @@ -444,6 +460,8 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|StreamingAppDataConnector||Not supported, but support could be added|
|SubscriptionManagementSettings|||
|SurveySettings|||
|SustainabilityUom||Not supported, but support could be added|
|SustnUomConversion||Not supported, but support could be added|
|SvcCatalogCategory|||
|SvcCatalogFulfillmentFlow|||
|SvcCatalogItemDef|||
Expand All @@ -464,6 +482,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t
|TrialOrgSettings|||
|UIObjectRelationConfig|||
|UiPlugin|||
|UserAccessPolicy||Not supported, but support could be added|
|UserAuthCertificate|||
|UserCriteria|||
|UserEngagementSettings|||
Expand Down Expand Up @@ -504,39 +523,13 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t



## Next Release (v56)
v56 introduces the following new types. Here's their current level of support
## Next Release (v57)
v57 introduces the following new types. Here's their current level of support

|Metadata Type|Support|Notes|
|:---|:---|:---|
|AIUsecaseDefinition|⚠️|Supports deploy/retrieve but not source tracking|
|AccountingFieldMapping||Not supported, but support could be added|
|AccountingModelConfig||Not supported, but support could be added|
|AccountingSettings|||
|BotBlock||Not supported, but support could be added|
|BotBlockVersion||Not supported, but support could be added|
|CollectionsDashboardSettings|||
|CustomizablePropensityScoringSettings|||
|DataPackageKitDefinition|||
|DataPackageKitObject|||
|DataSourceBundleDefinition|||
|DataSrcDataModelFieldMap|||
|DataStreamTemplate|||
|DigitalExperience||Not supported, but support could be added (but not for tracking)|
|DigitalExperienceBundle||Not supported, but support could be added (but not for tracking)|
|DigitalExperienceConfig||Not supported, but support could be added (but not for tracking)|
|ExplainabilityMsgTemplate||Not supported, but support could be added|
|ExpressionSetObjectAlias||Not supported, but support could be added|
|FuelType||Not supported, but support could be added|
|FuelTypeSustnUom||Not supported, but support could be added|
|IncludeEstTaxInQuoteSettings|||
|MfgServiceConsoleSettings|||
|OauthOidcSettings|||
|PortalDelegablePermissionSet||Not supported, but support could be added|
|ReportingTypeConfig||Not supported, but support could be added|
|SustainabilityUom||Not supported, but support could be added|
|SustnUomConversion||Not supported, but support could be added|
|UserAccessPolicy||Not supported, but support could be added|
|ExternalServicesSettings|||
|ReferencedDashboard||Not supported, but support could be added|

## Additional Types

Expand Down Expand Up @@ -584,6 +577,13 @@ v56 introduces the following new types. Here's their current level of support
- DynamicTrigger
- MktDataTranField
- ConversationVendorFieldDef
- DataMappingSchema
- DataMappingObjectDefinition
- DataMappingFieldDefinition
- DataMapping
- FederationDataMappingUsage
- ConnectedSystem
- InternalOrganization
- UiViewDefinition
- MobileSecurityPolicySet
- DataWeaveResource
5 changes: 5 additions & 0 deletions src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ export class MetadataApiDeploy extends MetadataTransfer<MetadataApiDeployStatus,
const connection = await this.getConnection();
// store for use in the scopedPostDeploy event
this.orgId = connection.getAuthInfoFields().orgId;
if (this.components && !this.components.apiVersion && !this.components.sourceApiVersion) {
// if we have a ComponentSet, but got no version info, let's use the org's max version for calculating what goes into the package.xml
this.components.apiVersion = connection.getApiVersion();
this.components.sourceApiVersion = connection.getApiVersion();
}
// only do event hooks if source, (NOT a metadata format) deploy
if (this.options.components) {
await Lifecycle.getInstance().emit('scopedPreDeploy', {
Expand Down
15 changes: 14 additions & 1 deletion src/client/metadataTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export abstract class MetadataTransfer<Status extends MetadataRequestStatus, Res
this.logger.debug(`Overriding apiVersion to: ${this.apiVersion}`);
}
}
return this.usernameOrConnection;
return getConnectionNoHigherThanOrgAllows(this.usernameOrConnection, this.apiVersion);
}

private async poll(): Promise<StatusResult> {
Expand Down Expand Up @@ -269,3 +269,16 @@ export abstract class MetadataTransfer<Status extends MetadataRequestStatus, Res
protected abstract pre(): Promise<AsyncResult>;
protected abstract post(result: Status): Promise<Result>;
}

/* prevent requests on apiVersions higher than the org supports */
const getConnectionNoHigherThanOrgAllows = async (conn: Connection, requestedVersion: string): Promise<Connection> => {
// uses a TTL cache, so mostly won't hit the server
const maxApiVersion = await conn.retrieveMaxApiVersion();
if (requestedVersion && parseInt(requestedVersion, 10) > parseInt(maxApiVersion, 10)) {
await Lifecycle.getInstance().emitWarning(
`The requested API version (${requestedVersion}) is higher than the org supports. Using ${maxApiVersion}.`
);
conn.setApiVersion(maxApiVersion);
}
return conn;
};
27 changes: 27 additions & 0 deletions test/client/metadataTransfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ describe('MetadataTransfer', () => {
expect(setApiVersionSpy.calledWith(apiVersion)).to.equal(true);
});

it('caps api version at the org max', async () => {
class TestTransferConnection extends TestTransfer {
protected async pre(): Promise<{ id: string }> {
const connection = await this.getConnection();
return this.lifecycle.pre(connection);
}
}
const apiVersion = '51.0';
const maxApiVersion = '50.0';
const username = connection.getUsername();

const authInfo = await AuthInfo.create({ username });
env.stub(AuthInfo, 'create').withArgs({ username }).resolves(authInfo);
env.stub(Connection, 'create').withArgs({ authInfo }).resolves(connection);
env.stub(connection, 'retrieveMaxApiVersion').resolves(maxApiVersion);
const setApiVersionSpy = env.spy(Connection.prototype, 'setApiVersion');
operation = new TestTransferConnection({
components: new ComponentSet(),
usernameOrConnection: username,
apiVersion,
});

await operation.start();

expect(setApiVersionSpy.calledWith(maxApiVersion)).to.equal(true);
});

describe('Polling and Event Listeners', () => {
let listenerStub: SinonStub;

Expand Down

0 comments on commit 8d81800

Please sign in to comment.