From 8d8180085958329fa72cb21c7c011765d0beac2d Mon Sep 17 00:00:00 2001 From: Shane McLaughlin Date: Mon, 8 Aug 2022 13:02:51 -0700 Subject: [PATCH] Sm/max-api-version-on-deploys (#684) * 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 --- METADATA_SUPPORT.md | 82 ++++++++++++++-------------- src/client/metadataApiDeploy.ts | 5 ++ src/client/metadataTransfer.ts | 15 ++++- test/client/metadataTransfer.test.ts | 27 +++++++++ 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/METADATA_SUPPORT.md b/METADATA_SUPPORT.md index cbec9368d5..7adce202fd 100644 --- a/METADATA_SUPPORT.md +++ b/METADATA_SUPPORT.md @@ -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) @@ -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|✅|| @@ -29,7 +33,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |AdvAcctForecastDimSource|✅|| |AdvAcctForecastPeriodGroup|✅|| |AnalyticSnapshot|✅|| -|AnalyticsDataServicesSettings|✅|| |AnalyticsSettings|✅|| |AnimationRule|✅|| |ApexClass|✅|| @@ -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|✅|| @@ -103,6 +108,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |ChatterExtension|✅|| |ChatterSettings|✅|| |CleanDataService|✅|| +|CollectionsDashboardSettings|✅|| |CommandAction|✅|| |CommerceSettings|✅|| |CommunitiesSettings|✅|| @@ -113,7 +119,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |CompanySettings|✅|| |ConnectedApp|✅|| |ConnectedAppSettings|✅|| -|ConnectedSystem|✅|| |ContentAsset|✅|| |ContentSettings|✅|| |ContractSettings|✅|| @@ -141,6 +146,7 @@ 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|✅|| @@ -148,14 +154,15 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |DataConnectorS3|✅|| |DataDotComSettings|✅|| |DataImportManagementSettings|✅|| -|DataMapping|✅|| -|DataMappingFieldDefinition|✅|| -|DataMappingObjectDefinition|✅|| -|DataMappingSchema|✅|| +|DataPackageKitDefinition|✅|| +|DataPackageKitObject|✅|| |DataSource|✅|| +|DataSourceBundleDefinition|✅|| |DataSourceObject|✅|| |DataSourceTenant|✅|| +|DataSrcDataModelFieldMap|✅|| |DataStreamDefinition|✅|| +|DataStreamTemplate|✅|| |DecisionMatrixDefinition|✅|| |DecisionMatrixDefinitionVersion|✅|| |DecisionTable|✅|| @@ -163,6 +170,9 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -318,7 +332,6 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |MobileApplicationDetail|✅|| |MobileSecurityAssignment|✅|| |MobileSecurityPolicy|✅|| -|MobileSecurityPolicySet|✅|| |MobileSettings|✅|| |ModerationRule|✅|| |MutingPermissionSet|✅|| @@ -332,6 +345,7 @@ To contribute a new metadata type, please see the [Contributing Metadata Types t |NotificationTypeConfig|✅|| |NotificationsSettings|✅|| |OauthCustomScope|✅|| +|OauthOidcSettings|✅|| |ObjectHierarchyRelationship|✅|| |ObjectLinkingSettings|✅|| |ObjectSourceTargetMap|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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|✅|| @@ -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 @@ -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 diff --git a/src/client/metadataApiDeploy.ts b/src/client/metadataApiDeploy.ts index 42204c0cbc..fa46d40053 100644 --- a/src/client/metadataApiDeploy.ts +++ b/src/client/metadataApiDeploy.ts @@ -352,6 +352,11 @@ export class MetadataApiDeploy extends MetadataTransfer { @@ -269,3 +269,16 @@ export abstract class MetadataTransfer; protected abstract post(result: Status): Promise; } + +/* prevent requests on apiVersions higher than the org supports */ +const getConnectionNoHigherThanOrgAllows = async (conn: Connection, requestedVersion: string): Promise => { + // 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; +}; diff --git a/test/client/metadataTransfer.test.ts b/test/client/metadataTransfer.test.ts index 9fc6769a80..3ae77144bf 100644 --- a/test/client/metadataTransfer.test.ts +++ b/test/client/metadataTransfer.test.ts @@ -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;