@salesforce/plugin-omnistudio-migration-tool 2.0.0-rc.2 → 2.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +14 -26
  2. package/lib/commands/omnistudio/migration/assess.d.ts +0 -1
  3. package/lib/commands/omnistudio/migration/assess.js +64 -30
  4. package/lib/commands/omnistudio/migration/assess.js.map +1 -1
  5. package/lib/commands/omnistudio/migration/info.js +2 -3
  6. package/lib/commands/omnistudio/migration/info.js.map +1 -1
  7. package/lib/commands/omnistudio/migration/migrate.d.ts +35 -5
  8. package/lib/commands/omnistudio/migration/migrate.js +250 -102
  9. package/lib/commands/omnistudio/migration/migrate.js.map +1 -1
  10. package/lib/javascripts/reportGeneratorUtility.js +1 -3
  11. package/lib/migration/NameMappingRegistry.d.ts +130 -0
  12. package/lib/migration/NameMappingRegistry.js +376 -0
  13. package/lib/migration/NameMappingRegistry.js.map +1 -0
  14. package/lib/migration/base.d.ts +4 -2
  15. package/lib/migration/base.js +8 -1
  16. package/lib/migration/base.js.map +1 -1
  17. package/lib/migration/dataraptor.js +32 -13
  18. package/lib/migration/dataraptor.js.map +1 -1
  19. package/lib/migration/deployer.d.ts +11 -0
  20. package/lib/migration/deployer.js +59 -0
  21. package/lib/migration/deployer.js.map +1 -0
  22. package/lib/migration/flexcard.d.ts +44 -2
  23. package/lib/migration/flexcard.js +680 -112
  24. package/lib/migration/flexcard.js.map +1 -1
  25. package/lib/migration/globalautonumber.js +43 -53
  26. package/lib/migration/globalautonumber.js.map +1 -1
  27. package/lib/migration/interfaces.d.ts +5 -0
  28. package/lib/migration/interfaces.js +7 -0
  29. package/lib/migration/interfaces.js.map +1 -1
  30. package/lib/migration/omniscript.d.ts +10 -1
  31. package/lib/migration/omniscript.js +399 -78
  32. package/lib/migration/omniscript.js.map +1 -1
  33. package/lib/migration/postMigrate.d.ts +22 -3
  34. package/lib/migration/postMigrate.js +146 -12
  35. package/lib/migration/postMigrate.js.map +1 -1
  36. package/lib/migration/premigrate.d.ts +16 -0
  37. package/lib/migration/premigrate.js +114 -0
  38. package/lib/migration/premigrate.js.map +1 -0
  39. package/lib/migration/related/ApexMigration.js +23 -15
  40. package/lib/migration/related/ApexMigration.js.map +1 -1
  41. package/lib/migration/related/ExperienceSiteMigration.d.ts +12 -4
  42. package/lib/migration/related/ExperienceSiteMigration.js +121 -53
  43. package/lib/migration/related/ExperienceSiteMigration.js.map +1 -1
  44. package/lib/migration/related/FlexipageMigration.js +2 -7
  45. package/lib/migration/related/FlexipageMigration.js.map +1 -1
  46. package/lib/migration/related/LwcMigration.js +13 -13
  47. package/lib/migration/related/LwcMigration.js.map +1 -1
  48. package/lib/migration/related/OmnistudioRelatedObjectMigrationFacade.js +23 -29
  49. package/lib/migration/related/OmnistudioRelatedObjectMigrationFacade.js.map +1 -1
  50. package/lib/styles/reportGenerator.css +10 -11
  51. package/lib/templates/assessmentReport.template +29 -17
  52. package/lib/templates/dashboard.template +7 -2
  53. package/lib/templates/migrationReport.template +14 -12
  54. package/lib/utils/OmnistudioSettingsPrefManager.d.ts +12 -0
  55. package/lib/utils/OmnistudioSettingsPrefManager.js +82 -0
  56. package/lib/utils/OmnistudioSettingsPrefManager.js.map +1 -0
  57. package/lib/utils/constants/documentRegistry.d.ts +1 -1
  58. package/lib/utils/constants/documentRegistry.js +3 -3
  59. package/lib/utils/constants/documentRegistry.js.map +1 -1
  60. package/lib/utils/constants/stringContants.d.ts +2 -0
  61. package/lib/utils/constants/stringContants.js +3 -1
  62. package/lib/utils/constants/stringContants.js.map +1 -1
  63. package/lib/utils/file/fileUtil.d.ts +3 -1
  64. package/lib/utils/file/fileUtil.js +13 -4
  65. package/lib/utils/file/fileUtil.js.map +1 -1
  66. package/lib/utils/flexipage/flexiPageTransformer.js +12 -8
  67. package/lib/utils/flexipage/flexiPageTransformer.js.map +1 -1
  68. package/lib/utils/generatePackageXml.d.ts +4 -2
  69. package/lib/utils/generatePackageXml.js +20 -22
  70. package/lib/utils/generatePackageXml.js.map +1 -1
  71. package/lib/utils/interfaces.d.ts +29 -0
  72. package/lib/utils/logger.d.ts +1 -1
  73. package/lib/utils/logger.js +7 -2
  74. package/lib/utils/logger.js.map +1 -1
  75. package/lib/utils/lwcparser/fileutils/FileDiffUtil.js +78 -61
  76. package/lib/utils/lwcparser/fileutils/FileDiffUtil.js.map +1 -1
  77. package/lib/utils/lwcparser/jsParser/JavaScriptParser.js +1 -1
  78. package/lib/utils/lwcparser/jsParser/JavaScriptParser.js.map +1 -1
  79. package/lib/utils/lwcparser/xmlParser/XmlParser.js +1 -1
  80. package/lib/utils/lwcparser/xmlParser/XmlParser.js.map +1 -1
  81. package/lib/utils/orgPreferences.d.ts +1 -0
  82. package/lib/utils/orgPreferences.js +9 -6
  83. package/lib/utils/orgPreferences.js.map +1 -1
  84. package/lib/utils/orgUtils/index.d.ts +1 -1
  85. package/lib/utils/orgUtils/index.js +4 -14
  86. package/lib/utils/orgUtils/index.js.map +1 -1
  87. package/lib/utils/promptUtil.d.ts +2 -0
  88. package/lib/utils/promptUtil.js +26 -1
  89. package/lib/utils/promptUtil.js.map +1 -1
  90. package/lib/utils/reportGenerator/reportInterfaces.d.ts +2 -0
  91. package/lib/utils/resultsbuilder/ApexAssessmentReporter.js +27 -10
  92. package/lib/utils/resultsbuilder/ApexAssessmentReporter.js.map +1 -1
  93. package/lib/utils/resultsbuilder/DRAssessmentReporter.js +27 -11
  94. package/lib/utils/resultsbuilder/DRAssessmentReporter.js.map +1 -1
  95. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.d.ts +12 -0
  96. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.js +93 -0
  97. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.js.map +1 -0
  98. package/lib/utils/resultsbuilder/FlexcardAssessmentReporter.js +35 -13
  99. package/lib/utils/resultsbuilder/FlexcardAssessmentReporter.js.map +1 -1
  100. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.d.ts +1 -0
  101. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.js +3 -2
  102. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.js.map +1 -1
  103. package/lib/utils/resultsbuilder/IPAssessmentReporter.js +31 -12
  104. package/lib/utils/resultsbuilder/IPAssessmentReporter.js.map +1 -1
  105. package/lib/utils/resultsbuilder/LWCAssessmentReporter.d.ts +12 -0
  106. package/lib/utils/resultsbuilder/LWCAssessmentReporter.js +117 -139
  107. package/lib/utils/resultsbuilder/LWCAssessmentReporter.js.map +1 -1
  108. package/lib/utils/resultsbuilder/OSAssessmentReporter.js +19 -20
  109. package/lib/utils/resultsbuilder/OSAssessmentReporter.js.map +1 -1
  110. package/lib/utils/resultsbuilder/assessmentReporter.d.ts +3 -1
  111. package/lib/utils/resultsbuilder/assessmentReporter.js +106 -67
  112. package/lib/utils/resultsbuilder/assessmentReporter.js.map +1 -1
  113. package/lib/utils/resultsbuilder/index.d.ts +5 -1
  114. package/lib/utils/resultsbuilder/index.js +186 -71
  115. package/lib/utils/resultsbuilder/index.js.map +1 -1
  116. package/lib/utils/resultsbuilder/reportingHelper.js +1 -1
  117. package/lib/utils/resultsbuilder/reportingHelper.js.map +1 -1
  118. package/lib/utils/sfcli/project/sfProject.d.ts +4 -0
  119. package/lib/utils/sfcli/project/sfProject.js +56 -1
  120. package/lib/utils/sfcli/project/sfProject.js.map +1 -1
  121. package/lib/utils/shell/cli.js +3 -7
  122. package/lib/utils/shell/cli.js.map +1 -1
  123. package/lib/utils/storageUtil.d.ts +1 -0
  124. package/lib/utils/storageUtil.js +3 -0
  125. package/lib/utils/storageUtil.js.map +1 -1
  126. package/lib/utils/stringUtils.d.ts +1 -0
  127. package/lib/utils/stringUtils.js +22 -1
  128. package/lib/utils/stringUtils.js.map +1 -1
  129. package/messages/assess.json +79 -38
  130. package/messages/migrate.json +117 -32
  131. package/oclif.manifest.json +1 -1
  132. package/package.json +8 -6
  133. package/lib/utils/OmniGlobalAutoNumberPrefManager.d.ts +0 -39
  134. package/lib/utils/OmniGlobalAutoNumberPrefManager.js +0 -64
  135. package/lib/utils/OmniGlobalAutoNumberPrefManager.js.map +0 -1
@@ -8,6 +8,7 @@ const VlocityCard_1 = __importDefault(require("../mappings/VlocityCard"));
8
8
  const utils_1 = require("../utils");
9
9
  const net_1 = require("../utils/net");
10
10
  const base_1 = require("./base");
11
+ const interfaces_1 = require("./interfaces");
11
12
  const logger_1 = require("../utils/logger");
12
13
  const base_2 = require("./base");
13
14
  const stringContants_1 = require("../utils/constants/stringContants");
@@ -21,7 +22,9 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
21
22
  return 'FlexCards';
22
23
  }
23
24
  getRecordName(record) {
24
- return record['Name'];
25
+ return this.allVersions
26
+ ? `${record['Name']}_${record[this.namespacePrefix + CardMigrationTool.VERSION_PROP]}`
27
+ : record['Name'];
25
28
  }
26
29
  getMappings() {
27
30
  return [
@@ -55,14 +58,41 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
55
58
  // Perform Records Migration from VlocityCard__c to OmniUiCard
56
59
  async migrate() {
57
60
  // Get All the Active VlocityCard__c records
58
- const cards = await this.getAllActiveCards();
59
- logger_1.Logger.log(this.messages.getMessage('foundFlexCardsToMigrate', [cards.length]));
60
- const progressBar = (0, base_2.createProgressBar)('Migrating', 'Flexcard');
61
+ const allCards = await this.getAllActiveCards();
62
+ logger_1.Logger.log(this.messages.getMessage('foundFlexCardsToMigrate', [allCards.length]));
63
+ // Filter out FlexCards with Angular OmniScript dependencies
64
+ const cards = [];
65
+ const skippedCards = new Map();
66
+ for (const card of allCards) {
67
+ if (this.hasAngularOmniScriptDependencies(card)) {
68
+ // Skip FlexCard with Angular dependencies
69
+ logger_1.Logger.logVerbose(`${this.messages.getMessage('skipFlexcardAngularOmniScriptDependencyWarning', [card['Name']])}`);
70
+ skippedCards.set(card['Id'], {
71
+ referenceId: card['Id'],
72
+ id: '',
73
+ success: false,
74
+ hasErrors: false,
75
+ errors: [],
76
+ warnings: [this.messages.getMessage('flexCardWithAngularOmniScriptWarning')],
77
+ newName: '',
78
+ skipped: true,
79
+ });
80
+ }
81
+ else {
82
+ cards.push(card);
83
+ }
84
+ }
85
+ logger_1.Logger.log(`${this.messages.getMessage('flexCardMigrationProcessingMessage', [cards.length, skippedCards.size])}`);
86
+ const progressBar = (0, base_2.createProgressBar)('Migrating', 'Flexcards');
61
87
  // Save the Vlocity Cards in OmniUiCard
62
88
  const cardUploadResponse = await this.uploadAllCards(cards, progressBar);
89
+ // Add skipped cards to the response
90
+ for (const [cardId, skippedResult] of skippedCards.entries()) {
91
+ cardUploadResponse.set(cardId, skippedResult);
92
+ }
63
93
  const records = new Map();
64
- for (let i = 0; i < cards.length; i++) {
65
- records.set(cards[i]['Id'], cards[i]);
94
+ for (let i = 0; i < allCards.length; i++) {
95
+ records.set(allCards[i]['Id'], allCards[i]);
66
96
  }
67
97
  return [
68
98
  {
@@ -77,19 +107,21 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
77
107
  logger_1.Logger.log(this.messages.getMessage('startingFlexCardAssessment'));
78
108
  const flexCards = await this.getAllActiveCards();
79
109
  logger_1.Logger.log(this.messages.getMessage('foundFlexCardsToAssess', [flexCards.length]));
80
- const flexCardsAssessmentInfos = this.processCardComponents(flexCards);
110
+ const flexCardsAssessmentInfos = await this.processCardComponents(flexCards);
111
+ this.prepareAssessmentStorageForFlexcards(flexCardsAssessmentInfos);
81
112
  return flexCardsAssessmentInfos;
82
113
  }
83
114
  catch (err) {
84
- logger_1.Logger.error(this.messages.getMessage('errorDuringFlexCardAssessment'));
85
- logger_1.Logger.error(JSON.stringify(err));
86
- logger_1.Logger.error(err.stack);
115
+ if (err instanceof interfaces_1.InvalidEntityTypeError) {
116
+ throw err;
117
+ }
118
+ logger_1.Logger.error(this.messages.getMessage('errorDuringFlexCardAssessment'), err);
87
119
  }
88
120
  }
89
121
  async processCardComponents(flexCards) {
90
122
  const flexCardAssessmentInfos = [];
91
123
  let progressCounter = 0;
92
- const progressBar = (0, base_2.createProgressBar)('Assessing', 'Flexcard');
124
+ const progressBar = (0, base_2.createProgressBar)('Assessing', 'Flexcards');
93
125
  progressBar.start(flexCards.length, progressCounter);
94
126
  const uniqueNames = new Set();
95
127
  // Now process each OmniScript and its elements
@@ -101,6 +133,7 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
101
133
  catch (e) {
102
134
  flexCardAssessmentInfos.push({
103
135
  name: flexCard['Name'],
136
+ oldName: flexCard['Name'],
104
137
  id: flexCard['Id'],
105
138
  dependenciesIP: [],
106
139
  dependenciesDR: [],
@@ -109,11 +142,12 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
109
142
  dependenciesLWC: [],
110
143
  dependenciesApexRemoteAction: [],
111
144
  infos: [],
112
- warnings: [this.messages.getMessage('unexpectedError')],
145
+ warnings: [],
146
+ errors: [this.messages.getMessage('unexpectedError')],
147
+ migrationStatus: 'Failed',
113
148
  });
114
149
  const error = e;
115
- logger_1.Logger.error(JSON.stringify(error));
116
- logger_1.Logger.error(error.stack);
150
+ logger_1.Logger.error('Error processing flex card', error);
117
151
  }
118
152
  progressBar.update(++progressCounter);
119
153
  }
@@ -123,8 +157,10 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
123
157
  async processFlexCard(flexCard, uniqueNames) {
124
158
  const flexCardName = flexCard['Name'];
125
159
  logger_1.Logger.info(this.messages.getMessage('processingFlexCard', [flexCardName]));
160
+ const version = flexCard[this.namespacePrefix + CardMigrationTool.VERSION_PROP];
126
161
  const flexCardAssessmentInfo = {
127
- name: flexCardName,
162
+ name: this.allVersions ? `${flexCardName}_${version}` : flexCardName,
163
+ oldName: this.allVersions ? `${flexCardName}_${version}` : flexCardName,
128
164
  id: flexCard['Id'],
129
165
  dependenciesIP: [],
130
166
  dependenciesDR: [],
@@ -134,27 +170,38 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
134
170
  dependenciesApexRemoteAction: [],
135
171
  infos: [],
136
172
  warnings: [],
173
+ errors: [],
174
+ migrationStatus: '',
137
175
  };
138
176
  // Check for name changes due to API naming requirements
139
177
  const originalName = flexCardName;
140
178
  const cleanedName = this.cleanName(originalName);
179
+ let assessmentStatus = 'Ready for migration';
180
+ flexCardAssessmentInfo.name = this.allVersions ? `${cleanedName}_${version}` : cleanedName;
141
181
  if (cleanedName !== originalName) {
142
182
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('cardNameChangeMessage', [originalName, cleanedName]));
183
+ assessmentStatus = 'Warnings';
143
184
  }
144
185
  // Check for duplicate names
145
186
  if (uniqueNames.has(cleanedName)) {
146
187
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('duplicateCardNameMessage', [cleanedName]));
188
+ assessmentStatus = 'Needs Manual Intervention';
147
189
  }
148
190
  uniqueNames.add(cleanedName);
149
- this.addToAssessmentStorage(originalName, cleanedName);
150
191
  // Check for author name changes
151
192
  const originalAuthor = flexCard[this.namespacePrefix + 'Author__c'];
152
193
  if (originalAuthor) {
153
194
  const cleanedAuthor = this.cleanName(originalAuthor);
154
195
  if (cleanedAuthor !== originalAuthor) {
155
196
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('authordNameChangeMessage', [originalAuthor, cleanedAuthor]));
197
+ assessmentStatus = 'Warnings';
156
198
  }
157
199
  }
200
+ flexCardAssessmentInfo.nameMapping = {
201
+ oldName: flexCardName,
202
+ newName: cleanedName,
203
+ };
204
+ flexCardAssessmentInfo.migrationStatus = assessmentStatus;
158
205
  this.updateDependencies(flexCard, flexCardAssessmentInfo);
159
206
  return flexCardAssessmentInfo;
160
207
  }
@@ -173,10 +220,12 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
173
220
  const originalBundle = (_a = dataSource.value) === null || _a === void 0 ? void 0 : _a.bundle;
174
221
  if (originalBundle) {
175
222
  const cleanedBundle = this.cleanName(originalBundle);
176
- flexCardAssessmentInfo.dependenciesDR.push(cleanedBundle);
223
+ // Push original name instead of cleaned name for assessment consistency
224
+ flexCardAssessmentInfo.dependenciesDR.push(originalBundle);
177
225
  // Add warning if DataRaptor name will change
178
226
  if (originalBundle !== cleanedBundle) {
179
227
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('dataRaptorNameChangeMessage', [originalBundle, cleanedBundle]));
228
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
180
229
  }
181
230
  }
182
231
  }
@@ -186,14 +235,17 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
186
235
  const parts = originalIpMethod.split('_');
187
236
  const cleanedParts = parts.map((p) => this.cleanName(p, true));
188
237
  const cleanedIpMethod = cleanedParts.join('_');
189
- flexCardAssessmentInfo.dependenciesIP.push(cleanedIpMethod);
238
+ // Push original name instead of cleaned name for assessment consistency
239
+ flexCardAssessmentInfo.dependenciesIP.push(originalIpMethod);
190
240
  // Add warning if IP name will change
191
241
  if (originalIpMethod !== cleanedIpMethod) {
192
242
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('integrationProcedureNameChangeMessage', [originalIpMethod, cleanedIpMethod]));
243
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
193
244
  }
194
245
  // Add warning for IP references with more than 2 parts (which potentially need manual updates)
195
246
  if (parts.length > 2) {
196
247
  flexCardAssessmentInfo.warnings.push(this.messages.getMessage('integrationProcedureManualUpdateMessage', [originalIpMethod]));
248
+ flexCardAssessmentInfo.migrationStatus = 'Needs Manual Intervention';
197
249
  }
198
250
  }
199
251
  }
@@ -206,7 +258,7 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
206
258
  flexCardAssessmentInfo.dependenciesApexRemoteAction.push(`${remoteClass}.${remoteMethod}`);
207
259
  }
208
260
  }
209
- // Check for OmniScript dependencies in the card's definition
261
+ // Check for Omniscript dependencies in the card's definition
210
262
  try {
211
263
  const definition = JSON.parse(flexCard[this.namespacePrefix + 'Definition__c'] || '{}');
212
264
  if (definition && definition.states) {
@@ -214,8 +266,15 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
214
266
  if (state.omniscripts && Array.isArray(state.omniscripts)) {
215
267
  for (const os of state.omniscripts) {
216
268
  if (os.type && os.subtype) {
217
- const osRef = `${os.type}_${os.subtype}_${os.language || 'English'}`;
218
- flexCardAssessmentInfo.dependenciesOS.push(osRef);
269
+ const originalOsRef = `${os.type}_${os.subtype}_${os.language || 'English'}`;
270
+ const cleanedOsRef = `${this.cleanName(os.type)}_${this.cleanName(os.subtype)}_${os.language || 'English'}`;
271
+ // Push original name for consistency
272
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
273
+ // Add warning if OmniScript name will change
274
+ if (originalOsRef !== cleanedOsRef) {
275
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
276
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
277
+ }
219
278
  }
220
279
  }
221
280
  }
@@ -231,7 +290,17 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
231
290
  }
232
291
  }
233
292
  let childCards = this.readChildCardsFromDefinition(flexCard);
234
- flexCardAssessmentInfo.dependenciesFC.push(...childCards);
293
+ // Add warnings for child card name changes
294
+ for (const childCardName of childCards) {
295
+ const cleanedChildCardName = this.cleanName(childCardName);
296
+ // Push original child card name for consistency
297
+ flexCardAssessmentInfo.dependenciesFC.push(childCardName);
298
+ // Add warning if child card name will change
299
+ if (childCardName !== cleanedChildCardName) {
300
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('cardNameChangeMessage', [childCardName, cleanedChildCardName]));
301
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
302
+ }
303
+ }
235
304
  }
236
305
  catch (err) {
237
306
  // Log the error but continue processing
@@ -263,19 +332,46 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
263
332
  const originalName = omniType.Name;
264
333
  const parts = originalName.split('/');
265
334
  if (parts.length >= 2) {
266
- // Check for name changes in each part
335
+ // Create both original and cleaned references for comparison
336
+ const originalOsRef = parts.join('_');
267
337
  const cleanedParts = parts.map((p) => this.cleanName(p));
268
- const cleanedName = cleanedParts.join('_');
269
- flexCardAssessmentInfo.dependenciesOS.push(cleanedName);
270
- // Add warning if any part of the name will change
271
- for (let i = 0; i < parts.length; i++) {
272
- if (parts[i] !== cleanedParts[i]) {
273
- flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [parts[i], cleanedParts[i]]));
274
- }
338
+ const cleanedOsRef = cleanedParts.join('_');
339
+ // Push original name for consistency
340
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
341
+ // Add warning only if the overall name will change
342
+ if (originalOsRef !== cleanedOsRef) {
343
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
344
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
275
345
  }
276
346
  }
277
347
  }
278
348
  }
349
+ // MISSING PATTERN FIXED: Case 1b: Direct OmniScript reference without type check (for test compatibility)
350
+ else if (action.stateAction.omniType && !action.stateAction.type) {
351
+ const omniType = action.stateAction.omniType;
352
+ // Handle both string omniType and object with Name property
353
+ let omniTypeName;
354
+ if (typeof omniType === 'string') {
355
+ omniTypeName = omniType;
356
+ }
357
+ else if (omniType.Name && typeof omniType.Name === 'string') {
358
+ omniTypeName = omniType.Name;
359
+ }
360
+ else {
361
+ continue; // Skip if we can't extract the name
362
+ }
363
+ const parts = omniTypeName.split('/');
364
+ if (parts.length >= 2) {
365
+ const originalOsRef = parts.join('_');
366
+ const cleanedParts = parts.map((p) => this.cleanName(p));
367
+ const cleanedOsRef = cleanedParts.join('_');
368
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
369
+ if (originalOsRef !== cleanedOsRef) {
370
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
371
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
372
+ }
373
+ }
374
+ }
279
375
  // Case 2: Flyout OmniScript reference
280
376
  else if (action.stateAction.type === 'Flyout' &&
281
377
  action.stateAction.flyoutType === stringContants_1.Constants.OmniScriptPluralName &&
@@ -286,15 +382,16 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
286
382
  const originalName = osName;
287
383
  const parts = originalName.split('/');
288
384
  if (parts.length >= 2) {
289
- // Check for name changes in each part
385
+ // Create both original and cleaned references for comparison
386
+ const originalOsRef = parts.join('_');
290
387
  const cleanedParts = parts.map((p) => this.cleanName(p));
291
- const cleanedName = cleanedParts.join('_');
292
- flexCardAssessmentInfo.dependenciesOS.push(cleanedName);
293
- // Add warning if any part of the name will change
294
- for (let i = 0; i < parts.length; i++) {
295
- if (parts[i] !== cleanedParts[i]) {
296
- flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [parts[i], cleanedParts[i]]));
297
- }
388
+ const cleanedOsRef = cleanedParts.join('_');
389
+ // Push original name for consistency
390
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
391
+ // Add warning only if the overall name will change
392
+ if (originalOsRef !== cleanedOsRef) {
393
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
394
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
298
395
  }
299
396
  }
300
397
  }
@@ -320,10 +417,79 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
320
417
  if (action.stateAction && action.stateAction.omniType) {
321
418
  const omniType = action.stateAction.omniType;
322
419
  if (omniType.Name && typeof omniType.Name === 'string') {
323
- const parts = omniType.Name.split('/');
420
+ const originalName = omniType.Name;
421
+ const parts = originalName.split('/');
324
422
  if (parts.length >= 2) {
325
- const osRef = parts.join('_');
326
- flexCardAssessmentInfo.dependenciesOS.push(osRef);
423
+ // Create both original and cleaned references for comparison
424
+ const originalOsRef = parts.join('_');
425
+ const cleanedParts = parts.map((p) => this.cleanName(p));
426
+ const cleanedOsRef = cleanedParts.join('_');
427
+ // Push original name for consistency
428
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
429
+ // Add warning if OmniScript name will change
430
+ if (originalOsRef !== cleanedOsRef) {
431
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
432
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
433
+ }
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+ // MISSING PATTERN FIXED: Handle direct stateAction on component property
440
+ if (component.property && component.property.stateAction) {
441
+ // Case 1: Direct OmniScript reference on component property
442
+ if (component.property.stateAction.omniType) {
443
+ const omniType = component.property.stateAction.omniType;
444
+ if (omniType.Name && typeof omniType.Name === 'string') {
445
+ const originalName = omniType.Name;
446
+ const parts = originalName.split('/');
447
+ if (parts.length >= 2) {
448
+ const originalOsRef = parts.join('_');
449
+ const cleanedParts = parts.map((p) => this.cleanName(p));
450
+ const cleanedOsRef = cleanedParts.join('_');
451
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
452
+ if (originalOsRef !== cleanedOsRef) {
453
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
454
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
455
+ }
456
+ }
457
+ }
458
+ }
459
+ // Case 2: Flyout OmniScript reference on component property
460
+ if (component.property.stateAction.type === 'Flyout' &&
461
+ component.property.stateAction.flyoutType === 'OmniScripts' &&
462
+ component.property.stateAction.osName) {
463
+ const osName = component.property.stateAction.osName;
464
+ if (typeof osName === 'string') {
465
+ const parts = osName.split('/');
466
+ if (parts.length >= 2) {
467
+ const originalOsRef = parts.join('_');
468
+ const cleanedParts = parts.map((p) => this.cleanName(p));
469
+ const cleanedOsRef = cleanedParts.join('_');
470
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
471
+ if (originalOsRef !== cleanedOsRef) {
472
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
473
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
474
+ }
475
+ }
476
+ }
477
+ }
478
+ }
479
+ // MISSING PATTERN FIXED: Handle omni-flyout elements (from tests)
480
+ if (component.element === 'omni-flyout' && component.property && component.property.flyoutOmniScript) {
481
+ if (component.property.flyoutOmniScript.osName) {
482
+ const osName = component.property.flyoutOmniScript.osName;
483
+ if (typeof osName === 'string') {
484
+ const parts = osName.split('/');
485
+ if (parts.length >= 2) {
486
+ const originalOsRef = parts.join('_');
487
+ const cleanedParts = parts.map((p) => this.cleanName(p));
488
+ const cleanedOsRef = cleanedParts.join('_');
489
+ flexCardAssessmentInfo.dependenciesOS.push(originalOsRef);
490
+ if (originalOsRef !== cleanedOsRef) {
491
+ flexCardAssessmentInfo.warnings.push(this.messages.getMessage('omniScriptNameChangeMessage', [originalOsRef, cleanedOsRef]));
492
+ flexCardAssessmentInfo.migrationStatus = 'Warnings';
327
493
  }
328
494
  }
329
495
  }
@@ -346,11 +512,21 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
346
512
  { field: 'Name', direction: utils_1.SortDirection.ASC },
347
513
  { field: this.namespacePrefix + 'Version__c', direction: utils_1.SortDirection.ASC },
348
514
  ];
349
- return await utils_1.QueryTools.queryWithFilterAndSort(this.connection, this.namespace, CardMigrationTool.VLOCITYCARD_NAME, this.getCardFields(), filters, sortFields);
515
+ return await utils_1.QueryTools.queryWithFilterAndSort(this.connection, this.namespace, CardMigrationTool.VLOCITYCARD_NAME, this.getCardFields(), filters, sortFields).catch((err) => {
516
+ if (err.errorCode === 'INVALID_TYPE') {
517
+ throw new interfaces_1.InvalidEntityTypeError(`${CardMigrationTool.VLOCITYCARD_NAME} type is not found under this namespace`);
518
+ }
519
+ throw err;
520
+ });
350
521
  }
351
522
  else {
352
523
  filters.set(this.namespacePrefix + 'Active__c', true);
353
- return await utils_1.QueryTools.queryWithFilter(this.connection, this.namespace, CardMigrationTool.VLOCITYCARD_NAME, this.getCardFields(), filters);
524
+ return await utils_1.QueryTools.queryWithFilter(this.connection, this.namespace, CardMigrationTool.VLOCITYCARD_NAME, this.getCardFields(), filters).catch((err) => {
525
+ if (err.errorCode === 'INVALID_TYPE') {
526
+ throw new interfaces_1.InvalidEntityTypeError(`${CardMigrationTool.VLOCITYCARD_NAME} type is not found under this namespace`);
527
+ }
528
+ throw err;
529
+ });
354
530
  }
355
531
  }
356
532
  // Upload All the VlocityCard__c records to OmniUiCard
@@ -399,13 +575,13 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
399
575
  transformedCardName = transformedCard['Name'];
400
576
  }
401
577
  const transformedCardAuthorName = transformedCard['AuthorName'];
402
- if (uniqueNames.has(transformedCardName)) {
578
+ if (uniqueNames.has(transformedCard['Name'])) {
403
579
  this.setRecordErrors(card, this.messages.getMessage('duplicatedCardName'));
404
580
  originalRecords.set(recordId, card);
405
581
  return;
406
582
  }
407
583
  // Save the name for duplicated names check
408
- uniqueNames.add(transformedCardName);
584
+ uniqueNames.add(transformedCard['Name']);
409
585
  // Create a map of the original records
410
586
  originalRecords.set(recordId, card);
411
587
  // Create card
@@ -422,7 +598,7 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
422
598
  uploadResult.warnings.unshift(this.messages.getMessage('cardAuthorNameChangeMessage', [transformedCardAuthorName]));
423
599
  }
424
600
  uploadResult.newName = transformedCardName;
425
- if (transformedCardName !== card['Name']) {
601
+ if (transformedCard['Name'] !== card['Name']) {
426
602
  uploadResult.warnings.unshift(this.messages.getMessage('cardNameChangeMessage', [transformedCardName]));
427
603
  }
428
604
  if (uploadResult.id && invalidIpNames.size > 0) {
@@ -454,42 +630,76 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
454
630
  });
455
631
  }
456
632
  }
457
- addToAssessmentStorage(originalName, cleanedName) {
633
+ prepareAssessmentStorageForFlexcards(flexcardAssessmentInfos) {
458
634
  let storage = storageUtil_1.StorageUtil.getOmnistudioAssessmentStorage();
459
- if (storage.fcStorage.has(originalName)) {
460
- storage.fcStorage.get(originalName).isDuplicate = true;
461
- }
462
- else {
463
- storage.fcStorage.set(originalName, {
464
- name: cleanedName,
465
- isDuplicate: false,
466
- });
635
+ for (let flexCardAssessmentInfo of flexcardAssessmentInfos) {
636
+ try {
637
+ if (flexCardAssessmentInfo === undefined ||
638
+ flexCardAssessmentInfo === null ||
639
+ flexCardAssessmentInfo.nameMapping === undefined ||
640
+ flexCardAssessmentInfo.nameMapping === null) {
641
+ logger_1.Logger.error(this.messages.getMessage('missingInfo'));
642
+ return;
643
+ }
644
+ let value = {
645
+ name: flexCardAssessmentInfo.nameMapping.newName,
646
+ isDuplicate: false,
647
+ };
648
+ if (flexCardAssessmentInfo.errors && flexCardAssessmentInfo.errors.length > 0) {
649
+ value.error = flexCardAssessmentInfo.errors;
650
+ value.migrationSuccess = false;
651
+ }
652
+ else {
653
+ value.migrationSuccess = true;
654
+ }
655
+ let finalKey = `${flexCardAssessmentInfo.nameMapping.oldName}`;
656
+ finalKey = finalKey.toLowerCase();
657
+ if (storage.fcStorage.has(finalKey)) {
658
+ // Key already exists - handle accordingly
659
+ logger_1.Logger.logVerbose(this.messages.getMessage('keyAlreadyInStorage', [finalKey]));
660
+ value.isDuplicate = true;
661
+ storage.fcStorage.set(finalKey, value);
662
+ }
663
+ else {
664
+ // Key doesn't exist - safe to set
665
+ storage.fcStorage.set(finalKey, value);
666
+ }
667
+ }
668
+ catch (error) {
669
+ logger_1.Logger.logVerbose(this.messages.getMessage('errorWhileProcessingFlexcardStorage'));
670
+ logger_1.Logger.error(error);
671
+ }
467
672
  }
673
+ storageUtil_1.StorageUtil.printAssessmentStorage();
468
674
  }
469
675
  prepareStorageForFlexcards(cardsUploadInfo, originalRecords) {
470
- logger_1.Logger.logVerbose('Started preparing storage for flexcards');
676
+ logger_1.Logger.logVerbose(this.messages.getMessage('flexcardStorageProcessingStarted'));
471
677
  let storage = storageUtil_1.StorageUtil.getOmnistudioMigrationStorage();
472
678
  for (let key of Array.from(originalRecords.keys())) {
473
679
  try {
474
680
  let oldrecord = originalRecords.get(key);
475
681
  let newrecord = cardsUploadInfo.get(key);
476
- logger_1.Logger.logVerbose('Oldrecord - ' + JSON.stringify(oldrecord));
477
- logger_1.Logger.logVerbose('Newrecord - ' + JSON.stringify(newrecord));
478
682
  let value = {
479
- name: newrecord['newName'],
683
+ name: newrecord === null || newrecord === void 0 ? void 0 : newrecord.newName,
480
684
  isDuplicate: false,
481
685
  };
482
- if (newrecord.hasErrors) {
483
- value.error = newrecord.errors;
484
- value.migrationSuccess = false;
686
+ if (newrecord === undefined) {
687
+ value.error = ['Migration Failed'];
485
688
  }
486
689
  else {
487
- value.migrationSuccess = true;
690
+ if (newrecord.hasErrors) {
691
+ value.error = newrecord.errors;
692
+ value.migrationSuccess = false;
693
+ }
694
+ else {
695
+ value.migrationSuccess = true;
696
+ }
488
697
  }
489
698
  let finalKey = `${oldrecord['Name']}`;
699
+ finalKey = finalKey.toLowerCase();
490
700
  if (storage.fcStorage.has(finalKey)) {
491
701
  // Key already exists - handle accordingly
492
- logger_1.Logger.logVerbose(`Key ${finalKey} already exists in flexcard storage`);
702
+ logger_1.Logger.logVerbose(this.messages.getMessage('keyAlreadyInStorage', [finalKey]));
493
703
  value.isDuplicate = true;
494
704
  storage.fcStorage.set(finalKey, value);
495
705
  }
@@ -499,7 +709,7 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
499
709
  }
500
710
  }
501
711
  catch (error) {
502
- logger_1.Logger.logVerbose('Error occurred while processing key for flexcard storage');
712
+ logger_1.Logger.logVerbose(this.messages.getMessage('errorWhileProcessingFlexcardStorage'));
503
713
  logger_1.Logger.error(error);
504
714
  }
505
715
  storageUtil_1.StorageUtil.printMigrationStorage();
@@ -579,77 +789,435 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
579
789
  }
580
790
  mappedObject[VlocityCard_1.default.Datasource__c] = JSON.stringify(datasource);
581
791
  }
582
- // Update the propertyset datasource
792
+ // Update all dependencies comprehensively
793
+ this.updateAllDependenciesWithRegistry(mappedObject, invalidIpNames);
794
+ mappedObject['attributes'] = {
795
+ type: CardMigrationTool.OMNIUICARD_NAME,
796
+ referenceId: cardRecord['Id'],
797
+ };
798
+ return mappedObject;
799
+ }
800
+ /**
801
+ * Comprehensive dependency update using NameMappingRegistry - mirrors assessment logic
802
+ */
803
+ updateAllDependenciesWithRegistry(mappedObject, invalidIpNames) {
804
+ // 1. Handle propertySet (Definition) datasource
583
805
  const propertySet = JSON.parse(mappedObject[VlocityCard_1.default.Definition__c] || '{}');
584
806
  if (propertySet) {
585
- if (propertySet.dataSource) {
586
- const type = propertySet.dataSource.type;
587
- if (type === 'DataRaptor') {
588
- propertySet.dataSource.value.bundle = this.cleanName(propertySet.dataSource.value.bundle);
589
- }
590
- else if (type === 'IntegrationProcedures') {
591
- const ipMethod = propertySet.dataSource.value.ipMethod || '';
592
- const parts = ipMethod.split('_');
593
- const newKey = parts.map((p) => this.cleanName(p, true)).join('_');
594
- propertySet.dataSource.value.ipMethod = newKey;
595
- if (parts.length > 2) {
596
- invalidIpNames.set('DataSource', ipMethod);
807
+ // Use NameMappingRegistry to update all dependency references first
808
+ const updatedPropertySet = this.nameRegistry.updateDependencyReferences(propertySet);
809
+ // Handle dataSource in propertySet
810
+ if (updatedPropertySet.dataSource) {
811
+ this.updateDataSourceWithRegistry(updatedPropertySet.dataSource, invalidIpNames, 'PropertySet');
812
+ }
813
+ // Handle states comprehensively
814
+ if (updatedPropertySet.states && Array.isArray(updatedPropertySet.states)) {
815
+ for (let i = 0; i < updatedPropertySet.states.length; i++) {
816
+ const state = updatedPropertySet.states[i];
817
+ // Handle child cards using registry
818
+ if (state.childCards && Array.isArray(state.childCards)) {
819
+ state.childCards = state.childCards.map((c) => {
820
+ if (c && this.nameRegistry.hasFlexCardMapping(c)) {
821
+ return this.nameRegistry.getFlexCardCleanedName(c);
822
+ }
823
+ else {
824
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['FlexCard', c])}`);
825
+ return this.cleanName(c);
826
+ }
827
+ });
828
+ }
829
+ // Handle omniscripts using registry
830
+ if (state.omniscripts && Array.isArray(state.omniscripts)) {
831
+ for (let osIdx = 0; osIdx < state.omniscripts.length; osIdx++) {
832
+ this.updateOmniScriptReferenceWithRegistry(state.omniscripts[osIdx]);
833
+ }
834
+ }
835
+ // Handle components comprehensively using registry
836
+ if (state.components) {
837
+ for (const componentKey in state.components) {
838
+ if (state.components.hasOwnProperty(componentKey)) {
839
+ const component = state.components[componentKey];
840
+ this.updateComponentDependenciesWithRegistry(component);
841
+ }
842
+ }
597
843
  }
598
844
  }
599
845
  }
600
- // update the states for child cards
601
- for (let i = 0; i < (propertySet.states || []).length; i++) {
602
- const state = propertySet.states[i];
603
- // Clean childCards property
604
- if (state.childCards && Array.isArray(state.childCards)) {
605
- state.childCards = state.childCards.map((c) => this.cleanName(c));
846
+ mappedObject[VlocityCard_1.default.Definition__c] = JSON.stringify(updatedPropertySet);
847
+ }
848
+ }
849
+ /**
850
+ * Update dataSource (DataRaptor, Integration Procedures, Apex Remote) using registry
851
+ */
852
+ updateDataSourceWithRegistry(dataSource, invalidIpNames, context) {
853
+ var _a, _b;
854
+ const type = dataSource.type;
855
+ if (type === stringContants_1.Constants.DataRaptorComponentName || type === 'DataRaptor') {
856
+ // Handle DataRaptor using registry
857
+ const originalBundle = ((_a = dataSource.value) === null || _a === void 0 ? void 0 : _a.bundle) || '';
858
+ if (originalBundle && this.nameRegistry.hasDataMapperMapping(originalBundle)) {
859
+ dataSource.value.bundle = this.nameRegistry.getDataMapperCleanedName(originalBundle);
860
+ }
861
+ else {
862
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['DataMapper', originalBundle])}`);
863
+ dataSource.value.bundle = this.cleanName(originalBundle);
864
+ }
865
+ }
866
+ else if (type === stringContants_1.Constants.IntegrationProcedurePluralName || type === 'IntegrationProcedures') {
867
+ // Handle Integration Procedures using registry
868
+ const ipMethod = ((_b = dataSource.value) === null || _b === void 0 ? void 0 : _b.ipMethod) || '';
869
+ const hasRegistryMapping = this.nameRegistry.hasIntegrationProcedureMapping(ipMethod);
870
+ if (hasRegistryMapping) {
871
+ const cleanedIpName = this.nameRegistry.getIntegrationProcedureCleanedName(ipMethod);
872
+ dataSource.value.ipMethod = cleanedIpName;
873
+ }
874
+ else {
875
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['IntegrationProcedure', ipMethod])}`);
876
+ const parts = ipMethod.split('_');
877
+ const newKey = parts.map((p) => this.cleanName(p, true)).join('_');
878
+ dataSource.value.ipMethod = newKey;
879
+ if (parts.length > 2) {
880
+ invalidIpNames.set(context, ipMethod);
606
881
  }
607
- // Fix the "components" for child cards
608
- for (let componentKey in state.components) {
609
- if (state.components.hasOwnProperty(componentKey)) {
610
- const component = state.components[componentKey];
611
- if (component.children && Array.isArray(component.children)) {
612
- this.fixChildren(component.children);
613
- }
882
+ }
883
+ }
884
+ }
885
+ /**
886
+ * Update OmniScript reference using registry
887
+ */
888
+ updateOmniScriptReferenceWithRegistry(omniscriptRef) {
889
+ const originalType = omniscriptRef.type;
890
+ const originalSubtype = omniscriptRef.subtype;
891
+ const language = omniscriptRef.language || 'English';
892
+ // Construct full OmniScript name to check registry
893
+ const fullOmniScriptName = `${originalType}_${originalSubtype}_${language}`;
894
+ if (this.nameRegistry.hasOmniScriptMapping(fullOmniScriptName)) {
895
+ // Registry has mapping for this OmniScript - extract cleaned parts
896
+ const cleanedFullName = this.nameRegistry.getCleanedName(fullOmniScriptName, 'OmniScript');
897
+ const parts = cleanedFullName.split('_');
898
+ if (parts.length >= 2) {
899
+ omniscriptRef.type = parts[0];
900
+ omniscriptRef.subtype = parts[1];
901
+ // Language doesn't typically change, but update if provided
902
+ if (parts.length >= 3) {
903
+ omniscriptRef.language = parts[2];
904
+ }
905
+ }
906
+ }
907
+ else {
908
+ // No registry mapping - use original fallback approach
909
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['OmniScript', fullOmniScriptName])}`);
910
+ omniscriptRef.type = this.cleanName(originalType);
911
+ omniscriptRef.subtype = this.cleanName(originalSubtype);
912
+ }
913
+ }
914
+ /**
915
+ * Update component dependencies comprehensively
916
+ */
917
+ updateComponentDependenciesWithRegistry(component) {
918
+ // Handle action elements with actionList (like assessment)
919
+ if (component.element === 'action' && component.property && component.property.actionList) {
920
+ for (const action of component.property.actionList) {
921
+ if (action.stateAction) {
922
+ // Case 1: Direct OmniScript reference
923
+ if (action.stateAction.type === stringContants_1.Constants.OmniScriptComponentName && action.stateAction.omniType) {
924
+ this.updateOmniTypeNameWithRegistry(action.stateAction.omniType);
925
+ }
926
+ // Case 2: Flyout OmniScript reference
927
+ else if (action.stateAction.type === 'Flyout' &&
928
+ action.stateAction.flyoutType === stringContants_1.Constants.OmniScriptPluralName &&
929
+ action.stateAction.osName) {
930
+ this.updateOsNameWithRegistry(action.stateAction, 'osName');
614
931
  }
615
932
  }
616
- if (state.omniscripts && Array.isArray(state.omniscripts)) {
617
- for (let osIdx = 0; osIdx < state.omniscripts.length; osIdx++) {
618
- state.omniscripts[osIdx].type = this.cleanName(state.omniscripts[osIdx].type);
619
- state.omniscripts[osIdx].subtype = this.cleanName(state.omniscripts[osIdx].subtype);
933
+ }
934
+ }
935
+ // Handle Custom LWC components (no cleaning needed typically)
936
+ if (component.element === 'customLwc' && component.property) {
937
+ // Note: Custom LWC names typically don't need cleaning
938
+ }
939
+ // Handle standard component actions (like assessment)
940
+ if (component.actions && Array.isArray(component.actions)) {
941
+ for (const action of component.actions) {
942
+ if (action.stateAction && action.stateAction.omniType) {
943
+ this.updateOmniTypeNameWithRegistry(action.stateAction.omniType);
944
+ }
945
+ }
946
+ }
947
+ // Handle direct stateAction on component property (existing logic)
948
+ if (component.property && component.property.stateAction) {
949
+ if (component.property.stateAction.omniType) {
950
+ this.updateOmniTypeNameWithRegistry(component.property.stateAction.omniType);
951
+ }
952
+ if (component.property.stateAction.type === 'Flyout' &&
953
+ component.property.stateAction.flyoutType === 'OmniScripts' &&
954
+ component.property.stateAction.osName) {
955
+ this.updateOsNameWithRegistry(component.property.stateAction, 'osName');
956
+ }
957
+ }
958
+ // Handle childCardPreview elements (from old fixChildren method)
959
+ if (component.element === 'childCardPreview' && component.property) {
960
+ if (component.property.cardName) {
961
+ const originalCardName = component.property.cardName;
962
+ if (this.nameRegistry.hasFlexCardMapping(originalCardName)) {
963
+ component.property.cardName = this.nameRegistry.getFlexCardCleanedName(originalCardName);
964
+ }
965
+ else {
966
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['FlexCard', originalCardName])}`);
967
+ component.property.cardName = this.cleanName(originalCardName);
968
+ }
969
+ }
970
+ }
971
+ // Handle omni-flyout elements (missing from migration logic)
972
+ if (component.element === 'omni-flyout' && component.property && component.property.flyoutOmniScript) {
973
+ if (component.property.flyoutOmniScript.osName) {
974
+ const osName = component.property.flyoutOmniScript.osName;
975
+ if (typeof osName === 'string') {
976
+ const parts = osName.split('/');
977
+ if (parts.length >= 2) {
978
+ // Construct full OmniScript name: Type_SubType_Language
979
+ const originalOsRef = parts.join('_');
980
+ if (this.nameRegistry.hasOmniScriptMapping(originalOsRef)) {
981
+ // Registry has mapping - extract cleaned parts and convert back to / format
982
+ const cleanedFullName = this.nameRegistry.getCleanedName(originalOsRef, 'OmniScript');
983
+ const cleanedParts = cleanedFullName.split('_');
984
+ if (cleanedParts.length >= 2) {
985
+ component.property.flyoutOmniScript.osName = cleanedParts.join('/');
986
+ }
987
+ }
988
+ else {
989
+ // No registry mapping - use original fallback approach
990
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['OmniScript', originalOsRef])}`);
991
+ component.property.flyoutOmniScript.osName = parts.map((p) => this.cleanName(p)).join('/');
992
+ }
620
993
  }
621
994
  }
622
995
  }
623
- mappedObject[VlocityCard_1.default.Definition__c] = JSON.stringify(propertySet);
624
996
  }
625
- mappedObject['attributes'] = {
626
- type: CardMigrationTool.OMNIUICARD_NAME,
627
- referenceId: cardRecord['Id'],
628
- };
629
- return mappedObject;
997
+ // Check child components recursively
998
+ if (component.children && Array.isArray(component.children)) {
999
+ for (const child of component.children) {
1000
+ this.updateComponentDependenciesWithRegistry(child);
1001
+ }
1002
+ }
630
1003
  }
631
- fixChildren(children) {
632
- for (let j = 0; j < children.length; j++) {
633
- const child = children[j];
634
- if (child.element === 'childCardPreview') {
635
- child.property.cardName = this.cleanName(child.property.cardName);
1004
+ /**
1005
+ * Update omniType.Name using registry (handles Type/SubType/Language format)
1006
+ */
1007
+ updateOmniTypeNameWithRegistry(omniType) {
1008
+ const originalName = omniType.Name || '';
1009
+ const parts = originalName.split('/');
1010
+ if (parts.length >= 3) {
1011
+ // Construct full OmniScript name: Type_SubType_Language
1012
+ const fullOmniScriptName = `${parts[0]}_${parts[1]}_${parts[2]}`;
1013
+ if (this.nameRegistry.hasOmniScriptMapping(fullOmniScriptName)) {
1014
+ // Registry has mapping - extract cleaned parts and convert back to / format
1015
+ const cleanedFullName = this.nameRegistry.getCleanedName(fullOmniScriptName, 'OmniScript');
1016
+ const cleanedParts = cleanedFullName.split('_');
1017
+ if (cleanedParts.length >= 3) {
1018
+ omniType.Name = cleanedParts.join('/');
1019
+ }
1020
+ }
1021
+ else {
1022
+ // No registry mapping - use original fallback approach
1023
+ logger_1.Logger.logVerbose(`\n${this.messages.getMessage('componentMappingNotFound', ['OmniScript', fullOmniScriptName])}`);
1024
+ omniType.Name = parts.map((p) => this.cleanName(p)).join('/');
636
1025
  }
637
- else if (child.element === 'action') {
638
- if (child.property && child.property.stateAction && child.property.stateAction.omniType) {
639
- const parts = (child.property.stateAction.omniType.Name || '').split('/');
640
- child.property.stateAction.omniType.Name = parts.map((p) => this.cleanName(p)).join('/');
1026
+ }
1027
+ else {
1028
+ // Fallback for unexpected format
1029
+ omniType.Name = parts.map((p) => this.cleanName(p)).join('/');
1030
+ }
1031
+ }
1032
+ /**
1033
+ * Update osName using registry (handles Type/SubType/Language format)
1034
+ */
1035
+ updateOsNameWithRegistry(stateAction, fieldName) {
1036
+ const originalOsName = stateAction[fieldName];
1037
+ const parts = originalOsName.split('/');
1038
+ if (parts.length >= 3) {
1039
+ // Construct full OmniScript name: Type_SubType_Language
1040
+ const fullOmniScriptName = `${parts[0]}_${parts[1]}_${parts[2]}`;
1041
+ if (this.nameRegistry.hasOmniScriptMapping(fullOmniScriptName)) {
1042
+ // Registry has mapping - extract cleaned parts and convert back to / format
1043
+ const cleanedFullName = this.nameRegistry.getCleanedName(fullOmniScriptName, 'OmniScript');
1044
+ const cleanedParts = cleanedFullName.split('_');
1045
+ if (cleanedParts.length >= 3) {
1046
+ stateAction[fieldName] = cleanedParts.join('/');
641
1047
  }
642
1048
  }
643
- if (child.children && Array.isArray(child.children)) {
644
- this.fixChildren(child.children);
1049
+ else {
1050
+ // No registry mapping - use original fallback approach
1051
+ logger_1.Logger.logVerbose(this.messages.getMessage('componentMappingNotFound', ['OmniScript', fullOmniScriptName]));
1052
+ stateAction[fieldName] = parts.map((p) => this.cleanName(p)).join('/');
645
1053
  }
646
1054
  }
1055
+ else {
1056
+ // Fallback for unexpected format
1057
+ stateAction[fieldName] = parts.map((p) => this.cleanName(p)).join('/');
1058
+ }
647
1059
  }
648
1060
  getCardFields() {
649
1061
  return Object.keys(VlocityCard_1.default);
650
1062
  }
1063
+ /**
1064
+ * Check if a FlexCard has dependencies on Angular OmniScripts
1065
+ */
1066
+ hasAngularOmniScriptDependencies(card) {
1067
+ try {
1068
+ const definition = JSON.parse(card[this.namespacePrefix + 'Definition__c'] || '{}');
1069
+ if (definition && definition.states) {
1070
+ for (const state of definition.states) {
1071
+ // Check direct OmniScript references in states
1072
+ if (state.omniscripts && Array.isArray(state.omniscripts)) {
1073
+ for (const os of state.omniscripts) {
1074
+ if (os.type && os.subtype) {
1075
+ const osRef = `${os.type}_${os.subtype}_${os.language || 'English'}`;
1076
+ if (this.nameRegistry.isAngularOmniScript(osRef)) {
1077
+ return true;
1078
+ }
1079
+ }
1080
+ }
1081
+ }
1082
+ // Check OmniScript references in component actions
1083
+ if (state.components) {
1084
+ for (const componentKey in state.components) {
1085
+ if (state.components.hasOwnProperty(componentKey)) {
1086
+ const component = state.components[componentKey];
1087
+ if (this.componentHasAngularOmniScriptDependency(component)) {
1088
+ return true;
1089
+ }
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ }
1096
+ catch (err) {
1097
+ logger_1.Logger.error(`Error checking Angular dependencies for card ${card['Name']}: ${err.message}`);
1098
+ }
1099
+ return false;
1100
+ }
1101
+ /**
1102
+ * Recursively check if a component has Angular Omniscript dependencies
1103
+ */
1104
+ componentHasAngularOmniScriptDependency(component) {
1105
+ // Pattern 1: Handle action elements with actionList (like migration logic)
1106
+ if (component.element === 'action' && component.property && component.property.actionList) {
1107
+ for (const action of component.property.actionList) {
1108
+ if (action.stateAction) {
1109
+ // Case 1: Direct OmniScript reference with type check
1110
+ if (action.stateAction.type === stringContants_1.Constants.OmniScriptComponentName && action.stateAction.omniType) {
1111
+ if (this.checkOmniTypeForAngular(action.stateAction.omniType)) {
1112
+ return true;
1113
+ }
1114
+ }
1115
+ // Case 1b: Direct OmniScript reference without type check (for test compatibility)
1116
+ else if (action.stateAction.omniType && !action.stateAction.type) {
1117
+ if (this.checkOmniTypeForAngular(action.stateAction.omniType)) {
1118
+ return true;
1119
+ }
1120
+ }
1121
+ // Case 2: Flyout OmniScript reference
1122
+ else if (action.stateAction.type === 'Flyout' &&
1123
+ action.stateAction.flyoutType === stringContants_1.Constants.OmniScriptPluralName &&
1124
+ action.stateAction.osName) {
1125
+ if (this.checkOsNameForAngular(action.stateAction.osName)) {
1126
+ return true;
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ // Pattern 2: Handle standard component actions (like migration logic)
1133
+ if (component.actions && Array.isArray(component.actions)) {
1134
+ for (const action of component.actions) {
1135
+ if (action.stateAction && action.stateAction.omniType) {
1136
+ if (this.checkOmniTypeForAngular(action.stateAction.omniType)) {
1137
+ return true;
1138
+ }
1139
+ }
1140
+ }
1141
+ }
1142
+ // Pattern 3: Handle direct stateAction on component property (like migration logic)
1143
+ if (component.property && component.property.stateAction) {
1144
+ if (component.property.stateAction.omniType) {
1145
+ if (this.checkOmniTypeForAngular(component.property.stateAction.omniType)) {
1146
+ return true;
1147
+ }
1148
+ }
1149
+ if (component.property.stateAction.type === 'Flyout' &&
1150
+ component.property.stateAction.flyoutType === 'OmniScripts' &&
1151
+ component.property.stateAction.osName) {
1152
+ if (this.checkOsNameForAngular(component.property.stateAction.osName)) {
1153
+ return true;
1154
+ }
1155
+ }
1156
+ }
1157
+ // Pattern 4: Handle omni-flyout elements (for test compatibility)
1158
+ if (component.element === 'omni-flyout' && component.property && component.property.flyoutOmniScript) {
1159
+ if (component.property.flyoutOmniScript.osName) {
1160
+ if (this.checkOsNameForAngular(component.property.flyoutOmniScript.osName)) {
1161
+ return true;
1162
+ }
1163
+ }
1164
+ }
1165
+ // Recursively check child components
1166
+ if (component.children && Array.isArray(component.children)) {
1167
+ for (const child of component.children) {
1168
+ if (this.componentHasAngularOmniScriptDependency(child)) {
1169
+ return true;
1170
+ }
1171
+ }
1172
+ }
1173
+ return false;
1174
+ }
1175
+ /**
1176
+ * Check if an omniType references an Angular OmniScript
1177
+ * Handles both string format and object with Name property
1178
+ */
1179
+ checkOmniTypeForAngular(omniType) {
1180
+ if (!omniType) {
1181
+ return false;
1182
+ }
1183
+ let omniTypeName;
1184
+ // Handle both string omniType and object with Name property
1185
+ if (typeof omniType === 'string') {
1186
+ omniTypeName = omniType;
1187
+ }
1188
+ else if (omniType.Name && typeof omniType.Name === 'string') {
1189
+ omniTypeName = omniType.Name;
1190
+ }
1191
+ else {
1192
+ return false;
1193
+ }
1194
+ const parts = omniTypeName.split('/');
1195
+ if (parts.length >= 3) {
1196
+ // Construct full OmniScript name: Type_SubType_Language
1197
+ const fullOmniScriptName = `${parts[0]}_${parts[1]}_${parts[2]}`;
1198
+ return this.nameRegistry.isAngularOmniScript(fullOmniScriptName);
1199
+ }
1200
+ return false;
1201
+ }
1202
+ /**
1203
+ * Check if an osName string references an Angular OmniScript
1204
+ * Handles Type/SubType/Language format in string
1205
+ */
1206
+ checkOsNameForAngular(osName) {
1207
+ if (!osName || typeof osName !== 'string') {
1208
+ return false;
1209
+ }
1210
+ const parts = osName.split('/');
1211
+ if (parts.length >= 3) {
1212
+ // Construct full OmniScript name: Type_SubType_Language
1213
+ const fullOmniScriptName = `${parts[0]}_${parts[1]}_${parts[2]}`;
1214
+ return this.nameRegistry.isAngularOmniScript(fullOmniScriptName);
1215
+ }
1216
+ return false;
1217
+ }
651
1218
  }
652
1219
  exports.CardMigrationTool = CardMigrationTool;
653
1220
  CardMigrationTool.VLOCITYCARD_NAME = 'VlocityCard__c';
654
1221
  CardMigrationTool.OMNIUICARD_NAME = 'OmniUiCard';
1222
+ CardMigrationTool.VERSION_PROP = 'Version__c';
655
1223
  //# sourceMappingURL=flexcard.js.map