@e-llm-studio/instant-learning 1.3.6 → 1.3.8

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 (58) hide show
  1. package/dist/ILMarketplaceWrapper.js +16 -11
  2. package/dist/ILMarketplaceWrapper.js.map +1 -1
  3. package/dist/cjs/ILMarketplaceWrapper.js +16 -11
  4. package/dist/cjs/ILMarketplaceWrapper.js.map +1 -1
  5. package/dist/cjs/features/IL-OTJ/ILOTJ.js +1 -1
  6. package/dist/cjs/features/IL-OTJ/ILOTJ.js.map +1 -1
  7. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js +220 -0
  8. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js.map +1 -0
  9. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js +12 -0
  10. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js.map +1 -0
  11. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js +188 -178
  12. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  13. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.module.css.js +2 -2
  14. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-constants.js +69 -0
  15. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-constants.js.map +1 -0
  16. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js +62 -1
  17. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  18. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +23 -7
  19. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  20. package/dist/cjs/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js +7 -4
  21. package/dist/cjs/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js.map +1 -1
  22. package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -4
  23. package/dist/cjs/features/LearningManagement/LearningManagement.js.map +1 -1
  24. package/dist/features/IL-OTJ/ILOTJ.js +1 -1
  25. package/dist/features/IL-OTJ/ILOTJ.js.map +1 -1
  26. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js +216 -0
  27. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js.map +1 -0
  28. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js +8 -0
  29. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js.map +1 -0
  30. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js +186 -172
  31. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  32. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.module.css.js +2 -2
  33. package/dist/features/IL-marketplace/PromoteFlow/promote-constants.js +51 -0
  34. package/dist/features/IL-marketplace/PromoteFlow/promote-constants.js.map +1 -0
  35. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js +60 -2
  36. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  37. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +23 -8
  38. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  39. package/dist/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js +7 -4
  40. package/dist/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js.map +1 -1
  41. package/dist/features/LearningManagement/LearningManagement.js +1 -4
  42. package/dist/features/LearningManagement/LearningManagement.js.map +1 -1
  43. package/dist/types/src/ILMarketplaceWrapper.d.ts +2 -2
  44. package/dist/types/src/ILMarketplaceWrapper.d.ts.map +1 -1
  45. package/dist/types/src/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.d.ts +9 -0
  46. package/dist/types/src/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.d.ts.map +1 -0
  47. package/dist/types/src/features/IL-marketplace/PromoteFlow/PromoteFlow.d.ts.map +1 -1
  48. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-constants.d.ts +23 -0
  49. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-constants.d.ts.map +1 -0
  50. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts +4 -1
  51. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts.map +1 -1
  52. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts +56 -2
  53. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts.map +1 -1
  54. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts +3 -2
  55. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts.map +1 -1
  56. package/dist/types/src/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.d.ts.map +1 -1
  57. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  58. package/package.json +5 -5
@@ -4,65 +4,47 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
- var Tooltip = require('@mui/material/Tooltip');
8
- var styles = require('@mui/material/styles');
9
7
  var lucideReact = require('lucide-react');
10
8
  var utils = require('../utils.js');
11
9
  var EnvironmentConfigurationModal = require('./EnvironmentConfigurationModal.js');
10
+ var PreflightDetailsPage = require('./PreflightDetailsPage.js');
11
+ var promoteConstants = require('./promote-constants.js');
12
12
  var promoteFlow_api = require('./promote-flow.api.js');
13
13
  var promoteFlow_store = require('./promote-flow.store.js');
14
14
  var promoteFlow_utils = require('./promote-flow.utils.js');
15
15
  var PromoteFlow_module = require('./PromoteFlow.module.css.js');
16
16
 
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
20
-
21
- const StyledPromoteTooltip = styles.styled(({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(Tooltip__default["default"], { ...props, classes: { popper: className } }))(() => ({
22
- [`& .${Tooltip.tooltipClasses.tooltip}`]: {
23
- backgroundColor: "#161616cf",
24
- color: "#ffffff",
25
- fontSize: "12px",
26
- padding: "7px 11px",
27
- borderRadius: 6,
28
- maxWidth: 250,
29
- textAlign: "center",
30
- whiteSpace: "normal",
31
- wordBreak: "break-word",
32
- lineHeight: 1.5
33
- },
34
- [`& .${Tooltip.tooltipClasses.arrow}`]: {
35
- color: "#000000"
36
- }
37
- }));
38
- const ACCORDIONS = [
39
- {
40
- id: "overview",
41
- title: "Overview"
42
- },
43
- {
44
- id: "history",
45
- title: "Promotion History",
46
- comingSoon: false
47
- },
48
- {
49
- id: "database",
50
- title: "Database Details",
51
- comingSoon: false
52
- }
53
- // {
54
- // id: 'knowledgebase',
55
- // title: 'Knowledgebase Details',
56
- // comingSoon: true,
57
- // },
58
- ];
17
+ const isTenantEnvironment = (environment) => environment === "tenantSource" || environment === "tenantDestination";
18
+ const isSourceEnvironment = (environment) => environment === "source" || environment === "tenantSource";
19
+ const getLatestPromotion = (history) => history.reduce((latest, entry) => {
20
+ if (!latest) return entry;
21
+ return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
22
+ }, null);
23
+ const getDefaultEnvironmentTier = (environment, selectedEnvironment, permittedDestinationTiers) => {
24
+ var _a;
25
+ return (_a = selectedEnvironment == null ? void 0 : selectedEnvironment.env_tier) != null ? _a : isSourceEnvironment(environment) ? promoteConstants.DEFAULT_SOURCE_ENVIRONMENT_TIER : permittedDestinationTiers[0];
26
+ };
27
+ const getPromotionActionRestriction = (isPromotionInProgress, hasScheduledPromotion) => {
28
+ if (isPromotionInProgress) return promoteConstants.PROMOTION_IN_PROGRESS_TOOLTIP;
29
+ if (hasScheduledPromotion) return promoteConstants.SCHEDULED_PROMOTION_TOOLTIP;
30
+ return null;
31
+ };
32
+ const getHistoryActionLabel = (isPending, canRollback) => {
33
+ if (!isPending) return canRollback ? "Rollback" : "View details";
34
+ return canRollback ? "Rolling back\u2026" : "Loading\u2026";
35
+ };
36
+ const getPreflightResultMessage = ({
37
+ ready,
38
+ items_ready,
39
+ items_checked
40
+ }) => ready ? `Migration is ready (${items_ready}/${items_checked} checks passed).` : `Migration readiness requires attention (${items_ready}/${items_checked} checks passed).`;
59
41
  const isMissingPromotionStatus = (error) => {
60
42
  var _a;
61
43
  if (error instanceof Error && error.message.includes("404")) return true;
62
44
  return typeof error === "object" && error !== null && "response" in error && ((_a = error.response) == null ? void 0 : _a.status) === 404;
63
45
  };
64
46
  function PromoteFlow({ guideline, onBack, onPromote, className }) {
65
- var _a, _b, _c, _d, _e, _f, _g, _h;
47
+ var _a, _b, _c, _d;
66
48
  const [openSections, setOpenSections] = React.useState({
67
49
  overview: true
68
50
  });
@@ -80,9 +62,11 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
80
62
  const [configSearchTier, setConfigSearchTier] = React.useState(null);
81
63
  const [submittingAction, setSubmittingAction] = React.useState(null);
82
64
  const [historyActionTaskId, setHistoryActionTaskId] = React.useState(null);
65
+ const [viewedHistoryTaskId, setViewedHistoryTaskId] = React.useState(null);
83
66
  const [isStatusPollingStopped, setIsStatusPollingStopped] = React.useState(false);
84
67
  const [isInitialStatusLoading, setIsInitialStatusLoading] = React.useState(true);
85
68
  const [isCheckingPreflight, setIsCheckingPreflight] = React.useState(false);
69
+ const [isViewingPreflightDetails, setIsViewingPreflightDetails] = React.useState(false);
86
70
  const [promotionStatusForActions, setPromotionStatusForActions] = React.useState(null);
87
71
  const [preflightResult, setPreflightResult] = React.useState(null);
88
72
  const sourceEnvironment = promoteFlow_store.usePromoteFlowStore((state) => state.sourceEnvironment);
@@ -103,7 +87,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
103
87
  const resetPromotionSession = promoteFlow_store.usePromoteFlowStore((state) => state.resetPromotionSession);
104
88
  const title = utils.getGuidelineTitle(guideline);
105
89
  const versionLabel = guideline.version ? `v${guideline.version}` : "v1";
106
- const statusLabel = (_a = guideline.status) != null ? _a : "Published";
90
+ const statusLabel = (_a = guideline.status) != null ? _a : promoteConstants.DEFAULT_GUIDELINE_STATUS;
107
91
  const guidelineResourceId = promoteFlow_utils.getPromotionResourceId(guideline);
108
92
  const promotionTaskForGuideline = promotionResourceId === guidelineResourceId ? promotionTask : null;
109
93
  const errorForGuideline = errorResourceId === guidelineResourceId ? error : null;
@@ -119,13 +103,43 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
119
103
  );
120
104
  const isPromoting = Boolean(promotionTaskForGuideline);
121
105
  const canRetryPromotion = (promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.status) === "FAILED";
122
- const sourceTier = (_b = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _b : "dev";
106
+ const sourceTier = (_b = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _b : promoteConstants.DEFAULT_SOURCE_ENVIRONMENT_TIER;
123
107
  const permittedDestinationTiers = React.useMemo(
124
108
  () => promoteFlow_utils.getPermittedDestinationTiers(sourceTier),
125
109
  [sourceTier]
126
110
  );
127
- const permittedSourceTiers = ["dev", "qa", "prod", "external"];
128
- const selectedEnvironment = configuredEnvironment === "source" ? sourceEnvironment : configuredEnvironment === "destination" ? destinationEnvironment : configuredEnvironment === "tenantSource" ? tenantSourceEnvironment : tenantDestinationEnvironment;
111
+ const environments = {
112
+ source: sourceEnvironment,
113
+ destination: destinationEnvironment,
114
+ tenantSource: tenantSourceEnvironment,
115
+ tenantDestination: tenantDestinationEnvironment
116
+ };
117
+ const selectedEnvironment = configuredEnvironment ? environments[configuredEnvironment] : void 0;
118
+ const configuredEnvironmentDefaultTier = configuredEnvironment ? getDefaultEnvironmentTier(
119
+ configuredEnvironment,
120
+ selectedEnvironment,
121
+ permittedDestinationTiers
122
+ ) : promoteConstants.DEFAULT_SOURCE_ENVIRONMENT_TIER;
123
+ const configuredEnvironmentIsSource = configuredEnvironment ? isSourceEnvironment(configuredEnvironment) : true;
124
+ const configuredEnvironmentIsTenant = configuredEnvironment ? isTenantEnvironment(configuredEnvironment) : false;
125
+ const modalInitialConfiguration = selectedEnvironment ? {
126
+ env_name: selectedEnvironment.env_name,
127
+ env_tier: selectedEnvironment.env_tier,
128
+ db_type: selectedEnvironment.db_type,
129
+ host: selectedEnvironment.host,
130
+ port: String(selectedEnvironment.port),
131
+ username: selectedEnvironment.username,
132
+ password: "",
133
+ database_name: selectedEnvironment.database_name,
134
+ is_tenant_db: selectedEnvironment.is_tenant_db
135
+ } : {
136
+ ...promoteFlow_utils.EMPTY_ENVIRONMENT_CONFIGURATION,
137
+ env_tier: configuredEnvironmentDefaultTier,
138
+ db_type: !configuredEnvironmentIsSource && configuredEnvironmentDefaultTier === "external" ? "EXTERNAL" : "INTERNAL",
139
+ is_tenant_db: configuredEnvironmentIsTenant
140
+ };
141
+ const modalPermittedTiers = configuredEnvironmentIsSource ? promoteConstants.PERMITTED_SOURCE_TIERS : permittedDestinationTiers;
142
+ const modalPresetTier = configSearchTier != null ? configSearchTier : configuredEnvironmentDefaultTier;
129
143
  const latestPromotionForPair = React.useMemo(
130
144
  () => promoteFlow_utils.getLatestPromotionForEnvironmentPair(
131
145
  promotionHistory,
@@ -134,36 +148,36 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
134
148
  ),
135
149
  [destinationEnvironment, promotionHistory, sourceEnvironment]
136
150
  );
137
- const latestPromotionTaskId = React.useMemo(() => {
138
- var _a2;
139
- const latestPromotion2 = promotionHistory.reduce(
140
- (latest, entry) => {
141
- if (!latest) return entry;
142
- return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
143
- },
144
- null
145
- );
146
- return (_a2 = latestPromotion2 == null ? void 0 : latestPromotion2.promotion_task_id) != null ? _a2 : null;
147
- }, [promotionHistory]);
148
- const latestPromotion = React.useMemo(
149
- () => promotionHistory.reduce((latest, entry) => {
150
- if (!latest) return entry;
151
- return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
152
- }, null),
153
- [promotionHistory]
151
+ const latestPromotion = React.useMemo(() => getLatestPromotion(promotionHistory), [promotionHistory]);
152
+ const latestPromotionTaskId = (_c = latestPromotion == null ? void 0 : latestPromotion.promotion_task_id) != null ? _c : null;
153
+ const isPromotionInProgress = promoteConstants.PROMOTION_IN_PROGRESS_STATUSES.some(
154
+ (status) => status === (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status)
154
155
  );
155
- const isPromotionInProgress = ["MIGRATING", "ROLLBACK_IN_PROGRESS"].includes(
156
- (_c = promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) != null ? _c : ""
156
+ const hasScheduledPromotion = (latestPromotion == null ? void 0 : latestPromotion.status) === "SCHEDULED" || (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) === "SCHEDULED";
157
+ const promotionActionRestriction = getPromotionActionRestriction(
158
+ isPromotionInProgress,
159
+ hasScheduledPromotion
157
160
  );
158
- const latestHistoryIsScheduled = (latestPromotion == null ? void 0 : latestPromotion.status) === "SCHEDULED" || (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) === "SCHEDULED";
159
- const promotionActionRestriction = isPromotionInProgress ? "A promotion is currently in progress. Wait for it to complete before taking another promotion action." : latestHistoryIsScheduled ? "The latest promotion is scheduled. You may schedule another promotion, but cannot check readiness or promote now." : null;
160
161
  const canCheckPromotionReadiness = canPromote && !promotionActionRestriction;
161
162
  const canPromoteNow = canPromote && !promotionActionRestriction;
162
163
  const canPromoteLater = canPromote && !isPromotionInProgress;
163
- const environmentConfigurationTooltip = "Configure both source and destination environments first.";
164
- const readinessAndNowTooltip = promotionActionRestriction != null ? promotionActionRestriction : environmentConfigurationTooltip;
165
- const promoteLaterTooltip = isPromotionInProgress ? promotionActionRestriction : environmentConfigurationTooltip;
164
+ const readinessAndNowTooltip = promotionActionRestriction != null ? promotionActionRestriction : promoteConstants.ENVIRONMENT_CONFIGURATION_TOOLTIP;
165
+ const promoteLaterTooltip = isPromotionInProgress ? promotionActionRestriction : promoteConstants.ENVIRONMENT_CONFIGURATION_TOOLTIP;
166
166
  const promoteActionLabel = (latestPromotionForPair == null ? void 0 : latestPromotionForPair.status) === "SUCCESS" ? "Sync" : "Promote Now";
167
+ const createPromotionRequest = () => {
168
+ if (!sourceEnvironment || !destinationEnvironment) return null;
169
+ return {
170
+ resource_id: guidelineResourceId,
171
+ resource_type: "PACKAGE",
172
+ target_version: "latest",
173
+ global_source_env_id: sourceEnvironment.env_id,
174
+ global_target_env_id: destinationEnvironment.env_id,
175
+ ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
176
+ tenant_source_env_id: tenantSourceEnvironment.env_id,
177
+ tenant_target_env_id: tenantDestinationEnvironment.env_id
178
+ } : {}
179
+ };
180
+ };
167
181
  const toggleSection = (id) => {
168
182
  setOpenSections((current) => ({ ...current, [id]: !current[id] }));
169
183
  };
@@ -174,6 +188,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
174
188
  setError(null);
175
189
  setPromotionTask(null);
176
190
  setPromotionStatusForActions(null);
191
+ setViewedHistoryTaskId(null);
177
192
  const refreshInitialPromotionState = async () => {
178
193
  try {
179
194
  const status = await promoteFlow_api.getPromotionStatus(guidelineResourceId);
@@ -213,14 +228,20 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
213
228
  promoteFlow_api.getSchemaPreview(guidelineResourceId).then((preview) => {
214
229
  if (!isCurrent) return;
215
230
  setSchemaPreview(
216
- Object.entries(preview != null ? preview : {}).reduce((groups, [key, value]) => {
217
- if (value && Array.isArray(value.tables)) groups[key] = value;
218
- return groups;
219
- }, {})
231
+ Object.entries(preview != null ? preview : {}).reduce(
232
+ (groups, [key, value]) => {
233
+ if (value && Array.isArray(value.tables)) groups[key] = value;
234
+ return groups;
235
+ },
236
+ {}
237
+ )
220
238
  );
221
239
  }).catch((schemaError) => {
222
240
  if (isCurrent) {
223
- console.error("Failed to load schema preview", { resourceId: guidelineResourceId, schemaError });
241
+ console.error("Failed to load schema preview", {
242
+ resourceId: guidelineResourceId,
243
+ schemaError
244
+ });
224
245
  setSchemaPreview({});
225
246
  }
226
247
  }).finally(() => {
@@ -231,18 +252,20 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
231
252
  };
232
253
  }, [guidelineResourceId]);
233
254
  React.useEffect(() => {
234
- var _a2, _b2, _c2, _d2;
235
255
  if (!configuredEnvironment) return;
236
- const selectedEnvironment2 = configuredEnvironment === "source" ? (_a2 = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _a2 : "dev" : configuredEnvironment === "destination" ? (_b2 = destinationEnvironment == null ? void 0 : destinationEnvironment.env_tier) != null ? _b2 : permittedDestinationTiers[0] : configuredEnvironment === "tenantSource" ? (_c2 = tenantSourceEnvironment == null ? void 0 : tenantSourceEnvironment.env_tier) != null ? _c2 : "dev" : (_d2 = tenantDestinationEnvironment == null ? void 0 : tenantDestinationEnvironment.env_tier) != null ? _d2 : permittedDestinationTiers[0];
237
- const defaultTier = selectedEnvironment2;
238
- const envTier = configSearchTier != null ? configSearchTier : defaultTier;
256
+ const defaultTier = getDefaultEnvironmentTier(
257
+ configuredEnvironment,
258
+ environments[configuredEnvironment],
259
+ permittedDestinationTiers
260
+ );
261
+ const environmentTier = configSearchTier != null ? configSearchTier : defaultTier;
239
262
  let isCurrent = true;
240
263
  setIsLoadingConfigs(true);
241
264
  setPromotionConfigs([]);
242
265
  promoteFlow_api.searchEnvironmentConfigs({
243
- env_tier: envTier,
244
- db_type: envTier === "external" ? "EXTERNAL" : "INTERNAL",
245
- is_tenant: configuredEnvironment === "tenantSource" || configuredEnvironment === "tenantDestination"
266
+ env_tier: environmentTier,
267
+ db_type: environmentTier === "external" ? "EXTERNAL" : "INTERNAL",
268
+ is_tenant: isTenantEnvironment(configuredEnvironment)
246
269
  }).then((configs) => {
247
270
  if (isCurrent) setPromotionConfigs(configs);
248
271
  }).catch(() => {
@@ -285,7 +308,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
285
308
  }, [promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.created_by, promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.promotion_task_id]);
286
309
  React.useEffect(() => {
287
310
  const promotionStatusToPoll = promotionTaskForGuideline != null ? promotionTaskForGuideline : promotionStatusForActions;
288
- if (!promotionStatusToPoll || isStatusPollingStopped || !["MIGRATING", "ROLLBACK_IN_PROGRESS"].includes(promotionStatusToPoll.status)) {
311
+ if (viewedHistoryTaskId || !promotionStatusToPoll || isStatusPollingStopped || !promoteConstants.PROMOTION_IN_PROGRESS_STATUSES.some((status) => status === promotionStatusToPoll.status)) {
289
312
  return;
290
313
  }
291
314
  const pollStatus = async () => {
@@ -301,7 +324,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
301
324
  );
302
325
  }
303
326
  };
304
- const intervalId = window.setInterval(pollStatus, 3e4);
327
+ const intervalId = window.setInterval(pollStatus, promoteConstants.PROMOTION_POLL_INTERVAL_MS);
305
328
  return () => window.clearInterval(intervalId);
306
329
  }, [
307
330
  guidelineResourceId,
@@ -309,25 +332,18 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
309
332
  promotionStatusForActions,
310
333
  promotionTaskForGuideline,
311
334
  setError,
312
- setPromotionTask
335
+ setPromotionTask,
336
+ viewedHistoryTaskId
313
337
  ]);
314
338
  const handlePromoteNow = async () => {
315
- if (!canPromoteNow || !sourceEnvironment || !destinationEnvironment) return;
339
+ const promotionRequest = createPromotionRequest();
340
+ if (!canPromoteNow || !promotionRequest) return;
316
341
  setSubmitting(true);
317
342
  setSubmittingAction("now");
318
343
  setError(null);
344
+ setViewedHistoryTaskId(null);
319
345
  try {
320
- const task = await promoteFlow_api.startPromotion({
321
- resource_id: promoteFlow_utils.getPromotionResourceId(guideline),
322
- resource_type: "PACKAGE",
323
- target_version: "latest",
324
- global_source_env_id: sourceEnvironment.env_id,
325
- global_target_env_id: destinationEnvironment.env_id,
326
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
327
- tenant_source_env_id: tenantSourceEnvironment.env_id,
328
- tenant_target_env_id: tenantDestinationEnvironment.env_id
329
- } : {}
330
- });
346
+ const task = await promoteFlow_api.startPromotion(promotionRequest);
331
347
  setIsStatusPollingStopped(false);
332
348
  setPromotionTask(task, guidelineResourceId);
333
349
  setPromotionStatusForActions(task);
@@ -349,28 +365,15 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
349
365
  }
350
366
  };
351
367
  const handlePreflightCheck = async () => {
352
- if (!canCheckPromotionReadiness || !sourceEnvironment || !destinationEnvironment || isCheckingPreflight)
353
- return;
368
+ const promotionRequest = createPromotionRequest();
369
+ if (!canCheckPromotionReadiness || !promotionRequest || isCheckingPreflight) return;
354
370
  setIsCheckingPreflight(true);
355
371
  setPreflightResult(null);
372
+ setIsViewingPreflightDetails(false);
356
373
  setError(null);
357
374
  try {
358
- const result = await promoteFlow_api.checkPromotionPreflight({
359
- resource_id: guidelineResourceId,
360
- resource_type: "PACKAGE",
361
- target_version: "latest",
362
- global_source_env_id: sourceEnvironment.env_id,
363
- global_target_env_id: destinationEnvironment.env_id,
364
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
365
- tenant_source_env_id: tenantSourceEnvironment.env_id,
366
- tenant_target_env_id: tenantDestinationEnvironment.env_id
367
- } : {}
368
- });
369
- setPreflightResult({
370
- ready: result.ready,
371
- itemsChecked: result.items_checked,
372
- itemsReady: result.items_ready
373
- });
375
+ const result = await promoteFlow_api.checkPromotionPreflight(promotionRequest);
376
+ setPreflightResult(result);
374
377
  } catch (preflightError) {
375
378
  setError(
376
379
  preflightError instanceof Error ? preflightError.message : "Unable to complete pre-flight check.",
@@ -381,42 +384,44 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
381
384
  }
382
385
  };
383
386
  const handleSaveEnvironment = async (environment, configuration) => {
384
- const isTenantEnvironment = environment === "tenantSource" || environment === "tenantDestination";
385
387
  const configurationToSave = {
386
388
  ...configuration,
387
- is_tenant_db: isTenantEnvironment
389
+ is_tenant_db: isTenantEnvironment(environment)
388
390
  };
389
- const response = await promoteFlow_api.createEnvironmentConfig(
390
- promoteFlow_utils.toCreateEnvironmentConfigRequest(configurationToSave)
391
+ const credential = await promoteFlow_api.addAlloyDbCredential(
392
+ promoteFlow_utils.toAddAlloyDbCredentialRequest(configurationToSave)
393
+ );
394
+ await promoteFlow_api.createEnvironmentConfig(
395
+ promoteFlow_utils.toCreateEnvironmentConfigRequest(
396
+ configurationToSave,
397
+ credential.credId,
398
+ credential.credName
399
+ )
400
+ );
401
+ setEnvironment(
402
+ environment,
403
+ promoteFlow_utils.toRegistryRecord(credential.credId, {
404
+ ...configurationToSave,
405
+ env_name: credential.credName
406
+ })
391
407
  );
392
- setEnvironment(environment, promoteFlow_utils.toRegistryRecord(response.env_id, configurationToSave));
393
408
  };
394
409
  const openEnvironmentConfiguration = (environment) => {
395
- var _a2;
396
- const selected = environment === "source" ? sourceEnvironment : environment === "destination" ? destinationEnvironment : environment === "tenantSource" ? tenantSourceEnvironment : tenantDestinationEnvironment;
397
410
  setConfigSearchTier(
398
- (_a2 = selected == null ? void 0 : selected.env_tier) != null ? _a2 : environment === "source" || environment === "tenantSource" ? "dev" : permittedDestinationTiers[0]
411
+ getDefaultEnvironmentTier(environment, environments[environment], permittedDestinationTiers)
399
412
  );
400
413
  setConfiguredEnvironment(environment);
401
414
  };
402
415
  const handlePromoteLater = async () => {
403
416
  var _a2, _b2;
404
- if (!canPromoteLater || !sourceEnvironment || !destinationEnvironment) return;
417
+ const promotionRequest = createPromotionRequest();
418
+ if (!canPromoteLater || !promotionRequest) return;
405
419
  setSubmitting(true);
406
420
  setSubmittingAction("later");
407
421
  setError(null);
422
+ setViewedHistoryTaskId(null);
408
423
  try {
409
- const scheduledPromotion = await promoteFlow_api.schedulePromotion({
410
- resource_id: guidelineResourceId,
411
- resource_type: "PACKAGE",
412
- target_version: "latest",
413
- global_source_env_id: sourceEnvironment.env_id,
414
- global_target_env_id: destinationEnvironment.env_id,
415
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
416
- tenant_source_env_id: tenantSourceEnvironment.env_id,
417
- tenant_target_env_id: tenantDestinationEnvironment.env_id
418
- } : {}
419
- });
424
+ const scheduledPromotion = await promoteFlow_api.schedulePromotion(promotionRequest);
420
425
  const now = (/* @__PURE__ */ new Date()).toISOString();
421
426
  setPromotionTask(
422
427
  {
@@ -449,6 +454,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
449
454
  setSubmitting(true);
450
455
  setSubmittingAction("trigger");
451
456
  setError(null);
457
+ setViewedHistoryTaskId(null);
452
458
  try {
453
459
  const task = await promoteFlow_api.triggerScheduledPromotion(triggerUrl);
454
460
  setIsStatusPollingStopped(false);
@@ -475,8 +481,9 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
475
481
  setHistoryActionTaskId(promotionTaskId);
476
482
  setError(null);
477
483
  try {
478
- setIsStatusPollingStopped(false);
479
- setPromotionTask(await promoteFlow_api.getPromotionStatus(guidelineResourceId), guidelineResourceId);
484
+ const task = await promoteFlow_api.getPromotionTaskDetails(promotionTaskId);
485
+ setViewedHistoryTaskId(promotionTaskId);
486
+ setPromotionTask(task, guidelineResourceId);
480
487
  } catch (statusError) {
481
488
  setError(
482
489
  statusError instanceof Error ? statusError.message : "Unable to load promotion details.",
@@ -489,6 +496,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
489
496
  const handleRollbackPromotion = async (promotionTaskId) => {
490
497
  setHistoryActionTaskId(promotionTaskId);
491
498
  setError(null);
499
+ setViewedHistoryTaskId(null);
492
500
  try {
493
501
  const task = await promoteFlow_api.rollbackPromotion(promotionTaskId);
494
502
  setIsStatusPollingStopped(false);
@@ -505,6 +513,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
505
513
  const handleBack = async () => {
506
514
  if (promotionTaskForGuideline) {
507
515
  setPromotionTask(null);
516
+ setViewedHistoryTaskId(null);
508
517
  setIsInitialStatusLoading(true);
509
518
  setIsLoadingHistory(true);
510
519
  try {
@@ -664,7 +673,10 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
664
673
  ),
665
674
  onClick: () => canRollback ? handleRollbackPromotion(row.promotion_task_id) : handleViewPromotionDetails(row.promotion_task_id),
666
675
  disabled: isInitialStatusLoading || historyActionTaskId !== null,
667
- children: historyActionTaskId === row.promotion_task_id ? canRollback ? "Rolling back\u2026" : "Loading\u2026" : canRollback ? "Rollback" : "View details"
676
+ children: getHistoryActionLabel(
677
+ historyActionTaskId === row.promotion_task_id,
678
+ canRollback
679
+ )
668
680
  }
669
681
  )
670
682
  ] })
@@ -673,9 +685,11 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
673
685
  ] }) }) });
674
686
  }
675
687
  if (id === "database") {
676
- if (isLoadingSchemaPreview) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].emptyBody, children: "Loading database details\u2026" });
688
+ if (isLoadingSchemaPreview)
689
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].emptyBody, children: "Loading database details\u2026" });
677
690
  const groups = Object.entries(schemaPreview);
678
- if (groups.length === 0) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].emptyBody, children: "No database details available." });
691
+ if (groups.length === 0)
692
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].emptyBody, children: "No database details available." });
679
693
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].databaseGrid, children: groups.flatMap(
680
694
  ([groupName, group]) => ["Source", "Destination"].map((environment) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].databaseCard, children: [
681
695
  /* @__PURE__ */ jsxRuntime.jsxs("h3", { children: [
@@ -698,6 +712,15 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
698
712
  }
699
713
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].emptyBody, children: "No details available yet." });
700
714
  };
715
+ if (isViewingPreflightDetails && preflightResult) {
716
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: utils.cx(PromoteFlow_module["default"].root, className), children: /* @__PURE__ */ jsxRuntime.jsx(
717
+ PreflightDetailsPage.PreflightDetailsPage,
718
+ {
719
+ result: preflightResult,
720
+ onBack: () => setIsViewingPreflightDetails(false)
721
+ }
722
+ ) });
723
+ }
701
724
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cx(PromoteFlow_module["default"].root, className), children: [
702
725
  /* @__PURE__ */ jsxRuntime.jsxs("main", { className: PromoteFlow_module["default"].body, children: [
703
726
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].topRow, children: [
@@ -711,7 +734,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
711
734
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].ctaRow, children: [
712
735
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].preflightAction, children: [
713
736
  /* @__PURE__ */ jsxRuntime.jsx(
714
- StyledPromoteTooltip,
737
+ promoteConstants.StyledPromoteTooltip,
715
738
  {
716
739
  title: canCheckPromotionReadiness ? "Optionally check that this migration is ready before promoting." : readinessAndNowTooltip,
717
740
  disableHoverListener: canCheckPromotionReadiness,
@@ -732,15 +755,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
732
755
  ) })
733
756
  }
734
757
  ),
735
- /* @__PURE__ */ jsxRuntime.jsx(
736
- StyledPromoteTooltip,
737
- {
738
- title: "Runs a safe validation of the selected source and destination environments. It does not start a migration.",
739
- placement: "top",
740
- arrow: true,
741
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: PromoteFlow_module["default"].preflightInfo, "aria-label": "About the pre-flight check", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: PromoteFlow_module["default"].helpIcon, strokeWidth: 2.2, "aria-hidden": "true" }) })
742
- }
743
- )
758
+ /* @__PURE__ */ jsxRuntime.jsx(promoteConstants.StyledPromoteTooltip, { title: promoteConstants.PREFLIGHT_TOOLTIP, placement: "top", arrow: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: PromoteFlow_module["default"].preflightInfo, "aria-label": "About the pre-flight check", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: PromoteFlow_module["default"].helpIcon, strokeWidth: 2.2, "aria-hidden": "true" }) }) })
744
759
  ] }),
745
760
  isPromoting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
746
761
  canRetryPromotion && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -770,7 +785,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
770
785
  )
771
786
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
772
787
  submittingAction !== "now" && /* @__PURE__ */ jsxRuntime.jsx(
773
- StyledPromoteTooltip,
788
+ promoteConstants.StyledPromoteTooltip,
774
789
  {
775
790
  title: canPromoteLater ? "" : promoteLaterTooltip,
776
791
  disableHoverListener: canPromoteLater,
@@ -792,7 +807,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
792
807
  }
793
808
  ),
794
809
  submittingAction !== "later" && /* @__PURE__ */ jsxRuntime.jsx(
795
- StyledPromoteTooltip,
810
+ promoteConstants.StyledPromoteTooltip,
796
811
  {
797
812
  title: canPromoteNow ? "" : readinessAndNowTooltip,
798
813
  disableHoverListener: canPromoteNow,
@@ -817,9 +832,19 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
817
832
  ] })
818
833
  ] }),
819
834
  preflightResult && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].preflightSuccess, role: "status", children: [
820
- "Pre-flight check completed successfully.",
821
- " ",
822
- preflightResult.ready ? `Migration is ready (${preflightResult.itemsReady}/${preflightResult.itemsChecked} checks passed).` : `Migration readiness requires attention (${preflightResult.itemsReady}/${preflightResult.itemsChecked} checks passed).`
835
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
836
+ "Pre-flight check completed successfully. ",
837
+ getPreflightResultMessage(preflightResult)
838
+ ] }),
839
+ preflightResult.ready && /* @__PURE__ */ jsxRuntime.jsx(
840
+ "button",
841
+ {
842
+ type: "button",
843
+ className: PromoteFlow_module["default"].preflightDetailsButton,
844
+ onClick: () => setIsViewingPreflightDetails(true),
845
+ children: "View preflight details"
846
+ }
847
+ )
823
848
  ] }),
824
849
  isPromoting ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].promotionStatusBox, children: [
825
850
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].promotionStatusRow, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].promotionStatusRowHeader, children: [
@@ -844,7 +869,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
844
869
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].metaValue, children: promoteFlow_utils.formatPromotionDate(promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.created_at) })
845
870
  ] }),
846
871
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
847
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].metaLabel, children: "Promoted by" }),
872
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].metaLabel, children: (promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.status) === "SCHEDULED" ? "Scheduled by" : "Promoted by" }),
848
873
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: PromoteFlow_module["default"].metaValue, children: promotedByName != null ? promotedByName : "\u2014" })
849
874
  ] }),
850
875
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -927,7 +952,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
927
952
  errorForGuideline && /* @__PURE__ */ jsxRuntime.jsx("p", { className: PromoteFlow_module["default"].promotionError, role: "alert", children: errorForGuideline })
928
953
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
929
954
  errorForGuideline && /* @__PURE__ */ jsxRuntime.jsx("p", { className: PromoteFlow_module["default"].promotionError, role: "alert", children: errorForGuideline }),
930
- /* @__PURE__ */ jsxRuntime.jsx("section", { className: PromoteFlow_module["default"].accordionList, "aria-label": "Promotion details", children: ACCORDIONS.map((item) => {
955
+ /* @__PURE__ */ jsxRuntime.jsx("section", { className: PromoteFlow_module["default"].accordionList, "aria-label": "Promotion details", children: promoteConstants.ACCORDIONS.map((item) => {
931
956
  const isOpen = Boolean(openSections[item.id]);
932
957
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PromoteFlow_module["default"].accordion, children: [
933
958
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -963,27 +988,12 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
963
988
  EnvironmentConfigurationModal.EnvironmentConfigurationModal,
964
989
  {
965
990
  environment: configuredEnvironment,
966
- initialConfiguration: selectedEnvironment ? {
967
- env_name: selectedEnvironment.env_name,
968
- env_tier: selectedEnvironment.env_tier,
969
- db_type: selectedEnvironment.db_type,
970
- host: selectedEnvironment.host,
971
- port: String(selectedEnvironment.port),
972
- username: selectedEnvironment.username,
973
- password: "",
974
- database_name: selectedEnvironment.database_name,
975
- is_tenant_db: selectedEnvironment.is_tenant_db
976
- } : {
977
- ...promoteFlow_utils.EMPTY_ENVIRONMENT_CONFIGURATION,
978
- env_tier: configuredEnvironment === "source" || configuredEnvironment === "tenantSource" ? "dev" : permittedDestinationTiers[0],
979
- db_type: (configuredEnvironment === "destination" || configuredEnvironment === "tenantDestination") && permittedDestinationTiers[0] === "external" ? "EXTERNAL" : "INTERNAL",
980
- is_tenant_db: configuredEnvironment === "tenantSource" || configuredEnvironment === "tenantDestination"
981
- },
982
- permittedTiers: configuredEnvironment === "source" || configuredEnvironment === "tenantSource" ? permittedSourceTiers : permittedDestinationTiers,
991
+ initialConfiguration: modalInitialConfiguration,
992
+ permittedTiers: modalPermittedTiers,
983
993
  onSave: handleSaveEnvironment,
984
994
  onSelectPreset: setEnvironment,
985
995
  onPresetTierChange: setConfigSearchTier,
986
- presetTier: configSearchTier != null ? configSearchTier : configuredEnvironment === "source" ? (_e = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _e : "dev" : configuredEnvironment === "destination" ? (_f = destinationEnvironment == null ? void 0 : destinationEnvironment.env_tier) != null ? _f : permittedDestinationTiers[0] : configuredEnvironment === "tenantSource" ? (_g = tenantSourceEnvironment == null ? void 0 : tenantSourceEnvironment.env_tier) != null ? _g : "dev" : (_h = tenantDestinationEnvironment == null ? void 0 : tenantDestinationEnvironment.env_tier) != null ? _h : permittedDestinationTiers[0],
996
+ presetTier: modalPresetTier,
987
997
  onClose: () => {
988
998
  setConfiguredEnvironment(null);
989
999
  setConfigSearchTier(null);