55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77
8+ import { isStandardDataModel } from '../utils/dataModelService' ;
89import { Stringutil } from '../utils/StringValue/stringutil' ;
910
1011export interface ComponentNameMapping {
@@ -41,9 +42,6 @@ export class NameMappingRegistry {
4142 // Track Angular OmniScripts that should be skipped (Type_SubType_Language format)
4243 private angularOmniScriptRefs : Set < string > = new Set ( ) ;
4344
44- // eslint-disable-next-line @typescript-eslint/no-empty-function
45- private constructor ( ) { }
46-
4745 public static getInstance ( ) : NameMappingRegistry {
4846 if ( ! NameMappingRegistry . instance ) {
4947 NameMappingRegistry . instance = new NameMappingRegistry ( ) ;
@@ -151,8 +149,9 @@ export class NameMappingRegistry {
151149 public getOmniScriptCleanedName ( type : string , subType : string , language : string | 'English' ) : string {
152150 const originalName = `${ type } _${ subType } _${ language } ` ;
153151 // Check if we have a mapping for this OmniScript first
154- if ( this . omniScriptMappings . has ( originalName ) ) {
155- return this . omniScriptMappings . get ( originalName ) ! ;
152+ const mappedName = this . omniScriptMappings . get ( originalName ) ;
153+ if ( mappedName ) {
154+ return mappedName ;
156155 }
157156 // Fallback to cleaning individual parts
158157 const cleanedType = Stringutil . cleanName ( type ) ;
@@ -279,6 +278,24 @@ export class NameMappingRegistry {
279278 flexCards : any [ ]
280279 ) : void {
281280 // Register DataMapper mappings
281+ this . registerDataMappersMapping ( dataMappers ) ;
282+ this . registerLwcOmniscriptsMapping ( lwcOmniScripts ) ;
283+ this . registerAngularOmniscriptsMapping ( angularOmniScripts ) ;
284+ this . registerIntegrationProceduresMapping ( integrationProcedures ) ;
285+ this . registerFlexcardsMapping ( flexCards ) ;
286+ }
287+
288+ /**
289+ * Update all dependency references with cleaned names
290+ */
291+ public updateDependencyReferences < T > ( componentDefinition : T ) : T {
292+ // This will be called for each component to update its dependencies
293+ // Implementation depends on the specific structure of each component type
294+ return this . updateObjectReferences ( componentDefinition ) as T ;
295+ }
296+
297+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
298+ private registerDataMappersMapping ( dataMappers : any [ ] ) : void {
282299 for ( const dr of dataMappers ) {
283300 this . registerNameMapping ( {
284301 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
@@ -290,15 +307,23 @@ export class NameMappingRegistry {
290307 recordId : dr . Id ,
291308 } ) ;
292309 }
310+ }
293311
312+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
313+ private registerLwcOmniscriptsMapping ( lwcOmniScripts : any [ ] ) : void {
294314 // Register OmniScript mappings
295315 for ( const os of lwcOmniScripts ) {
296316 // Extract namespace from field names (e.g., vlocity_ins__Type__c -> vlocity_ins)
297- const fieldNames = Object . keys ( os ) ;
298- const typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
299- const subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
300- const languageField = fieldNames . find ( ( field ) => field . endsWith ( '__Language__c' ) ) || 'Language__c' ;
301-
317+ let typeField = 'Type' ;
318+ let subTypeField = 'SubType' ;
319+ let languageField = 'Language' ;
320+
321+ if ( ! isStandardDataModel ( ) ) {
322+ const fieldNames = Object . keys ( os ) ;
323+ typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
324+ subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
325+ languageField = fieldNames . find ( ( field ) => field . endsWith ( '__Language__c' ) ) || 'Language__c' ;
326+ }
302327 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
303328 const type = os [ typeField ] ;
304329 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
@@ -319,14 +344,23 @@ export class NameMappingRegistry {
319344 recordId : os . Id ,
320345 } ) ;
321346 }
347+ }
322348
349+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
350+ private registerAngularOmniscriptsMapping ( angularOmniScripts : any [ ] ) : void {
323351 // Register Angular OmniScript references (to be skipped during migration)
324352 for ( const angularOs of angularOmniScripts ) {
325353 // Extract namespace from field names (e.g., vlocity_ins__Type__c -> vlocity_ins)
326- const fieldNames = Object . keys ( angularOs ) ;
327- const typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
328- const subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
329- const languageField = fieldNames . find ( ( field ) => field . endsWith ( '__Language__c' ) ) || 'Language__c' ;
354+ let typeField = 'Type' ;
355+ let subTypeField = 'SubType' ;
356+ let languageField = 'Language' ;
357+
358+ if ( ! isStandardDataModel ( ) ) {
359+ const fieldNames = Object . keys ( angularOs ) ;
360+ typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
361+ subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
362+ languageField = fieldNames . find ( ( field ) => field . endsWith ( '__Language__c' ) ) || 'Language__c' ;
363+ }
330364
331365 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
332366 const type = angularOs [ typeField ] ;
@@ -339,13 +373,21 @@ export class NameMappingRegistry {
339373 const angularRef = `${ type } _${ subType } _${ language } ` ;
340374 this . registerAngularOmniScript ( angularRef ) ;
341375 }
376+ }
342377
378+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379+ private registerIntegrationProceduresMapping ( integrationProcedures : any [ ] ) : void {
343380 // Register Integration Procedure mappings
344381 for ( const ip of integrationProcedures ) {
345- // Extract namespace from field names (e.g., vlocity_ins__Type__c -> vlocity_ins)
346- const fieldNames = Object . keys ( ip ) ;
347- const typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
348- const subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
382+ let typeField = 'Type' ;
383+ let subTypeField = 'SubType' ;
384+
385+ if ( ! isStandardDataModel ( ) ) {
386+ // Extract namespace from field names (e.g., vlocity_ins__Type__c -> vlocity_ins)
387+ const fieldNames = Object . keys ( ip ) ;
388+ typeField = fieldNames . find ( ( field ) => field . endsWith ( '__Type__c' ) ) || 'Type__c' ;
389+ subTypeField = fieldNames . find ( ( field ) => field . endsWith ( '__SubType__c' ) ) || 'SubType__c' ;
390+ }
349391
350392 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
351393 const type = ip [ typeField ] ;
@@ -366,7 +408,10 @@ export class NameMappingRegistry {
366408 recordId : ip . Id ,
367409 } ) ;
368410 }
411+ }
369412
413+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
414+ private registerFlexcardsMapping ( flexCards : any [ ] ) : void {
370415 // Register FlexCard mappings
371416 for ( const fc of flexCards ) {
372417 this . registerNameMapping ( {
@@ -381,15 +426,6 @@ export class NameMappingRegistry {
381426 }
382427 }
383428
384- /**
385- * Update all dependency references with cleaned names
386- */
387- public updateDependencyReferences < T > ( componentDefinition : T ) : T {
388- // This will be called for each component to update its dependencies
389- // Implementation depends on the specific structure of each component type
390- return this . updateObjectReferences ( componentDefinition ) as T ;
391- }
392-
393429 /**
394430 * Recursively update references in an object
395431 */
0 commit comments