From 9a6c8810d17df0db4788cf781998242db1fb82e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 May 2026 17:05:30 +0000 Subject: [PATCH 1/2] fix: correct matching key priority in datapack export queries The getQuery method in DatapackExportQueries was incorrectly prioritizing the Salesforce-queried DRMatchingKey__mdt definition over the statically configured matchingKey in DatapackTypeDefinitions. This caused OmniScript and IntegrationProcedure exports to search by Name instead of Type/SubType/Version/Language, resulting in wrong datapack retrieval and duplicate records shown without version numbers. The fix aligns getQuery's priority with the already-correct getMatchingFields method: exportDefinition.matchingKey takes precedence, falling back to the Salesforce-queried key, then to the Name field as a last resort. https://claude.ai/code/session_01XNp87yZic77AnvLuL2gcXg --- .../vscode-extension/src/lib/vlocity/datapackExportQueries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts b/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts index 7403e3247..1681b4010 100644 --- a/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts +++ b/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts @@ -39,7 +39,7 @@ export class DatapackExportQueries { } ); const matchingDefinition = await this.matchingKeys.getMatchingKeyDefinition(datapack.datapackType); - const macthingKey = matchingDefinition.fields.length ? matchingDefinition : (exportDefinition?.matchingKey ?? matchingDefinition); + const macthingKey = exportDefinition?.matchingKey ?? (matchingDefinition.fields.length ? matchingDefinition : { fields: [] as string[], returnField: undefined }); const nameField = await this.salesforce.schema.getNameField(datapack.sobjectType); if (!macthingKey.fields.length && nameField) { From 38480453fba37a9488839d2f5dc021575d38624a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 May 2026 17:16:47 +0000 Subject: [PATCH 2/2] fix: restore rich UI metadata for OmniStudio datapack tree view definitions A prior refactor changed DatapackDefinitionRegistry.getDatapackTypeDefinitions to build DatapackTypeDefinition objects from sparse YAML export definitions, losing the grouping, displayName and matchingKey metadata that was originally sourced from the static DatapackTypeDefinitions map. This caused OmniScript and IntegrationProcedure nodes in the explorer to: - Show all versions as a flat list without Type/SubType grouping - Display the auto-generated Name field (same for all versions) instead of "Version X", making entries look like duplicates - Omit the version field from the Salesforce query so export could not distinguish between versions The fix adds resolveDatapackTypeDefinition which matches each YAML entry to the corresponding static definition by datapackType + sobjectType (namespace-prefix-stripped), falls back to the YAML-derived definition for any type not present in DatapackTypeDefinitions. The earlier incorrect change to datapackExportQueries.ts is also reverted; the Salesforce DRMatchingKey__mdt definitions already carry the correct Type/SubType/Version fields and should take priority as they allow per-org customisation. https://claude.ai/code/session_01XNp87yZic77AnvLuL2gcXg --- .../lib/vlocity/datapackDefinitionRegistry.ts | 25 ++++++++++++++++--- .../src/lib/vlocity/datapackExportQueries.ts | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/vscode-extension/src/lib/vlocity/datapackDefinitionRegistry.ts b/packages/vscode-extension/src/lib/vlocity/datapackDefinitionRegistry.ts index 3138657a4..13c31ac16 100644 --- a/packages/vscode-extension/src/lib/vlocity/datapackDefinitionRegistry.ts +++ b/packages/vscode-extension/src/lib/vlocity/datapackDefinitionRegistry.ts @@ -4,7 +4,7 @@ import * as yaml from 'js-yaml'; import * as vscode from 'vscode'; import { Logger, injectable } from '@vlocode/core'; -import { filterAsyncParallel, getErrorMessage, getObjectProperty, singleFlight } from '@vlocode/util'; +import { filterAsyncParallel, getErrorMessage, getObjectProperty, removeNamespacePrefix, singleFlight } from '@vlocode/util'; import { QueryConditionBuilder, QueryParser, type SalesforceQueryData } from '@vlocode/salesforce'; import { DatapackInfoService, DatapackTypeDefinition, DatapackTypeDefinitions } from '@vlocode/vlocity'; import { @@ -132,9 +132,26 @@ export class DatapackDefinitionRegistry { private getDatapackTypeDefinitions(definitions: Record): DatapackTypeDefinition[] { return Object.entries(definitions) .filter(([, definition]) => !definition.dependent) - .map(([datapackType, definition]) => { - return this.toDatapackTypeDefinition(datapackType, definition); - }); + .map(([datapackType, definition]) => this.resolveDatapackTypeDefinition(datapackType, definition)); + } + + /** + * Resolves a DatapackTypeDefinition for the given datapack type and export definition. + * Uses the static DatapackTypeDefinitions when a match exists (preserving grouping, + * displayName, matchingKey, and full field list), falling back to YAML-derived definition. + */ + private resolveDatapackTypeDefinition(datapackType: string, exportDefinition: DatapackExportDefinition): DatapackTypeDefinition { + const staticEntry = DatapackTypeDefinitions[datapackType]; + if (staticEntry) { + const allStatic = Array.isArray(staticEntry) ? staticEntry : [staticEntry]; + const match = allStatic.find(def => + removeNamespacePrefix(def.source.sobjectType) === removeNamespacePrefix(exportDefinition.objectType) + ); + if (match) { + return { ...match, exportMode: 'direct' }; + } + } + return this.toDatapackTypeDefinition(datapackType, exportDefinition); } private async loadCustomDefinitions() { diff --git a/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts b/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts index 1681b4010..7403e3247 100644 --- a/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts +++ b/packages/vscode-extension/src/lib/vlocity/datapackExportQueries.ts @@ -39,7 +39,7 @@ export class DatapackExportQueries { } ); const matchingDefinition = await this.matchingKeys.getMatchingKeyDefinition(datapack.datapackType); - const macthingKey = exportDefinition?.matchingKey ?? (matchingDefinition.fields.length ? matchingDefinition : { fields: [] as string[], returnField: undefined }); + const macthingKey = matchingDefinition.fields.length ? matchingDefinition : (exportDefinition?.matchingKey ?? matchingDefinition); const nameField = await this.salesforce.schema.getNameField(datapack.sobjectType); if (!macthingKey.fields.length && nameField) {