@solidxai/core-ui 0.1.12-beta.7 → 0.1.12-beta.9

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 (233) hide show
  1. package/dist/components/auth/AuthLayout.d.ts.map +1 -1
  2. package/dist/components/auth/AuthLayout.js +19 -17
  3. package/dist/components/auth/AuthLayout.js.map +1 -1
  4. package/dist/components/auth/AuthLayout.tsx +59 -34
  5. package/dist/components/common/BackendReconnectIndicator.d.ts +6 -0
  6. package/dist/components/common/BackendReconnectIndicator.d.ts.map +1 -0
  7. package/dist/components/common/BackendReconnectIndicator.js +25 -0
  8. package/dist/components/common/BackendReconnectIndicator.js.map +1 -0
  9. package/dist/components/common/BackendReconnectIndicator.tsx +45 -0
  10. package/dist/components/common/SettingsComponent.d.ts.map +1 -1
  11. package/dist/components/common/SettingsComponent.js +7 -3
  12. package/dist/components/common/SettingsComponent.js.map +1 -1
  13. package/dist/components/common/SettingsComponent.module.css +144 -12
  14. package/dist/components/common/SettingsComponent.tsx +22 -3
  15. package/dist/components/common/SolidAdmin.d.ts.map +1 -1
  16. package/dist/components/common/SolidAdmin.js +7 -2
  17. package/dist/components/common/SolidAdmin.js.map +1 -1
  18. package/dist/components/common/SolidAdmin.tsx +7 -2
  19. package/dist/components/common/SolidBreadcrumb.d.ts.map +1 -1
  20. package/dist/components/common/SolidBreadcrumb.js +1 -6
  21. package/dist/components/common/SolidBreadcrumb.js.map +1 -1
  22. package/dist/components/common/SolidBreadcrumb.tsx +1 -8
  23. package/dist/components/common/SolidMaterialSymbol.d.ts +10 -0
  24. package/dist/components/common/SolidMaterialSymbol.d.ts.map +1 -0
  25. package/dist/components/common/SolidMaterialSymbol.js +69 -0
  26. package/dist/components/common/SolidMaterialSymbol.js.map +1 -0
  27. package/dist/components/common/SolidMaterialSymbol.tsx +96 -0
  28. package/dist/components/common/SolidToastProvider.d.ts.map +1 -1
  29. package/dist/components/common/SolidToastProvider.js +14 -1
  30. package/dist/components/common/SolidToastProvider.js.map +1 -1
  31. package/dist/components/common/SolidToastProvider.tsx +19 -1
  32. package/dist/components/core/common/SolidAccountSettings/SolidAccountSettings.module.css +3 -1
  33. package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
  34. package/dist/components/core/common/SolidGlobalSearchElement.js +3 -2
  35. package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
  36. package/dist/components/core/common/SolidGlobalSearchElement.tsx +14 -18
  37. package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.d.ts.map +1 -1
  38. package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js +43 -16
  39. package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js.map +1 -1
  40. package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.tsx +24 -2
  41. package/dist/components/core/form/SolidFormFooter.js +1 -1
  42. package/dist/components/core/form/SolidFormFooter.js.map +1 -1
  43. package/dist/components/core/form/SolidFormFooter.tsx +1 -1
  44. package/dist/components/core/form/SolidFormLayouts.js +1 -1
  45. package/dist/components/core/form/SolidFormLayouts.js.map +1 -1
  46. package/dist/components/core/form/SolidFormLayouts.tsx +2 -2
  47. package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
  48. package/dist/components/core/form/fields/SolidMediaMultipleField.js +120 -56
  49. package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
  50. package/dist/components/core/form/fields/SolidMediaMultipleField.tsx +63 -50
  51. package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
  52. package/dist/components/core/form/fields/SolidMediaSingleField.js +115 -37
  53. package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
  54. package/dist/components/core/form/fields/SolidMediaSingleField.tsx +36 -35
  55. package/dist/components/core/form/fields/SolidRichTextField.d.ts.map +1 -1
  56. package/dist/components/core/form/fields/SolidRichTextField.js +54 -5
  57. package/dist/components/core/form/fields/SolidRichTextField.js.map +1 -1
  58. package/dist/components/core/form/fields/SolidRichTextField.tsx +71 -7
  59. package/dist/components/core/form/fields/mediaFieldUtils.d.ts +3 -0
  60. package/dist/components/core/form/fields/mediaFieldUtils.d.ts.map +1 -0
  61. package/dist/components/core/form/fields/mediaFieldUtils.js +30 -0
  62. package/dist/components/core/form/fields/mediaFieldUtils.js.map +1 -0
  63. package/dist/components/core/form/fields/mediaFieldUtils.ts +45 -0
  64. package/dist/components/core/form/fields/relations/RolesGroupedByModuleWidget.d.ts.map +1 -1
  65. package/dist/components/core/form/fields/relations/RolesGroupedByModuleWidget.js +1 -1
  66. package/dist/components/core/form/fields/relations/RolesGroupedByModuleWidget.js.map +1 -1
  67. package/dist/components/core/form/fields/relations/RolesGroupedByModuleWidget.tsx +3 -1
  68. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
  69. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +22 -23
  70. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
  71. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +13 -7
  72. package/dist/components/core/form/fields/widgets/SolidIconEditWidget.d.ts.map +1 -1
  73. package/dist/components/core/form/fields/widgets/SolidIconEditWidget.js +16 -11
  74. package/dist/components/core/form/fields/widgets/SolidIconEditWidget.js.map +1 -1
  75. package/dist/components/core/form/fields/widgets/SolidIconEditWidget.tsx +32 -18
  76. package/dist/components/core/form/fields/widgets/SolidIconViewWidget.d.ts.map +1 -1
  77. package/dist/components/core/form/fields/widgets/SolidIconViewWidget.js +3 -1
  78. package/dist/components/core/form/fields/widgets/SolidIconViewWidget.js.map +1 -1
  79. package/dist/components/core/form/fields/widgets/SolidIconViewWidget.tsx +11 -5
  80. package/dist/components/core/list/SolidDataTable.d.ts.map +1 -1
  81. package/dist/components/core/list/SolidDataTable.js +3 -2
  82. package/dist/components/core/list/SolidDataTable.js.map +1 -1
  83. package/dist/components/core/list/SolidDataTable.tsx +3 -2
  84. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  85. package/dist/components/core/list/SolidListView.js +11 -5
  86. package/dist/components/core/list/SolidListView.js.map +1 -1
  87. package/dist/components/core/list/SolidListView.tsx +15 -8
  88. package/dist/components/core/list/SolidListViewColumn.d.ts.map +1 -1
  89. package/dist/components/core/list/SolidListViewColumn.js +1 -0
  90. package/dist/components/core/list/SolidListViewColumn.js.map +1 -1
  91. package/dist/components/core/list/SolidListViewColumn.tsx +1 -0
  92. package/dist/components/core/list/columns/SolidShortTextColumn.d.ts.map +1 -1
  93. package/dist/components/core/list/columns/SolidShortTextColumn.js +7 -2
  94. package/dist/components/core/list/columns/SolidShortTextColumn.js.map +1 -1
  95. package/dist/components/core/list/columns/SolidShortTextColumn.tsx +7 -2
  96. package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.d.ts.map +1 -1
  97. package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.js +4 -1
  98. package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.js.map +1 -1
  99. package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.tsx +5 -2
  100. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.d.ts.map +1 -1
  101. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js +2 -1
  102. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js.map +1 -1
  103. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.tsx +2 -1
  104. package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.d.ts.map +1 -1
  105. package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.js +4 -1
  106. package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.js.map +1 -1
  107. package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.tsx +5 -2
  108. package/dist/components/core/locales/SolidLocale.d.ts.map +1 -1
  109. package/dist/components/core/locales/SolidLocale.js +1 -1
  110. package/dist/components/core/locales/SolidLocale.js.map +1 -1
  111. package/dist/components/core/locales/SolidLocale.tsx +1 -0
  112. package/dist/components/core/model/CreateModel.css +26 -0
  113. package/dist/components/core/model/FieldMetaData.d.ts.map +1 -1
  114. package/dist/components/core/model/FieldMetaData.js +21 -3
  115. package/dist/components/core/model/FieldMetaData.js.map +1 -1
  116. package/dist/components/core/model/FieldMetaData.tsx +45 -4
  117. package/dist/components/core/model/FieldMetaDataForm.css +82 -0
  118. package/dist/components/core/model/FieldMetaDataForm.d.ts +1 -0
  119. package/dist/components/core/model/FieldMetaDataForm.d.ts.map +1 -1
  120. package/dist/components/core/model/FieldMetaDataForm.js +246 -235
  121. package/dist/components/core/model/FieldMetaDataForm.js.map +1 -1
  122. package/dist/components/core/model/FieldMetaDataForm.tsx +46 -34
  123. package/dist/components/core/model/FieldSelector.js +1 -1
  124. package/dist/components/core/model/FieldSelector.js.map +1 -1
  125. package/dist/components/core/model/FieldSelector.tsx +1 -1
  126. package/dist/components/core/model/ModelMetaData.js +1 -1
  127. package/dist/components/core/model/ModelMetaData.js.map +1 -1
  128. package/dist/components/core/model/ModelMetaData.tsx +1 -1
  129. package/dist/components/core/module/CreateModule.css +55 -2
  130. package/dist/components/core/module/CreateModule.d.ts.map +1 -1
  131. package/dist/components/core/module/CreateModule.js +2 -2
  132. package/dist/components/core/module/CreateModule.js.map +1 -1
  133. package/dist/components/core/module/CreateModule.tsx +3 -2
  134. package/dist/components/core/module/ModuleMetadataExplorer.css +27 -0
  135. package/dist/components/core/module/ModuleMetadataExplorer.d.ts.map +1 -1
  136. package/dist/components/core/module/ModuleMetadataExplorer.js +1 -1
  137. package/dist/components/core/module/ModuleMetadataExplorer.js.map +1 -1
  138. package/dist/components/core/module/ModuleMetadataExplorer.tsx +1 -0
  139. package/dist/components/core/tree/SolidTreeView.d.ts.map +1 -1
  140. package/dist/components/core/tree/SolidTreeView.js +6 -1
  141. package/dist/components/core/tree/SolidTreeView.js.map +1 -1
  142. package/dist/components/core/tree/SolidTreeView.tsx +7 -1
  143. package/dist/components/layout/AdminHeaderActions.d.ts.map +1 -1
  144. package/dist/components/layout/AdminHeaderActions.js +10 -9
  145. package/dist/components/layout/AdminHeaderActions.js.map +1 -1
  146. package/dist/components/layout/AdminHeaderActions.tsx +2 -0
  147. package/dist/components/layout/AppSidebar.d.ts.map +1 -1
  148. package/dist/components/layout/AppSidebar.js +2 -1
  149. package/dist/components/layout/AppSidebar.js.map +1 -1
  150. package/dist/components/layout/AppSidebar.tsx +12 -5
  151. package/dist/components/layout/SolidMenuItemIcon.d.ts +9 -0
  152. package/dist/components/layout/SolidMenuItemIcon.d.ts.map +1 -0
  153. package/dist/components/layout/SolidMenuItemIcon.js +20 -0
  154. package/dist/components/layout/SolidMenuItemIcon.js.map +1 -0
  155. package/dist/components/layout/SolidMenuItemIcon.tsx +45 -0
  156. package/dist/components/layout/navbar-two-menu.d.ts.map +1 -1
  157. package/dist/components/layout/navbar-two-menu.js +6 -7
  158. package/dist/components/layout/navbar-two-menu.js.map +1 -1
  159. package/dist/components/layout/navbar-two-menu.tsx +4 -12
  160. package/dist/components/shad-cn-ui/SolidCodeEditor.d.ts.map +1 -1
  161. package/dist/components/shad-cn-ui/SolidCodeEditor.js +30 -2
  162. package/dist/components/shad-cn-ui/SolidCodeEditor.js.map +1 -1
  163. package/dist/components/shad-cn-ui/SolidCodeEditor.tsx +38 -1
  164. package/dist/helpers/backendHealthMonitor.d.ts +39 -0
  165. package/dist/helpers/backendHealthMonitor.d.ts.map +1 -0
  166. package/dist/helpers/backendHealthMonitor.js +255 -0
  167. package/dist/helpers/backendHealthMonitor.js.map +1 -0
  168. package/dist/helpers/backendHealthMonitor.ts +177 -0
  169. package/dist/helpers/helpers.d.ts +1 -0
  170. package/dist/helpers/helpers.d.ts.map +1 -1
  171. package/dist/helpers/helpers.js +9 -0
  172. package/dist/helpers/helpers.js.map +1 -1
  173. package/dist/helpers/helpers.ts +11 -1
  174. package/dist/helpers/menuItemIcons.d.ts +34 -0
  175. package/dist/helpers/menuItemIcons.d.ts.map +1 -0
  176. package/dist/helpers/menuItemIcons.js +144 -0
  177. package/dist/helpers/menuItemIcons.js.map +1 -0
  178. package/dist/helpers/menuItemIcons.ts +191 -0
  179. package/dist/helpers/relationDisplay.d.ts +3 -0
  180. package/dist/helpers/relationDisplay.d.ts.map +1 -0
  181. package/dist/helpers/relationDisplay.js +92 -0
  182. package/dist/helpers/relationDisplay.js.map +1 -0
  183. package/dist/helpers/relationDisplay.ts +101 -0
  184. package/dist/helpers/settingsPayload.d.ts +1 -0
  185. package/dist/helpers/settingsPayload.d.ts.map +1 -1
  186. package/dist/helpers/settingsPayload.js.map +1 -1
  187. package/dist/helpers/settingsPayload.ts +1 -0
  188. package/dist/helpers/solidIcons.d.ts +2 -0
  189. package/dist/helpers/solidIcons.d.ts.map +1 -1
  190. package/dist/helpers/solidIcons.js +8 -0
  191. package/dist/helpers/solidIcons.js.map +1 -1
  192. package/dist/helpers/solidIcons.tsx +10 -1
  193. package/dist/helpers/waitForBackendAvailability.d.ts +1 -0
  194. package/dist/helpers/waitForBackendAvailability.d.ts.map +1 -1
  195. package/dist/helpers/waitForBackendAvailability.js +35 -22
  196. package/dist/helpers/waitForBackendAvailability.js.map +1 -1
  197. package/dist/helpers/waitForBackendAvailability.ts +18 -12
  198. package/dist/http/solidHttp.d.ts.map +1 -1
  199. package/dist/http/solidHttp.js +10 -4
  200. package/dist/http/solidHttp.js.map +1 -1
  201. package/dist/http/solidHttp.ts +9 -4
  202. package/dist/redux/api/datasourceIntrospectionApi.d.ts +4 -0
  203. package/dist/redux/api/datasourceIntrospectionApi.d.ts.map +1 -1
  204. package/dist/redux/api/datasourceIntrospectionApi.js.map +1 -1
  205. package/dist/redux/api/datasourceIntrospectionApi.ts +4 -0
  206. package/dist/redux/api/fetchBaseQuery.d.ts.map +1 -1
  207. package/dist/redux/api/fetchBaseQuery.js +9 -3
  208. package/dist/redux/api/fetchBaseQuery.js.map +1 -1
  209. package/dist/redux/api/fetchBaseQuery.tsx +9 -3
  210. package/dist/redux/store/StoreProvider.d.ts.map +1 -1
  211. package/dist/redux/store/StoreProvider.js +4 -3
  212. package/dist/redux/store/StoreProvider.js.map +1 -1
  213. package/dist/redux/store/StoreProvider.tsx +4 -3
  214. package/dist/resources/globals.css +341 -49
  215. package/dist/resources/solid-custom.css +410 -12
  216. package/dist/resources/solid-responsive.css +27 -16
  217. package/dist/resources/solid-tailwind-generated.css +1 -1
  218. package/dist/routes/AppEventListener.d.ts.map +1 -1
  219. package/dist/routes/AppEventListener.js +23 -0
  220. package/dist/routes/AppEventListener.js.map +1 -1
  221. package/dist/routes/AppEventListener.tsx +29 -0
  222. package/dist/routes/pages/admin/core/DashboardPage.module.css +12 -0
  223. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.css +306 -3
  224. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.d.ts.map +1 -1
  225. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.js +745 -393
  226. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.js.map +1 -1
  227. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.tsx +1074 -420
  228. package/dist/routes/pages/admin/core/DatasourcesPage.css +15 -0
  229. package/dist/routes/pages/admin/core/DatasourcesPage.d.ts.map +1 -1
  230. package/dist/routes/pages/admin/core/DatasourcesPage.js +7 -188
  231. package/dist/routes/pages/admin/core/DatasourcesPage.js.map +1 -1
  232. package/dist/routes/pages/admin/core/DatasourcesPage.tsx +3 -393
  233. package/package.json +3 -2
@@ -66,7 +66,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
66
  return to.concat(ar || Array.prototype.slice.call(from));
67
67
  };
68
68
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
69
- import { ArrowLeft, Check, Cog, Database, ExternalLink, RefreshCw, Save, Search, ShieldAlert, Sparkles, } from "lucide-react";
69
+ import { ArrowLeft, Check, Cog, Copy, Database, ExternalLink, RefreshCw, Save, Search, ShieldAlert, Sparkles, } from "lucide-react";
70
70
  import { camelCase, startCase } from "lodash";
71
71
  import { useEffect, useMemo, useRef, useState } from "react";
72
72
  import { useDispatch } from "react-redux";
@@ -77,8 +77,8 @@ import { Column, SolidDataTable } from "../../../../components/core/list/SolidDa
77
77
  import FieldMetaDataForm from "../../../../components/core/model/FieldMetaDataForm";
78
78
  import { waitForBackendAvailability } from "../../../../helpers/waitForBackendAvailability";
79
79
  import { SolidButton, SolidCheckbox, SolidDialog, SolidDialogBody, SolidDialogClose, SolidDialogDescription, SolidDialogFooter, SolidDialogHeader, SolidDialogSeparator, SolidDialogTitle, SolidInput, SolidSelect, SolidSpinner, SolidSwitch, SolidTabGroup, SolidTextarea, } from "../../../../components/shad-cn-ui";
80
- import { useApplyDatasourceIntrospectionMappingMutation, useCreateDatasourceIntrospectionMigrationArtifactsMutation, useGenerateDatasourceIntrospectionCodeMutation, useGetDatasourceIntrospectionBootstrapQuery, useGetDatasourceIntrospectionTableDetailQuery, useGetDatasourceIntrospectionTablesQuery, usePreviewDatasourceIntrospectionMappingMutation, useRunDatasourceIntrospectionMigrationMutation, } from "../../../../redux/api/datasourceIntrospectionApi";
81
- import { useGetmodelByIdQuery } from "../../../../redux/api/modelApi";
80
+ import { datasourceIntrospectionApi, useApplyDatasourceIntrospectionMappingMutation, useCreateDatasourceIntrospectionMigrationArtifactsMutation, useGenerateDatasourceIntrospectionCodeMutation, useGetDatasourceIntrospectionBootstrapQuery, useGetDatasourceIntrospectionTablesQuery, usePreviewDatasourceIntrospectionMappingMutation, useRunDatasourceIntrospectionMigrationMutation, } from "../../../../redux/api/datasourceIntrospectionApi";
81
+ import { modelsApi } from "../../../../redux/api/modelApi";
82
82
  import "./DatasourceIntrospectionPage.css";
83
83
  function providerLabel(type) {
84
84
  if (type === "postgres")
@@ -105,7 +105,10 @@ var scalarFieldTypeOptions = [
105
105
  { value: "email", label: "Email" },
106
106
  { value: "password", label: "Password" },
107
107
  ];
108
- var scalarFieldTypeValueSet = new Set(scalarFieldTypeOptions.map(function (option) { return option.value; }));
108
+ function getFieldTypeLabel(type) {
109
+ var _a, _b;
110
+ return (_b = (_a = scalarFieldTypeOptions.find(function (option) { return option.value === type; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : startCase(type);
111
+ }
109
112
  var mappingStrategyOptions = [
110
113
  { value: "generated_id", label: "Legacy generated id" },
111
114
  { value: "existing_id", label: "Legacy existing id" },
@@ -199,6 +202,9 @@ function getDefaultOrmTypeForSolidFieldType(dataSourceType, solidFieldType) {
199
202
  return (_b = (_a = ormTypesByDatasource[normalizedDatasourceType]) === null || _a === void 0 ? void 0 : _a[solidFieldType]) !== null && _b !== void 0 ? _b : "varchar";
200
203
  }
201
204
  function statusLabel(record) {
205
+ if (!record.hasPrimaryKey) {
206
+ return "Blocked";
207
+ }
202
208
  return record.mapped ? "Mapped" : "Ready to map";
203
209
  }
204
210
  function readQueryError(error) {
@@ -251,7 +257,7 @@ function sanitizeExistingFieldPayload(field) {
251
257
  return rest;
252
258
  }
253
259
  function buildDrawerDraft(tableDetail, selectedTable, mappedModelData) {
254
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
260
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
255
261
  var modelData = selectedTable.mapped ? ((_a = mappedModelData === null || mappedModelData === void 0 ? void 0 : mappedModelData.data) !== null && _a !== void 0 ? _a : null) : null;
256
262
  var modelFields = (_b = modelData === null || modelData === void 0 ? void 0 : modelData.fields) !== null && _b !== void 0 ? _b : [];
257
263
  var preservedFields = modelFields.map(function (field) { return sanitizeExistingFieldPayload(field); });
@@ -285,26 +291,34 @@ function buildDrawerDraft(tableDetail, selectedTable, mappedModelData) {
285
291
  fieldConfig: matchingField ? sanitizeExistingFieldPayload(matchingField) : null,
286
292
  };
287
293
  });
288
- var draftUserKeyField = modelUserKeyField || tableDetail.suggestedMetadata.userKeyField;
294
+ var requestedUserKeyField = modelUserKeyField || tableDetail.suggestedMetadata.userKeyField;
295
+ var resolvedUserKeyField = (_f = (_e = (columns.find(function (column) { return column.fieldName === requestedUserKeyField; })
296
+ || columns.find(function (column) { return column.columnName === requestedUserKeyField; })
297
+ || columns.find(function (column) { return !column.handledBySuperclass && column.isPrimaryKey; })
298
+ || columns.find(function (column) { return !column.handledBySuperclass && column.include; }))) === null || _e === void 0 ? void 0 : _e.fieldName) !== null && _f !== void 0 ? _f : requestedUserKeyField;
289
299
  return {
290
300
  mapped: selectedTable.mapped,
291
301
  modelId: selectedTable.mappedModelId,
292
302
  mappedModuleLabel: selectedTable.mappedModuleDisplayName || selectedTable.mappedModuleName || null,
293
- singularName: (_e = modelData === null || modelData === void 0 ? void 0 : modelData.singularName) !== null && _e !== void 0 ? _e : tableDetail.suggestedMetadata.singularName,
294
- pluralName: (_f = modelData === null || modelData === void 0 ? void 0 : modelData.pluralName) !== null && _f !== void 0 ? _f : tableDetail.suggestedMetadata.pluralName,
295
- displayName: (_g = modelData === null || modelData === void 0 ? void 0 : modelData.displayName) !== null && _g !== void 0 ? _g : tableDetail.suggestedMetadata.displayName,
296
- description: (_h = modelData === null || modelData === void 0 ? void 0 : modelData.description) !== null && _h !== void 0 ? _h : tableDetail.suggestedMetadata.displayName,
297
- tableName: (_j = modelData === null || modelData === void 0 ? void 0 : modelData.tableName) !== null && _j !== void 0 ? _j : tableDetail.suggestedMetadata.tableName,
303
+ singularName: (_g = modelData === null || modelData === void 0 ? void 0 : modelData.singularName) !== null && _g !== void 0 ? _g : tableDetail.suggestedMetadata.singularName,
304
+ pluralName: (_h = modelData === null || modelData === void 0 ? void 0 : modelData.pluralName) !== null && _h !== void 0 ? _h : tableDetail.suggestedMetadata.pluralName,
305
+ displayName: (_j = modelData === null || modelData === void 0 ? void 0 : modelData.displayName) !== null && _j !== void 0 ? _j : tableDetail.suggestedMetadata.displayName,
306
+ description: (_k = modelData === null || modelData === void 0 ? void 0 : modelData.description) !== null && _k !== void 0 ? _k : tableDetail.suggestedMetadata.displayName,
307
+ tableName: (_l = modelData === null || modelData === void 0 ? void 0 : modelData.tableName) !== null && _l !== void 0 ? _l : tableDetail.suggestedMetadata.tableName,
298
308
  schema: tableDetail.suggestedMetadata.schema,
299
- dataSource: (_k = modelData === null || modelData === void 0 ? void 0 : modelData.dataSource) !== null && _k !== void 0 ? _k : tableDetail.suggestedMetadata.dataSource,
300
- dataSourceType: (_l = modelData === null || modelData === void 0 ? void 0 : modelData.dataSourceType) !== null && _l !== void 0 ? _l : tableDetail.suggestedMetadata.dataSourceType,
301
- legacyTableType: (_m = modelData === null || modelData === void 0 ? void 0 : modelData.legacyTableType) !== null && _m !== void 0 ? _m : tableDetail.suggestedMetadata.legacyTableType,
309
+ dataSource: (_m = modelData === null || modelData === void 0 ? void 0 : modelData.dataSource) !== null && _m !== void 0 ? _m : tableDetail.suggestedMetadata.dataSource,
310
+ dataSourceType: (_o = modelData === null || modelData === void 0 ? void 0 : modelData.dataSourceType) !== null && _o !== void 0 ? _o : tableDetail.suggestedMetadata.dataSourceType,
311
+ legacyTableType: (_p = modelData === null || modelData === void 0 ? void 0 : modelData.legacyTableType) !== null && _p !== void 0 ? _p : tableDetail.suggestedMetadata.legacyTableType,
302
312
  baseClassName: tableDetail.suggestedMetadata.baseClassName,
303
- userKeyField: draftUserKeyField,
304
- enableAuditTracking: (_o = modelData === null || modelData === void 0 ? void 0 : modelData.enableAuditTracking) !== null && _o !== void 0 ? _o : true,
305
- enableSoftDelete: (_p = modelData === null || modelData === void 0 ? void 0 : modelData.enableSoftDelete) !== null && _p !== void 0 ? _p : false,
306
- draftPublishWorkflow: (_q = modelData === null || modelData === void 0 ? void 0 : modelData.draftPublishWorkflow) !== null && _q !== void 0 ? _q : false,
307
- internationalisation: (_r = modelData === null || modelData === void 0 ? void 0 : modelData.internationalisation) !== null && _r !== void 0 ? _r : false,
313
+ userKeyField: resolvedUserKeyField,
314
+ enableAuditTracking: (_q = modelData === null || modelData === void 0 ? void 0 : modelData.enableAuditTracking) !== null && _q !== void 0 ? _q : true,
315
+ enableSoftDelete: (_r = modelData === null || modelData === void 0 ? void 0 : modelData.enableSoftDelete) !== null && _r !== void 0 ? _r : false,
316
+ draftPublishWorkflow: (_s = modelData === null || modelData === void 0 ? void 0 : modelData.draftPublishWorkflow) !== null && _s !== void 0 ? _s : false,
317
+ internationalisation: (_t = modelData === null || modelData === void 0 ? void 0 : modelData.internationalisation) !== null && _t !== void 0 ? _t : false,
318
+ hasPrimaryKey: selectedTable.hasPrimaryKey,
319
+ primaryKeyColumnCount: selectedTable.primaryKeyColumnCount,
320
+ primaryKeyColumnNames: selectedTable.primaryKeyColumnNames,
321
+ mappingBlockedReason: selectedTable.mappingBlockedReason,
308
322
  columns: columns,
309
323
  preservedFields: preservedFields,
310
324
  };
@@ -325,6 +339,10 @@ function getDrawerValidationErrors(draft) {
325
339
  if (!includedColumns.length) {
326
340
  errors.push("Select at least one physical column to include in the mapping.");
327
341
  }
342
+ if (!draft.hasPrimaryKey) {
343
+ errors.push(draft.mappingBlockedReason
344
+ || "Table \"".concat(draft.tableName, "\" cannot be mapped because the datasource table does not define any primary key."));
345
+ }
328
346
  for (var _i = 0, includedColumns_1 = includedColumns; _i < includedColumns_1.length; _i++) {
329
347
  var column = includedColumns_1[_i];
330
348
  var normalizedFieldName = column.fieldName.trim();
@@ -336,8 +354,8 @@ function getDrawerValidationErrors(draft) {
336
354
  errors.push("Field label is required for column \"".concat(column.columnName, "\"."));
337
355
  continue;
338
356
  }
339
- if (!scalarFieldTypeValueSet.has(column.solidFieldType)) {
340
- errors.push("SolidX type \"".concat(column.solidFieldType, "\" is not allowed in step 1 for column \"").concat(column.columnName, "\"."));
357
+ if (!column.solidFieldType.trim()) {
358
+ errors.push("SolidX type is required for column \"".concat(column.columnName, "\"."));
341
359
  continue;
342
360
  }
343
361
  if (seenFieldNames.has(normalizedFieldName.toLowerCase())) {
@@ -350,16 +368,22 @@ function getDrawerValidationErrors(draft) {
350
368
  errors.push("Choose a user key field before saving the mapping.");
351
369
  }
352
370
  else {
353
- var userKeyExists = includedColumns.some(function (column) { return column.fieldName === draft.userKeyField; });
371
+ var userKeyExists = draft.columns.some(function (column) { return (column.fieldName === draft.userKeyField
372
+ && (column.handledBySuperclass || column.include)); });
354
373
  if (!userKeyExists) {
355
374
  errors.push("The chosen user key field must remain part of the mapped columns.");
356
375
  }
357
376
  }
358
- if (draft.legacyTableType === "existing_id") {
359
- var hasPrimaryKey = includedColumns.some(function (column) { return column.isPrimaryKey; });
360
- if (!hasPrimaryKey) {
361
- errors.push("Legacy existing-id mappings must keep the generated id column mapped to field name \"id\".");
362
- }
377
+ var includedPrimaryKeyColumns = includedColumns.filter(function (column) { return column.isPrimaryKey; });
378
+ if (draft.hasPrimaryKey && !includedPrimaryKeyColumns.length) {
379
+ errors.push("Keep the datasource primary key columns included in the mapping.");
380
+ }
381
+ var missingDetectedPrimaryKeyColumns = draft.columns
382
+ .filter(function (column) { return column.isDetectedPrimaryKey && !column.handledBySuperclass; })
383
+ .filter(function (column) { return !column.include || !column.isPrimaryKey; })
384
+ .map(function (column) { return column.columnName; });
385
+ if (missingDetectedPrimaryKeyColumns.length) {
386
+ errors.push("Keep all datasource primary key columns mapped and marked as primary key: ".concat(missingDetectedPrimaryKeyColumns.join(", "), "."));
363
387
  }
364
388
  return errors;
365
389
  }
@@ -409,7 +433,7 @@ function buildMappingRequest(draft, plannedMigrationTimestamp) {
409
433
  };
410
434
  }
411
435
  function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
412
- var _a, _b;
436
+ var _a, _b, _c, _d;
413
437
  var parsed;
414
438
  try {
415
439
  parsed = JSON.parse(metadataJsonText);
@@ -451,8 +475,8 @@ function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
451
475
  { key: "tableName", expected: draft.tableName },
452
476
  { key: "legacyTableType", expected: draft.legacyTableType },
453
477
  ];
454
- for (var _c = 0, immutableChecks_1 = immutableChecks; _c < immutableChecks_1.length; _c++) {
455
- var check = immutableChecks_1[_c];
478
+ for (var _e = 0, immutableChecks_1 = immutableChecks; _e < immutableChecks_1.length; _e++) {
479
+ var check = immutableChecks_1[_e];
456
480
  if ("".concat((_b = parsed[check.key]) !== null && _b !== void 0 ? _b : "") !== "".concat(check.expected)) {
457
481
  return {
458
482
  error: "Metadata JSON cannot change immutable binding key \"".concat(check.key, "\"."),
@@ -466,8 +490,8 @@ function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
466
490
  "draftPublishWorkflow",
467
491
  "internationalisation",
468
492
  ];
469
- for (var _d = 0, requiredBooleanKeys_1 = requiredBooleanKeys; _d < requiredBooleanKeys_1.length; _d++) {
470
- var key = requiredBooleanKeys_1[_d];
493
+ for (var _f = 0, requiredBooleanKeys_1 = requiredBooleanKeys; _f < requiredBooleanKeys_1.length; _f++) {
494
+ var key = requiredBooleanKeys_1[_f];
471
495
  if (typeof parsed[key] !== "boolean") {
472
496
  return {
473
497
  error: "Metadata JSON must include a boolean \"".concat(key, "\" value."),
@@ -482,8 +506,8 @@ function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
482
506
  };
483
507
  }
484
508
  var seenFieldNames = new Set();
485
- for (var _e = 0, _f = parsed.fields.entries(); _e < _f.length; _e++) {
486
- var _g = _f[_e], index = _g[0], field = _g[1];
509
+ for (var _g = 0, _h = parsed.fields.entries(); _g < _h.length; _g++) {
510
+ var _j = _h[_g], index = _j[0], field = _j[1];
487
511
  if (!field || typeof field !== "object" || Array.isArray(field)) {
488
512
  return {
489
513
  error: "Field at index ".concat(index, " is not a valid object."),
@@ -523,65 +547,106 @@ function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
523
547
  }
524
548
  seenFieldNames.add(normalizedFieldName);
525
549
  }
526
- if (!parsed.fields.some(function (field) { return (field === null || field === void 0 ? void 0 : field.name) === parsed.userKeyFieldUserKey && !(field === null || field === void 0 ? void 0 : field.isMarkedForRemoval); })) {
550
+ var expectedUserKeyFieldName = "".concat((_d = (_c = parsed.userKeyFieldUserKey) !== null && _c !== void 0 ? _c : draft.userKeyField) !== null && _d !== void 0 ? _d : "").trim();
551
+ var resolvedUserKeyFieldName = resolveReviewedUserKeyFieldName(parsed.fields, expectedUserKeyFieldName, draft.userKeyField);
552
+ var inheritedGeneratedIdUserKey = draft.legacyTableType === "generated_id" && expectedUserKeyFieldName.toLowerCase() === "id";
553
+ if (!resolvedUserKeyFieldName && !inheritedGeneratedIdUserKey) {
527
554
  return {
528
555
  error: "Metadata JSON must keep userKeyFieldUserKey present in the fields array.",
529
556
  parsed: null,
530
557
  };
531
558
  }
559
+ if (draft.hasPrimaryKey) {
560
+ var activeFields_1 = parsed.fields.filter(function (field) { return !(field === null || field === void 0 ? void 0 : field.isMarkedForRemoval); });
561
+ var missingPrimaryKeyColumns = draft.columns
562
+ .filter(function (column) { return column.isDetectedPrimaryKey && !column.handledBySuperclass; })
563
+ .filter(function (column) {
564
+ var matchingField = activeFields_1.find(function (field) { var _a; return "".concat((_a = field === null || field === void 0 ? void 0 : field.columnName) !== null && _a !== void 0 ? _a : "").trim().toLowerCase() === column.columnName.trim().toLowerCase(); });
565
+ return !matchingField || matchingField.isPrimaryKey !== true;
566
+ })
567
+ .map(function (column) { return column.columnName; });
568
+ if (missingPrimaryKeyColumns.length) {
569
+ return {
570
+ error: "Metadata JSON must keep all datasource primary key columns marked with isPrimaryKey: true: ".concat(missingPrimaryKeyColumns.join(", "), "."),
571
+ parsed: null,
572
+ };
573
+ }
574
+ }
575
+ parsed.userKeyFieldUserKey = resolvedUserKeyFieldName !== null && resolvedUserKeyFieldName !== void 0 ? resolvedUserKeyFieldName : expectedUserKeyFieldName;
532
576
  return {
533
577
  error: null,
534
578
  parsed: parsed,
535
579
  };
536
580
  }
581
+ function resolveReviewedUserKeyFieldName(reviewedFields, requestedUserKeyFieldName, fallbackUserKeyFieldName) {
582
+ var _a;
583
+ var activeFields = reviewedFields.filter(function (field) { return !(field === null || field === void 0 ? void 0 : field.isMarkedForRemoval); });
584
+ var normalizedRequested = "".concat(requestedUserKeyFieldName !== null && requestedUserKeyFieldName !== void 0 ? requestedUserKeyFieldName : "").trim().toLowerCase();
585
+ var normalizedFallback = "".concat(fallbackUserKeyFieldName !== null && fallbackUserKeyFieldName !== void 0 ? fallbackUserKeyFieldName : "").trim().toLowerCase();
586
+ var byExactRequested = activeFields.find(function (field) { var _a, _b; return ((_b = (_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === normalizedRequested; });
587
+ if (byExactRequested === null || byExactRequested === void 0 ? void 0 : byExactRequested.name) {
588
+ return byExactRequested.name;
589
+ }
590
+ var byExistingUserKeyFlag = activeFields.find(function (field) { return field === null || field === void 0 ? void 0 : field.isUserKey; });
591
+ if (byExistingUserKeyFlag === null || byExistingUserKeyFlag === void 0 ? void 0 : byExistingUserKeyFlag.name) {
592
+ return byExistingUserKeyFlag.name;
593
+ }
594
+ var byPrimaryKeyFallback = activeFields.find(function (field) {
595
+ var _a;
596
+ if (!(field === null || field === void 0 ? void 0 : field.isPrimaryKey)) {
597
+ return false;
598
+ }
599
+ var normalizedName = "".concat((_a = field === null || field === void 0 ? void 0 : field.name) !== null && _a !== void 0 ? _a : "").trim().toLowerCase();
600
+ return normalizedName === normalizedFallback || normalizedName === "id" || normalizedName === "legacyid";
601
+ });
602
+ if (byPrimaryKeyFallback === null || byPrimaryKeyFallback === void 0 ? void 0 : byPrimaryKeyFallback.name) {
603
+ return byPrimaryKeyFallback.name;
604
+ }
605
+ var byFallbackFieldName = activeFields.find(function (field) { var _a, _b; return ((_b = (_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === normalizedFallback; });
606
+ return (_a = byFallbackFieldName === null || byFallbackFieldName === void 0 ? void 0 : byFallbackFieldName.name) !== null && _a !== void 0 ? _a : null;
607
+ }
537
608
  export function DatasourceIntrospectionPage() {
538
609
  var _this = this;
539
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
610
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
540
611
  var params = useParams();
541
612
  var navigate = useNavigate();
542
613
  var dispatch = useDispatch();
543
614
  var moduleId = Number((_a = params.moduleId) !== null && _a !== void 0 ? _a : 0);
544
615
  var isValidModuleId = Number.isFinite(moduleId) && moduleId > 0;
545
- var _t = useGetDatasourceIntrospectionBootstrapQuery(moduleId, {
616
+ var _2 = useGetDatasourceIntrospectionBootstrapQuery(moduleId, {
546
617
  skip: !isValidModuleId,
547
- }), bootstrap = _t.data, isBootstrapLoading = _t.isLoading, isBootstrapFetching = _t.isFetching, bootstrapError = _t.error, refetchBootstrap = _t.refetch;
548
- var _u = useState(""), selectedDatasource = _u[0], setSelectedDatasource = _u[1];
549
- var _v = useState([]), selectedRows = _v[0], setSelectedRows = _v[1];
550
- var _w = useState(""), workspaceTableKey = _w[0], setWorkspaceTableKey = _w[1];
551
- var _x = useState(""), tableSearch = _x[0], setTableSearch = _x[1];
552
- var _y = useState(false), settingsOpen = _y[0], setSettingsOpen = _y[1];
553
- var _z = useState("datasource-info"), settingsTab = _z[0], setSettingsTab = _z[1];
554
- var _0 = useState(null), drawerDraft = _0[0], setDrawerDraft = _0[1];
555
- var _1 = useState("general-info"), drawerTab = _1[0], setDrawerTab = _1[1];
556
- var _2 = useState("configure"), workspaceStep = _2[0], setWorkspaceStep = _2[1];
557
- var _3 = useState(null), mappingPreview = _3[0], setMappingPreview = _3[1];
558
- var _4 = useState(null), persistedMappingResult = _4[0], setPersistedMappingResult = _4[1];
559
- var _5 = useState(null), migrationArtifactsResult = _5[0], setMigrationArtifactsResult = _5[1];
560
- var _6 = useState(""), generateCodeOutput = _6[0], setGenerateCodeOutput = _6[1];
561
- var _7 = useState(false), isGeneratingCodeWorkflow = _7[0], setIsGeneratingCodeWorkflow = _7[1];
562
- var _8 = useState(""), generateCodeStatusMessage = _8[0], setGenerateCodeStatusMessage = _8[1];
563
- var _9 = useState(null), generateCodeTimeoutMessage = _9[0], setGenerateCodeTimeoutMessage = _9[1];
564
- var _10 = useState(false), generateCodeReady = _10[0], setGenerateCodeReady = _10[1];
565
- var _11 = useState(false), hasAttemptedGenerateCode = _11[0], setHasAttemptedGenerateCode = _11[1];
566
- var _12 = useState(""), runMigrationOutput = _12[0], setRunMigrationOutput = _12[1];
567
- var _13 = useState(false), runMigrationCompleted = _13[0], setRunMigrationCompleted = _13[1];
568
- var _14 = useState(null), reviewedMetadataJsonValue = _14[0], setReviewedMetadataJsonValue = _14[1];
569
- var _15 = useState(""), metadataJsonText = _15[0], setMetadataJsonText = _15[1];
570
- var _16 = useState(null), metadataJsonValidationError = _16[0], setMetadataJsonValidationError = _16[1];
571
- var _17 = useState("initial"), metadataJsonResetToken = _17[0], setMetadataJsonResetToken = _17[1];
572
- var _18 = useState(false), drawerBootstrapping = _18[0], setDrawerBootstrapping = _18[1];
573
- var _19 = useState(null), fieldConfigColumnName = _19[0], setFieldConfigColumnName = _19[1];
574
- var _20 = useState({
618
+ }), bootstrap = _2.data, isBootstrapLoading = _2.isLoading, isBootstrapFetching = _2.isFetching, bootstrapError = _2.error, refetchBootstrap = _2.refetch;
619
+ var _3 = useState(""), selectedDatasource = _3[0], setSelectedDatasource = _3[1];
620
+ var _4 = useState([]), selectedRows = _4[0], setSelectedRows = _4[1];
621
+ var _5 = useState([]), workspaceTableKeys = _5[0], setWorkspaceTableKeys = _5[1];
622
+ var _6 = useState(""), activeWorkspaceTableKey = _6[0], setActiveWorkspaceTableKey = _6[1];
623
+ var _7 = useState({}), workspaceItems = _7[0], setWorkspaceItems = _7[1];
624
+ var workspaceRailItemRefs = useRef({});
625
+ var _8 = useState(""), tableSearch = _8[0], setTableSearch = _8[1];
626
+ var _9 = useState(false), settingsOpen = _9[0], setSettingsOpen = _9[1];
627
+ var _10 = useState("datasource-info"), settingsTab = _10[0], setSettingsTab = _10[1];
628
+ var _11 = useState("general-info"), drawerTab = _11[0], setDrawerTab = _11[1];
629
+ var _12 = useState("configure"), workspaceStep = _12[0], setWorkspaceStep = _12[1];
630
+ var _13 = useState(""), generateCodeOutput = _13[0], setGenerateCodeOutput = _13[1];
631
+ var _14 = useState(false), isGeneratingCodeWorkflow = _14[0], setIsGeneratingCodeWorkflow = _14[1];
632
+ var _15 = useState(""), generateCodeStatusMessage = _15[0], setGenerateCodeStatusMessage = _15[1];
633
+ var _16 = useState(null), generateCodeTimeoutMessage = _16[0], setGenerateCodeTimeoutMessage = _16[1];
634
+ var _17 = useState(false), generateCodeReady = _17[0], setGenerateCodeReady = _17[1];
635
+ var _18 = useState(false), hasAttemptedGenerateCode = _18[0], setHasAttemptedGenerateCode = _18[1];
636
+ var _19 = useState(false), migrationPreviewCopied = _19[0], setMigrationPreviewCopied = _19[1];
637
+ var _20 = useState(""), runMigrationOutput = _20[0], setRunMigrationOutput = _20[1];
638
+ var _21 = useState(false), runMigrationCompleted = _21[0], setRunMigrationCompleted = _21[1];
639
+ var _22 = useState(null), fieldConfigColumnName = _22[0], setFieldConfigColumnName = _22[1];
640
+ var _23 = useState({
575
641
  relationInferenceEnabled: false,
576
642
  prioritizeUnmappedTables: true,
577
- }), sessionSettings = _20[0], setSessionSettings = _20[1];
578
- var _21 = useState(sessionSettings), draftSessionSettings = _21[0], setDraftSessionSettings = _21[1];
579
- var drawerBootstrapTimerRef = useRef(null);
580
- var _22 = usePreviewDatasourceIntrospectionMappingMutation(), previewMapping = _22[0], isPreviewMappingLoading = _22[1].isLoading;
581
- var _23 = useApplyDatasourceIntrospectionMappingMutation(), applyMapping = _23[0], isApplyMappingLoading = _23[1].isLoading;
582
- var _24 = useCreateDatasourceIntrospectionMigrationArtifactsMutation(), createMigrationArtifacts = _24[0], isCreateMigrationArtifactsLoading = _24[1].isLoading;
583
- var _25 = useGenerateDatasourceIntrospectionCodeMutation(), generateCode = _25[0], isGenerateCodeLoading = _25[1].isLoading;
584
- var _26 = useRunDatasourceIntrospectionMigrationMutation(), runMigration = _26[0], isRunMigrationLoading = _26[1].isLoading;
643
+ }), sessionSettings = _23[0], setSessionSettings = _23[1];
644
+ var _24 = useState(sessionSettings), draftSessionSettings = _24[0], setDraftSessionSettings = _24[1];
645
+ var _25 = usePreviewDatasourceIntrospectionMappingMutation(), previewMapping = _25[0], isPreviewMappingLoading = _25[1].isLoading;
646
+ var _26 = useApplyDatasourceIntrospectionMappingMutation(), applyMapping = _26[0], isApplyMappingLoading = _26[1].isLoading;
647
+ var _27 = useCreateDatasourceIntrospectionMigrationArtifactsMutation(), createMigrationArtifacts = _27[0], isCreateMigrationArtifactsLoading = _27[1].isLoading;
648
+ var _28 = useGenerateDatasourceIntrospectionCodeMutation(), generateCode = _28[0], isGenerateCodeLoading = _28[1].isLoading;
649
+ var _29 = useRunDatasourceIntrospectionMigrationMutation(), runMigration = _29[0], isRunMigrationLoading = _29[1].isLoading;
585
650
  var isSavingMapping = isApplyMappingLoading;
586
651
  var isCreatingMigrationArtifacts = isCreateMigrationArtifactsLoading;
587
652
  var showFieldDraftToaster = function (message, severity) {
@@ -606,14 +671,12 @@ export function DatasourceIntrospectionPage() {
606
671
  }, [bootstrap, selectedDatasource]);
607
672
  useEffect(function () {
608
673
  setSelectedRows([]);
609
- setWorkspaceTableKey("");
610
- setDrawerDraft(null);
674
+ setWorkspaceTableKeys([]);
675
+ setActiveWorkspaceTableKey("");
676
+ setWorkspaceItems({});
611
677
  setFieldConfigColumnName(null);
612
678
  setTableSearch("");
613
679
  setWorkspaceStep("configure");
614
- setMappingPreview(null);
615
- setPersistedMappingResult(null);
616
- setMigrationArtifactsResult(null);
617
680
  setGenerateCodeOutput("");
618
681
  setIsGeneratingCodeWorkflow(false);
619
682
  setGenerateCodeStatusMessage("");
@@ -622,16 +685,32 @@ export function DatasourceIntrospectionPage() {
622
685
  setHasAttemptedGenerateCode(false);
623
686
  setRunMigrationOutput("");
624
687
  setRunMigrationCompleted(false);
625
- setReviewedMetadataJsonValue(null);
626
- setMetadataJsonText("");
627
- setMetadataJsonValidationError(null);
628
- setMetadataJsonResetToken("datasource-".concat(Date.now()));
629
688
  }, [selectedDatasource]);
630
- useEffect(function () { return function () {
631
- if (drawerBootstrapTimerRef.current) {
632
- window.clearTimeout(drawerBootstrapTimerRef.current);
633
- }
634
- }; }, []);
689
+ var activeWorkspaceProcessingKey = useMemo(function () {
690
+ var _a;
691
+ return (_a = workspaceTableKeys.find(function (key) {
692
+ var item = workspaceItems[key];
693
+ if (!item)
694
+ return false;
695
+ return [
696
+ item.loadStatus.state,
697
+ item.reviewStatus.state,
698
+ item.saveStatus.state,
699
+ item.migrationStatus.state,
700
+ ].includes("loading");
701
+ })) !== null && _a !== void 0 ? _a : null;
702
+ }, [workspaceItems, workspaceTableKeys]);
703
+ useEffect(function () {
704
+ var targetKey = activeWorkspaceProcessingKey !== null && activeWorkspaceProcessingKey !== void 0 ? activeWorkspaceProcessingKey : activeWorkspaceTableKey;
705
+ if (!targetKey)
706
+ return;
707
+ var targetNode = workspaceRailItemRefs.current[targetKey];
708
+ targetNode === null || targetNode === void 0 ? void 0 : targetNode.scrollIntoView({
709
+ block: "nearest",
710
+ inline: "nearest",
711
+ behavior: "smooth",
712
+ });
713
+ }, [activeWorkspaceProcessingKey, activeWorkspaceTableKey]);
635
714
  var datasourceOptions = useMemo(function () {
636
715
  var _a;
637
716
  return ((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.datasources) !== null && _a !== void 0 ? _a : []).map(function (datasource) { return ({
@@ -639,27 +718,25 @@ export function DatasourceIntrospectionPage() {
639
718
  value: datasource.name,
640
719
  }); });
641
720
  }, [bootstrap]);
642
- var _27 = useGetDatasourceIntrospectionTablesQuery({ moduleId: moduleId, datasource: selectedDatasource }, {
721
+ var _30 = useGetDatasourceIntrospectionTablesQuery({ moduleId: moduleId, datasource: selectedDatasource }, {
643
722
  skip: !isValidModuleId || !selectedDatasource,
644
- }), tablesResponse = _27.data, isTablesLoading = _27.isLoading, isTablesFetching = _27.isFetching, tablesError = _27.error, refetchTables = _27.refetch;
645
- var selectedListRow = (_b = selectedRows[0]) !== null && _b !== void 0 ? _b : null;
646
- var selectedListRowKey = selectedListRow ? "".concat((_c = selectedListRow.schema) !== null && _c !== void 0 ? _c : "", "::").concat(selectedListRow.tableName) : "";
647
- var isWorkspaceMode = Boolean(workspaceTableKey);
648
- var selectedTable = useMemo(function () { var _a, _b; return (_b = (_a = tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records) === null || _a === void 0 ? void 0 : _a.find(function (record) { var _a; return "".concat((_a = record.schema) !== null && _a !== void 0 ? _a : "", "::").concat(record.tableName) === workspaceTableKey; })) !== null && _b !== void 0 ? _b : null; }, [tablesResponse, workspaceTableKey]);
649
- var _28 = useGetDatasourceIntrospectionTableDetailQuery({
650
- moduleId: moduleId,
651
- datasource: selectedDatasource,
652
- table: (_d = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.tableName) !== null && _d !== void 0 ? _d : "",
653
- schema: (_e = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.schema) !== null && _e !== void 0 ? _e : undefined,
654
- }, {
655
- skip: !isWorkspaceMode || !isValidModuleId || !selectedDatasource || !selectedTable || !!(tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.synchronizeBlocked),
656
- }), tableDetail = _28.data, isTableDetailLoading = _28.isLoading, isTableDetailFetching = _28.isFetching, tableDetailError = _28.error, refetchTableDetail = _28.refetch;
657
- var _29 = useGetmodelByIdQuery((_f = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelId) !== null && _f !== void 0 ? _f : 0, {
658
- skip: !isWorkspaceMode || !(selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mapped) || !(selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelId),
659
- }), mappedModelResponse = _29.data, isMappedModelLoading = _29.isLoading, isMappedModelFetching = _29.isFetching, mappedModelError = _29.error;
660
- var mappedModelData = mappedModelResponse === null || mappedModelResponse === void 0 ? void 0 : mappedModelResponse.data;
661
- var selectedDatasourceRecord = (_h = (_g = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.datasources) === null || _g === void 0 ? void 0 : _g.find(function (datasource) { return datasource.name === selectedDatasource; })) !== null && _h !== void 0 ? _h : null;
662
- var activeFieldConfigColumn = (_j = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.find(function (column) { return column.columnName === fieldConfigColumnName; })) !== null && _j !== void 0 ? _j : null;
723
+ }), tablesResponse = _30.data, isTablesLoading = _30.isLoading, isTablesFetching = _30.isFetching, tablesError = _30.error, refetchTables = _30.refetch;
724
+ var selectedDatasourceRecord = (_c = (_b = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.datasources) === null || _b === void 0 ? void 0 : _b.find(function (datasource) { return datasource.name === selectedDatasource; })) !== null && _c !== void 0 ? _c : null;
725
+ var isSynchronizeBlocked = Boolean(selectedDatasource && (tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.synchronizeBlocked));
726
+ var makeTableKey = function (schema, tableName) { return "".concat(schema !== null && schema !== void 0 ? schema : "", "::").concat(tableName); };
727
+ var selectedListRowKeySet = useMemo(function () { return new Set(selectedRows.map(function (row) { return makeTableKey(row.schema, row.tableName); })); }, [selectedRows]);
728
+ var isWorkspaceMode = workspaceTableKeys.length > 0 && Boolean(activeWorkspaceTableKey);
729
+ var selectedTable = useMemo(function () { var _a, _b; return (_b = (_a = workspaceItems[activeWorkspaceTableKey]) === null || _a === void 0 ? void 0 : _a.record) !== null && _b !== void 0 ? _b : null; }, [activeWorkspaceTableKey, workspaceItems]);
730
+ var activeWorkspaceItem = activeWorkspaceTableKey ? (_d = workspaceItems[activeWorkspaceTableKey]) !== null && _d !== void 0 ? _d : null : null;
731
+ var drawerDraft = (_e = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.draft) !== null && _e !== void 0 ? _e : null;
732
+ var mappingPreview = (_f = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.mappingPreview) !== null && _f !== void 0 ? _f : null;
733
+ var persistedMappingResult = (_g = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.persistedMappingResult) !== null && _g !== void 0 ? _g : null;
734
+ var migrationArtifactsResult = (_h = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.migrationArtifactsResult) !== null && _h !== void 0 ? _h : null;
735
+ var reviewedMetadataJsonValue = (_j = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.reviewedMetadataJsonValue) !== null && _j !== void 0 ? _j : null;
736
+ var metadataJsonText = (_k = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.metadataJsonText) !== null && _k !== void 0 ? _k : "";
737
+ var metadataJsonValidationError = (_l = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.metadataJsonValidationError) !== null && _l !== void 0 ? _l : null;
738
+ var metadataJsonResetToken = (_m = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.metadataJsonResetToken) !== null && _m !== void 0 ? _m : "initial";
739
+ var activeFieldConfigColumn = (_o = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.find(function (column) { return column.columnName === fieldConfigColumnName; })) !== null && _o !== void 0 ? _o : null;
663
740
  var activeFieldConfigMetaData = useMemo(function () {
664
741
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
665
742
  if (!drawerDraft || !activeFieldConfigColumn) {
@@ -688,64 +765,11 @@ export function DatasourceIntrospectionPage() {
688
765
  });
689
766
  });
690
767
  }, [activeFieldConfigColumn, drawerDraft]);
691
- var drawerLoadingError = (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mapped) ? (tableDetailError || mappedModelError) : tableDetailError;
692
- var isDrawerBlockingLoading = Boolean(selectedTable
693
- && (drawerBootstrapping
694
- || !drawerDraft
695
- || isTableDetailLoading
696
- || isTableDetailFetching
697
- || (selectedTable.mapped && (isMappedModelLoading || isMappedModelFetching))));
698
- useEffect(function () {
699
- if (!isWorkspaceMode) {
700
- setDrawerDraft(null);
701
- setFieldConfigColumnName(null);
702
- return;
703
- }
704
- if (drawerBootstrapTimerRef.current) {
705
- window.clearTimeout(drawerBootstrapTimerRef.current);
706
- }
707
- setDrawerDraft(null);
708
- setFieldConfigColumnName(null);
709
- setDrawerTab("general-info");
710
- setWorkspaceStep("configure");
711
- setMappingPreview(null);
712
- setPersistedMappingResult(null);
713
- setMigrationArtifactsResult(null);
714
- setGenerateCodeOutput("");
715
- setIsGeneratingCodeWorkflow(false);
716
- setGenerateCodeStatusMessage("");
717
- setGenerateCodeTimeoutMessage(null);
718
- setGenerateCodeReady(false);
719
- setHasAttemptedGenerateCode(false);
720
- setRunMigrationOutput("");
721
- setRunMigrationCompleted(false);
722
- setReviewedMetadataJsonValue(null);
723
- setMetadataJsonText("");
724
- setMetadataJsonValidationError(null);
725
- setMetadataJsonResetToken("table-".concat(workspaceTableKey, "-").concat(Date.now()));
726
- setDrawerBootstrapping(true);
727
- }, [isWorkspaceMode, workspaceTableKey]);
728
- useEffect(function () {
729
- if (!isWorkspaceMode || !selectedTable)
730
- return;
731
- setSelectedRows([selectedTable]);
732
- }, [isWorkspaceMode, selectedTable]);
733
- useEffect(function () {
734
- if (!isWorkspaceMode || !selectedTable || !tableDetail)
735
- return;
736
- if (selectedTable.mapped && (!mappedModelData || mappedModelData.id !== selectedTable.mappedModelId))
737
- return;
738
- if (drawerBootstrapTimerRef.current) {
739
- window.clearTimeout(drawerBootstrapTimerRef.current);
740
- }
741
- setDrawerDraft(buildDrawerDraft(tableDetail, selectedTable, selectedTable.mapped ? mappedModelResponse : undefined));
742
- drawerBootstrapTimerRef.current = window.setTimeout(function () {
743
- setDrawerBootstrapping(false);
744
- }, 150);
745
- }, [isWorkspaceMode, selectedTable, tableDetail, mappedModelData, mappedModelResponse]);
768
+ var drawerLoadingError = (_p = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.error) !== null && _p !== void 0 ? _p : null;
769
+ var isDrawerBlockingLoading = (activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.loadStatus.state) === "loading" || !drawerDraft;
746
770
  var filteredRecords = useMemo(function () {
747
771
  var _a;
748
- var records = __spreadArray([], ((_a = tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records) !== null && _a !== void 0 ? _a : []), true);
772
+ var records = __spreadArray([], ((_a = tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records) !== null && _a !== void 0 ? _a : []), true).filter(function (record) { return !record.tableName.toLowerCase().startsWith("ss_"); });
749
773
  var searchNeedle = tableSearch.trim().toLowerCase();
750
774
  var filtered = searchNeedle
751
775
  ? records.filter(function (record) {
@@ -767,10 +791,118 @@ export function DatasourceIntrospectionPage() {
767
791
  }
768
792
  return filtered;
769
793
  }, [sessionSettings.prioritizeUnmappedTables, tableSearch, tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records]);
794
+ var workspaceRecords = useMemo(function () { return workspaceTableKeys
795
+ .map(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.record; })
796
+ .filter(Boolean); }, [workspaceItems, workspaceTableKeys]);
797
+ var selectedRowCount = selectedRows.length;
798
+ var visibleRowKeySet = useMemo(function () { return new Set(filteredRecords.map(function (row) { return makeTableKey(row.schema, row.tableName); })); }, [filteredRecords]);
799
+ var visibleSelectedRowCount = useMemo(function () { return selectedRows.filter(function (row) { return row.hasPrimaryKey && visibleRowKeySet.has(makeTableKey(row.schema, row.tableName)); }).length; }, [selectedRows, visibleRowKeySet]);
800
+ var visibleSelectableRowCount = useMemo(function () { return filteredRecords.filter(function (row) { return row.hasPrimaryKey; }).length; }, [filteredRecords]);
801
+ var hasVisibleRows = filteredRecords.length > 0;
802
+ var allVisibleRowsSelected = visibleSelectableRowCount > 0 && visibleSelectedRowCount === visibleSelectableRowCount;
803
+ var totalWorkspaceCount = workspaceTableKeys.length;
804
+ var activeWorkspacePosition = activeWorkspaceTableKey
805
+ ? Math.max(0, workspaceTableKeys.indexOf(activeWorkspaceTableKey)) + 1
806
+ : 0;
807
+ var allWorkspaceItemsReady = useMemo(function () { return workspaceTableKeys.length > 0 && workspaceTableKeys.every(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.draft; }); }, [workspaceItems, workspaceTableKeys]);
808
+ var allWorkspaceItemsPreviewed = useMemo(function () { return workspaceTableKeys.length > 0 && workspaceTableKeys.every(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview; }); }, [workspaceItems, workspaceTableKeys]);
809
+ var allWorkspaceItemsPersisted = useMemo(function () { return workspaceTableKeys.length > 0 && workspaceTableKeys.every(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.persistedMappingResult; }); }, [workspaceItems, workspaceTableKeys]);
810
+ var allWorkspaceItemsMigrated = useMemo(function () { return workspaceTableKeys.length > 0 && workspaceTableKeys.every(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.migrationArtifactsResult; }); }, [workspaceItems, workspaceTableKeys]);
811
+ var hasMigrationGenerationWork = useMemo(function () { return workspaceTableKeys.some(function (key) { var _a, _b; return Boolean((_b = (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview) === null || _b === void 0 ? void 0 : _b.migration.willGenerate); }); }, [workspaceItems, workspaceTableKeys]);
812
+ var reviewedWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview; }).length; }, [workspaceItems, workspaceTableKeys]);
813
+ var savedWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.persistedMappingResult; }).length; }, [workspaceItems, workspaceTableKeys]);
814
+ var migrationReadyWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.migrationArtifactsResult; }).length; }, [workspaceItems, workspaceTableKeys]);
815
+ var reviewErrorWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return ((_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.reviewStatus.state) === "error"; }).length; }, [workspaceItems, workspaceTableKeys]);
816
+ var saveErrorWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return ((_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.saveStatus.state) === "error"; }).length; }, [workspaceItems, workspaceTableKeys]);
817
+ var migrationErrorWorkspaceCount = useMemo(function () { return workspaceTableKeys.filter(function (key) { var _a; return ((_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.migrationStatus.state) === "error"; }).length; }, [workspaceItems, workspaceTableKeys]);
818
+ var totalIncludedMappedColumns = useMemo(function () { return workspaceTableKeys.reduce(function (count, key) {
819
+ var _a, _b;
820
+ var preview = (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview;
821
+ return count + ((_b = preview === null || preview === void 0 ? void 0 : preview.summary.includedColumnNames.length) !== null && _b !== void 0 ? _b : 0);
822
+ }, 0); }, [workspaceItems, workspaceTableKeys]);
823
+ var totalGeneratedSystemColumns = useMemo(function () { return workspaceTableKeys.reduce(function (count, key) {
824
+ var _a, _b;
825
+ var preview = (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview;
826
+ return count + ((_b = preview === null || preview === void 0 ? void 0 : preview.summary.generatedSystemColumnCount) !== null && _b !== void 0 ? _b : 0);
827
+ }, 0); }, [workspaceItems, workspaceTableKeys]);
828
+ var totalGeneratedMigrations = useMemo(function () { return workspaceTableKeys.reduce(function (count, key) {
829
+ var _a, _b;
830
+ return count + (((_b = (_a = workspaceItems[key]) === null || _a === void 0 ? void 0 : _a.mappingPreview) === null || _b === void 0 ? void 0 : _b.migration.willGenerate) ? 1 : 0);
831
+ }, 0); }, [workspaceItems, workspaceTableKeys]);
832
+ var updateWorkspaceItem = function (key, updater) {
833
+ setWorkspaceItems(function (current) {
834
+ var _a;
835
+ var item = current[key];
836
+ if (!item) {
837
+ return current;
838
+ }
839
+ return __assign(__assign({}, current), (_a = {}, _a[key] = updater(item), _a));
840
+ });
841
+ };
842
+ var buildWorkspacePlaceholder = function (record) { return ({
843
+ key: makeTableKey(record.schema, record.tableName),
844
+ record: record,
845
+ detail: null,
846
+ mappedModelData: null,
847
+ draft: null,
848
+ loadStatus: { state: "loading", message: "Loading mapping workspace..." },
849
+ reviewStatus: { state: "idle", message: "Not reviewed yet." },
850
+ saveStatus: { state: "idle", message: "Not saved yet." },
851
+ migrationStatus: { state: "idle", message: "Migration artifacts not created yet." },
852
+ mappingPreview: null,
853
+ persistedMappingResult: null,
854
+ migrationArtifactsResult: null,
855
+ reviewedMetadataJsonValue: null,
856
+ metadataJsonText: "",
857
+ metadataJsonValidationError: null,
858
+ metadataJsonResetToken: "workspace-".concat(record.tableName, "-").concat(Date.now()),
859
+ error: null,
860
+ }); };
861
+ var loadWorkspaceItem = function (record) { return __awaiter(_this, void 0, void 0, function () {
862
+ var key, tableDetailRequest, tableDetailData_1, mappedModelData_1, modelRequest, modelResponse, draft_1, error_1;
863
+ var _a, _b, _c, _d, _e;
864
+ return __generator(this, function (_f) {
865
+ switch (_f.label) {
866
+ case 0:
867
+ key = makeTableKey(record.schema, record.tableName);
868
+ _f.label = 1;
869
+ case 1:
870
+ _f.trys.push([1, 5, , 6]);
871
+ tableDetailRequest = dispatch(datasourceIntrospectionApi.endpoints.getDatasourceIntrospectionTableDetail.initiate({
872
+ moduleId: moduleId,
873
+ datasource: selectedDatasource,
874
+ table: record.tableName,
875
+ schema: (_a = record.schema) !== null && _a !== void 0 ? _a : undefined,
876
+ }));
877
+ return [4 /*yield*/, tableDetailRequest.unwrap()];
878
+ case 2:
879
+ tableDetailData_1 = _f.sent();
880
+ (_b = tableDetailRequest.unsubscribe) === null || _b === void 0 ? void 0 : _b.call(tableDetailRequest);
881
+ mappedModelData_1 = null;
882
+ if (!(record.mapped && record.mappedModelId)) return [3 /*break*/, 4];
883
+ modelRequest = dispatch(modelsApi.endpoints.getmodelById.initiate(record.mappedModelId));
884
+ return [4 /*yield*/, modelRequest.unwrap()];
885
+ case 3:
886
+ modelResponse = _f.sent();
887
+ (_c = modelRequest.unsubscribe) === null || _c === void 0 ? void 0 : _c.call(modelRequest);
888
+ mappedModelData_1 = (_e = (_d = modelResponse === null || modelResponse === void 0 ? void 0 : modelResponse.data) !== null && _d !== void 0 ? _d : modelResponse) !== null && _e !== void 0 ? _e : null;
889
+ _f.label = 4;
890
+ case 4:
891
+ draft_1 = buildDrawerDraft(tableDetailData_1, record, mappedModelData_1 ? { data: mappedModelData_1 } : undefined);
892
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { detail: tableDetailData_1, mappedModelData: mappedModelData_1, draft: draft_1, loadStatus: { state: "ready", message: "Ready to configure." }, error: null })); });
893
+ return [3 /*break*/, 6];
894
+ case 5:
895
+ error_1 = _f.sent();
896
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { loadStatus: { state: "error", message: readQueryError(error_1) }, error: readQueryError(error_1) })); });
897
+ return [3 /*break*/, 6];
898
+ case 6: return [2 /*return*/];
899
+ }
900
+ });
901
+ }); };
770
902
  var drawerUserKeyOptions = useMemo(function () {
771
- var _a;
903
+ var _a, _b;
772
904
  var options = new Map();
773
- (_a = tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.userKeyCandidates) === null || _a === void 0 ? void 0 : _a.forEach(function (candidate) {
905
+ (_b = (_a = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.detail) === null || _a === void 0 ? void 0 : _a.userKeyCandidates) === null || _b === void 0 ? void 0 : _b.forEach(function (candidate) {
774
906
  options.set(candidate.name, {
775
907
  label: "".concat(candidate.label, " \u00B7 ").concat(candidate.reason),
776
908
  value: candidate.name,
@@ -785,12 +917,12 @@ export function DatasourceIntrospectionPage() {
785
917
  }
786
918
  });
787
919
  return Array.from(options.values());
788
- }, [drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns, tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.userKeyCandidates]);
920
+ }, [(_q = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.detail) === null || _q === void 0 ? void 0 : _q.userKeyCandidates, drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns]);
789
921
  var settingsTabs = [
790
922
  {
791
923
  value: "datasource-info",
792
924
  label: "Datasource Info",
793
- content: (_jsxs("div", { className: "sdix-settings-grid", children: [_jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Target module" }), _jsx("strong", { children: (_k = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _k === void 0 ? void 0 : _k.displayName })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Default datasource" }), _jsx("strong", { children: ((_l = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _l === void 0 ? void 0 : _l.defaultDataSource) || "Not set" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Datasource name" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.displayName) || "Not selected" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Datasource type" }), _jsx("strong", { children: selectedDatasourceRecord ? providerLabel(selectedDatasourceRecord.type) : "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Host" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.host) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Port" }), _jsx("strong", { children: (_m = selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.port) !== null && _m !== void 0 ? _m : "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Database" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.database) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Env Prefix" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.envPrefix) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Synchronize" }), _jsx("strong", { children: selectedDatasourceRecord ? (selectedDatasourceRecord.synchronize === true ? "true" : "false") : "-" })] })] })),
925
+ content: (_jsxs("div", { className: "sdix-settings-grid", children: [_jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Target module" }), _jsx("strong", { children: (_r = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _r === void 0 ? void 0 : _r.displayName })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Default datasource" }), _jsx("strong", { children: ((_s = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _s === void 0 ? void 0 : _s.defaultDataSource) || "Not set" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Datasource name" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.displayName) || "Not selected" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Datasource type" }), _jsx("strong", { children: selectedDatasourceRecord ? providerLabel(selectedDatasourceRecord.type) : "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Host" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.host) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Port" }), _jsx("strong", { children: (_t = selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.port) !== null && _t !== void 0 ? _t : "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Database" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.database) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Env Prefix" }), _jsx("strong", { children: (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.envPrefix) || "-" })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Synchronize" }), _jsx("strong", { children: selectedDatasourceRecord ? (selectedDatasourceRecord.synchronize === true ? "true" : "false") : "-" })] })] })),
794
926
  },
795
927
  {
796
928
  value: "session-settings",
@@ -810,35 +942,95 @@ export function DatasourceIntrospectionPage() {
810
942
  _a.sent();
811
943
  _a.label = 3;
812
944
  case 3:
813
- if (!(isWorkspaceMode && selectedTable)) return [3 /*break*/, 5];
814
- return [4 /*yield*/, refetchTableDetail()];
815
- case 4:
816
- _a.sent();
817
- _a.label = 5;
818
- case 5: return [2 /*return*/];
945
+ if (isWorkspaceMode) {
946
+ workspaceRecords.forEach(function (record) {
947
+ void loadWorkspaceItem(record);
948
+ });
949
+ }
950
+ return [2 /*return*/];
819
951
  }
820
952
  });
821
953
  }); };
822
- var startMappingForRecord = function (record) {
823
- var _a;
824
- if (drawerBootstrapTimerRef.current) {
825
- window.clearTimeout(drawerBootstrapTimerRef.current);
954
+ var toggleSelectedRow = function (row, checked) {
955
+ if (!row.hasPrimaryKey) {
956
+ return;
826
957
  }
827
- setSelectedRows([record]);
828
- setWorkspaceTableKey("".concat((_a = record.schema) !== null && _a !== void 0 ? _a : "", "::").concat(record.tableName));
958
+ var rowKey = makeTableKey(row.schema, row.tableName);
959
+ setSelectedRows(function (current) {
960
+ var exists = current.some(function (item) { return makeTableKey(item.schema, item.tableName) === rowKey; });
961
+ var shouldInclude = checked !== null && checked !== void 0 ? checked : !exists;
962
+ if (shouldInclude) {
963
+ if (exists)
964
+ return current;
965
+ return __spreadArray(__spreadArray([], current, true), [row], false);
966
+ }
967
+ return current.filter(function (item) { return makeTableKey(item.schema, item.tableName) !== rowKey; });
968
+ });
829
969
  };
830
- var leaveWorkspace = function () {
831
- if (drawerBootstrapTimerRef.current) {
832
- window.clearTimeout(drawerBootstrapTimerRef.current);
970
+ var toggleAllVisibleRows = function (checked) {
971
+ setSelectedRows(function (current) {
972
+ if (checked) {
973
+ var merged_1 = __spreadArray([], current, true);
974
+ var currentKeySet_1 = new Set(current.map(function (row) { return makeTableKey(row.schema, row.tableName); }));
975
+ filteredRecords.forEach(function (row) {
976
+ if (!row.hasPrimaryKey) {
977
+ return;
978
+ }
979
+ var rowKey = makeTableKey(row.schema, row.tableName);
980
+ if (!currentKeySet_1.has(rowKey)) {
981
+ merged_1.push(row);
982
+ }
983
+ });
984
+ return merged_1;
985
+ }
986
+ return current.filter(function (row) { return !visibleRowKeySet.has(makeTableKey(row.schema, row.tableName)); });
987
+ });
988
+ };
989
+ var startMappingForRows = function (records) {
990
+ if (!records.length)
991
+ return;
992
+ var eligibleRecords = records.filter(function (record) { return record.hasPrimaryKey; });
993
+ var skippedRecords = records.filter(function (record) { return !record.hasPrimaryKey; });
994
+ if (skippedRecords.length) {
995
+ dispatch(showToast({
996
+ severity: "warn",
997
+ summary: "Skipped blocked tables",
998
+ detail: skippedRecords.length === 1
999
+ ? skippedRecords[0].mappingBlockedReason || "Table \"".concat(skippedRecords[0].tableName, "\" was skipped because it has no primary key.")
1000
+ : "".concat(skippedRecords.length, " tables were skipped because they do not define a datasource primary key."),
1001
+ }));
833
1002
  }
834
- setWorkspaceTableKey("");
835
- setDrawerDraft(null);
1003
+ if (!eligibleRecords.length) {
1004
+ return;
1005
+ }
1006
+ var keys = eligibleRecords.map(function (record) { return makeTableKey(record.schema, record.tableName); });
1007
+ var nextWorkspaceItems = Object.fromEntries(eligibleRecords.map(function (record) { return [makeTableKey(record.schema, record.tableName), buildWorkspacePlaceholder(record)]; }));
1008
+ setSelectedRows(eligibleRecords);
1009
+ setWorkspaceTableKeys(keys);
1010
+ setActiveWorkspaceTableKey(keys[0]);
1011
+ setWorkspaceItems(nextWorkspaceItems);
1012
+ setFieldConfigColumnName(null);
1013
+ setDrawerTab("general-info");
1014
+ setWorkspaceStep("configure");
1015
+ setGenerateCodeOutput("");
1016
+ setIsGeneratingCodeWorkflow(false);
1017
+ setGenerateCodeStatusMessage("");
1018
+ setGenerateCodeTimeoutMessage(null);
1019
+ setGenerateCodeReady(false);
1020
+ setHasAttemptedGenerateCode(false);
1021
+ setRunMigrationOutput("");
1022
+ setRunMigrationCompleted(false);
1023
+ eligibleRecords.forEach(function (record) {
1024
+ void loadWorkspaceItem(record);
1025
+ });
1026
+ };
1027
+ var leaveWorkspace = function () {
1028
+ setWorkspaceTableKeys([]);
1029
+ setActiveWorkspaceTableKey("");
1030
+ setWorkspaceItems({});
836
1031
  setFieldConfigColumnName(null);
837
1032
  setWorkspaceStep("configure");
838
1033
  setDrawerTab("general-info");
839
- setMappingPreview(null);
840
- setPersistedMappingResult(null);
841
- setMigrationArtifactsResult(null);
842
1034
  setGenerateCodeOutput("");
843
1035
  setIsGeneratingCodeWorkflow(false);
844
1036
  setGenerateCodeStatusMessage("");
@@ -847,29 +1039,62 @@ export function DatasourceIntrospectionPage() {
847
1039
  setHasAttemptedGenerateCode(false);
848
1040
  setRunMigrationOutput("");
849
1041
  setRunMigrationCompleted(false);
850
- setReviewedMetadataJsonValue(null);
851
- setMetadataJsonText("");
852
- setMetadataJsonValidationError(null);
853
- setMetadataJsonResetToken("workspace-closed-".concat(Date.now()));
854
- setDrawerBootstrapping(false);
855
1042
  };
856
1043
  var applyDraftSettings = function () {
857
1044
  setSessionSettings(draftSessionSettings);
858
1045
  setSettingsOpen(false);
859
1046
  };
1047
+ var updateActiveWorkspaceItem = function (updater) {
1048
+ if (!activeWorkspaceTableKey)
1049
+ return;
1050
+ updateWorkspaceItem(activeWorkspaceTableKey, updater);
1051
+ };
860
1052
  var updateDrawerDraft = function (updater) {
861
- setMappingPreview(null);
862
- setPersistedMappingResult(null);
863
- setMigrationArtifactsResult(null);
864
1053
  setGenerateCodeOutput("");
865
1054
  setIsGeneratingCodeWorkflow(false);
866
1055
  setGenerateCodeStatusMessage("");
867
1056
  setGenerateCodeTimeoutMessage(null);
868
1057
  setGenerateCodeReady(false);
869
1058
  setHasAttemptedGenerateCode(false);
1059
+ setMigrationPreviewCopied(false);
870
1060
  setRunMigrationOutput("");
871
- setDrawerDraft(function (current) { return (current ? updater(current) : current); });
1061
+ updateActiveWorkspaceItem(function (current) { return (__assign(__assign({}, current), { mappingPreview: null, persistedMappingResult: null, migrationArtifactsResult: null, reviewStatus: { state: "idle", message: "Not reviewed yet." }, saveStatus: { state: "idle", message: "Not saved yet." }, migrationStatus: { state: "idle", message: "Migration artifacts not created yet." }, draft: current.draft ? updater(current.draft) : current.draft })); });
872
1062
  };
1063
+ var handleCopyMigrationPreview = function () { return __awaiter(_this, void 0, void 0, function () {
1064
+ var migrationContent, error_2;
1065
+ return __generator(this, function (_a) {
1066
+ switch (_a.label) {
1067
+ case 0:
1068
+ migrationContent = mappingPreview === null || mappingPreview === void 0 ? void 0 : mappingPreview.migration.content;
1069
+ if (!migrationContent) {
1070
+ return [2 /*return*/];
1071
+ }
1072
+ _a.label = 1;
1073
+ case 1:
1074
+ _a.trys.push([1, 3, , 4]);
1075
+ return [4 /*yield*/, navigator.clipboard.writeText(migrationContent)];
1076
+ case 2:
1077
+ _a.sent();
1078
+ setMigrationPreviewCopied(true);
1079
+ window.setTimeout(function () { return setMigrationPreviewCopied(false); }, 2000);
1080
+ dispatch(showToast({
1081
+ severity: "success",
1082
+ summary: "Migration copied",
1083
+ detail: "The migration preview was copied to the clipboard.",
1084
+ }));
1085
+ return [3 /*break*/, 4];
1086
+ case 3:
1087
+ error_2 = _a.sent();
1088
+ dispatch(showToast({
1089
+ severity: "error",
1090
+ summary: "Copy failed",
1091
+ detail: "Unable to copy the migration preview to the clipboard.",
1092
+ }));
1093
+ return [3 /*break*/, 4];
1094
+ case 4: return [2 /*return*/];
1095
+ }
1096
+ });
1097
+ }); };
873
1098
  var updateGeneralField = function (field, value) {
874
1099
  updateDrawerDraft(function (current) {
875
1100
  var _a;
@@ -901,16 +1126,6 @@ export function DatasourceIntrospectionPage() {
901
1126
  ? __assign(__assign({}, column), { displayName: nextDisplayName, fieldConfig: column.fieldConfig
902
1127
  ? __assign(__assign({}, column.fieldConfig), { displayName: nextDisplayName }) : column.fieldConfig }) : column); }) })); });
903
1128
  };
904
- var updateColumnSolidFieldType = function (columnName, nextSolidFieldType) {
905
- updateDrawerDraft(function (current) { return (__assign(__assign({}, current), { columns: current.columns.map(function (column) {
906
- if (column.columnName !== columnName)
907
- return column;
908
- if (column.handledBySuperclass)
909
- return column;
910
- return __assign(__assign({}, column), { solidFieldType: nextSolidFieldType, ormType: getDefaultOrmTypeForSolidFieldType(current.dataSourceType, nextSolidFieldType), fieldConfig: column.fieldConfig
911
- ? __assign(__assign({}, column.fieldConfig), { type: nextSolidFieldType, ormType: getDefaultOrmTypeForSolidFieldType(current.dataSourceType, nextSolidFieldType) }) : column.fieldConfig });
912
- }) })); });
913
- };
914
1129
  var openFieldConfigEditor = function (columnName) {
915
1130
  setFieldConfigColumnName(columnName);
916
1131
  };
@@ -1006,124 +1221,193 @@ export function DatasourceIntrospectionPage() {
1006
1221
  window.open("/admin/core/solid-core/model-metadata/form/".concat(targetModelId), "_blank", "noopener,noreferrer");
1007
1222
  };
1008
1223
  var reviewMappingJson = function () { return __awaiter(_this, void 0, void 0, function () {
1009
- var validationErrors, preview, error_1;
1224
+ var tablesWithErrors, firstSuccessKey, _loop_1, _i, workspaceTableKeys_1, key;
1010
1225
  var _a;
1011
1226
  return __generator(this, function (_b) {
1012
1227
  switch (_b.label) {
1013
1228
  case 0:
1014
- if (!drawerDraft || !((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id))
1229
+ if (!((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id) || !workspaceTableKeys.length)
1015
1230
  return [2 /*return*/];
1016
- validationErrors = getDrawerValidationErrors(drawerDraft);
1017
- if (validationErrors.length) {
1018
- validationErrors.forEach(function (detail) {
1019
- dispatch(showToast({ severity: "error", summary: "Validation", detail: detail }));
1231
+ tablesWithErrors = workspaceTableKeys
1232
+ .map(function (key) { return ({ key: key, item: workspaceItems[key] }); })
1233
+ .filter(function (entry) { var _a; return (_a = entry.item) === null || _a === void 0 ? void 0 : _a.draft; })
1234
+ .flatMap(function (_a) {
1235
+ var item = _a.item;
1236
+ return getDrawerValidationErrors(item.draft).map(function (detail) { return ({
1237
+ tableName: item === null || item === void 0 ? void 0 : item.record.tableName,
1238
+ detail: detail,
1239
+ }); });
1240
+ });
1241
+ if (tablesWithErrors.length) {
1242
+ tablesWithErrors.forEach(function (_a) {
1243
+ var tableName = _a.tableName, detail = _a.detail;
1244
+ dispatch(showToast({ severity: "error", summary: tableName || "Validation", detail: detail }));
1020
1245
  });
1021
1246
  return [2 /*return*/];
1022
1247
  }
1248
+ firstSuccessKey = "";
1249
+ _loop_1 = function (key) {
1250
+ var item, preview_1, error_3;
1251
+ return __generator(this, function (_c) {
1252
+ switch (_c.label) {
1253
+ case 0:
1254
+ item = workspaceItems[key];
1255
+ if (!(item === null || item === void 0 ? void 0 : item.draft))
1256
+ return [2 /*return*/, "continue"];
1257
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { reviewStatus: { state: "loading", message: "Generating mapping preview..." } })); });
1258
+ _c.label = 1;
1259
+ case 1:
1260
+ _c.trys.push([1, 3, , 4]);
1261
+ return [4 /*yield*/, previewMapping({
1262
+ moduleId: bootstrap.module.id,
1263
+ payload: buildMappingRequest(item.draft),
1264
+ }).unwrap()];
1265
+ case 2:
1266
+ preview_1 = _c.sent();
1267
+ if (!firstSuccessKey) {
1268
+ firstSuccessKey = key;
1269
+ }
1270
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { mappingPreview: preview_1, reviewedMetadataJsonValue: preview_1.metadataJson.model, metadataJsonText: JSON.stringify(preview_1.metadataJson.model, null, 2), metadataJsonValidationError: null, metadataJsonResetToken: "preview-".concat(preview_1.metadataJson.filePath, "-").concat(Date.now()), persistedMappingResult: null, migrationArtifactsResult: null, reviewStatus: { state: "success", message: "Preview ready." }, saveStatus: { state: "idle", message: "Not saved yet." }, migrationStatus: { state: "idle", message: "Migration artifacts not created yet." } })); });
1271
+ return [3 /*break*/, 4];
1272
+ case 3:
1273
+ error_3 = _c.sent();
1274
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { reviewStatus: { state: "error", message: readQueryError(error_3) } })); });
1275
+ dispatch(showToast({
1276
+ severity: "error",
1277
+ summary: "Preview failed for ".concat(item.record.tableName),
1278
+ detail: readQueryError(error_3),
1279
+ }));
1280
+ return [3 /*break*/, 4];
1281
+ case 4: return [2 /*return*/];
1282
+ }
1283
+ });
1284
+ };
1285
+ _i = 0, workspaceTableKeys_1 = workspaceTableKeys;
1023
1286
  _b.label = 1;
1024
1287
  case 1:
1025
- _b.trys.push([1, 3, , 4]);
1026
- return [4 /*yield*/, previewMapping({
1027
- moduleId: bootstrap.module.id,
1028
- payload: buildMappingRequest(drawerDraft),
1029
- }).unwrap()];
1288
+ if (!(_i < workspaceTableKeys_1.length)) return [3 /*break*/, 4];
1289
+ key = workspaceTableKeys_1[_i];
1290
+ return [5 /*yield**/, _loop_1(key)];
1030
1291
  case 2:
1031
- preview = _b.sent();
1032
- setMappingPreview(preview);
1033
- setReviewedMetadataJsonValue(preview.metadataJson.model);
1034
- setMetadataJsonText(JSON.stringify(preview.metadataJson.model, null, 2));
1035
- setMetadataJsonValidationError(null);
1036
- setMetadataJsonResetToken("preview-".concat(preview.metadataJson.filePath, "-").concat(Date.now()));
1037
- setPersistedMappingResult(null);
1038
- setMigrationArtifactsResult(null);
1039
- setGenerateCodeOutput("");
1040
- setRunMigrationOutput("");
1041
- setWorkspaceStep("review-json");
1042
- return [3 /*break*/, 4];
1292
+ _b.sent();
1293
+ _b.label = 3;
1043
1294
  case 3:
1044
- error_1 = _b.sent();
1045
- dispatch(showToast({
1046
- severity: "error",
1047
- summary: "Preview failed",
1048
- detail: readQueryError(error_1),
1049
- }));
1050
- return [3 /*break*/, 4];
1051
- case 4: return [2 /*return*/];
1295
+ _i++;
1296
+ return [3 /*break*/, 1];
1297
+ case 4:
1298
+ if (firstSuccessKey) {
1299
+ setActiveWorkspaceTableKey(firstSuccessKey);
1300
+ setWorkspaceStep("review-json");
1301
+ setGenerateCodeOutput("");
1302
+ setRunMigrationOutput("");
1303
+ }
1304
+ return [2 /*return*/];
1052
1305
  }
1053
1306
  });
1054
1307
  }); };
1055
1308
  var persistMappingArtifacts = function () { return __awaiter(_this, void 0, void 0, function () {
1056
- var validationErrors, reviewedModelValidation, response_1, error_2;
1057
- var _a, _b, _c, _d;
1058
- return __generator(this, function (_e) {
1059
- switch (_e.label) {
1309
+ var firstSavedKey, _loop_2, _i, workspaceTableKeys_2, key;
1310
+ var _a, _b, _c;
1311
+ return __generator(this, function (_d) {
1312
+ switch (_d.label) {
1060
1313
  case 0:
1061
- if (!drawerDraft || !((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id))
1314
+ if (!((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id) || !workspaceTableKeys.length)
1062
1315
  return [2 /*return*/];
1063
- validationErrors = getDrawerValidationErrors(drawerDraft);
1064
- if (validationErrors.length) {
1065
- validationErrors.forEach(function (detail) {
1066
- dispatch(showToast({ severity: "error", summary: "Validation", detail: detail }));
1316
+ firstSavedKey = "";
1317
+ _loop_2 = function (key) {
1318
+ var item, validationErrors, reviewedModelValidation, response_1, error_4;
1319
+ return __generator(this, function (_e) {
1320
+ switch (_e.label) {
1321
+ case 0:
1322
+ item = workspaceItems[key];
1323
+ if (!(item === null || item === void 0 ? void 0 : item.draft) || !item.mappingPreview)
1324
+ return [2 /*return*/, "continue"];
1325
+ validationErrors = getDrawerValidationErrors(item.draft);
1326
+ if (validationErrors.length) {
1327
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { saveStatus: { state: "error", message: validationErrors[0] } })); });
1328
+ validationErrors.forEach(function (detail) {
1329
+ dispatch(showToast({ severity: "error", summary: item.record.tableName, detail: detail }));
1330
+ });
1331
+ return [2 /*return*/, "continue"];
1332
+ }
1333
+ reviewedModelValidation = parseAndValidateReviewedModelJson(item.metadataJsonText, item.draft);
1334
+ if (reviewedModelValidation.error || !reviewedModelValidation.parsed) {
1335
+ updateWorkspaceItem(key, function (current) {
1336
+ var _a, _b;
1337
+ return (__assign(__assign({}, current), { metadataJsonValidationError: (_a = reviewedModelValidation.error) !== null && _a !== void 0 ? _a : "Metadata JSON is invalid.", saveStatus: { state: "error", message: (_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid." } }));
1338
+ });
1339
+ dispatch(showToast({
1340
+ severity: "error",
1341
+ summary: item.record.tableName,
1342
+ detail: (_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid.",
1343
+ }));
1344
+ return [2 /*return*/, "continue"];
1345
+ }
1346
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { metadataJsonValidationError: null, saveStatus: { state: "loading", message: "Saving mapping..." } })); });
1347
+ _e.label = 1;
1348
+ case 1:
1349
+ _e.trys.push([1, 3, , 4]);
1350
+ return [4 /*yield*/, applyMapping({
1351
+ moduleId: bootstrap.module.id,
1352
+ payload: __assign(__assign({}, buildMappingRequest(item.draft, (_c = item.mappingPreview.migration.timestamp) !== null && _c !== void 0 ? _c : null)), { reviewedModel: reviewedModelValidation.parsed }),
1353
+ }).unwrap()];
1354
+ case 2:
1355
+ response_1 = _e.sent();
1356
+ if (!firstSavedKey) {
1357
+ firstSavedKey = key;
1358
+ }
1359
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { persistedMappingResult: response_1, migrationArtifactsResult: null, saveStatus: { state: "success", message: "Mapping saved." }, migrationStatus: { state: "idle", message: "Migration artifacts not created yet." }, draft: current.draft
1360
+ ? __assign(__assign({}, current.draft), { mapped: true, modelId: response_1.modelId }) : current.draft, record: __assign(__assign({}, current.record), { mapped: true, mappedModelId: response_1.modelId }) })); });
1361
+ return [3 /*break*/, 4];
1362
+ case 3:
1363
+ error_4 = _e.sent();
1364
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { saveStatus: { state: "error", message: readQueryError(error_4) } })); });
1365
+ dispatch(showToast({
1366
+ severity: "error",
1367
+ summary: "Save failed for ".concat(item.record.tableName),
1368
+ detail: readQueryError(error_4),
1369
+ }));
1370
+ return [3 /*break*/, 4];
1371
+ case 4: return [2 /*return*/];
1372
+ }
1067
1373
  });
1068
- setWorkspaceStep("configure");
1069
- return [2 /*return*/];
1070
- }
1071
- reviewedModelValidation = parseAndValidateReviewedModelJson(metadataJsonText, drawerDraft);
1072
- if (reviewedModelValidation.error || !reviewedModelValidation.parsed) {
1073
- setMetadataJsonValidationError((_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid.");
1074
- setWorkspaceStep("review-json");
1075
- dispatch(showToast({
1076
- severity: "error",
1077
- summary: "Validation",
1078
- detail: (_c = reviewedModelValidation.error) !== null && _c !== void 0 ? _c : "Metadata JSON is invalid.",
1079
- }));
1080
- return [2 /*return*/];
1081
- }
1082
- setMetadataJsonValidationError(null);
1083
- _e.label = 1;
1374
+ };
1375
+ _i = 0, workspaceTableKeys_2 = workspaceTableKeys;
1376
+ _d.label = 1;
1084
1377
  case 1:
1085
- _e.trys.push([1, 3, , 4]);
1086
- return [4 /*yield*/, applyMapping({
1087
- moduleId: bootstrap.module.id,
1088
- payload: __assign(__assign({}, buildMappingRequest(drawerDraft, (_d = mappingPreview === null || mappingPreview === void 0 ? void 0 : mappingPreview.migration.timestamp) !== null && _d !== void 0 ? _d : null)), { reviewedModel: reviewedModelValidation.parsed }),
1089
- }).unwrap()];
1378
+ if (!(_i < workspaceTableKeys_2.length)) return [3 /*break*/, 4];
1379
+ key = workspaceTableKeys_2[_i];
1380
+ return [5 /*yield**/, _loop_2(key)];
1090
1381
  case 2:
1091
- response_1 = _e.sent();
1092
- dispatch(showToast({
1093
- severity: "success",
1094
- summary: "Mapping saved",
1095
- detail: drawerDraft.mapped
1096
- ? "The model mapping metadata was updated successfully."
1097
- : "The model mapping metadata was created successfully.",
1098
- }));
1099
- setPersistedMappingResult(response_1);
1100
- setMigrationArtifactsResult(null);
1101
- setGenerateCodeOutput("");
1102
- setIsGeneratingCodeWorkflow(false);
1103
- setGenerateCodeStatusMessage("");
1104
- setGenerateCodeTimeoutMessage(null);
1105
- setGenerateCodeReady(false);
1106
- setHasAttemptedGenerateCode(false);
1107
- setRunMigrationOutput("");
1108
- setRunMigrationCompleted(false);
1109
- setDrawerDraft(function (current) { return (current
1110
- ? __assign(__assign({}, current), { mapped: true, modelId: response_1.modelId }) : current); });
1111
- setWorkspaceStep("generate-code");
1112
- return [3 /*break*/, 4];
1382
+ _d.sent();
1383
+ _d.label = 3;
1113
1384
  case 3:
1114
- error_2 = _e.sent();
1115
- dispatch(showToast({
1116
- severity: "error",
1117
- summary: "Save failed",
1118
- detail: readQueryError(error_2),
1119
- }));
1120
- return [3 /*break*/, 4];
1121
- case 4: return [2 /*return*/];
1385
+ _i++;
1386
+ return [3 /*break*/, 1];
1387
+ case 4:
1388
+ if (firstSavedKey) {
1389
+ setActiveWorkspaceTableKey(firstSavedKey);
1390
+ setGenerateCodeOutput("");
1391
+ setIsGeneratingCodeWorkflow(false);
1392
+ setGenerateCodeStatusMessage("");
1393
+ setGenerateCodeTimeoutMessage(null);
1394
+ setGenerateCodeReady(false);
1395
+ setHasAttemptedGenerateCode(false);
1396
+ setRunMigrationOutput("");
1397
+ setRunMigrationCompleted(false);
1398
+ setWorkspaceStep("generate-code");
1399
+ dispatch(showToast({
1400
+ severity: "success",
1401
+ summary: "Mappings saved",
1402
+ detail: "The selected table mappings were saved successfully.",
1403
+ }));
1404
+ }
1405
+ return [2 /*return*/];
1122
1406
  }
1123
1407
  });
1124
1408
  }); };
1125
1409
  var handleGenerateCode = function () { return __awaiter(_this, void 0, void 0, function () {
1126
- var responseMessage, response, error_3, isBackendAvailable;
1410
+ var responseMessage, response, error_5, isBackendAvailable;
1127
1411
  var _a;
1128
1412
  return __generator(this, function (_b) {
1129
1413
  switch (_b.label) {
@@ -1148,8 +1432,8 @@ export function DatasourceIntrospectionPage() {
1148
1432
  setGenerateCodeStatusMessage("Waiting briefly for the backend restart window...");
1149
1433
  return [3 /*break*/, 4];
1150
1434
  case 3:
1151
- error_3 = _b.sent();
1152
- if (!isRecoverableGenerateCodeError(error_3)) {
1435
+ error_5 = _b.sent();
1436
+ if (!isRecoverableGenerateCodeError(error_5)) {
1153
1437
  setIsGeneratingCodeWorkflow(false);
1154
1438
  setGenerateCodeStatusMessage("");
1155
1439
  setGenerateCodeTimeoutMessage(null);
@@ -1157,7 +1441,7 @@ export function DatasourceIntrospectionPage() {
1157
1441
  dispatch(showToast({
1158
1442
  severity: "error",
1159
1443
  summary: "Generate code failed",
1160
- detail: readQueryError(error_3),
1444
+ detail: readQueryError(error_5),
1161
1445
  }));
1162
1446
  return [2 /*return*/];
1163
1447
  }
@@ -1185,7 +1469,6 @@ export function DatasourceIntrospectionPage() {
1185
1469
  }
1186
1470
  setGenerateCodeStatusMessage("Backend is back online. You can continue.");
1187
1471
  setGenerateCodeReady(true);
1188
- setMigrationArtifactsResult(null);
1189
1472
  setRunMigrationOutput("");
1190
1473
  dispatch(showToast({
1191
1474
  severity: "success",
@@ -1197,57 +1480,94 @@ export function DatasourceIntrospectionPage() {
1197
1480
  });
1198
1481
  }); };
1199
1482
  var handleCreateMigrationArtifacts = function () { return __awaiter(_this, void 0, void 0, function () {
1200
- var reviewedModelValidation, response, error_4;
1483
+ var firstMigrationKey, _loop_3, _i, workspaceTableKeys_3, key;
1201
1484
  var _a, _b, _c, _d;
1202
1485
  return __generator(this, function (_e) {
1203
1486
  switch (_e.label) {
1204
1487
  case 0:
1205
- if (!drawerDraft || !((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id) || !(persistedMappingResult === null || persistedMappingResult === void 0 ? void 0 : persistedMappingResult.modelId))
1488
+ if (!((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id) || !workspaceTableKeys.length)
1206
1489
  return [2 /*return*/];
1207
- reviewedModelValidation = parseAndValidateReviewedModelJson(metadataJsonText, drawerDraft);
1208
- if (reviewedModelValidation.error || !reviewedModelValidation.parsed) {
1209
- setMetadataJsonValidationError((_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid.");
1210
- setWorkspaceStep("review-json");
1211
- dispatch(showToast({
1212
- severity: "error",
1213
- summary: "Validation",
1214
- detail: (_c = reviewedModelValidation.error) !== null && _c !== void 0 ? _c : "Metadata JSON is invalid.",
1215
- }));
1216
- return [2 /*return*/];
1217
- }
1490
+ firstMigrationKey = "";
1491
+ _loop_3 = function (key) {
1492
+ var item, reviewedModelValidation, response_2, error_6;
1493
+ return __generator(this, function (_f) {
1494
+ switch (_f.label) {
1495
+ case 0:
1496
+ item = workspaceItems[key];
1497
+ if (!(item === null || item === void 0 ? void 0 : item.draft) || !((_b = item.persistedMappingResult) === null || _b === void 0 ? void 0 : _b.modelId) || !item.mappingPreview)
1498
+ return [2 /*return*/, "continue"];
1499
+ reviewedModelValidation = parseAndValidateReviewedModelJson(item.metadataJsonText, item.draft);
1500
+ if (reviewedModelValidation.error || !reviewedModelValidation.parsed) {
1501
+ updateWorkspaceItem(key, function (current) {
1502
+ var _a, _b;
1503
+ return (__assign(__assign({}, current), { metadataJsonValidationError: (_a = reviewedModelValidation.error) !== null && _a !== void 0 ? _a : "Metadata JSON is invalid.", migrationStatus: { state: "error", message: (_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid." } }));
1504
+ });
1505
+ dispatch(showToast({
1506
+ severity: "error",
1507
+ summary: item.record.tableName,
1508
+ detail: (_c = reviewedModelValidation.error) !== null && _c !== void 0 ? _c : "Metadata JSON is invalid.",
1509
+ }));
1510
+ return [2 /*return*/, "continue"];
1511
+ }
1512
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { metadataJsonValidationError: null, migrationStatus: { state: "loading", message: "Creating migration artifacts..." } })); });
1513
+ _f.label = 1;
1514
+ case 1:
1515
+ _f.trys.push([1, 3, , 4]);
1516
+ return [4 /*yield*/, createMigrationArtifacts({
1517
+ moduleId: bootstrap.module.id,
1518
+ payload: __assign(__assign({}, buildMappingRequest(__assign(__assign({}, item.draft), { mapped: true, modelId: item.persistedMappingResult.modelId }), (_d = item.mappingPreview.migration.timestamp) !== null && _d !== void 0 ? _d : null)), { reviewedModel: reviewedModelValidation.parsed }),
1519
+ }).unwrap()];
1520
+ case 2:
1521
+ response_2 = _f.sent();
1522
+ if (!firstMigrationKey) {
1523
+ firstMigrationKey = key;
1524
+ }
1525
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { migrationArtifactsResult: response_2, migrationStatus: {
1526
+ state: "success",
1527
+ message: response_2.migration.written ? "Migration artifacts created." : "No migration file required.",
1528
+ } })); });
1529
+ return [3 /*break*/, 4];
1530
+ case 3:
1531
+ error_6 = _f.sent();
1532
+ updateWorkspaceItem(key, function (current) { return (__assign(__assign({}, current), { migrationStatus: { state: "error", message: readQueryError(error_6) } })); });
1533
+ dispatch(showToast({
1534
+ severity: "error",
1535
+ summary: "Create migration artifacts failed for ".concat(item.record.tableName),
1536
+ detail: readQueryError(error_6),
1537
+ }));
1538
+ return [3 /*break*/, 4];
1539
+ case 4: return [2 /*return*/];
1540
+ }
1541
+ });
1542
+ };
1543
+ _i = 0, workspaceTableKeys_3 = workspaceTableKeys;
1218
1544
  _e.label = 1;
1219
1545
  case 1:
1220
- _e.trys.push([1, 3, , 4]);
1221
- return [4 /*yield*/, createMigrationArtifacts({
1222
- moduleId: bootstrap.module.id,
1223
- payload: __assign(__assign({}, buildMappingRequest(__assign(__assign({}, drawerDraft), { mapped: true, modelId: persistedMappingResult.modelId }), (_d = mappingPreview === null || mappingPreview === void 0 ? void 0 : mappingPreview.migration.timestamp) !== null && _d !== void 0 ? _d : null)), { reviewedModel: reviewedModelValidation.parsed }),
1224
- }).unwrap()];
1546
+ if (!(_i < workspaceTableKeys_3.length)) return [3 /*break*/, 4];
1547
+ key = workspaceTableKeys_3[_i];
1548
+ return [5 /*yield**/, _loop_3(key)];
1225
1549
  case 2:
1226
- response = _e.sent();
1227
- setMigrationArtifactsResult(response);
1228
- setWorkspaceStep("run-migration");
1229
- dispatch(showToast({
1230
- severity: "success",
1231
- summary: "Migration artifacts created",
1232
- detail: response.migration.written
1233
- ? "The migration file and datasource registration were written successfully."
1234
- : "No migration file was required, but the datasource registration was updated successfully.",
1235
- }));
1236
- return [3 /*break*/, 4];
1550
+ _e.sent();
1551
+ _e.label = 3;
1237
1552
  case 3:
1238
- error_4 = _e.sent();
1239
- dispatch(showToast({
1240
- severity: "error",
1241
- summary: "Create migration artifacts failed",
1242
- detail: readQueryError(error_4),
1243
- }));
1244
- return [3 /*break*/, 4];
1245
- case 4: return [2 /*return*/];
1553
+ _i++;
1554
+ return [3 /*break*/, 1];
1555
+ case 4:
1556
+ if (firstMigrationKey) {
1557
+ setActiveWorkspaceTableKey(firstMigrationKey);
1558
+ setWorkspaceStep("run-migration");
1559
+ dispatch(showToast({
1560
+ severity: "success",
1561
+ summary: "Migration artifacts ready",
1562
+ detail: "Datasource registration and migration artifacts were prepared for the selected tables.",
1563
+ }));
1564
+ }
1565
+ return [2 /*return*/];
1246
1566
  }
1247
1567
  });
1248
1568
  }); };
1249
1569
  var handleRunMigration = function () { return __awaiter(_this, void 0, void 0, function () {
1250
- var response, error_5;
1570
+ var response, error_7;
1251
1571
  var _a;
1252
1572
  return __generator(this, function (_b) {
1253
1573
  switch (_b.label) {
@@ -1278,12 +1598,12 @@ export function DatasourceIntrospectionPage() {
1278
1598
  _b.sent();
1279
1599
  return [3 /*break*/, 6];
1280
1600
  case 5:
1281
- error_5 = _b.sent();
1282
- setRunMigrationOutput(readQueryError(error_5));
1601
+ error_7 = _b.sent();
1602
+ setRunMigrationOutput(readQueryError(error_7));
1283
1603
  dispatch(showToast({
1284
1604
  severity: "error",
1285
1605
  summary: "Run migration failed",
1286
- detail: readQueryError(error_5),
1606
+ detail: readQueryError(error_7),
1287
1607
  }));
1288
1608
  return [3 /*break*/, 6];
1289
1609
  case 6: return [2 /*return*/];
@@ -1315,20 +1635,20 @@ export function DatasourceIntrospectionPage() {
1315
1635
  label: "Review Mapping JSON",
1316
1636
  complete: currentStepIndex > 1,
1317
1637
  active: workspaceStep === "review-json",
1318
- disabled: !mappingPreview,
1638
+ disabled: !allWorkspaceItemsPreviewed,
1319
1639
  onClick: function () {
1320
- if (mappingPreview)
1640
+ if (allWorkspaceItemsPreviewed)
1321
1641
  setWorkspaceStep("review-json");
1322
1642
  },
1323
1643
  },
1324
1644
  {
1325
1645
  key: "generate-code",
1326
1646
  label: "Generate Code",
1327
- complete: currentStepIndex > 2,
1647
+ complete: currentStepIndex > 2 || generateCodeReady,
1328
1648
  active: workspaceStep === "generate-code",
1329
- disabled: !persistedMappingResult,
1649
+ disabled: !allWorkspaceItemsPersisted,
1330
1650
  onClick: function () {
1331
- if (persistedMappingResult)
1651
+ if (allWorkspaceItemsPersisted)
1332
1652
  setWorkspaceStep("generate-code");
1333
1653
  },
1334
1654
  },
@@ -1345,30 +1665,30 @@ export function DatasourceIntrospectionPage() {
1345
1665
  },
1346
1666
  {
1347
1667
  key: "run-migration",
1348
- label: "Run Migration",
1668
+ label: hasMigrationGenerationWork ? "Run Migration" : "Finish",
1349
1669
  complete: false,
1350
1670
  active: workspaceStep === "run-migration",
1351
- disabled: !migrationArtifactsResult,
1671
+ disabled: !allWorkspaceItemsMigrated,
1352
1672
  onClick: function () {
1353
- if (migrationArtifactsResult)
1673
+ if (allWorkspaceItemsMigrated)
1354
1674
  setWorkspaceStep("run-migration");
1355
1675
  },
1356
1676
  },
1357
1677
  ];
1358
- var selectableUnmappedColumns = (_o = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.filter(function (column) { return !column.handledBySuperclass && !column.matched && !column.isPrimaryKey; })) !== null && _o !== void 0 ? _o : [];
1678
+ var selectableUnmappedColumns = (_u = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.filter(function (column) { return !column.handledBySuperclass && !column.matched && !column.isPrimaryKey; })) !== null && _u !== void 0 ? _u : [];
1359
1679
  var allSelectableUnmappedIncluded = selectableUnmappedColumns.length > 0
1360
1680
  && selectableUnmappedColumns.every(function (column) { return column.include; });
1361
- var drawerRawDdl = (_p = tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.rawDdl) !== null && _p !== void 0 ? _p : null;
1681
+ var drawerRawDdl = (_w = (_v = activeWorkspaceItem === null || activeWorkspaceItem === void 0 ? void 0 : activeWorkspaceItem.detail) === null || _v === void 0 ? void 0 : _v.rawDdl) !== null && _w !== void 0 ? _w : null;
1362
1682
  var drawerTabs = drawerDraft ? [
1363
1683
  {
1364
1684
  value: "general-info",
1365
1685
  label: "General Info",
1366
- content: (_jsxs("div", { className: "sdix-drawer-form", children: [_jsxs("section", { className: "sdix-form-section", children: [_jsx("h4", { className: "solid-form-layout-label", children: "Model Info" }), _jsxs("div", { className: "sdix-form-grid", children: [_jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-singular-name", children: "Singular Name" }), _jsx(SolidInput, { id: "sdix-singular-name", value: drawerDraft.singularName, onChange: function (event) { return updateGeneralField("singularName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-plural-name", children: "Plural Name" }), _jsx(SolidInput, { id: "sdix-plural-name", value: drawerDraft.pluralName, onChange: function (event) { return updateGeneralField("pluralName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-display-name", children: "Display Name" }), _jsx(SolidInput, { id: "sdix-display-name", value: drawerDraft.displayName, onChange: function (event) { return updateGeneralField("displayName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-user-key-field", children: "User Key Field" }), _jsx(SolidSelect, { id: "sdix-user-key-field", value: drawerDraft.userKeyField, options: drawerUserKeyOptions, placeholder: "Select user key field", onChange: function (event) { return changeUserKeyField(event.value); } })] }), _jsxs("div", { className: "sdix-form-field sdix-form-field--full", children: [_jsx("label", { htmlFor: "sdix-description", children: "Description" }), _jsx(SolidTextarea, { className: "sdix-description-textarea", id: "sdix-description", rows: 2, value: drawerDraft.description, onChange: function (event) { return updateGeneralField("description", event.target.value); } })] })] })] }), _jsxs("section", { className: "sdix-form-section", children: [_jsx("h4", { className: "solid-form-layout-label", children: "Datasource Binding" }), _jsxs("div", { className: "sdix-form-grid", children: [_jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-table-name", children: "Table Name" }), _jsx(SolidInput, { id: "sdix-table-name", value: drawerDraft.tableName, onChange: function (event) { return updateGeneralField("tableName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-schema-name", children: "Schema" }), _jsx(SolidInput, { id: "sdix-schema-name", value: (_q = drawerDraft.schema) !== null && _q !== void 0 ? _q : "default", disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-datasource-name", children: "Datasource" }), _jsx(SolidInput, { id: "sdix-datasource-name", value: drawerDraft.dataSource, disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-datasource-type", children: "Provider" }), _jsx(SolidInput, { id: "sdix-datasource-type", value: providerLabel(drawerDraft.dataSourceType), disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-legacy-type", children: "Mapping Strategy" }), _jsx(SolidSelect, { id: "sdix-legacy-type", value: drawerDraft.legacyTableType, options: mappingStrategyOptions, onChange: function (event) { return updateLegacyTableType(event.value); } }), _jsxs("small", { className: "sdix-inline-note", children: ["This will use ", _jsx("strong", { children: drawerDraft.baseClassName }), " for the generated entity."] })] })] })] })] })),
1686
+ content: (_jsxs("div", { className: "sdix-drawer-form", children: [_jsxs("section", { className: "sdix-form-section", children: [_jsx("h4", { className: "solid-form-layout-label", children: "Model Info" }), _jsxs("div", { className: "sdix-form-grid", children: [_jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-singular-name", children: "Singular Name" }), _jsx(SolidInput, { id: "sdix-singular-name", value: drawerDraft.singularName, onChange: function (event) { return updateGeneralField("singularName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-plural-name", children: "Plural Name" }), _jsx(SolidInput, { id: "sdix-plural-name", value: drawerDraft.pluralName, onChange: function (event) { return updateGeneralField("pluralName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-display-name", children: "Display Name" }), _jsx(SolidInput, { id: "sdix-display-name", value: drawerDraft.displayName, onChange: function (event) { return updateGeneralField("displayName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-user-key-field", children: "User Key Field" }), _jsx(SolidSelect, { id: "sdix-user-key-field", value: drawerDraft.userKeyField, options: drawerUserKeyOptions, placeholder: "Select user key field", onChange: function (event) { return changeUserKeyField(event.value); } })] }), _jsxs("div", { className: "sdix-form-field sdix-form-field--full", children: [_jsx("label", { htmlFor: "sdix-description", children: "Description" }), _jsx(SolidTextarea, { className: "sdix-description-textarea", id: "sdix-description", rows: 2, value: drawerDraft.description, onChange: function (event) { return updateGeneralField("description", event.target.value); } })] })] })] }), _jsxs("section", { className: "sdix-form-section", children: [_jsx("h4", { className: "solid-form-layout-label", children: "Datasource Binding" }), _jsxs("div", { className: "sdix-form-grid", children: [_jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-table-name", children: "Table Name" }), _jsx(SolidInput, { id: "sdix-table-name", value: drawerDraft.tableName, onChange: function (event) { return updateGeneralField("tableName", event.target.value); } })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-schema-name", children: "Schema" }), _jsx(SolidInput, { id: "sdix-schema-name", value: (_x = drawerDraft.schema) !== null && _x !== void 0 ? _x : "default", disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-datasource-name", children: "Datasource" }), _jsx(SolidInput, { id: "sdix-datasource-name", value: drawerDraft.dataSource, disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-datasource-type", children: "Provider" }), _jsx(SolidInput, { id: "sdix-datasource-type", value: providerLabel(drawerDraft.dataSourceType), disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-legacy-type", children: "Mapping Strategy" }), _jsx(SolidSelect, { id: "sdix-legacy-type", value: drawerDraft.legacyTableType, options: mappingStrategyOptions, onChange: function (event) { return updateLegacyTableType(event.value); } }), _jsxs("small", { className: "sdix-inline-note", children: ["This will use ", _jsx("strong", { children: drawerDraft.baseClassName }), " for the generated entity."] })] })] })] })] })),
1367
1687
  },
1368
1688
  {
1369
1689
  value: "columns-mapping",
1370
1690
  label: "Columns Mapping",
1371
- content: (_jsxs("div", { className: "sdix-columns", children: [_jsx("div", { className: "sdix-columns__toolbar", children: _jsxs("div", { className: "sdix-columns__legend", "aria-label": "Column legend", children: [_jsx("span", { className: "sdix-status-badge is-superclass", children: "System column" }), _jsx("span", { className: "sdix-status-badge is-muted", children: "Application column" })] }) }), _jsxs("div", { className: "sdix-column-table", children: [_jsxs("div", { className: "sdix-column-row sdix-column-row--head sdix-column-row--mapping", children: [_jsx("span", { className: "sdix-column-select-header", children: selectableUnmappedColumns.length ? (_jsx(SolidCheckbox, { checked: allSelectableUnmappedIncluded, onChange: function (event) { return setUnmappedColumnsIncluded(event.target.checked); }, "aria-label": allSelectableUnmappedIncluded ? "Deselect all unmapped columns" : "Select all unmapped columns" })) : ("Include") }), _jsx("span", { children: "Column" }), _jsx("span", { children: "Field" }), _jsx("span", { children: "Label" }), _jsx("span", { children: "Database" }), _jsx("span", { children: "SolidX" }), _jsx("span", { children: "Status" }), _jsx("span", { children: "Action" })] }), drawerDraft.columns.map(function (column) {
1691
+ content: (_jsxs("div", { className: "sdix-columns", children: [_jsx("div", { className: "sdix-columns__toolbar", children: _jsxs("div", { className: "sdix-columns__legend", "aria-label": "Column legend", children: [_jsx("span", { className: "sdix-status-badge is-superclass", children: "System column" }), _jsx("span", { className: "sdix-status-badge is-muted", children: "Application column" })] }) }), _jsxs("div", { className: "sdix-column-table", children: [_jsxs("div", { className: "sdix-column-row sdix-column-row--head sdix-column-row--mapping", children: [_jsx("span", { className: "sdix-column-select-header", children: selectableUnmappedColumns.length ? (_jsx(SolidCheckbox, { checked: allSelectableUnmappedIncluded, onChange: function (event) { return setUnmappedColumnsIncluded(event.target.checked); }, "aria-label": allSelectableUnmappedIncluded ? "Deselect all unmapped columns" : "Select all unmapped columns" })) : ("Include") }), _jsx("span", { children: "Column" }), _jsx("span", { children: "Field" }), _jsx("span", { children: "Label" }), _jsx("span", { children: "Database" }), _jsx("span", { children: "SolidX" }), _jsx("span", { children: "Status" }), _jsx("span", { children: "Mapping" })] }), drawerDraft.columns.map(function (column) {
1372
1692
  var isUserKey = drawerDraft.userKeyField === column.fieldName;
1373
1693
  var isPrimaryKeyField = column.isPrimaryKey;
1374
1694
  var statusClassName = column.handledBySuperclass
@@ -1387,7 +1707,7 @@ export function DatasourceIntrospectionPage() {
1387
1707
  : column.matched
1388
1708
  ? "Currently omitted"
1389
1709
  : "Skipped for now";
1390
- return (_jsxs("div", { className: "sdix-column-row sdix-column-row--mapping", children: [_jsx("span", { className: "sdix-column-include", children: column.handledBySuperclass ? (_jsx("span", { className: "sdix-column-placeholder", children: "-" })) : column.matched ? (_jsx("span", { className: "sdix-column-placeholder", children: "-" })) : column.isPrimaryKey ? (_jsx(SolidCheckbox, { checked: true, disabled: true, "aria-label": "Required included column" })) : (_jsx(SolidCheckbox, { checked: column.include, onChange: function (event) { return setColumnIncluded(column.columnName, event.target.checked); } })) }), _jsxs("span", { className: "sdix-column-meta", children: [_jsx("strong", { children: column.columnName }), column.isAutoGenerated ? _jsx("small", { children: "Generated id column" }) : null] }), _jsxs("span", { children: [_jsx(SolidInput, { value: column.fieldName, disabled: column.handledBySuperclass, onChange: function (event) { return updateColumnFieldName(column.columnName, event.target.value); } }), isUserKey || isPrimaryKeyField ? (_jsxs("div", { className: "sdix-inline-note-stack", children: [isUserKey ? _jsx("small", { className: "sdix-inline-note", children: "User key" }) : null, isPrimaryKeyField ? _jsx("small", { className: "sdix-inline-note", children: "Primary key" }) : null] })) : null] }), _jsx("span", { children: _jsx(SolidInput, { value: column.displayName, disabled: column.handledBySuperclass, onChange: function (event) { return updateColumnDisplayName(column.columnName, event.target.value); } }) }), _jsx("span", { className: "sdix-column-meta", children: _jsx("strong", { children: column.dataType }) }), _jsx("span", { children: column.handledBySuperclass ? (_jsx("span", { children: column.solidFieldType })) : (_jsx(SolidSelect, { value: column.solidFieldType, options: scalarFieldTypeOptions, onChange: function (event) { return updateColumnSolidFieldType(column.columnName, event.value); } })) }), _jsx("span", { children: _jsx("span", { className: "sdix-status-badge ".concat(statusClassName), children: statusText }) }), _jsx("span", { className: "sdix-column-action", children: _jsxs("div", { className: "sdix-column-action-stack", children: [!column.handledBySuperclass && (column.include || column.matched) ? (_jsx(SolidButton, { size: "small", variant: "outline", className: "sdix-column-action-icon", onClick: function () { return openFieldConfigEditor(column.columnName); }, "aria-label": "Configure ".concat(column.fieldName || column.columnName, " field"), children: _jsx(Cog, { size: 14 }) })) : null, column.handledBySuperclass ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, className: "sdix-column-action-chip sdix-column-action-chip--managed", children: "Managed" })) : column.isPrimaryKey ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, className: "sdix-column-action-chip sdix-column-action-chip--required", children: "Required" })) : column.matched ? (_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setColumnIncluded(column.columnName, false); }, children: "Remove mapping" })) : (_jsx("span", { className: "sdix-column-placeholder", children: "-" }))] }) })] }, column.columnName));
1710
+ return (_jsxs("div", { className: "sdix-column-row sdix-column-row--mapping", children: [_jsx("span", { className: "sdix-column-include", children: column.handledBySuperclass ? (_jsx("span", { className: "sdix-column-placeholder", children: "-" })) : column.matched ? (_jsx("span", { className: "sdix-column-placeholder", children: "-" })) : column.isPrimaryKey ? (_jsx(SolidCheckbox, { checked: true, disabled: true, "aria-label": "Required included column" })) : (_jsx(SolidCheckbox, { checked: column.include, onChange: function (event) { return setColumnIncluded(column.columnName, event.target.checked); } })) }), _jsxs("span", { className: "sdix-column-meta", children: [_jsx("strong", { children: column.columnName }), column.isAutoGenerated ? _jsx("small", { children: "Generated id column" }) : null] }), _jsxs("span", { children: [_jsx(SolidInput, { value: column.fieldName, disabled: column.handledBySuperclass, onChange: function (event) { return updateColumnFieldName(column.columnName, event.target.value); } }), isUserKey || isPrimaryKeyField ? (_jsxs("div", { className: "sdix-inline-note-stack", children: [isUserKey ? _jsx("small", { className: "sdix-inline-note", children: "User key" }) : null, isPrimaryKeyField ? _jsx("small", { className: "sdix-inline-note", children: "Primary key" }) : null] })) : null] }), _jsx("span", { children: _jsx(SolidInput, { value: column.displayName, disabled: column.handledBySuperclass, onChange: function (event) { return updateColumnDisplayName(column.columnName, event.target.value); } }) }), _jsx("span", { className: "sdix-column-meta", children: _jsx("strong", { children: column.dataType }) }), _jsxs("span", { className: "sdix-column-type-cell", children: [!column.handledBySuperclass && (column.include || column.matched) ? (_jsx(SolidButton, { size: "small", variant: "outline", className: "sdix-column-action-icon", onClick: function () { return openFieldConfigEditor(column.columnName); }, "aria-label": "Configure ".concat(column.fieldName || column.columnName, " field"), children: _jsx(Cog, { size: 14 }) })) : null, _jsx("span", { className: "sdix-status-badge ".concat(column.handledBySuperclass ? "is-superclass" : "is-muted"), children: getFieldTypeLabel(column.solidFieldType) })] }), _jsx("span", { children: _jsx("span", { className: "sdix-status-badge ".concat(statusClassName), children: statusText }) }), _jsx("span", { className: "sdix-column-action", children: _jsx("div", { className: "sdix-column-action-stack", children: column.handledBySuperclass ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, className: "sdix-column-action-chip sdix-column-action-chip--managed", children: "Managed" })) : column.isPrimaryKey ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, className: "sdix-column-action-chip sdix-column-action-chip--required", children: "Required" })) : column.matched ? (_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setColumnIncluded(column.columnName, false); }, children: "Remove mapping" })) : (_jsx("span", { className: "sdix-column-placeholder", children: "-" })) }) })] }, column.columnName));
1391
1711
  })] })] })),
1392
1712
  },
1393
1713
  {
@@ -1396,17 +1716,18 @@ export function DatasourceIntrospectionPage() {
1396
1716
  content: (_jsx("div", { className: "sdix-ddl-tab", children: (drawerRawDdl === null || drawerRawDdl === void 0 ? void 0 : drawerRawDdl.available) && drawerRawDdl.statement ? (_jsx("pre", { className: "sdix-ddl-code", children: _jsx("code", { children: drawerRawDdl.statement }) })) : (_jsxs("div", { className: "sdix-empty-state is-inline sdix-ddl-empty", children: [_jsx(Database, { size: 18 }), _jsx("p", { children: (drawerRawDdl === null || drawerRawDdl === void 0 ? void 0 : drawerRawDdl.note) || "DDL preview is not available for this table." })] })) })),
1397
1717
  },
1398
1718
  ] : [];
1399
- var reviewJsonPanel = mappingPreview ? (_jsxs("div", { className: "sdix-review-panel sdix-review-panel--metadata", children: [_jsxs("div", { className: "sdix-review-meta sdix-review-meta--compact", children: [_jsx("span", { children: "Target file" }), _jsx("strong", { children: mappingPreview.metadataJson.filePath })] }), _jsx(SolidJsonEditor, { className: "sdix-json-editor", value: reviewedMetadataJsonValue !== null && reviewedMetadataJsonValue !== void 0 ? reviewedMetadataJsonValue : mappingPreview.metadataJson.model, resetToken: metadataJsonResetToken, onValueChange: function (nextValue) {
1400
- setReviewedMetadataJsonValue(nextValue);
1401
- if (metadataJsonValidationError) {
1402
- setMetadataJsonValidationError(null);
1403
- }
1719
+ var reviewJsonPanel = mappingPreview ? (_jsxs("div", { className: "sdix-review-panel sdix-review-panel--metadata", children: [_jsxs("div", { className: "sdix-workspace-summary", children: [_jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Selected tables" }), _jsx("strong", { children: totalWorkspaceCount })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Previews ready" }), _jsxs("strong", { children: [reviewedWorkspaceCount, "/", totalWorkspaceCount] })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Current table" }), _jsxs("strong", { children: [activeWorkspacePosition, "/", totalWorkspaceCount] })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Review errors" }), _jsx("strong", { children: reviewErrorWorkspaceCount })] })] }), _jsxs("div", { className: "sdix-review-meta sdix-review-meta--compact", children: [_jsx("span", { children: "Target file" }), _jsx("strong", { children: mappingPreview.metadataJson.filePath })] }), _jsx(SolidJsonEditor, { className: "sdix-json-editor", value: reviewedMetadataJsonValue !== null && reviewedMetadataJsonValue !== void 0 ? reviewedMetadataJsonValue : mappingPreview.metadataJson.model, resetToken: metadataJsonResetToken, onValueChange: function (nextValue) {
1720
+ updateActiveWorkspaceItem(function (current) { return (__assign(__assign({}, current), { reviewedMetadataJsonValue: nextValue, metadataJsonValidationError: null })); });
1404
1721
  }, onTextChange: function (nextText) {
1405
- setMetadataJsonText(nextText);
1406
- }, onErrorChange: setMetadataJsonValidationError }), metadataJsonValidationError ? (_jsx("div", { className: "sdix-json-validation-error", children: _jsx("span", { children: metadataJsonValidationError }) })) : null] })) : null;
1407
- var createMigrationsPanel = mappingPreview ? (_jsx("div", { className: "sdix-review-panel sdix-review-panel--migration", children: mappingPreview.migration.willGenerate && mappingPreview.migration.filePath ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "sdix-review-meta sdix-review-meta--compact", children: [_jsx("span", { children: "Target file" }), _jsx("strong", { children: mappingPreview.migration.filePath })] }), _jsx("p", { className: "sdix-review-note", children: "This migration preview is generated from the current mapping and stays read-only here. Moving ahead writes the migration file to disk and updates the datasource registration now that the entity code already exists." }), mappingPreview.migration.content ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: mappingPreview.migration.content }) })) : null] })) : (_jsxs("div", { className: "sdix-empty-state is-inline sdix-ddl-empty", children: [_jsx(Database, { size: 18 }), _jsx("p", { children: mappingPreview.migration.note })] })) })) : null;
1408
- var generateCodePanel = (_jsxs("div", { className: "sdix-stage-panel", children: [_jsxs("div", { className: "sdix-stage-panel__header", children: [_jsx("span", { className: "sdix-stage-panel__eyebrow", children: "Step 3" }), _jsx("h3", { children: "Generate module code" }), _jsx("p", { children: "The reviewed metadata JSON is now persisted. Run the normal SolidX module generation flow next so the entity, DTOs, repository, service, controller, and UI code are refreshed before we register the entity on the datasource and write the migration." })] }), _jsxs("div", { className: "sdix-stage-panel__body", children: [_jsxs("div", { className: "sdix-stage-panel__card", children: [_jsx("div", { className: "sdix-stage-panel__card-title", children: "What happens here" }), _jsxs("ul", { className: "sdix-stage-panel__list", children: [_jsxs("li", { children: ["The module generate-code pipeline runs for ", _jsx("strong", { children: (_r = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _r === void 0 ? void 0 : _r.displayName }), "."] }), _jsx("li", { children: "The newly mapped model entity is generated inside the module source folder." }), _jsx("li", { children: "Any existing generated assets for this module may be refreshed." })] })] }), _jsx("div", { className: "sdix-stage-panel__actions", children: _jsx(SolidButton, { leftIcon: _jsx(Sparkles, { size: 14 }), loading: isGenerateCodeLoading || isGeneratingCodeWorkflow, disabled: isGenerateCodeLoading || isGeneratingCodeWorkflow, onClick: function () { return void handleGenerateCode(); }, children: "Generate Code" }) }), isGeneratingCodeWorkflow ? (_jsxs("div", { className: "sdix-empty-state is-inline sdix-stage-progress", children: [_jsx(SolidSpinner, { size: 30 }), _jsx("h3", { children: "Generating code" }), _jsx("p", { children: generateCodeStatusMessage || "Waiting for the backend to finish restarting..." })] })) : null, !isGeneratingCodeWorkflow && generateCodeTimeoutMessage ? (_jsxs("div", { className: "sdix-error is-inline sdix-stage-progress sdix-stage-progress--warning", children: [_jsx(ShieldAlert, { size: 22 }), _jsx("h3", { children: "Manual review recommended" }), _jsx("p", { children: generateCodeTimeoutMessage })] })) : null, generateCodeOutput ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: generateCodeOutput }) })) : null] })] }));
1409
- var runMigrationPanel = (_jsxs("div", { className: "sdix-stage-panel", children: [!runMigrationCompleted ? (_jsxs("div", { className: "sdix-stage-panel__header", children: [_jsx("span", { className: "sdix-stage-panel__eyebrow", children: "Step 5" }), _jsx("h3", { children: "Run migration, build, and seed" }), _jsx("p", { children: "With the datasource file updated and module code generated, SolidX can now run the TypeORM migration for the selected datasource, rebuild the project, and reseed the mapped module metadata." })] })) : null, _jsxs("div", { className: "sdix-stage-panel__body", children: [!runMigrationCompleted ? (_jsxs("div", { className: "sdix-stage-panel__card", children: [_jsx("div", { className: "sdix-stage-panel__card-title", children: "Commands" }), _jsx("pre", { className: "sdix-stage-panel__command", children: _jsx("code", { children: "npx @solidxai/solidctl@latest migration -d ".concat(selectedDatasource, " run\nnpx @solidxai/solidctl@latest build\nnpx @solidxai/solidctl@latest seed --modules-to-seed ").concat(((_s = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _s === void 0 ? void 0 : _s.name) || "") }) })] })) : null, runMigrationCompleted ? (_jsxs("div", { className: "sdix-empty-state is-inline sdix-stage-progress", children: [_jsx(Check, { size: 24 }), _jsx("h3", { children: "Migration workflow finished" }), _jsx("p", { children: "Review the command output below. When you are satisfied, click Finish to return to the model list." })] })) : null, runMigrationOutput ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: runMigrationOutput }) })) : null] })] }));
1722
+ updateActiveWorkspaceItem(function (current) { return (__assign(__assign({}, current), { metadataJsonText: nextText })); });
1723
+ }, onErrorChange: function (nextError) {
1724
+ updateActiveWorkspaceItem(function (current) { return (__assign(__assign({}, current), { metadataJsonValidationError: nextError })); });
1725
+ } }), metadataJsonValidationError ? (_jsx("div", { className: "sdix-json-validation-error", children: _jsx("span", { children: metadataJsonValidationError }) })) : null] })) : null;
1726
+ var createMigrationsPanel = mappingPreview ? (_jsxs("div", { className: "sdix-review-panel sdix-review-panel--migration", children: [_jsxs("div", { className: "sdix-workspace-summary", children: [_jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Selected tables" }), _jsx("strong", { children: totalWorkspaceCount })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Migration previews ready" }), _jsxs("strong", { children: [migrationReadyWorkspaceCount, "/", totalWorkspaceCount] })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Migration files to write" }), _jsx("strong", { children: totalGeneratedMigrations })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "System columns to add" }), _jsx("strong", { children: totalGeneratedSystemColumns })] })] }), mappingPreview.migration.willGenerate && mappingPreview.migration.filePath ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "sdix-review-code-header", children: [_jsxs("div", { className: "sdix-review-meta sdix-review-meta--compact", children: [_jsx("span", { children: "Target file" }), _jsx("strong", { children: mappingPreview.migration.filePath })] }), mappingPreview.migration.content ? (_jsx(SolidButton, { size: "small", variant: "outline", className: "sdix-review-copy-button", leftIcon: migrationPreviewCopied ? _jsx(Check, { size: 14 }) : _jsx(Copy, { size: 14 }), onClick: function () { return void handleCopyMigrationPreview(); }, children: migrationPreviewCopied ? "Copied" : "Copy" })) : null] }), _jsx("p", { className: "sdix-review-note", children: "This migration preview is generated from the current mapping and stays read-only here. Moving ahead writes the migration file to disk and updates the datasource registration now that the entity code already exists." }), mappingPreview.migration.content ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: mappingPreview.migration.content }) })) : null] })) : (_jsxs("div", { className: "sdix-empty-state is-inline sdix-ddl-empty", children: [_jsx(Database, { size: 18 }), _jsx("p", { children: mappingPreview.migration.note })] }))] })) : null;
1727
+ var generateCodePanel = (_jsxs("div", { className: "sdix-stage-panel", children: [_jsxs("div", { className: "sdix-stage-panel__header", children: [_jsx("span", { className: "sdix-stage-panel__eyebrow", children: "Step 3" }), _jsx("h3", { children: "Generate module code" }), _jsx("p", { children: "The reviewed metadata JSON is now persisted for the selected batch. Run the normal SolidX module generation flow next so every mapped entity, DTO, repository, service, controller, and UI asset is refreshed before datasource registration and migration files are written." })] }), _jsxs("div", { className: "sdix-stage-panel__body", children: [_jsxs("div", { className: "sdix-workspace-summary", children: [_jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Selected tables" }), _jsx("strong", { children: totalWorkspaceCount })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Saved mappings" }), _jsxs("strong", { children: [savedWorkspaceCount, "/", totalWorkspaceCount] })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Columns queued" }), _jsx("strong", { children: totalIncludedMappedColumns })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "System columns pending" }), _jsx("strong", { children: totalGeneratedSystemColumns })] })] }), _jsxs("div", { className: "sdix-stage-panel__card", children: [_jsx("div", { className: "sdix-stage-panel__card-title", children: "What happens here" }), _jsxs("ul", { className: "sdix-stage-panel__list", children: [_jsxs("li", { children: ["The module generate-code pipeline runs once for ", _jsx("strong", { children: (_y = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _y === void 0 ? void 0 : _y.displayName }), "."] }), _jsx("li", { children: "All saved mappings in this batch contribute to the generated entities inside the module source folder." }), _jsx("li", { children: "Any existing generated assets for this module may be refreshed in the same pass." })] })] }), _jsx("div", { className: "sdix-stage-panel__actions", children: _jsx(SolidButton, { leftIcon: _jsx(Sparkles, { size: 14 }), loading: isGenerateCodeLoading || isGeneratingCodeWorkflow, disabled: isGenerateCodeLoading || isGeneratingCodeWorkflow, onClick: function () { return void handleGenerateCode(); }, children: "Generate Code" }) }), generateCodeReady && !isGeneratingCodeWorkflow ? (_jsxs("div", { className: "sdix-empty-state is-inline sdix-stage-progress sdix-stage-progress--success", children: [_jsx(Check, { size: 24 }), _jsx("h3", { children: "Code generation finished" }), _jsx("p", { children: "The module generation workflow completed and the backend is back online. You can continue to migrations, or run generate code again if you want to retry." })] })) : null, isGeneratingCodeWorkflow ? (_jsxs("div", { className: "sdix-empty-state is-inline sdix-stage-progress", children: [_jsx(SolidSpinner, { size: 30 }), _jsx("h3", { children: "Generating code" }), _jsx("p", { children: generateCodeStatusMessage || "Waiting for the backend to finish restarting..." })] })) : null, !isGeneratingCodeWorkflow && generateCodeTimeoutMessage ? (_jsxs("div", { className: "sdix-error is-inline sdix-stage-progress sdix-stage-progress--warning", children: [_jsx(ShieldAlert, { size: 22 }), _jsx("h3", { children: "Manual review recommended" }), _jsx("p", { children: generateCodeTimeoutMessage })] })) : null, generateCodeOutput ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: generateCodeOutput }) })) : null] })] }));
1728
+ var runMigrationPanel = (_jsxs("div", { className: "sdix-stage-panel", children: [!runMigrationCompleted ? (_jsxs("div", { className: "sdix-stage-panel__header", children: [_jsx("span", { className: "sdix-stage-panel__eyebrow", children: "Step 5" }), _jsx("h3", { children: hasMigrationGenerationWork ? "Run migration, build, and seed" : "Finish mapping workflow" }), _jsx("p", { children: hasMigrationGenerationWork
1729
+ ? "With datasource registration updated and module code generated, SolidX can now run the TypeORM migration, rebuild the project, and reseed metadata for the full selected batch."
1730
+ : "SolidX will now run the final wrap-up workflow for the full selected batch: execute the datasource migration command, rebuild the project, and reseed the mapped module metadata." })] })) : null, _jsxs("div", { className: "sdix-stage-panel__body", children: [_jsxs("div", { className: "sdix-workspace-summary", children: [_jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Selected tables" }), _jsx("strong", { children: totalWorkspaceCount })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Generated code ready" }), _jsx("strong", { children: hasAttemptedGenerateCode ? "Yes" : "No" })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Migration artifacts ready" }), _jsxs("strong", { children: [migrationReadyWorkspaceCount, "/", totalWorkspaceCount] })] }), _jsxs("div", { className: "sdix-workspace-summary__item", children: [_jsx("span", { children: "Datasource" }), _jsx("strong", { children: selectedDatasource })] })] }), !runMigrationCompleted ? (_jsxs("div", { className: "sdix-stage-panel__card", children: [_jsx("div", { className: "sdix-stage-panel__card-title", children: "Commands" }), _jsx("pre", { className: "sdix-stage-panel__command", children: _jsx("code", { children: "npx @solidxai/solidctl@latest migration -d ".concat(selectedDatasource, " run\nnpx @solidxai/solidctl@latest build\nnpx @solidxai/solidctl@latest seed --modules-to-seed ").concat(((_z = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _z === void 0 ? void 0 : _z.name) || "") }) })] })) : null, runMigrationCompleted ? (_jsxs("div", { className: "sdix-empty-state is-inline sdix-stage-progress", children: [_jsx(Check, { size: 24 }), _jsx("h3", { children: "Migration workflow finished" }), _jsx("p", { children: "Review the command output below. When you are satisfied, click Finish to return to the model list." })] })) : null, runMigrationOutput ? (_jsx("pre", { className: "sdix-ddl-code sdix-ddl-code--fill", children: _jsx("code", { children: runMigrationOutput }) })) : null] })] }));
1410
1731
  var workspaceContent = drawerDraft ? (function () {
1411
1732
  switch (workspaceStep) {
1412
1733
  case "review-json":
@@ -1425,51 +1746,82 @@ export function DatasourceIntrospectionPage() {
1425
1746
  var workspaceMeta = drawerDraft ? (function () {
1426
1747
  switch (workspaceStep) {
1427
1748
  case "review-json":
1428
- return (_jsx("span", { children: "Review the generated metadata JSON before it is written to the module metadata file." }));
1749
+ return (_jsxs("span", { children: ["Reviewing", " ", _jsxs("strong", { children: [activeWorkspacePosition, " of ", totalWorkspaceCount] }), " ", "selected tables. Preview generation is ready for", " ", _jsx("strong", { children: reviewedWorkspaceCount }), " ", "table(s)", reviewErrorWorkspaceCount ? ", with ".concat(reviewErrorWorkspaceCount, " table(s) still needing review fixes.") : "."] }));
1429
1750
  case "generate-code":
1430
- return persistedMappingResult ? (_jsxs("span", { children: ["Metadata JSON has been saved for", " ", _jsx("strong", { children: drawerDraft.displayName || drawerDraft.singularName }), ". Generate the module code next so the entity file exists before datasource registration is updated. Continue stays disabled until you attempt code generation at least once."] })) : (_jsx("span", { children: "Save the metadata JSON before generating code." }));
1751
+ return persistedMappingResult ? (_jsxs("span", { children: ["Metadata JSON has been saved for", " ", _jsx("strong", { children: savedWorkspaceCount }), " ", "of", " ", _jsx("strong", { children: totalWorkspaceCount }), " ", "selected tables. Generate the module code next so every entity file exists before datasource registration is updated. Continue stays disabled until you attempt code generation at least once."] })) : (_jsx("span", { children: "Save the reviewed metadata JSON for the selected tables before generating code." }));
1431
1752
  case "create-migrations":
1432
- return mappingPreview ? (_jsxs("span", { children: ["Create the migration artifacts for", " ", _jsx("strong", { children: mappingPreview.summary.includedColumnNames.length }), " ", "mapped columns", mappingPreview.summary.generatedSystemColumnCount
1433
- ? " and ".concat(mappingPreview.summary.generatedSystemColumnCount, " SolidX system column migration changes")
1434
- : "", "."] })) : null;
1753
+ return mappingPreview ? (_jsxs("span", { children: ["Create migration artifacts for", " ", _jsx("strong", { children: migrationReadyWorkspaceCount }), " ", "of", " ", _jsx("strong", { children: totalWorkspaceCount }), " ", "selected tables. This batch currently includes", " ", _jsx("strong", { children: totalIncludedMappedColumns }), " ", "mapped columns and", " ", _jsx("strong", { children: totalGeneratedSystemColumns }), " ", "SolidX system column changes."] })) : null;
1435
1754
  case "run-migration":
1436
- return runMigrationCompleted ? (_jsxs("span", { children: ["The migration, build, and seed workflow has completed for", " ", _jsx("strong", { children: selectedDatasource }), ". Review the output below and click Finish when you are ready to return to the model list."] })) : (_jsxs("span", { children: ["Run the migration, build, and seed workflow for", " ", _jsx("strong", { children: selectedDatasource }), " ", "to apply the SolidX system columns on the legacy table and refresh the module metadata state."] }));
1755
+ return runMigrationCompleted ? (_jsxs("span", { children: ["The migration, build, and seed workflow has completed for", " ", _jsx("strong", { children: selectedDatasource }), " ", "across", " ", _jsx("strong", { children: totalWorkspaceCount }), " ", "selected table mappings. Review the output below and click Finish when you are ready to return to the model list."] })) : (_jsxs("span", { children: [hasMigrationGenerationWork ? "Run the migration, build, and seed workflow for" : "Finish the mapping workflow for", " ", _jsx("strong", { children: selectedDatasource }), " ", "across", " ", _jsx("strong", { children: totalWorkspaceCount }), " ", "selected table mappings.", " ", hasMigrationGenerationWork
1756
+ ? "to apply the SolidX system columns on the legacy table and refresh the module metadata state."
1757
+ : "to execute the final rebuild and reseed flow after the mapping changes are already in place."] }));
1437
1758
  case "configure":
1438
1759
  default:
1439
- return drawerDraft.mapped ? (_jsxs("span", { children: ["Editing mapped model", " ", _jsx("strong", { children: (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelDisplayName) || (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelSingularName) }), drawerDraft.mappedModuleLabel ? " in ".concat(drawerDraft.mappedModuleLabel) : ""] })) : (_jsx("span", { children: "Configure the field mapping draft before generating the metadata JSON preview." }));
1760
+ return drawerDraft.mapped ? (_jsxs("span", { children: ["Editing", " ", _jsxs("strong", { children: [activeWorkspacePosition, " of ", totalWorkspaceCount] }), " ", "selected tables.", " ", "Current mapped model:", " ", _jsx("strong", { children: (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelDisplayName) || (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelSingularName) }), drawerDraft.mappedModuleLabel ? " in ".concat(drawerDraft.mappedModuleLabel) : ""] })) : (_jsxs("span", { children: ["Configure", " ", _jsxs("strong", { children: [activeWorkspacePosition, " of ", totalWorkspaceCount] }), " ", "selected tables before generating the batch metadata JSON previews.", allWorkspaceItemsReady ? " All selected mapping drafts are loaded." : ""] }));
1440
1761
  }
1441
1762
  })() : null;
1442
- return (_jsx("div", { className: "sdix-page", children: isBootstrapLoading ? (_jsxs("div", { className: "sdix-loading", children: [_jsx(SolidSpinner, { size: 28 }), _jsx("p", { children: "Loading introspection workspace..." })] })) : bootstrapError ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: readQueryError(bootstrapError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return void refetchBootstrap(); }, children: "Retry" })] })) : (_jsxs(_Fragment, { children: [!isWorkspaceMode ? (_jsxs("div", { className: "sdix-toolbar", children: [_jsx("div", { className: "sdix-toolbar__left", children: _jsxs("div", { className: "sdix-toolbar-search", children: [_jsx(Search, { size: 15 }), _jsx(SolidInput, { value: tableSearch, onChange: function (event) { return setTableSearch(event.target.value); }, placeholder: "Search tables", disabled: !selectedDatasource })] }) }), _jsxs("div", { className: "sdix-toolbar__actions", children: [isBootstrapFetching || isTablesFetching ? (_jsxs("div", { className: "sdix-inline-status", children: [_jsx(SolidSpinner, { size: 16 }), _jsx("span", { children: "Refreshing" })] })) : null, _jsx(SolidButton, { size: "small", leftIcon: _jsx(Sparkles, { size: 14 }), onClick: function () {
1443
- if (selectedListRow) {
1444
- startMappingForRecord(selectedListRow);
1445
- }
1446
- }, disabled: !selectedListRow, children: "Start Mapping" }), _jsx(SolidSelect, { value: selectedDatasource, options: datasourceOptions, placeholder: "Datasource", className: "sdix-toolbar-select sdix-toolbar-select--compact", onChange: function (event) { return setSelectedDatasource(event.value); } }), _jsx(SolidButton, { size: "small", className: "sdix-icon-button", leftIcon: _jsx(RefreshCw, { size: 16 }), onClick: function () { return void handleRefresh(); }, tooltip: "Refresh", "aria-label": "Refresh" }), _jsx(SolidButton, { size: "small", className: "sdix-icon-button", leftIcon: _jsx(Cog, { size: 16 }), onClick: function () {
1763
+ return (_jsx("div", { className: "sdix-page", children: isBootstrapLoading ? (_jsxs("div", { className: "sdix-loading", children: [_jsx(SolidSpinner, { size: 28 }), _jsx("p", { children: "Loading introspection workspace..." })] })) : bootstrapError ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: readQueryError(bootstrapError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return void refetchBootstrap(); }, children: "Retry" })] })) : (_jsxs(_Fragment, { children: [!isWorkspaceMode ? (_jsxs("div", { className: "sdix-toolbar", children: [_jsx("div", { className: "sdix-toolbar__left", children: _jsxs("div", { className: "sdix-toolbar-search", children: [_jsx(Search, { size: 15 }), _jsx(SolidInput, { value: tableSearch, onChange: function (event) { return setTableSearch(event.target.value); }, placeholder: "Search tables", disabled: !selectedDatasource })] }) }), _jsxs("div", { className: "sdix-toolbar__actions", children: [isBootstrapFetching || isTablesFetching ? (_jsxs("div", { className: "sdix-inline-status", children: [_jsx(SolidSpinner, { size: 16 }), _jsx("span", { children: "Refreshing" })] })) : null, _jsx(SolidButton, { size: "small", leftIcon: _jsx(Sparkles, { size: 14 }), onClick: function () { return startMappingForRows(selectedRows); }, disabled: !selectedRowCount, children: "Start Mapping" }), _jsx(SolidSelect, { value: selectedDatasource, options: datasourceOptions, placeholder: "Datasource", className: "sdix-toolbar-select sdix-toolbar-select--compact", onChange: function (event) { return setSelectedDatasource(event.value); } }), _jsx(SolidButton, { size: "small", className: "sdix-icon-button", leftIcon: _jsx(RefreshCw, { size: 16 }), onClick: function () { return void handleRefresh(); }, tooltip: "Refresh", "aria-label": "Refresh" }), _jsx(SolidButton, { size: "small", className: "sdix-icon-button", leftIcon: _jsx(Cog, { size: 16 }), onClick: function () {
1447
1764
  setDraftSessionSettings(sessionSettings);
1448
1765
  setSettingsTab("datasource-info");
1449
1766
  setSettingsOpen(true);
1450
- }, tooltip: "Session settings", "aria-label": "Session settings" })] })] })) : null, selectedDatasource && (tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.synchronizeBlocked) ? (_jsxs("div", { className: "sdix-blocker", children: [_jsx(ShieldAlert, { size: 20 }), _jsxs("div", { children: [_jsx("h3", { children: "Synchronize must be disabled before introspection" }), _jsx("p", { children: tablesResponse.synchronizeMessage })] })] })) : null, !isWorkspaceMode ? (_jsx("div", { className: "sdix-workbench", children: _jsx("div", { className: "sdix-table-shell", children: !selectedDatasource ? (_jsxs("div", { className: "sdix-empty-state is-inline", children: [_jsx(Database, { size: 22 }), _jsx("p", { children: "Select a datasource to load its tables." })] })) : isTablesLoading ? (_jsxs("div", { className: "sdix-loading is-inline", children: [_jsx(SolidSpinner, { size: 24 }), _jsx("p", { children: "Inspecting datasource tables..." })] })) : tablesError ? (_jsxs("div", { className: "sdix-error is-inline", children: [_jsx("span", { children: readQueryError(tablesError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return void refetchTables(); }, children: "Retry" })] })) : !filteredRecords.length ? (_jsxs("div", { className: "sdix-empty-state is-inline", children: [_jsx(Database, { size: 22 }), _jsx("p", { children: tableSearch ? "No tables match the current quick filter." : "No database tables were discovered for this datasource." })] })) : (_jsx("div", { className: "sdix-table-area", children: _jsxs(SolidDataTable, { value: filteredRecords, dataKey: "tableName", viewportHeight: "calc(100vh - 162px)", size: "small", onRowClick: function (_a) {
1767
+ }, tooltip: "Session settings", "aria-label": "Session settings" })] })] })) : null, isSynchronizeBlocked ? (_jsxs("div", { className: "sdix-blocker", children: [_jsx("div", { className: "sdix-blocker__icon", children: _jsx(ShieldAlert, { size: 22 }) }), _jsxs("div", { className: "sdix-blocker__content", children: [_jsx("span", { className: "sdix-blocker__eyebrow", children: "Configuration blocker" }), _jsx("h3", { children: "Disable TypeORM synchronize before running datasource introspection" }), _jsx("p", { children: tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.synchronizeMessage }), _jsx("div", { className: "sdix-blocker__note", children: "Introspection is paused here to avoid schema-sync side effects while reviewing legacy datasource tables." })] })] })) : null, !isWorkspaceMode ? (_jsx("div", { className: "sdix-workbench", children: _jsx("div", { className: "sdix-table-shell", children: !selectedDatasource ? (_jsxs("div", { className: "sdix-empty-state is-inline", children: [_jsx(Database, { size: 22 }), _jsx("p", { children: "Select a datasource to load its tables." })] })) : isTablesLoading ? (_jsxs("div", { className: "sdix-loading is-inline", children: [_jsx(SolidSpinner, { size: 24 }), _jsx("p", { children: "Inspecting datasource tables..." })] })) : tablesError ? (_jsxs("div", { className: "sdix-error is-inline", children: [_jsx("span", { children: readQueryError(tablesError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return void refetchTables(); }, children: "Retry" })] })) : isSynchronizeBlocked ? null : !filteredRecords.length ? (_jsxs("div", { className: "sdix-empty-state is-inline", children: [_jsx(Database, { size: 22 }), _jsx("p", { children: tableSearch ? "No tables match the current quick filter." : "No database tables were discovered for this datasource." })] })) : (_jsx("div", { className: "sdix-table-area", children: _jsxs(SolidDataTable, { value: filteredRecords, dataKey: "tableName", viewportHeight: "calc(100vh - 162px)", size: "small", onRowClick: function (_a) {
1451
1768
  var data = _a.data;
1452
- return setSelectedRows([data]);
1453
- }, rowClassName: function (rowData) { var _a; return "".concat((_a = rowData.schema) !== null && _a !== void 0 ? _a : "", "::").concat(rowData.tableName) === selectedListRowKey ? "sdix-table-row-selected" : ""; }, emptyMessage: "No datasource tables found", children: [_jsx(Column, { header: "", body: function (rowData) {
1769
+ return toggleSelectedRow(data);
1770
+ }, rowClassName: function (rowData) { return selectedListRowKeySet.has(makeTableKey(rowData.schema, rowData.tableName)) ? "sdix-table-row-selected" : ""; }, emptyMessage: "No datasource tables found", children: [_jsx(Column, { header: _jsx("div", { className: "sdix-selection-cell", "data-no-row-click": "true", children: _jsx(SolidCheckbox, { checked: allVisibleRowsSelected, disabled: !hasVisibleRows || !filteredRecords.some(function (row) { return row.hasPrimaryKey; }), onChange: function (event) { return toggleAllVisibleRows(event.target.checked); }, "aria-label": allVisibleRowsSelected
1771
+ ? "Deselect all visible tables"
1772
+ : "Select all visible tables" }) }), body: function (rowData) {
1454
1773
  var _a;
1455
1774
  var rowKey = "".concat((_a = rowData.schema) !== null && _a !== void 0 ? _a : "", "::").concat(rowData.tableName);
1456
- return (_jsx("div", { className: "sdix-selection-cell", "data-no-row-click": "true", children: _jsx(SolidCheckbox, { checked: rowKey === selectedListRowKey, onChange: function (event) { return setSelectedRows(event.target.checked ? [rowData] : []); } }) }));
1457
- }, style: { width: 52, minWidth: 52 } }), _jsx(Column, { field: "tableName", header: "Table", body: function (rowData) { return (_jsx("div", { className: "sdix-table-primary-cell", children: _jsx("strong", { children: rowData.tableName }) })); }, style: { minWidth: 240 } }), _jsx(Column, { field: "schema", header: "Schema", body: function (rowData) { return rowData.schema || "dbo/default"; }, style: { minWidth: 120 } }), _jsx(Column, { header: "Status", body: function (rowData) { return (_jsx("span", { className: "sdix-status-badge ".concat(rowData.mapped ? "is-mapped" : "is-unmapped"), children: statusLabel(rowData) })); }, style: { minWidth: 150 } }), _jsx(Column, { header: "Superclass", body: function (rowData) { return rowData.suggestedBaseClassName; }, style: { minWidth: 220 } }), _jsx(Column, { field: "suggestedUserKeyField", header: "User Key", style: { minWidth: 160 } }), _jsx(Column, { header: "Mapped Model", body: function (rowData) { return (rowData.mapped
1775
+ return (_jsx("div", { className: "sdix-selection-cell", "data-no-row-click": "true", children: _jsx(SolidCheckbox, { checked: selectedListRowKeySet.has(rowKey), disabled: !rowData.hasPrimaryKey, onChange: function (event) { return toggleSelectedRow(rowData, event.target.checked); } }) }));
1776
+ }, style: { width: 52, minWidth: 52 } }), _jsx(Column, { field: "tableName", header: "Table", body: function (rowData) { return (_jsx("div", { className: "sdix-table-primary-cell", children: _jsx("strong", { children: rowData.tableName }) })); }, style: { minWidth: 240 } }), _jsx(Column, { field: "schema", header: "Schema", body: function (rowData) { return rowData.schema || "dbo/default"; }, style: { minWidth: 120 } }), _jsx(Column, { header: "Status", body: function (rowData) { return (_jsx("span", { className: "sdix-status-badge ".concat(!rowData.hasPrimaryKey ? "is-blocked" : rowData.mapped ? "is-mapped" : "is-unmapped"), children: statusLabel(rowData) })); }, style: { minWidth: 150 } }), _jsx(Column, { header: "Primary Key", body: function (rowData) {
1777
+ var _a;
1778
+ return (rowData.hasPrimaryKey
1779
+ ? rowData.primaryKeyColumnCount > 1
1780
+ ? "".concat(rowData.primaryKeyColumnCount, " columns")
1781
+ : (_a = rowData.primaryKeyColumnNames[0]) !== null && _a !== void 0 ? _a : "1 column"
1782
+ : _jsx("span", { className: "sdix-muted-cell", children: "Missing" }));
1783
+ }, style: { minWidth: 160 } }), _jsx(Column, { header: "Superclass", body: function (rowData) { return rowData.suggestedBaseClassName; }, style: { minWidth: 220 } }), _jsx(Column, { field: "suggestedUserKeyField", header: "User Key", style: { minWidth: 160 } }), _jsx(Column, { header: "Mapped Model", body: function (rowData) { return (rowData.mapped
1458
1784
  ? (_jsxs("div", { className: "sdix-table-primary-cell", children: [_jsx("strong", { children: rowData.mappedModelDisplayName || rowData.mappedModelSingularName || "-" }), rowData.mappedModuleDisplayName || rowData.mappedModuleName ? (_jsx("span", { children: rowData.mappedModuleDisplayName || rowData.mappedModuleName })) : null] }))
1459
1785
  : _jsx("span", { className: "sdix-muted-cell", children: "Not mapped" })); }, style: { minWidth: 200 } }), _jsx(Column, { header: "System Columns", body: function (rowData) { return Math.max(rowData.columnCount - rowData.physicalColumnCount, 0); }, style: { minWidth: 130 } }), _jsx(Column, { header: "Columns", body: function (rowData) { return rowData.physicalColumnCount; }, style: { minWidth: 110 } })] }) })) }) })) : (_jsxs("div", { className: "sdix-workspace-screen", children: [_jsxs("div", { className: "sdix-workspace-header", children: [_jsx(SolidButton, { size: "small", variant: "outline", leftIcon: _jsx(ArrowLeft, { size: 14 }), onClick: leaveWorkspace, children: "Back" }), _jsxs("div", { className: "sdix-workspace-header__identity sdix-workspace-header__identity--right", children: [_jsx("h2", { children: (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.tableName) || "Mapping workspace" }), _jsx("p", { children: selectedTable
1460
1786
  ? "".concat(selectedTable.schema || "dbo", " \u00B7 ").concat((selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.database) || (selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.displayName) || "Datasource").concat(selectedDatasourceRecord ? " \u00B7 ".concat(providerLabel(selectedDatasourceRecord.type)) : "")
1461
- : "Complete the legacy table mapping in a dedicated workspace." })] })] }), !selectedTable && !isTablesLoading ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: "The selected table is no longer available for this datasource." }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: leaveWorkspace, children: "Back to table list" })] })) : drawerLoadingError ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: readQueryError(drawerLoadingError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return void refetchTableDetail(); }, children: "Retry" })] })) : isDrawerBlockingLoading ? (_jsxs("div", { className: "sdix-loading sdix-workspace-loading", children: [_jsx(SolidSpinner, { size: 24 }), _jsx("p", { children: "Preparing column mapping preview..." })] })) : (_jsxs("div", { className: "sdix-wizard-shell", children: [_jsx("div", { className: "sdix-wizard-stepper", children: stepperItems.map(function (step, index) { return (_jsxs("button", { type: "button", className: [
1462
- "sdix-wizard-stepper-item",
1463
- step.active ? "is-active" : "",
1464
- step.complete ? "is-complete" : "",
1465
- step.disabled ? "is-disabled" : "",
1466
- ].filter(Boolean).join(" "), onClick: step.onClick, disabled: step.disabled, children: [_jsx("span", { className: "sdix-wizard-stepper-badge", children: step.complete ? _jsx(Check, { size: 12 }) : index + 1 }), _jsx("span", { className: "sdix-wizard-stepper-label", children: step.label })] }, step.key)); }) }), _jsx("div", { className: "sdix-wizard-panel", children: _jsx("div", { className: "sdix-wizard-panel__body", children: workspaceContent }) }), drawerDraft ? (_jsxs("div", { className: "sdix-wizard-footer", children: [_jsx("div", { className: "sdix-wizard-footer__meta", children: workspaceMeta }), _jsxs("div", { className: "sdix-wizard-footer__actions", children: [drawerDraft.mapped && drawerDraft.modelId ? (_jsx(SolidButton, { size: "small", variant: "outline", leftIcon: _jsx(ExternalLink, { size: 14 }), onClick: openMappedModelForm, children: "Open model form" })) : null, workspaceStep === "configure" ? (_jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isPreviewMappingLoading, onClick: function () { return void reviewMappingJson(); }, children: "Review Mapping" })) : null, workspaceStep === "review-json" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("configure"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isSavingMapping, onClick: function () { return void persistMappingArtifacts(); }, children: "Continue" })] })) : null, workspaceStep === "generate-code" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("review-json"); }, children: "Back" }), _jsx(SolidButton, { size: "small", disabled: !hasAttemptedGenerateCode || isGenerateCodeLoading || isGeneratingCodeWorkflow, onClick: function () { return setWorkspaceStep("create-migrations"); }, children: "Continue" })] })) : null, workspaceStep === "create-migrations" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("generate-code"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isCreatingMigrationArtifacts, onClick: function () { return void handleCreateMigrationArtifacts(); }, children: "Continue" })] })) : null, workspaceStep === "run-migration" ? (runMigrationCompleted ? (_jsx(SolidButton, { size: "small", leftIcon: _jsx(Check, { size: 14 }), onClick: function () { return navigate("/admin/core/solid-core/model-metadata/list"); }, children: "Finish" })) : (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("create-migrations"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Database, { size: 14 }), loading: isRunMigrationLoading, onClick: function () { return void handleRunMigration(); }, children: "Continue" })] }))) : null] })] })) : null] }))] })), _jsxs(SolidDialog, { open: Boolean(activeFieldConfigColumn), onOpenChange: function (open) {
1787
+ : "Complete the legacy table mapping in a dedicated workspace." })] })] }), !selectedTable && !isTablesLoading ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: "The selected table is no longer available for this datasource." }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: leaveWorkspace, children: "Back to table list" })] })) : drawerLoadingError ? (_jsxs("div", { className: "sdix-error", children: [_jsx("span", { children: readQueryError(drawerLoadingError) }), _jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return selectedTable && void loadWorkspaceItem(selectedTable); }, children: "Retry" })] })) : isDrawerBlockingLoading ? (_jsxs("div", { className: "sdix-loading sdix-workspace-loading", children: [_jsx(SolidSpinner, { size: 24 }), _jsx("p", { children: "Preparing column mapping preview..." })] })) : (_jsxs("div", { className: "sdix-wizard-shell", children: [_jsxs("div", { className: "sdix-workspace-body", children: [_jsxs("aside", { className: "sdix-workspace-rail", children: [_jsxs("div", { className: "sdix-workspace-rail__header", children: [_jsx("strong", { children: "Selected tables" }), _jsx("span", { children: workspaceRecords.length })] }), _jsx("div", { className: "sdix-workspace-rail__list", children: workspaceTableKeys.map(function (key) {
1788
+ var item = workspaceItems[key];
1789
+ if (!item)
1790
+ return null;
1791
+ var isActive = key === activeWorkspaceTableKey;
1792
+ var status = item.migrationStatus.state !== "idle" ? item.migrationStatus
1793
+ : item.saveStatus.state !== "idle" ? item.saveStatus
1794
+ : item.reviewStatus.state !== "idle" ? item.reviewStatus
1795
+ : item.loadStatus;
1796
+ return (_jsxs("button", { ref: function (node) {
1797
+ workspaceRailItemRefs.current[key] = node;
1798
+ }, type: "button", className: "sdix-workspace-rail__item".concat(isActive ? " is-active" : ""), onClick: function () {
1799
+ setActiveWorkspaceTableKey(key);
1800
+ if (workspaceStep === "configure") {
1801
+ setDrawerTab("general-info");
1802
+ }
1803
+ }, children: [_jsxs("div", { className: "sdix-workspace-rail__item-main", children: [_jsx("strong", { children: item.record.tableName }), _jsx("span", { children: item.record.schema || "dbo" })] }), _jsxs("div", { className: "sdix-workspace-rail__item-status", children: [status.state === "loading" ? _jsx(SolidSpinner, { size: 12 }) : null, _jsx("span", { className: "sdix-workspace-rail__status sdix-workspace-rail__status--".concat(status.state), children: status.state === "success"
1804
+ ? "Ready"
1805
+ : status.state === "error"
1806
+ ? "Needs attention"
1807
+ : status.message })] })] }, key));
1808
+ }) })] }), _jsxs("div", { className: "sdix-workspace-main", children: [_jsx("div", { className: "sdix-wizard-stepper", children: stepperItems.map(function (step, index) { return (_jsxs("button", { type: "button", className: [
1809
+ "sdix-wizard-stepper-item",
1810
+ step.active ? "is-active" : "",
1811
+ step.complete ? "is-complete" : "",
1812
+ step.disabled ? "is-disabled" : "",
1813
+ ].filter(Boolean).join(" "), onClick: step.onClick, disabled: step.disabled, children: [_jsx("span", { className: "sdix-wizard-stepper-badge", children: step.complete ? _jsx(Check, { size: 12 }) : index + 1 }), _jsx("span", { className: "sdix-wizard-stepper-label", children: step.label })] }, step.key)); }) }), _jsx("div", { className: "sdix-wizard-panel", children: _jsx("div", { className: "sdix-wizard-panel__body", children: workspaceContent }) })] })] }), drawerDraft ? (_jsxs("div", { className: "sdix-wizard-footer", children: [_jsx("div", { className: "sdix-wizard-footer__meta", children: workspaceMeta }), _jsxs("div", { className: "sdix-wizard-footer__actions", children: [drawerDraft.mapped && drawerDraft.modelId ? (_jsx(SolidButton, { size: "small", variant: "outline", leftIcon: _jsx(ExternalLink, { size: 14 }), onClick: openMappedModelForm, children: "Open model form" })) : null, workspaceStep === "configure" ? (_jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isPreviewMappingLoading, onClick: function () { return void reviewMappingJson(); }, children: "Review Mapping" })) : null, workspaceStep === "review-json" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("configure"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isSavingMapping, onClick: function () { return void persistMappingArtifacts(); }, children: "Continue" })] })) : null, workspaceStep === "generate-code" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("review-json"); }, children: "Back" }), _jsx(SolidButton, { size: "small", disabled: !hasAttemptedGenerateCode || isGenerateCodeLoading || isGeneratingCodeWorkflow, onClick: function () { return setWorkspaceStep("create-migrations"); }, children: "Continue" })] })) : null, workspaceStep === "create-migrations" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("generate-code"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isCreatingMigrationArtifacts, onClick: function () { return void handleCreateMigrationArtifacts(); }, children: "Continue" })] })) : null, workspaceStep === "run-migration" ? (runMigrationCompleted ? (_jsx(SolidButton, { size: "small", leftIcon: _jsx(Check, { size: 14 }), onClick: function () { return navigate("/admin/core/solid-core/model-metadata/list"); }, children: "Finish" })) : (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setWorkspaceStep("create-migrations"); }, children: "Back" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Database, { size: 14 }), loading: isRunMigrationLoading, onClick: function () { return void handleRunMigration(); }, children: "Continue" })] }))) : null] })] })) : null] }))] })), _jsxs(SolidDialog, { open: Boolean(activeFieldConfigColumn), onOpenChange: function (open) {
1467
1814
  if (!open) {
1468
1815
  setFieldConfigColumnName(null);
1469
1816
  }
1470
- }, style: { width: "min(1080px, calc(100vw - 48px))" }, children: [_jsxs(SolidDialogHeader, { children: [_jsxs("div", { children: [_jsx(SolidDialogTitle, { children: "Field configuration" }), _jsx(SolidDialogDescription, { children: "Reuse the standard field form here to fine-tune the mapped SolidX field before saving the introspection draft." })] }), _jsx(SolidDialogClose, {})] }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { children: activeFieldConfigColumn && activeFieldConfigMetaData && drawerDraft ? (_jsx(FieldMetaDataForm, { modelMetaData: {
1471
- singularName: drawerDraft.singularName,
1472
- pluralName: drawerDraft.pluralName,
1473
- }, fieldMetaData: activeFieldConfigMetaData, setFieldMetaData: function () { return undefined; }, setVisiblePopup: function () { return undefined; }, setIsDirty: function () { return undefined; }, allFields: fieldDraftAllFields, deleteModelFunction: function () { return undefined; }, params: params, setIsRequiredPopUp: function () { return undefined; }, showToaster: showFieldDraftToaster, onDraftSubmit: function (nextFieldConfig) { return applyFieldConfigDraft(activeFieldConfigColumn.columnName, nextFieldConfig); }, onClose: function () { return setFieldConfigColumnName(null); }, availableFieldTypes: scalarFieldTypeOptions.map(function (option) { return option.value; }), forceShowTypeSelector: true, selectorRequireContinue: true, selectorContinueLabel: "Next", selectorInitialFieldType: activeFieldConfigColumn.solidFieldType, disableIdentityEditingForExisting: false, submitLabel: "Save field config" })) : null })] }), _jsxs(SolidDialog, { open: settingsOpen, onOpenChange: setSettingsOpen, style: { width: "min(560px, calc(100vw - 32px))" }, children: [_jsxs(SolidDialogHeader, { children: [_jsxs("div", { children: [_jsx(SolidDialogTitle, { children: "Session settings" }), _jsx(SolidDialogDescription, { children: "Review the selected datasource and adjust the session-specific introspection flags." })] }), _jsx(SolidDialogClose, {})] }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { children: _jsx(SolidTabGroup, { tabs: settingsTabs, value: settingsTab, onValueChange: setSettingsTab, className: "sdix-settings-tabs", panelClassName: "sdix-settings-tab-panel" }) }), _jsxs(SolidDialogFooter, { children: [_jsx(SolidButton, { variant: "outline", onClick: function () { return setSettingsOpen(false); }, children: "Cancel" }), _jsx(SolidButton, { onClick: applyDraftSettings, children: "Apply" })] })] })] })) }));
1817
+ }, style: { width: "min(760px, calc(100vw - 64px))" }, children: [_jsxs(SolidDialogHeader, { children: [_jsxs("div", { children: [_jsx(SolidDialogTitle, { children: "Field configuration" }), _jsx(SolidDialogDescription, { children: "Configure how this mapped field should work in SolidX before saving it to the mapping draft." })] }), _jsx(SolidDialogClose, {})] }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { children: _jsx("div", { className: "sdix-field-config-dialog", children: activeFieldConfigColumn && activeFieldConfigMetaData && drawerDraft ? (_jsx(FieldMetaDataForm, { modelMetaData: {
1818
+ singularName: drawerDraft.singularName,
1819
+ pluralName: drawerDraft.pluralName,
1820
+ dataSourceType: drawerDraft.dataSourceType,
1821
+ module: {
1822
+ name: (_0 = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _0 === void 0 ? void 0 : _0.name,
1823
+ displayName: (_1 = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _1 === void 0 ? void 0 : _1.displayName,
1824
+ },
1825
+ }, fieldMetaData: activeFieldConfigMetaData, setFieldMetaData: function () { return undefined; }, setVisiblePopup: function () { return undefined; }, setIsDirty: function () { return undefined; }, allFields: fieldDraftAllFields, deleteModelFunction: function () { return undefined; }, params: params, setIsRequiredPopUp: function () { return undefined; }, showToaster: showFieldDraftToaster, onDraftSubmit: function (nextFieldConfig) { return applyFieldConfigDraft(activeFieldConfigColumn.columnName, nextFieldConfig); }, onClose: function () { return setFieldConfigColumnName(null); }, forceShowTypeSelector: true, selectorRequireContinue: true, selectorContinueLabel: "Next", selectorInitialFieldType: activeFieldConfigColumn.solidFieldType, disableIdentityEditingForExisting: false, submitLabel: "Save field config" })) : null }) })] }), _jsxs(SolidDialog, { open: settingsOpen, onOpenChange: setSettingsOpen, style: { width: "min(560px, calc(100vw - 32px))" }, children: [_jsxs(SolidDialogHeader, { children: [_jsxs("div", { children: [_jsx(SolidDialogTitle, { children: "Session settings" }), _jsx(SolidDialogDescription, { children: "Review the selected datasource and adjust the session-specific introspection flags." })] }), _jsx(SolidDialogClose, {})] }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { children: _jsx(SolidTabGroup, { tabs: settingsTabs, value: settingsTab, onValueChange: setSettingsTab, className: "sdix-settings-tabs", panelClassName: "sdix-settings-tab-panel" }) }), _jsxs(SolidDialogFooter, { children: [_jsx(SolidButton, { variant: "outline", onClick: function () { return setSettingsOpen(false); }, children: "Cancel" }), _jsx(SolidButton, { onClick: applyDraftSettings, children: "Apply" })] })] })] })) }));
1474
1826
  }
1475
1827
  //# sourceMappingURL=DatasourceIntrospectionPage.js.map