@@ -4,7 +4,14 @@ import { AnyJson } from '@salesforce/ts-types';
44import OmniScriptMappings from '../mappings/OmniScript' ;
55import ElementMappings from '../mappings/Element' ;
66import OmniScriptDefinitionMappings from '../mappings/OmniScriptDefinition' ;
7- import { DataRaptorAssessmentInfo , DebugTimer , FlexCardAssessmentInfo , QueryTools , SortDirection } from '../utils' ;
7+ import {
8+ DataRaptorAssessmentInfo ,
9+ DebugTimer ,
10+ FlexCardAssessmentInfo ,
11+ nameLocation ,
12+ QueryTools ,
13+ SortDirection ,
14+ } from '../utils' ;
815import { BaseMigrationTool } from './base' ;
916import { MigrationResult , MigrationTool , TransformData , UploadRecordResult } from './interfaces' ;
1017import { ObjectMapping } from './interfaces' ;
@@ -13,6 +20,7 @@ import { Connection, Messages, Logger } from '@salesforce/core';
1320import { UX } from '@salesforce/command' ;
1421import { OSAssessmentInfo , OmniAssessmentInfo , IPAssessmentInfo } from '../../src/utils' ;
1522import { getAllFunctionMetadata , getReplacedString } from '../utils/formula/FormulaUtil' ;
23+ import { StringVal } from '../utils/StringValue/stringval' ;
1624
1725export class OmniScriptMigrationTool extends BaseMigrationTool implements MigrationTool {
1826 private readonly exportType : OmniScriptExportType ;
@@ -190,30 +198,24 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
190198 const osAssessmentInfos : OSAssessmentInfo [ ] = [ ] ;
191199 const ipAssessmentInfos : IPAssessmentInfo [ ] = [ ] ;
192200
193- const limitedOmniscripts = omniscripts . slice ( 0 , 200 ) ;
194-
195201 // Create a set to store existing OmniScript names and also extract DataRaptor and FlexCard names
196202 const existingOmniscriptNames = new Set < string > ( ) ;
197203 const existingDataRaptorNames = new Set ( dataRaptorAssessmentInfos . map ( ( info ) => info . name ) ) ;
198204 const existingFlexCardNames = new Set ( flexCardAssessmentInfos . map ( ( info ) => info . name ) ) ;
199205
200206 // First, collect all OmniScript names from the omniscripts array
201- for ( const omniscript of limitedOmniscripts ) {
202- const omniScriptName = `${ omniscript [ this . namespacePrefix + 'Name' ] } ` ;
203- existingOmniscriptNames . add ( omniScriptName ) ;
204- }
205-
206207 // Now process each OmniScript and its elements
207- for ( const omniscript of limitedOmniscripts ) {
208+ for ( const omniscript of omniscripts ) {
208209 const elements = await this . getAllElementsForOmniScript ( omniscript [ 'Id' ] ) ;
209210
210- const dependencyIP : string [ ] = [ ] ;
211+ const dependencyIP : nameLocation [ ] = [ ] ;
211212 const missingIP : string [ ] = [ ] ;
212- const dependencyDR : string [ ] = [ ] ;
213+ const dependencyDR : nameLocation [ ] = [ ] ;
213214 const missingDR : string [ ] = [ ] ;
214- const dependencyOS : string [ ] = [ ] ;
215+ const dependencyOS : nameLocation [ ] = [ ] ;
215216 const missingOS : string [ ] = [ ] ;
216- const dependenciesRA : string [ ] = [ ] ;
217+ const dependenciesRA : nameLocation [ ] = [ ] ;
218+ const dependenciesLWC : nameLocation [ ] = [ ] ;
217219 //const missingRA: string[] = [];
218220
219221 for ( const elem of elements ) {
@@ -223,55 +225,119 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
223225
224226 // Check for OmniScript dependencies
225227 if ( type === 'OmniScript' ) {
226- const nameVal = `${ elemName } _OmniScript ` ;
228+ const nameVal = `${ elemName } ` ;
227229 const type = propertySet [ 'Type' ] ;
228230 const subtype = propertySet [ 'Sub Type' ] ;
229231 const language = propertySet [ 'Language' ] ;
230232 const osName = type + '_' + subtype + '_' + language ;
231- dependencyOS . push ( osName + ' ( ' + nameVal + ' ) <br>' ) ;
233+ dependencyOS . push ( {
234+ name : osName ,
235+ location : nameVal ,
236+ } ) ;
232237 if ( ! existingOmniscriptNames . has ( nameVal ) ) {
233238 missingOS . push ( nameVal ) ;
234239 }
235240 }
236241
237242 // Check for Integration Procedure Action dependencies
238243 if ( type === 'Integration Procedure Action' ) {
239- const nameVal = `${ elemName } _Integration Procedure Action ` ;
240- dependencyIP . push ( propertySet [ 'integrationProcedureKey' ] + ' (' + nameVal + ') <br>' ) ;
244+ const nameVal = `${ elemName } ` ;
245+ dependencyIP . push ( { name : propertySet [ 'integrationProcedureKey' ] , location : nameVal } ) ;
241246 if ( ! existingOmniscriptNames . has ( nameVal ) && ! existingFlexCardNames . has ( nameVal ) ) {
242247 missingIP . push ( nameVal ) ;
243248 }
244249 }
245250
246251 // Check for DataRaptor dependencies
247252 if ( [ 'DataRaptor Extract Action' , 'DataRaptor Turbo Action' , 'DataRaptor Post Action' ] . includes ( type ) ) {
248- const nameVal = `${ elemName } _ ${ type } ` ;
249- dependencyDR . push ( propertySet [ 'bundle' ] + ' ( ' + nameVal + ' ) <br>' ) ;
253+ const nameVal = `${ elemName } ` ;
254+ dependencyDR . push ( { name : propertySet [ 'bundle' ] , location : nameVal } ) ;
250255 if ( ! existingOmniscriptNames . has ( nameVal ) && ! existingDataRaptorNames . has ( nameVal ) ) {
251256 missingDR . push ( nameVal ) ;
252257 }
253258 }
254259
255260 if ( type === 'Remote Action' ) {
256- const nameVal = `${ elemName } _ ${ type } ` ;
261+ const nameVal = `${ elemName } ` ;
257262 const className = propertySet [ 'remoteClass' ] ;
258263 const methodName = propertySet [ 'remoteMethod' ] ;
259- dependenciesRA . push ( className + '.' + methodName + ' (' + nameVal + ') <br>' ) ;
264+ dependenciesRA . push ( { name : className + '.' + methodName , location : nameVal } ) ;
265+ }
266+ // To handle radio , multiselect
267+ if ( propertySet [ 'optionSource' ] && propertySet [ 'optionSource' ] [ 'type' ] === 'Custom' ) {
268+ const nameVal = `${ elemName } ` ;
269+ dependenciesRA . push ( { name : propertySet [ 'optionSource' ] [ 'source' ] , location : nameVal } ) ;
260270 }
261- }
262271
263- /*const recordName = `${omniscript[this.namespacePrefix + 'Type__c']}_` +
264- `${omniscript[this.namespacePrefix + 'SubType__c']}` +
265- (omniscript[this.namespacePrefix + 'Language__c'] ? `_${omniscript[this.namespacePrefix + 'Language__c']}` : '') +
266- `_${omniscript[this.namespacePrefix + 'Version__c']}`;*/
272+ if ( type === 'Custom Lightning Web Component' ) {
273+ const nameVal = `${ elemName } ` ;
274+ const lwcName = propertySet [ 'lwcName' ] ;
275+ dependenciesLWC . push ( { name : lwcName , location : nameVal } ) ;
276+ }
277+ }
267278
268279 const omniProcessType = omniscript [ this . namespacePrefix + 'IsProcedure__c' ]
269280 ? 'Integration Procedure'
270281 : 'OmniScript' ;
271282
283+ const existingType = omniscript [ this . namespacePrefix + 'Type__c' ] ;
284+ const existingTypeVal = new StringVal ( existingType , 'type' ) ;
285+ const existingSubType = omniscript [ this . namespacePrefix + 'SubType__c' ] ;
286+ const existingSubTypeVal = new StringVal ( existingSubType , 'sub type' ) ;
287+ const omniScriptName = omniscript [ this . namespacePrefix + 'Name' ] ;
288+ const existingOmniScriptNameVal = new StringVal ( omniScriptName , 'name' ) ;
289+
290+ const warnings : string [ ] = [ ] ;
291+
292+ const recordName =
293+ `${ existingTypeVal . cleanName ( ) } _` +
294+ `${ existingSubTypeVal . cleanName ( ) } ` +
295+ ( omniscript [ this . namespacePrefix + 'Language__c' ]
296+ ? `_${ omniscript [ this . namespacePrefix + 'Language__c' ] } `
297+ : '' ) +
298+ `_${ omniscript [ this . namespacePrefix + 'Version__c' ] } ` ;
299+
300+ if ( ! existingTypeVal . isNameCleaned ( ) ) {
301+ warnings . push (
302+ this . messages . getMessage ( 'changeMessage' , [
303+ existingTypeVal . type ,
304+ existingTypeVal . val ,
305+ existingTypeVal . cleanName ( ) ,
306+ ] )
307+ ) ;
308+ }
309+ if ( ! existingSubTypeVal . isNameCleaned ( ) ) {
310+ warnings . push (
311+ this . messages . getMessage ( 'changeMessage' , [
312+ existingSubTypeVal . type ,
313+ existingSubTypeVal . val ,
314+ existingSubTypeVal . cleanName ( ) ,
315+ ] )
316+ ) ;
317+ }
318+ if ( ! existingOmniScriptNameVal . isNameCleaned ( ) ) {
319+ warnings . push (
320+ this . messages . getMessage ( 'changeMessage' , [
321+ existingOmniScriptNameVal . type ,
322+ existingOmniScriptNameVal . val ,
323+ existingOmniScriptNameVal . cleanName ( ) ,
324+ ] )
325+ ) ;
326+ }
327+ if ( existingOmniscriptNames . has ( recordName ) ) {
328+ warnings . push ( this . messages . getMessage ( 'duplicatedName' ) + recordName ) ;
329+ } else {
330+ existingOmniscriptNames . add ( recordName ) ;
331+ }
332+
272333 if ( omniProcessType === 'OmniScript' ) {
334+ const type = omniscript [ this . namespacePrefix + 'IsLwcEnabled__c' ] ? 'LWC' : 'Angular' ;
335+ if ( type === 'Angular' ) {
336+ warnings . unshift ( this . messages . getMessage ( 'angularOSWarning' ) ) ;
337+ }
273338 const osAssessmentInfo : OSAssessmentInfo = {
274- name : omniscript [ 'Name' ] ,
339+ name : recordName ,
340+ type : type ,
275341 id : omniscript [ 'Id' ] ,
276342 dependenciesIP : dependencyIP ,
277343 missingIP : [ ] ,
@@ -280,22 +346,22 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
280346 dependenciesOS : dependencyOS ,
281347 missingOS : missingOS ,
282348 dependenciesRemoteAction : dependenciesRA ,
349+ dependenciesLWC : dependenciesLWC ,
283350 infos : [ ] ,
284- warnings : [ ] ,
351+ warnings : warnings ,
285352 errors : [ ] ,
286- path : '' ,
287353 } ;
288354 osAssessmentInfos . push ( osAssessmentInfo ) ;
289355 } else {
290356 const ipAssessmentInfo : IPAssessmentInfo = {
291- name : omniscript [ 'Name' ] ,
357+ name : recordName ,
292358 id : omniscript [ 'Id' ] ,
293359 dependenciesIP : dependencyIP ,
294360 dependenciesDR : dependencyDR ,
295361 dependenciesOS : dependencyOS ,
296362 dependenciesRemoteAction : dependenciesRA ,
297363 infos : [ ] ,
298- warnings : [ ] ,
364+ warnings : warnings ,
299365 errors : [ ] ,
300366 path : '' ,
301367 } ;
0 commit comments