@salesforce/plugin-omnistudio-migration-tool 2.0.0-rc.6 → 2.0.0-rc.61

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 (252) hide show
  1. package/README.md +165 -73
  2. package/lib/commands/omnistudio/migration/assess.d.ts +23 -15
  3. package/lib/commands/omnistudio/migration/assess.js +250 -89
  4. package/lib/commands/omnistudio/migration/assess.js.map +1 -1
  5. package/lib/commands/omnistudio/migration/clean.d.ts +13 -0
  6. package/lib/commands/omnistudio/migration/clean.js +162 -0
  7. package/lib/commands/omnistudio/migration/clean.js.map +1 -0
  8. package/lib/commands/omnistudio/migration/info.d.ts +10 -16
  9. package/lib/commands/omnistudio/migration/info.js +53 -35
  10. package/lib/commands/omnistudio/migration/info.js.map +1 -1
  11. package/lib/commands/omnistudio/migration/migrate.d.ts +78 -18
  12. package/lib/commands/omnistudio/migration/migrate.js +461 -175
  13. package/lib/commands/omnistudio/migration/migrate.js.map +1 -1
  14. package/lib/error/deploymentErrors.d.ts +15 -0
  15. package/lib/error/deploymentErrors.js +35 -0
  16. package/lib/error/deploymentErrors.js.map +1 -0
  17. package/lib/error/errorInterfaces.d.ts +5 -0
  18. package/lib/error/errorInterfaces.js +9 -1
  19. package/lib/error/errorInterfaces.js.map +1 -1
  20. package/lib/javascripts/reportGeneratorUtility.js +585 -22
  21. package/lib/migration/ApexNamespaceRegistry.d.ts +49 -0
  22. package/lib/migration/ApexNamespaceRegistry.js +130 -0
  23. package/lib/migration/ApexNamespaceRegistry.js.map +1 -0
  24. package/lib/migration/CustomCssRegistry.d.ts +117 -0
  25. package/lib/migration/CustomCssRegistry.js +234 -0
  26. package/lib/migration/CustomCssRegistry.js.map +1 -0
  27. package/lib/migration/NameMappingRegistry.d.ts +134 -0
  28. package/lib/migration/NameMappingRegistry.js +411 -0
  29. package/lib/migration/NameMappingRegistry.js.map +1 -0
  30. package/lib/migration/base.d.ts +8 -6
  31. package/lib/migration/base.js +25 -8
  32. package/lib/migration/base.js.map +1 -1
  33. package/lib/migration/customLabels.d.ts +70 -0
  34. package/lib/migration/customLabels.js +177 -0
  35. package/lib/migration/customLabels.js.map +1 -0
  36. package/lib/migration/dataraptor.d.ts +13 -0
  37. package/lib/migration/dataraptor.js +205 -80
  38. package/lib/migration/dataraptor.js.map +1 -1
  39. package/lib/migration/deployer.d.ts +14 -0
  40. package/lib/migration/deployer.js +105 -0
  41. package/lib/migration/deployer.js.map +1 -0
  42. package/lib/migration/flexcard.d.ts +256 -6
  43. package/lib/migration/flexcard.js +1808 -268
  44. package/lib/migration/flexcard.js.map +1 -1
  45. package/lib/migration/globalautonumber.d.ts +8 -8
  46. package/lib/migration/globalautonumber.js +49 -24
  47. package/lib/migration/globalautonumber.js.map +1 -1
  48. package/lib/migration/interfaces.d.ts +14 -0
  49. package/lib/migration/interfaces.js.map +1 -1
  50. package/lib/migration/metadataobjnamecheck.js.map +1 -1
  51. package/lib/migration/omniscript.d.ts +218 -4
  52. package/lib/migration/omniscript.js +1709 -247
  53. package/lib/migration/omniscript.js.map +1 -1
  54. package/lib/migration/omniscriptInstance.d.ts +90 -0
  55. package/lib/migration/omniscriptInstance.js +755 -0
  56. package/lib/migration/omniscriptInstance.js.map +1 -0
  57. package/lib/migration/postMigrate.d.ts +20 -4
  58. package/lib/migration/postMigrate.js +199 -12
  59. package/lib/migration/postMigrate.js.map +1 -1
  60. package/lib/migration/premigrate.d.ts +51 -0
  61. package/lib/migration/premigrate.js +325 -0
  62. package/lib/migration/premigrate.js.map +1 -0
  63. package/lib/migration/related/ApexMigration.d.ts +3 -0
  64. package/lib/migration/related/ApexMigration.js +222 -56
  65. package/lib/migration/related/ApexMigration.js.map +1 -1
  66. package/lib/migration/related/ExperienceSiteMigration.d.ts +30 -5
  67. package/lib/migration/related/ExperienceSiteMigration.js +263 -73
  68. package/lib/migration/related/ExperienceSiteMigration.js.map +1 -1
  69. package/lib/migration/related/FlexipageMigration.d.ts +5 -5
  70. package/lib/migration/related/FlexipageMigration.js +60 -38
  71. package/lib/migration/related/FlexipageMigration.js.map +1 -1
  72. package/lib/migration/related/LwcMigration.js +45 -26
  73. package/lib/migration/related/LwcMigration.js.map +1 -1
  74. package/lib/migration/related/OmnistudioRelatedObjectMigrationFacade.js +48 -32
  75. package/lib/migration/related/OmnistudioRelatedObjectMigrationFacade.js.map +1 -1
  76. package/lib/styles/reportGenerator.css +241 -16
  77. package/lib/templates/assessmentReport.template +78 -8
  78. package/lib/templates/dashboard.template +86 -57
  79. package/lib/templates/migrationReport.template +151 -0
  80. package/lib/utils/OmnistudioSettingsPrefManager.d.ts +14 -0
  81. package/lib/utils/OmnistudioSettingsPrefManager.js +112 -0
  82. package/lib/utils/OmnistudioSettingsPrefManager.js.map +1 -0
  83. package/lib/utils/XMLUtil.js +2 -1
  84. package/lib/utils/XMLUtil.js.map +1 -1
  85. package/lib/utils/apex/executor/AnonymousApexRunner.d.ts +1 -1
  86. package/lib/utils/apex/parser/apexparser.d.ts +8 -1
  87. package/lib/utils/apex/parser/apexparser.js +79 -13
  88. package/lib/utils/apex/parser/apexparser.js.map +1 -1
  89. package/lib/utils/config/ExistingRecordCleanupService.d.ts +30 -0
  90. package/lib/utils/config/ExistingRecordCleanupService.js +266 -0
  91. package/lib/utils/config/ExistingRecordCleanupService.js.map +1 -0
  92. package/lib/utils/config/OmniStudioMetadataCleanupService.d.ts +36 -0
  93. package/lib/utils/config/OmniStudioMetadataCleanupService.js +123 -0
  94. package/lib/utils/config/OmniStudioMetadataCleanupService.js.map +1 -0
  95. package/lib/utils/config/SpecialCharacterRecordCleanupService.d.ts +17 -0
  96. package/lib/utils/config/SpecialCharacterRecordCleanupService.js +186 -0
  97. package/lib/utils/config/SpecialCharacterRecordCleanupService.js.map +1 -0
  98. package/lib/utils/constants/documentRegistry.d.ts +9 -17
  99. package/lib/utils/constants/documentRegistry.js +9 -17
  100. package/lib/utils/constants/documentRegistry.js.map +1 -1
  101. package/lib/utils/constants/stringContants.d.ts +78 -0
  102. package/lib/utils/constants/stringContants.js +91 -4
  103. package/lib/utils/constants/stringContants.js.map +1 -1
  104. package/lib/utils/customLabels.d.ts +35 -0
  105. package/lib/utils/customLabels.js +100 -0
  106. package/lib/utils/customLabels.js.map +1 -0
  107. package/lib/utils/dataModelService.d.ts +18 -0
  108. package/lib/utils/dataModelService.js +72 -0
  109. package/lib/utils/dataModelService.js.map +1 -0
  110. package/lib/utils/file/fileUtil.d.ts +3 -1
  111. package/lib/utils/file/fileUtil.js +30 -13
  112. package/lib/utils/file/fileUtil.js.map +1 -1
  113. package/lib/utils/flexipage/flexiPageTransformer.js +119 -23
  114. package/lib/utils/flexipage/flexiPageTransformer.js.map +1 -1
  115. package/lib/utils/formula/FormulaUtil.d.ts +1 -1
  116. package/lib/utils/formula/FormulaUtil.js +17 -9
  117. package/lib/utils/formula/FormulaUtil.js.map +1 -1
  118. package/lib/utils/formula/Stack.js.map +1 -1
  119. package/lib/utils/generatePackageXml.d.ts +6 -2
  120. package/lib/utils/generatePackageXml.js +73 -33
  121. package/lib/utils/generatePackageXml.js.map +1 -1
  122. package/lib/utils/index.d.ts +1 -0
  123. package/lib/utils/index.js +1 -0
  124. package/lib/utils/index.js.map +1 -1
  125. package/lib/utils/interfaces.d.ts +69 -8
  126. package/lib/utils/json/jsonutil.js.map +1 -1
  127. package/lib/utils/logger/fileLogger.js +17 -7
  128. package/lib/utils/logger/fileLogger.js.map +1 -1
  129. package/lib/utils/logger.d.ts +3 -3
  130. package/lib/utils/logger.js +10 -6
  131. package/lib/utils/logger.js.map +1 -1
  132. package/lib/utils/logging/debugtimer.js.map +1 -1
  133. package/lib/utils/lwcparser/fileutils/FileDiffUtil.js +30 -22
  134. package/lib/utils/lwcparser/fileutils/FileDiffUtil.js.map +1 -1
  135. package/lib/utils/lwcparser/fileutils/FileProcessorFactory.js.map +1 -1
  136. package/lib/utils/lwcparser/fileutils/HtmlFileProcessor.js.map +1 -1
  137. package/lib/utils/lwcparser/fileutils/JavascriptFileProcessor.js.map +1 -1
  138. package/lib/utils/lwcparser/fileutils/XmlFileProcessor.js.map +1 -1
  139. package/lib/utils/lwcparser/htmlParser/HTMLParser.js +29 -10
  140. package/lib/utils/lwcparser/htmlParser/HTMLParser.js.map +1 -1
  141. package/lib/utils/lwcparser/jsParser/JavaScriptParser.js +29 -11
  142. package/lib/utils/lwcparser/jsParser/JavaScriptParser.js.map +1 -1
  143. package/lib/utils/lwcparser/xmlParser/XmlParser.js +19 -8
  144. package/lib/utils/lwcparser/xmlParser/XmlParser.js.map +1 -1
  145. package/lib/utils/net/index.d.ts +5 -0
  146. package/lib/utils/net/index.js +40 -2
  147. package/lib/utils/net/index.js.map +1 -1
  148. package/lib/utils/omniscriptPackageManager.d.ts +31 -0
  149. package/lib/utils/omniscriptPackageManager.js +215 -0
  150. package/lib/utils/omniscriptPackageManager.js.map +1 -0
  151. package/lib/utils/orgPreferences.d.ts +25 -0
  152. package/lib/utils/orgPreferences.js +124 -8
  153. package/lib/utils/orgPreferences.js.map +1 -1
  154. package/lib/utils/orgUtils/index.d.ts +12 -5
  155. package/lib/utils/orgUtils/index.js +52 -22
  156. package/lib/utils/orgUtils/index.js.map +1 -1
  157. package/lib/utils/projectPathUtil.d.ts +1 -1
  158. package/lib/utils/projectPathUtil.js +27 -10
  159. package/lib/utils/projectPathUtil.js.map +1 -1
  160. package/lib/utils/promptUtil.d.ts +11 -1
  161. package/lib/utils/promptUtil.js +92 -0
  162. package/lib/utils/promptUtil.js.map +1 -1
  163. package/lib/utils/query/index.d.ts +1 -0
  164. package/lib/utils/query/index.js +18 -1
  165. package/lib/utils/query/index.js.map +1 -1
  166. package/lib/utils/recordPrioritization.d.ts +44 -0
  167. package/lib/utils/recordPrioritization.js +69 -0
  168. package/lib/utils/recordPrioritization.js.map +1 -0
  169. package/lib/utils/reportGenerator/reportInterfaces.d.ts +12 -0
  170. package/lib/utils/reportGenerator/reportUtil.d.ts +6 -1
  171. package/lib/utils/reportGenerator/reportUtil.js +22 -7
  172. package/lib/utils/reportGenerator/reportUtil.js.map +1 -1
  173. package/lib/utils/resultsbuilder/ApexAssessmentReporter.d.ts +1 -0
  174. package/lib/utils/resultsbuilder/ApexAssessmentReporter.js +40 -17
  175. package/lib/utils/resultsbuilder/ApexAssessmentReporter.js.map +1 -1
  176. package/lib/utils/resultsbuilder/CustomLabelAssessmentReporter.d.ts +13 -0
  177. package/lib/utils/resultsbuilder/CustomLabelAssessmentReporter.js +179 -0
  178. package/lib/utils/resultsbuilder/CustomLabelAssessmentReporter.js.map +1 -0
  179. package/lib/utils/resultsbuilder/CustomLabelMigrationReporter.d.ts +27 -0
  180. package/lib/utils/resultsbuilder/CustomLabelMigrationReporter.js +262 -0
  181. package/lib/utils/resultsbuilder/CustomLabelMigrationReporter.js.map +1 -0
  182. package/lib/utils/resultsbuilder/DRAssessmentReporter.js +38 -70
  183. package/lib/utils/resultsbuilder/DRAssessmentReporter.js.map +1 -1
  184. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.d.ts +14 -0
  185. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.js +143 -0
  186. package/lib/utils/resultsbuilder/ExperienceSiteAssessmentReporter.js.map +1 -0
  187. package/lib/utils/resultsbuilder/FlexcardAssessmentReporter.js +46 -85
  188. package/lib/utils/resultsbuilder/FlexcardAssessmentReporter.js.map +1 -1
  189. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.d.ts +1 -0
  190. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.js +37 -19
  191. package/lib/utils/resultsbuilder/FlexipageAssessmentReporter.js.map +1 -1
  192. package/lib/utils/resultsbuilder/GlobalAutoNumberAssessmentReporter.js +22 -14
  193. package/lib/utils/resultsbuilder/GlobalAutoNumberAssessmentReporter.js.map +1 -1
  194. package/lib/utils/resultsbuilder/IPAssessmentReporter.js +38 -71
  195. package/lib/utils/resultsbuilder/IPAssessmentReporter.js.map +1 -1
  196. package/lib/utils/resultsbuilder/LWCAssessmentReporter.d.ts +14 -0
  197. package/lib/utils/resultsbuilder/LWCAssessmentReporter.js +143 -139
  198. package/lib/utils/resultsbuilder/LWCAssessmentReporter.js.map +1 -1
  199. package/lib/utils/resultsbuilder/OSAssessmentReporter.js +41 -88
  200. package/lib/utils/resultsbuilder/OSAssessmentReporter.js.map +1 -1
  201. package/lib/utils/resultsbuilder/SaveForLaterAssessmentReporter.d.ts +12 -0
  202. package/lib/utils/resultsbuilder/SaveForLaterAssessmentReporter.js +109 -0
  203. package/lib/utils/resultsbuilder/SaveForLaterAssessmentReporter.js.map +1 -0
  204. package/lib/utils/resultsbuilder/assessmentReporter.d.ts +16 -6
  205. package/lib/utils/resultsbuilder/assessmentReporter.js +96 -152
  206. package/lib/utils/resultsbuilder/assessmentReporter.js.map +1 -1
  207. package/lib/utils/resultsbuilder/helpers/AssessmentReportHelper.d.ts +104 -0
  208. package/lib/utils/resultsbuilder/helpers/AssessmentReportHelper.js +380 -0
  209. package/lib/utils/resultsbuilder/helpers/AssessmentReportHelper.js.map +1 -0
  210. package/lib/utils/resultsbuilder/index.d.ts +37 -1
  211. package/lib/utils/resultsbuilder/index.js +582 -151
  212. package/lib/utils/resultsbuilder/index.js.map +1 -1
  213. package/lib/utils/resultsbuilder/reportingHelper.d.ts +2 -7
  214. package/lib/utils/resultsbuilder/reportingHelper.js +0 -43
  215. package/lib/utils/resultsbuilder/reportingHelper.js.map +1 -1
  216. package/lib/utils/sfcli/project/sfProject.d.ts +29 -0
  217. package/lib/utils/sfcli/project/sfProject.js +220 -2
  218. package/lib/utils/sfcli/project/sfProject.js.map +1 -1
  219. package/lib/utils/shell/cli.js +20 -14
  220. package/lib/utils/shell/cli.js.map +1 -1
  221. package/lib/utils/storageUtil.d.ts +14 -1
  222. package/lib/utils/storageUtil.js +31 -1
  223. package/lib/utils/storageUtil.js.map +1 -1
  224. package/lib/utils/stringUtils.d.ts +24 -0
  225. package/lib/utils/stringUtils.js +76 -9
  226. package/lib/utils/stringUtils.js.map +1 -1
  227. package/lib/utils/templateParser/__tests__/test.js +1 -2
  228. package/lib/utils/templateParser/__tests__/test.js.map +1 -1
  229. package/lib/utils/templateParser/generate.d.ts +1 -1
  230. package/lib/utils/templateParser/generate.js.map +1 -1
  231. package/lib/utils/templateParser/model/elementNode.d.ts +2 -2
  232. package/lib/utils/templateParser/model/elementNode.js +11 -2
  233. package/lib/utils/templateParser/model/elementNode.js.map +1 -1
  234. package/lib/utils/templateParser/model/nodeTypes.js +1 -1
  235. package/lib/utils/templateParser/model/nodeTypes.js.map +1 -1
  236. package/lib/utils/templateParser/util.d.ts +2 -2
  237. package/lib/utils/templateParser/util.js.map +1 -1
  238. package/lib/utils/validatorService.d.ts +14 -0
  239. package/lib/utils/validatorService.js +136 -0
  240. package/lib/utils/validatorService.js.map +1 -0
  241. package/messages/assess.json +220 -103
  242. package/messages/clean.json +40 -0
  243. package/messages/info.json +2 -1
  244. package/messages/migrate.json +314 -102
  245. package/oclif.manifest.json +1 -1
  246. package/package.json +49 -13
  247. package/lib/commands/basecommand.d.ts +0 -8
  248. package/lib/commands/basecommand.js +0 -13
  249. package/lib/commands/basecommand.js.map +0 -1
  250. package/lib/utils/OmniGlobalAutoNumberPrefManager.d.ts +0 -40
  251. package/lib/utils/OmniGlobalAutoNumberPrefManager.js +0 -65
  252. package/lib/utils/OmniGlobalAutoNumberPrefManager.js.map +0 -1
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.OmniscriptPackageManager = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const core_1 = require("@salesforce/core");
40
+ const logger_1 = require("./logger");
41
+ const sfProject_1 = require("./sfcli/project/sfProject");
42
+ core_1.Messages.importMessagesDirectory(__dirname);
43
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'migrate');
44
+ class OmniscriptPackageManager {
45
+ constructor(projectPath, packageConfig, username) {
46
+ this.pollingIntervalMs = 60000; // 60 seconds
47
+ this.maxRetries = 3;
48
+ this.deploymentStartTime = 0;
49
+ this.nodeModulesPath = path.join(projectPath, 'node_modules');
50
+ this.config = packageConfig;
51
+ this.username = username;
52
+ }
53
+ async deployPackageAsync() {
54
+ const packagePath = path.join(this.nodeModulesPath, this.config.packageName);
55
+ if (!fs.existsSync(packagePath)) {
56
+ logger_1.Logger.logVerbose(messages.getMessage('omniscriptPackagePathNotFound', [packagePath]));
57
+ logger_1.Logger.error(messages.getMessage('ensurePackageInstalled', [packagePath]));
58
+ return false;
59
+ }
60
+ logger_1.Logger.log(messages.getMessage('startingOmniscriptPackageDeployment'));
61
+ logger_1.Logger.log(messages.getMessage('waitingForDeploymentCompletion'));
62
+ let currentAttempt = 1;
63
+ while (currentAttempt <= this.maxRetries) {
64
+ try {
65
+ const success = await this.attemptDeployment(packagePath, currentAttempt);
66
+ if (success) {
67
+ return true;
68
+ }
69
+ }
70
+ catch (error) {
71
+ const errorMessage = String(error);
72
+ logger_1.Logger.logVerbose(messages.getMessage('omniscriptPackageDeploymentError', [errorMessage]));
73
+ if (currentAttempt < this.maxRetries) {
74
+ const shouldRetry = this.shouldRetryDeployment(errorMessage);
75
+ if (shouldRetry) {
76
+ logger_1.Logger.log(messages.getMessage('retryingDeployment', [errorMessage, currentAttempt + 1, this.maxRetries]));
77
+ currentAttempt++;
78
+ // Wait before retrying
79
+ await this.sleep(5000);
80
+ continue;
81
+ }
82
+ }
83
+ logger_1.Logger.error(messages.getMessage('packageDeploymentFailedWithError', [currentAttempt, errorMessage]));
84
+ throw error;
85
+ }
86
+ currentAttempt++;
87
+ }
88
+ logger_1.Logger.error(messages.getMessage('maxRetryAttemptsExceeded', [this.maxRetries]));
89
+ logger_1.Logger.error(messages.getMessage('deploymentRetryExhausted', [this.maxRetries]));
90
+ return false;
91
+ }
92
+ async attemptDeployment(packagePath, attemptNumber) {
93
+ this.deploymentStartTime = Date.now();
94
+ // Start async deployment
95
+ const deploymentId = sfProject_1.sfProject.deployPackageAsync(packagePath, this.username);
96
+ // Poll for completion
97
+ return await this.pollDeploymentStatus(deploymentId, attemptNumber);
98
+ }
99
+ async pollDeploymentStatus(deploymentId, attemptNumber) {
100
+ let pollAttempt = 1;
101
+ const maxPollAttempts = 20; // 20 minutes max with 60s intervals
102
+ while (pollAttempt <= maxPollAttempts) {
103
+ logger_1.Logger.logVerbose(messages.getMessage('pollingDeploymentStatus', [deploymentId, pollAttempt, maxPollAttempts]));
104
+ let status;
105
+ try {
106
+ status = sfProject_1.sfProject.checkDeploymentStatus(deploymentId, this.username);
107
+ }
108
+ catch (networkError) {
109
+ // Network/API error during status check - retry the status check
110
+ logger_1.Logger.logVerbose(messages.getMessage('deploymentStatusCheckFailed', [String(networkError)]));
111
+ pollAttempt++;
112
+ if (pollAttempt <= maxPollAttempts) {
113
+ logger_1.Logger.logVerbose(`Retrying status check in ${this.pollingIntervalMs / 1000}s...`);
114
+ await this.sleep(this.pollingIntervalMs);
115
+ continue;
116
+ }
117
+ else {
118
+ // Exhausted status check retries
119
+ throw new Error(messages.getMessage('deploymentStatusCheckExhausted', [maxPollAttempts, String(networkError)]));
120
+ }
121
+ }
122
+ // Log progress update
123
+ this.logProgressUpdate(status, attemptNumber);
124
+ // Handle deployment completion states - these exit polling immediately
125
+ if (status.status === 'Succeeded') {
126
+ const totalTime = this.formatElapsedTime(Date.now() - this.deploymentStartTime);
127
+ logger_1.Logger.log(messages.getMessage('deploymentCompleted', [totalTime]));
128
+ return true;
129
+ }
130
+ if (status.status === 'Failed') {
131
+ logger_1.Logger.error(messages.getMessage('deploymentFailed', [status.errorMessage || 'Unknown error']));
132
+ if (status.isRetryable) {
133
+ throw new Error(status.retryReason || status.errorMessage || 'Deployment failed');
134
+ }
135
+ else {
136
+ logger_1.Logger.error(messages.getMessage('deploymentNonRetryableError', [status.errorMessage]));
137
+ throw new Error(status.errorMessage || 'Deployment failed');
138
+ }
139
+ }
140
+ if (status.status === 'Canceled' || status.status === 'Canceling') {
141
+ logger_1.Logger.error(messages.getMessage('deploymentCancelled'));
142
+ throw new Error('Deployment was cancelled');
143
+ }
144
+ // Still in progress - wait and continue polling
145
+ await this.sleep(this.pollingIntervalMs);
146
+ pollAttempt++;
147
+ }
148
+ // Polling timeout reached
149
+ const timeoutMinutes = (maxPollAttempts * this.pollingIntervalMs) / 60000;
150
+ logger_1.Logger.error(messages.getMessage('deploymentTimedOut', [timeoutMinutes]));
151
+ throw new Error(`Deployment timed out after ${timeoutMinutes} minutes`);
152
+ }
153
+ logProgressUpdate(status, attemptNumber) {
154
+ const elapsedTime = this.formatElapsedTime(Date.now() - this.deploymentStartTime);
155
+ const estimatedRemaining = this.calculateEstimatedTime(status);
156
+ // Log status update
157
+ logger_1.Logger.log(messages.getMessage('deploymentStatusUpdate', [status.id, status.status, status.completionPercentage]));
158
+ // Log progress details
159
+ logger_1.Logger.log(messages.getMessage('deploymentProgressDetails', [
160
+ status.completedComponentsCount,
161
+ status.totalComponentsCount,
162
+ status.errorCount,
163
+ status.warningCount,
164
+ ]));
165
+ // Log timing information
166
+ logger_1.Logger.log(messages.getMessage('deploymentInProgress', [elapsedTime, estimatedRemaining]));
167
+ // Log verbose details for debugging
168
+ logger_1.Logger.logVerbose(`Attempt ${attemptNumber}/${this.maxRetries}, Poll status: ${status.status}, ` +
169
+ `Progress: ${status.completionPercentage}%, ` +
170
+ `Components: ${status.completedComponentsCount}/${status.totalComponentsCount}`);
171
+ }
172
+ calculateEstimatedTime(status) {
173
+ if (status.completionPercentage === 0) {
174
+ return 'Calculating...';
175
+ }
176
+ const elapsedMs = Date.now() - this.deploymentStartTime;
177
+ const remainingPercentage = 100 - status.completionPercentage;
178
+ const estimatedRemainingMs = (elapsedMs / status.completionPercentage) * remainingPercentage;
179
+ return this.formatElapsedTime(estimatedRemainingMs);
180
+ }
181
+ formatElapsedTime(milliseconds) {
182
+ const seconds = Math.floor(milliseconds / 1000);
183
+ const minutes = Math.floor(seconds / 60);
184
+ const remainingSeconds = seconds % 60;
185
+ if (minutes > 0) {
186
+ return `${minutes}m ${remainingSeconds}s`;
187
+ }
188
+ return `${seconds}s`;
189
+ }
190
+ shouldRetryDeployment(errorMessage) {
191
+ const message = errorMessage.toLowerCase();
192
+ // Retry on timeout or temporary errors
193
+ if (message.includes('timeout') ||
194
+ message.includes('temporarily unavailable') ||
195
+ message.includes('connection') ||
196
+ message.includes('network')) {
197
+ return true;
198
+ }
199
+ // Don't retry on validation or permission errors
200
+ if (message.includes('validation') ||
201
+ message.includes('permission') ||
202
+ message.includes('invalid') ||
203
+ message.includes('unauthorized') ||
204
+ message.includes('limit')) {
205
+ return false;
206
+ }
207
+ // Default to retry for unknown errors
208
+ return false;
209
+ }
210
+ async sleep(ms) {
211
+ return new Promise((resolve) => setTimeout(resolve, ms));
212
+ }
213
+ }
214
+ exports.OmniscriptPackageManager = OmniscriptPackageManager;
215
+ //# sourceMappingURL=omniscriptPackageManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omniscriptPackageManager.js","sourceRoot":"","sources":["../../src/utils/omniscriptPackageManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA4C;AAC5C,qCAAkC;AAClC,yDAAwE;AAExE,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,8CAA8C,EAAE,SAAS,CAAC,CAAC;AAiBlG,MAAa,wBAAwB;IAQnC,YAAmB,WAAmB,EAAE,aAAsC,EAAE,QAAgB;QAJ/E,sBAAiB,GAAG,KAAK,CAAC,CAAC,aAAa;QACxC,eAAU,GAAG,CAAC,CAAC;QACxB,wBAAmB,GAAG,CAAC,CAAC;QAG9B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAE7E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,eAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,+BAA+B,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACvF,eAAM,CAAC,KAAK,CAAC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
27
  */
28
28
  static enableOmniPreferences(connection: Connection): Promise<void>;
29
+ static checkDRVersioning(connection: Connection): Promise<boolean>;
29
30
  /**
30
31
  * Checks which rollback flags are enabled in OmniInteractionConfig
31
32
  *
@@ -48,6 +49,7 @@ export declare class OrgPreferences {
48
49
  * @returns {Promise<boolean>} True if the ExperienceBundle Metadata API is enabled, false otherwise
49
50
  */
50
51
  static isExperienceBundleMetadataAPIEnabled(connection: Connection): Promise<boolean>;
52
+ static toggleExperienceBundleMetadataAPI(connection: Connection, enable: boolean): Promise<void>;
51
53
  /**
52
54
  * Sets the ExperienceBundle Metadata API setting in Digital Experience Settings
53
55
  *
@@ -59,4 +61,27 @@ export declare class OrgPreferences {
59
61
  * @returns {Promise<boolean>} True if successfully set, false otherwise
60
62
  */
61
63
  static setExperienceBundleMetadataAPI(connection: Connection, enable: boolean): Promise<boolean>;
64
+ /**
65
+ * Checks if OmniStudio designers are already using the standard data model for the specific package.
66
+ *
67
+ * @public
68
+ * @static
69
+ * @async
70
+ * @param {Connection} connection - Salesforce connection instance
71
+ * @param {string} namespaceToModify - The namespace to check for standard designer
72
+ * @throws {Error} If checking the standard designer status fails
73
+ * @returns {Promise<boolean>} True if standard designer is enabled, false otherwise
74
+ */
75
+ static isStandardDesignerEnabled(connection: Connection, namespaceToModify: string): Promise<boolean>;
76
+ static isFoundationPackage(connection: Connection): Promise<boolean>;
77
+ /**
78
+ * Checks if an error is an INVALID_TYPE error for OmniInteractionConfig
79
+ * This indicates that the org doesn't have OmniStudio permissions enabled
80
+ *
81
+ * @private
82
+ * @static
83
+ * @param {unknown} error - The error to check
84
+ * @returns {boolean} True if the error is an INVALID_TYPE error for OmniInteractionConfig
85
+ */
86
+ private static isOmniInteractionConfigInvalidTypeError;
62
87
  }
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrgPreferences = void 0;
4
+ const core_1 = require("@salesforce/core");
4
5
  const logger_1 = require("./logger");
6
+ const stringContants_1 = require("./constants/stringContants");
7
+ // Load messages
8
+ core_1.Messages.importMessagesDirectory(__dirname);
9
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'migrate');
5
10
  /**
6
11
  * Class to manage OmniStudio organization preferences
7
12
  *
@@ -21,6 +26,7 @@ class OrgPreferences {
21
26
  */
22
27
  static async enableOmniPreferences(connection) {
23
28
  try {
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
24
30
  await connection.metadata.update('OmniStudioSettings', [
25
31
  {
26
32
  fullName: 'OmniStudio',
@@ -32,6 +38,20 @@ class OrgPreferences {
32
38
  throw new Error(`Failed to enable disableRollbackFlagsPref: ${error instanceof Error ? error.message : String(error)}`);
33
39
  }
34
40
  }
41
+ static async checkDRVersioning(connection) {
42
+ try {
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
44
+ const result = await connection.metadata.read('OmniStudioSettings', [
45
+ 'OmniStudioDrVersionOrgPreference',
46
+ ]);
47
+ logger_1.Logger.captureVerboseData('DR version response', result);
48
+ const metadata = (Array.isArray(result) ? result[0] : result);
49
+ return (metadata === null || metadata === void 0 ? void 0 : metadata.enableOmniStudioDrVersion) === 'true';
50
+ }
51
+ catch (error) {
52
+ throw new Error(`Failed to read DR version: ${error instanceof Error ? error.message : String(error)}`);
53
+ }
54
+ }
35
55
  /**
36
56
  * Checks which rollback flags are enabled in OmniInteractionConfig
37
57
  *
@@ -54,6 +74,12 @@ class OrgPreferences {
54
74
  return enabledFlags;
55
75
  }
56
76
  catch (error) {
77
+ // Check if error is INVALID_TYPE for OmniInteractionConfig (indicating no OmniStudio permissions)
78
+ if (this.isOmniInteractionConfigInvalidTypeError(error)) {
79
+ logger_1.Logger.warn(messages.getMessage('omniStudioPermissionsNotEnabled'));
80
+ return []; // Return empty array instead of throwing
81
+ }
82
+ // Generic error handling for other errors
57
83
  throw new Error(`Failed to check rollback flags: ${error instanceof Error ? error.message : String(error)}`);
58
84
  }
59
85
  }
@@ -70,7 +96,7 @@ class OrgPreferences {
70
96
  static async isExperienceBundleMetadataAPIEnabled(connection) {
71
97
  try {
72
98
  const result = await connection.metadata.read('ExperienceBundleSettings', ['ExperienceBundle']);
73
- logger_1.Logger.logVerbose(`The api is returning ${JSON.stringify(result)}`);
99
+ logger_1.Logger.logVerbose(`ExperienceBundle metadata API response: ${JSON.stringify(result)}`);
74
100
  // Check if the result is valid and contains the expected property
75
101
  let settings = {
76
102
  fullName: '',
@@ -95,10 +121,18 @@ class OrgPreferences {
95
121
  }
96
122
  catch (error) {
97
123
  // If the metadata type doesn't exist or there's an error, assume it's disabled
98
- logger_1.Logger.error('Unable to check ExperienceBundle Metadata API status');
124
+ logger_1.Logger.error('We couldn’t check the ExperienceBundle metadata API status.');
99
125
  return false;
100
126
  }
101
127
  }
128
+ static async toggleExperienceBundleMetadataAPI(connection, enable) {
129
+ await connection.metadata.update('ExperienceBundleSettings', [
130
+ {
131
+ fullName: 'ExperienceBundle',
132
+ enableExperienceBundleMetadata: enable,
133
+ },
134
+ ]);
135
+ }
102
136
  /**
103
137
  * Sets the ExperienceBundle Metadata API setting in Digital Experience Settings
104
138
  *
@@ -112,12 +146,7 @@ class OrgPreferences {
112
146
  static async setExperienceBundleMetadataAPI(connection, enable) {
113
147
  try {
114
148
  // Enable the setting
115
- await connection.metadata.update('ExperienceBundleSettings', [
116
- {
117
- fullName: 'ExperienceBundle',
118
- enableExperienceBundleMetadata: enable,
119
- },
120
- ]);
149
+ await OrgPreferences.toggleExperienceBundleMetadataAPI(connection, enable);
121
150
  logger_1.Logger.logVerbose(`Successfully set the experienceBundleMetadata API to ${enable}`);
122
151
  return true;
123
152
  }
@@ -126,6 +155,93 @@ class OrgPreferences {
126
155
  return false;
127
156
  }
128
157
  }
158
+ /**
159
+ * Checks if OmniStudio designers are already using the standard data model for the specific package.
160
+ *
161
+ * @public
162
+ * @static
163
+ * @async
164
+ * @param {Connection} connection - Salesforce connection instance
165
+ * @param {string} namespaceToModify - The namespace to check for standard designer
166
+ * @throws {Error} If checking the standard designer status fails
167
+ * @returns {Promise<boolean>} True if standard designer is enabled, false otherwise
168
+ */
169
+ static async isStandardDesignerEnabled(connection, namespaceToModify) {
170
+ try {
171
+ const query = `SELECT DeveloperName, Value FROM OmniInteractionConfig
172
+ WHERE DeveloperName IN ('TheFirstInstalledOmniPackage', 'InstalledIndustryPackage')`;
173
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
174
+ const result = await connection.query(query);
175
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
176
+ if ((result === null || result === void 0 ? void 0 : result.totalSize) > 0) {
177
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
178
+ const records = result.records;
179
+ for (const record of records) {
180
+ if (record.Value === namespaceToModify) {
181
+ return true;
182
+ }
183
+ }
184
+ return false;
185
+ }
186
+ else {
187
+ return false;
188
+ }
189
+ }
190
+ catch (error) {
191
+ // Check if error is INVALID_TYPE for OmniInteractionConfig (indicating no OmniStudio permissions)
192
+ if (this.isOmniInteractionConfigInvalidTypeError(error)) {
193
+ logger_1.Logger.warn(messages.getMessage('omniStudioPermissionsNotEnabled'));
194
+ return false; // Fall back to use case 1 since the org doesn't have OmniStudio permissions enabled
195
+ }
196
+ // Generic error handling for other errors
197
+ const errMsg = error instanceof Error ? error.message : String(error);
198
+ logger_1.Logger.error(`Error checking standard designer for namespace ${namespaceToModify}: ${errMsg}`);
199
+ return false;
200
+ }
201
+ }
202
+ static async isFoundationPackage(connection) {
203
+ try {
204
+ const query = `SELECT DeveloperName, Value FROM OmniInteractionConfig
205
+ WHERE DeveloperName = 'TheFirstInstalledOmniPackage'`;
206
+ const result = await connection.query(query);
207
+ if ((result === null || result === void 0 ? void 0 : result.totalSize) === 1) {
208
+ const records = result.records;
209
+ if (records[0].Value === stringContants_1.Constants.FoundationPackageName) {
210
+ return true;
211
+ }
212
+ }
213
+ return false;
214
+ }
215
+ catch (error) {
216
+ // Check if error is INVALID_TYPE for OmniInteractionConfig (indicating no OmniStudio permissions)
217
+ if (this.isOmniInteractionConfigInvalidTypeError(error)) {
218
+ logger_1.Logger.warn(messages.getMessage('omniStudioPermissionsNotEnabled'));
219
+ return false; // Fall back to use case 1 since the org doesn't have OmniStudio permissions enabled
220
+ }
221
+ // Generic error handling for other errors
222
+ const errMsg = error instanceof Error ? error.message : String(error);
223
+ logger_1.Logger.error(`Error checking foundation package : ${errMsg}`);
224
+ return false;
225
+ }
226
+ }
227
+ /**
228
+ * Checks if an error is an INVALID_TYPE error for OmniInteractionConfig
229
+ * This indicates that the org doesn't have OmniStudio permissions enabled
230
+ *
231
+ * @private
232
+ * @static
233
+ * @param {unknown} error - The error to check
234
+ * @returns {boolean} True if the error is an INVALID_TYPE error for OmniInteractionConfig
235
+ */
236
+ static isOmniInteractionConfigInvalidTypeError(error) {
237
+ return (error !== null &&
238
+ error !== undefined &&
239
+ typeof error === 'object' &&
240
+ 'errorCode' in error &&
241
+ error.errorCode === 'INVALID_TYPE' &&
242
+ 'message' in error &&
243
+ String(error.message).includes('OmniInteractionConfig'));
244
+ }
129
245
  }
130
246
  exports.OrgPreferences = OrgPreferences;
131
247
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"orgPreferences.js","sourceRoot":"","sources":["../../src/utils/orgPreferences.ts"],"names":[],"mappings":";;;AAOA,qCAAkC;AAElC;;;;;GAKG;AACH,MAAa,cAAc;IAWzB;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAsB;QAC9D,IAAI;YACF,MAAM,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,oBAAoB,EAAE;gBACrD;oBACE,QAAQ,EAAE,YAAY;oBACtB,wBAAwB,EAAE,IAAI;iBACD;aAChC,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CACb,8CAA8C,KA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AM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,eAAM,CAAC,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACK,MAAM,CAAC,uCAAuC,CAAC,KAAc;QACnE,OAAO,CACL,KAAK,KAAK,IAAI;YACd,KAAK,KAAK,SAAS;YACnB,OAAO,KAAK,KAAK,QAAQ;YACzB,WAAW,IAAI,KAAK;YACnB,KAAgC,CAAC,SAAS,KAAK,cAAc;YAC9D,SAAS,IAAI,KAAK;YAClB,MAAM,CAAE,KAA8B,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAClF,CAAC;IACJ,CAAC;;AAlQH,wCAmQC;AAlQC;;;;;;;GAOG;AACqB,6BAAc,GAAa,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC"}
@@ -10,16 +10,14 @@ export interface OmnistudioOrgDetails {
10
10
  dataModel: string;
11
11
  hasValidNamespace: boolean;
12
12
  rollbackFlags?: string[];
13
+ isFoundationPackage: boolean;
14
+ isOmnistudioMetadataAPIEnabled: boolean;
13
15
  }
14
16
  export interface PackageDetail {
15
17
  version: string;
16
18
  namespace: string;
17
19
  }
18
20
  export declare class OrgUtils {
19
- /**
20
- * Skip the 'omnistudio' namespace because it belongs to the foundation package,
21
- * which already works with the standard model and does not need migration.
22
- * */
23
21
  private static readonly namespaces;
24
22
  private static readonly fields;
25
23
  private static readonly objectName;
@@ -27,18 +25,27 @@ export declare class OrgUtils {
27
25
  private static readonly orgObjectName;
28
26
  private static readonly standardDataModel;
29
27
  private static readonly customDataModel;
28
+ private static readonly omnistudioFoundationPackage;
29
+ private static readonly vlocityIndustriesManagedPackage;
30
30
  /**
31
31
  * Fetches package details (version and namespace) for specific installed packages.
32
32
  *
33
33
  * @param connection - Salesforce connection object
34
34
  * @returns Promise resolving to an array of PackageDetail objects
35
35
  */
36
- static getOrgDetails(connection: Connection, namespace: string): Promise<OmnistudioOrgDetails>;
36
+ static getOrgDetails(connection: Connection): Promise<OmnistudioOrgDetails>;
37
37
  /** *
38
38
  * @param connection Salesforce connection object
39
39
  * @param namespace namespace of the org which is required to hit the apex rest resource.
40
40
  * @returns
41
41
  */
42
42
  static isOmniStudioOrgPermissionEnabled(connection: Connection, namespace: string): Promise<boolean>;
43
+ /**
44
+ * Checks if the org has Omnistudio Metadata API enabled
45
+ * @param connection
46
+ * @param namespace
47
+ * @returns
48
+ */
49
+ static isOmnistudioMetadataAPIEnabled(connection: Connection, namespace: string): Promise<boolean>;
43
50
  }
44
51
  export {};
@@ -5,6 +5,9 @@ exports.OrgUtils = void 0;
5
5
  const core_1 = require("@salesforce/core");
6
6
  const query_1 = require("../query");
7
7
  const logger_1 = require("../logger");
8
+ const orgPreferences_1 = require("../orgPreferences");
9
+ const OmnistudioSettingsPrefManager_1 = require("../OmnistudioSettingsPrefManager");
10
+ const stringContants_1 = require("../constants/stringContants");
8
11
  // Load messages
9
12
  const messages = core_1.Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'migrate');
10
13
  class OrgUtils {
@@ -14,7 +17,7 @@ class OrgUtils {
14
17
  * @param connection - Salesforce connection object
15
18
  * @returns Promise resolving to an array of PackageDetail objects
16
19
  */
17
- static async getOrgDetails(connection, namespace) {
20
+ static async getOrgDetails(connection) {
18
21
  // Query all installed packages and cast the result to InstalledPackage[]
19
22
  const allInstalledPackages = (await query_1.QueryTools.queryAll(connection, '', this.objectName, this.fields));
20
23
  let hasValidNamespace = true;
@@ -23,20 +26,10 @@ class OrgUtils {
23
26
  version: '',
24
27
  namespace: '',
25
28
  };
26
- for (const pkg of allInstalledPackages) {
27
- if (namespace && namespace === pkg.NamespacePrefix) {
28
- packageDetails.version = `${pkg.MajorVersion}.${pkg.MinorVersion}`;
29
- packageDetails.namespace = pkg.NamespacePrefix;
30
- break;
31
- }
32
- }
33
29
  const installedOmniPackages = [];
34
- if (packageDetails.namespace === '') {
35
- hasValidNamespace = false;
36
- for (const pkg of allInstalledPackages) {
37
- if ((namespace && namespace === pkg.NamespacePrefix) || this.namespaces.has(pkg.NamespacePrefix)) {
38
- installedOmniPackages.push(pkg);
39
- }
30
+ for (const pkg of allInstalledPackages) {
31
+ if (this.namespaces.has(pkg.NamespacePrefix)) {
32
+ installedOmniPackages.push(pkg);
40
33
  }
41
34
  }
42
35
  // Handle multiple packages by prompting user to select one
@@ -69,14 +62,36 @@ class OrgUtils {
69
62
  packageDetails.version = `${pkg.MajorVersion}.${pkg.MinorVersion}`;
70
63
  packageDetails.namespace = pkg.NamespacePrefix;
71
64
  }
65
+ else {
66
+ // return to validate the org information
67
+ return {
68
+ packageDetails: undefined,
69
+ omniStudioOrgPermissionEnabled: false,
70
+ orgDetails: orgDetails[0],
71
+ dataModel: undefined,
72
+ hasValidNamespace: false,
73
+ isFoundationPackage: false,
74
+ isOmnistudioMetadataAPIEnabled: false,
75
+ };
76
+ }
72
77
  //Execute apex rest resource to get omnistudio org permission
73
78
  const omniStudioOrgPermissionEnabled = await this.isOmniStudioOrgPermissionEnabled(connection, packageDetails.namespace);
79
+ const isFoundationPackage = await orgPreferences_1.OrgPreferences.isFoundationPackage(connection);
80
+ const isOmnistudioMetadataAPIEnabled = await this.isOmnistudioMetadataAPIEnabled(connection, packageDetails.namespace);
81
+ const orgDataModel = omniStudioOrgPermissionEnabled ? this.standardDataModel : this.customDataModel;
82
+ const orgPackageType = isFoundationPackage
83
+ ? this.omnistudioFoundationPackage
84
+ : this.vlocityIndustriesManagedPackage;
85
+ const isOmnistudioMetadataOn = isOmnistudioMetadataAPIEnabled ? stringContants_1.Constants.On : stringContants_1.Constants.Off;
86
+ logger_1.Logger.log(messages.getMessage('orgUsecaseDetails', [orgDataModel.toLowerCase(), orgPackageType, isOmnistudioMetadataOn]));
74
87
  return {
75
88
  packageDetails: packageDetails,
76
89
  omniStudioOrgPermissionEnabled: omniStudioOrgPermissionEnabled,
77
90
  orgDetails: orgDetails[0],
78
91
  dataModel: omniStudioOrgPermissionEnabled ? this.standardDataModel : this.customDataModel,
79
92
  hasValidNamespace: hasValidNamespace,
93
+ isFoundationPackage: isFoundationPackage,
94
+ isOmnistudioMetadataAPIEnabled: isOmnistudioMetadataAPIEnabled,
80
95
  };
81
96
  }
82
97
  /** *
@@ -89,19 +104,32 @@ class OrgUtils {
89
104
  return await connection.apex.get('/' + namespace + '/v1/orgPermission');
90
105
  }
91
106
  catch (e) {
92
- // Returning false as a fallback when the endpoint is not found.
93
- // As part of the 256 MVP, we don't want to block the migration just because the endpoint is missing.
94
- return !(e.errorCode === 'NOT_FOUND');
107
+ // Any error in the apex mechanism will fallback to check the standard designer status
108
+ return await orgPreferences_1.OrgPreferences.isStandardDesignerEnabled(connection, namespace);
109
+ }
110
+ }
111
+ /**
112
+ * Checks if the org has Omnistudio Metadata API enabled
113
+ * @param connection
114
+ * @param namespace
115
+ * @returns
116
+ */
117
+ static async isOmnistudioMetadataAPIEnabled(connection, namespace) {
118
+ try {
119
+ const omniStudioSettingsPrefManager = new OmnistudioSettingsPrefManager_1.OmnistudioSettingsPrefManager(connection, messages);
120
+ // Run both async operations in parallel
121
+ const isOmniStudioSettingsMetadataEnabled = await Promise.resolve(omniStudioSettingsPrefManager.isOmniStudioSettingsMetadataEnabled());
122
+ return isOmniStudioSettingsMetadataEnabled;
123
+ }
124
+ catch (error) {
125
+ logger_1.Logger.error(`Error checking org Omnistudio metadata API status`);
126
+ return false;
95
127
  }
96
- return true;
97
128
  }
98
129
  }
99
130
  exports.OrgUtils = OrgUtils;
100
- /**
101
- * Skip the 'omnistudio' namespace because it belongs to the foundation package,
102
- * which already works with the standard model and does not need migration.
103
- * */
104
131
  OrgUtils.namespaces = new Set([
132
+ 'omnistudio', // Adding now as this will also be supported
105
133
  'as_dev_01',
106
134
  'as_dev_02',
107
135
  'as_dev_03',
@@ -339,4 +367,6 @@ OrgUtils.orgFields = ['Name'];
339
367
  OrgUtils.orgObjectName = 'Organization';
340
368
  OrgUtils.standardDataModel = 'Standard';
341
369
  OrgUtils.customDataModel = 'Custom';
370
+ OrgUtils.omnistudioFoundationPackage = 'Omnistudio Foundation Package';
371
+ OrgUtils.vlocityIndustriesManagedPackage = 'Vlocity Industries managed package';
342
372
  //# sourceMappingURL=index.js.map