@salesforce/plugin-omnistudio-migration-tool 2.0.0-rc.4 → 2.0.0-rc.41

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