Skip to content

Commit a53b4df

Browse files
feat: @W-18480496 : Update reference fixes for IP and Omniscript
Changes: - Omniscript or Integration Procedures uses OmniProcessCompilation definition with runtime - Migration Assistant doesn't update compilation causing issues with runtime - Code fix to update the references in compilation definition - Added test cases for regression testing
1 parent 3b89f8d commit a53b4df

File tree

3 files changed

+970
-5
lines changed

3 files changed

+970
-5
lines changed

src/migration/dataraptor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
164164
}
165165

166166
if (transformedDataRaptor['Name'] && /^[0-9]/.test(transformedDataRaptor['Name'])) {
167-
this.setRecordErrors(dr, this.messages.getMessage('dataMapperNameStartsWithNumber', [transformedDataRaptor['Name'], 'DM' + transformedDataRaptor['Name']]));
167+
this.setRecordErrors(
168+
dr,
169+
this.messages.getMessage('dataMapperNameStartsWithNumber', [
170+
transformedDataRaptor['Name'],
171+
'DM' + transformedDataRaptor['Name'],
172+
])
173+
);
168174
originalDrRecords.set(recordId, dr);
169175
continue;
170176
}

src/migration/omniscript.ts

Lines changed: 227 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
534534
}
535535
if (!existingSubTypeVal.isNameCleaned()) {
536536
if (omniProcessType === 'Integration Procedure' && (!newSubType || newSubType.trim() === '')) {
537-
warnings.push(this.messages.getMessage('integrationProcedureSubtypeEmptyAfterCleaning', [existingSubTypeVal.val]));
537+
warnings.push(
538+
this.messages.getMessage('integrationProcedureSubtypeEmptyAfterCleaning', [existingSubTypeVal.val])
539+
);
538540
assessmentStatus = 'Needs Manual Intervention';
539541
} else {
540542
warnings.push(
@@ -871,7 +873,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
871873
const originalType = omniscript[this.namespacePrefix + 'Type__c'];
872874
const originalSubType = omniscript[this.namespacePrefix + 'SubType__c'];
873875

874-
if (!mappedOmniScript[OmniScriptMappings.Type__c] || mappedOmniScript[OmniScriptMappings.Type__c].trim() === '') {
876+
if (
877+
!mappedOmniScript[OmniScriptMappings.Type__c] ||
878+
mappedOmniScript[OmniScriptMappings.Type__c].trim() === ''
879+
) {
875880
const skippedResponse: UploadRecordResult = {
876881
referenceId: recordId,
877882
id: '',
@@ -887,7 +892,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
887892
continue;
888893
}
889894

890-
if (!mappedOmniScript[OmniScriptMappings.SubType__c] || mappedOmniScript[OmniScriptMappings.SubType__c].trim() === '') {
895+
if (
896+
!mappedOmniScript[OmniScriptMappings.SubType__c] ||
897+
mappedOmniScript[OmniScriptMappings.SubType__c].trim() === ''
898+
) {
891899
const skippedResponse: UploadRecordResult = {
892900
referenceId: recordId,
893901
id: '',
@@ -1608,8 +1616,14 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
16081616
content = JSON.parse(content);
16091617
if (content && content['sOmniScriptId']) {
16101618
content['sOmniScriptId'] = omniProcessId;
1611-
mappedObject[OmniScriptDefinitionMappings.Content__c] = JSON.stringify(content);
16121619
}
1620+
1621+
// Process the nested JSON structure to update bundle/reference names
1622+
if (content && content['children']) {
1623+
this.processContentChildren(content['children']);
1624+
}
1625+
1626+
mappedObject[OmniScriptDefinitionMappings.Content__c] = JSON.stringify(content);
16131627
} catch (ex) {
16141628
// Log
16151629
}
@@ -1624,6 +1638,215 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
16241638
return mappedObject;
16251639
}
16261640

1641+
/**
1642+
* Recursively processes children elements in the content JSON to update bundle/reference names
1643+
* @param children Array of child elements from the content JSON
1644+
*/
1645+
private processContentChildren(children: any[]): void {
1646+
if (!Array.isArray(children)) {
1647+
return;
1648+
}
1649+
1650+
children.forEach((child) => {
1651+
if (child && child.type && child.propSetMap) {
1652+
this.processContentElement(child);
1653+
}
1654+
1655+
// Process nested children in Step elements
1656+
if (child && child.children && Array.isArray(child.children)) {
1657+
child.children.forEach((nestedChild) => {
1658+
if (nestedChild && nestedChild.eleArray && Array.isArray(nestedChild.eleArray)) {
1659+
nestedChild.eleArray.forEach((element) => {
1660+
if (element && element.type && element.propSetMap) {
1661+
this.processContentElement(element);
1662+
}
1663+
});
1664+
}
1665+
});
1666+
}
1667+
});
1668+
}
1669+
1670+
/**
1671+
* Processes individual content element to update bundle/reference names based on type
1672+
* @param element Individual element from the content JSON
1673+
*/
1674+
private processContentElement(element: any): void {
1675+
const elementType = element.type;
1676+
const propSetMap = element.propSetMap;
1677+
1678+
if (!elementType || !propSetMap) {
1679+
return;
1680+
}
1681+
1682+
switch (elementType) {
1683+
case 'Integration Procedure Action':
1684+
this.processIntegrationProcedureAction(propSetMap);
1685+
break;
1686+
case 'DataRaptor Turbo Action':
1687+
case 'DataRaptor Transform Action':
1688+
case 'DataRaptor Post Action':
1689+
case 'DataRaptor Extract Action':
1690+
this.processDataRaptorAction(propSetMap);
1691+
break;
1692+
case 'OmniScript':
1693+
this.processOmniScriptAction(propSetMap);
1694+
break;
1695+
case 'Step':
1696+
this.processStepAction(propSetMap);
1697+
break;
1698+
default:
1699+
// Handle other element types if needed
1700+
break;
1701+
}
1702+
}
1703+
1704+
/**
1705+
* Processes Integration Procedure Action elements to update reference names
1706+
* @param propSetMap Property set map from the element
1707+
*/
1708+
private processIntegrationProcedureAction(propSetMap: any): void {
1709+
// Handle remoteOptions pre/post transform bundles
1710+
if (propSetMap.remoteOptions) {
1711+
if (propSetMap.remoteOptions.preTransformBundle) {
1712+
const bundleName = propSetMap.remoteOptions.preTransformBundle;
1713+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1714+
propSetMap.remoteOptions.preTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1715+
} else {
1716+
propSetMap.remoteOptions.preTransformBundle = this.cleanName(bundleName);
1717+
}
1718+
}
1719+
1720+
if (propSetMap.remoteOptions.postTransformBundle) {
1721+
const bundleName = propSetMap.remoteOptions.postTransformBundle;
1722+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1723+
propSetMap.remoteOptions.postTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1724+
} else {
1725+
propSetMap.remoteOptions.postTransformBundle = this.cleanName(bundleName);
1726+
}
1727+
}
1728+
}
1729+
1730+
// Handle direct pre/post transform bundles
1731+
if (propSetMap.preTransformBundle) {
1732+
const bundleName = propSetMap.preTransformBundle;
1733+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1734+
propSetMap.preTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1735+
} else {
1736+
propSetMap.preTransformBundle = this.cleanName(bundleName);
1737+
}
1738+
}
1739+
1740+
if (propSetMap.postTransformBundle) {
1741+
const bundleName = propSetMap.postTransformBundle;
1742+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1743+
propSetMap.postTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1744+
} else {
1745+
propSetMap.postTransformBundle = this.cleanName(bundleName);
1746+
}
1747+
}
1748+
1749+
// Handle integrationProcedureKey
1750+
if (propSetMap.integrationProcedureKey) {
1751+
const key = propSetMap.integrationProcedureKey;
1752+
if (this.nameRegistry.hasIntegrationProcedureMapping(key)) {
1753+
propSetMap.integrationProcedureKey = this.nameRegistry.getIntegrationProcedureCleanedName(key);
1754+
} else {
1755+
const parts = key.split('_');
1756+
propSetMap.integrationProcedureKey = parts.map((p) => this.cleanName(p, true)).join('_');
1757+
}
1758+
}
1759+
}
1760+
1761+
/**
1762+
* Processes DataRaptor Action elements to update bundle names
1763+
* @param propSetMap Property set map from the element
1764+
*/
1765+
private processDataRaptorAction(propSetMap: any): void {
1766+
if (propSetMap.bundle) {
1767+
const bundleName = propSetMap.bundle;
1768+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1769+
propSetMap.bundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1770+
} else {
1771+
propSetMap.bundle = this.cleanName(bundleName);
1772+
}
1773+
}
1774+
}
1775+
1776+
/**
1777+
* Processes OmniScript Action elements to update reference names
1778+
* @param propSetMap Property set map from the element
1779+
*/
1780+
private processOmniScriptAction(propSetMap: any): void {
1781+
const osType = propSetMap['Type'] || '';
1782+
const osSubType = propSetMap['Sub Type'] || '';
1783+
const osLanguage = propSetMap['Language'] || 'English';
1784+
1785+
// Construct full OmniScript name to check registry
1786+
const fullOmniScriptName = `${osType}_${osSubType}_${osLanguage}`;
1787+
1788+
if (this.nameRegistry.isAngularOmniScript(fullOmniScriptName)) {
1789+
// Keep original reference as-is since Angular OmniScript won't be migrated
1790+
propSetMap['Type'] = osType;
1791+
propSetMap['Sub Type'] = osSubType;
1792+
propSetMap['Language'] = osLanguage;
1793+
} else if (this.nameRegistry.hasOmniScriptMapping(fullOmniScriptName)) {
1794+
// Registry has mapping for this LWC OmniScript - extract cleaned parts
1795+
const cleanedFullName = this.nameRegistry.getCleanedName(fullOmniScriptName, 'OmniScript');
1796+
const parts = cleanedFullName.split('_');
1797+
1798+
if (parts.length >= 2) {
1799+
propSetMap['Type'] = parts[0];
1800+
propSetMap['Sub Type'] = parts[1];
1801+
// Language doesn't typically change, but update if provided
1802+
if (parts.length >= 3) {
1803+
propSetMap['Language'] = parts[2];
1804+
}
1805+
}
1806+
} else {
1807+
// No registry mapping - use original fallback approach
1808+
propSetMap['Type'] = this.cleanName(osType);
1809+
propSetMap['Sub Type'] = this.cleanName(osSubType);
1810+
}
1811+
}
1812+
1813+
/**
1814+
* Processes Step elements to update reference names
1815+
* @param propSetMap Property set map from the element
1816+
*/
1817+
private processStepAction(propSetMap: any): void {
1818+
// Handle remoteClass - typically references Apex classes
1819+
if (propSetMap.remoteClass && propSetMap.remoteClass.trim()) {
1820+
propSetMap.remoteClass = this.cleanName(propSetMap.remoteClass);
1821+
}
1822+
1823+
// Handle remoteMethod - typically references Apex methods
1824+
if (propSetMap.remoteMethod && propSetMap.remoteMethod.trim()) {
1825+
propSetMap.remoteMethod = this.cleanName(propSetMap.remoteMethod);
1826+
}
1827+
1828+
// Handle remoteOptions pre/post transform bundles if they exist in Step elements
1829+
if (propSetMap.remoteOptions) {
1830+
if (propSetMap.remoteOptions.preTransformBundle) {
1831+
const bundleName = propSetMap.remoteOptions.preTransformBundle;
1832+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1833+
propSetMap.remoteOptions.preTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1834+
} else {
1835+
propSetMap.remoteOptions.preTransformBundle = this.cleanName(bundleName);
1836+
}
1837+
}
1838+
1839+
if (propSetMap.remoteOptions.postTransformBundle) {
1840+
const bundleName = propSetMap.remoteOptions.postTransformBundle;
1841+
if (this.nameRegistry.hasDataMapperMapping(bundleName)) {
1842+
propSetMap.remoteOptions.postTransformBundle = this.nameRegistry.getDataMapperCleanedName(bundleName);
1843+
} else {
1844+
propSetMap.remoteOptions.postTransformBundle = this.cleanName(bundleName);
1845+
}
1846+
}
1847+
}
1848+
}
1849+
16271850
private getOmniScriptFields(): string[] {
16281851
return Object.keys(OmniScriptMappings);
16291852
}

0 commit comments

Comments
 (0)