@solidxai/core-ui 0.1.12-beta.0 → 0.1.12-beta.2

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 (241) hide show
  1. package/dist/components/auth/AuthLayout.d.ts.map +1 -1
  2. package/dist/components/auth/AuthLayout.js +15 -19
  3. package/dist/components/auth/AuthLayout.js.map +1 -1
  4. package/dist/components/auth/AuthLayout.tsx +26 -20
  5. package/dist/components/auth/SolidLogin.d.ts.map +1 -1
  6. package/dist/components/auth/SolidLogin.js +6 -3
  7. package/dist/components/auth/SolidLogin.js.map +1 -1
  8. package/dist/components/auth/SolidLogin.tsx +16 -2
  9. package/dist/components/auth/SolidRegister.d.ts.map +1 -1
  10. package/dist/components/auth/SolidRegister.js +7 -4
  11. package/dist/components/auth/SolidRegister.js.map +1 -1
  12. package/dist/components/auth/SolidRegister.tsx +16 -2
  13. package/dist/components/common/BackButton.js +1 -1
  14. package/dist/components/common/BackButton.js.map +1 -1
  15. package/dist/components/common/BackButton.tsx +1 -1
  16. package/dist/components/common/CancelButton.js +1 -1
  17. package/dist/components/common/CancelButton.js.map +1 -1
  18. package/dist/components/common/CancelButton.tsx +1 -1
  19. package/dist/components/common/GeneralSettings.d.ts.map +1 -1
  20. package/dist/components/common/GeneralSettings.js +6 -33
  21. package/dist/components/common/GeneralSettings.js.map +1 -1
  22. package/dist/components/common/GeneralSettings.tsx +20 -57
  23. package/dist/components/common/SettingsComponent.d.ts.map +1 -1
  24. package/dist/components/common/SettingsComponent.js +1 -9
  25. package/dist/components/common/SettingsComponent.js.map +1 -1
  26. package/dist/components/common/SettingsComponent.tsx +1 -8
  27. package/dist/components/common/SolidBreadcrumb.js +1 -1
  28. package/dist/components/common/SolidBreadcrumb.js.map +1 -1
  29. package/dist/components/common/SolidBreadcrumb.tsx +2 -2
  30. package/dist/components/common/SolidFaviconProvider.d.ts.map +1 -1
  31. package/dist/components/common/SolidFaviconProvider.js +1 -8
  32. package/dist/components/common/SolidFaviconProvider.js.map +1 -1
  33. package/dist/components/common/SolidFaviconProvider.tsx +1 -7
  34. package/dist/components/common/SolidLoadingState.d.ts +10 -0
  35. package/dist/components/common/SolidLoadingState.d.ts.map +1 -0
  36. package/dist/components/common/SolidLoadingState.js +8 -0
  37. package/dist/components/common/SolidLoadingState.js.map +1 -0
  38. package/dist/components/common/SolidLoadingState.module.css +56 -0
  39. package/dist/components/common/SolidLoadingState.tsx +28 -0
  40. package/dist/components/core/card/CardItem.d.ts.map +1 -1
  41. package/dist/components/core/card/CardItem.js +3 -4
  42. package/dist/components/core/card/CardItem.js.map +1 -1
  43. package/dist/components/core/card/CardItem.tsx +3 -4
  44. package/dist/components/core/card/SolidCardView.d.ts.map +1 -1
  45. package/dist/components/core/card/SolidCardView.js +6 -1
  46. package/dist/components/core/card/SolidCardView.js.map +1 -1
  47. package/dist/components/core/card/SolidCardView.tsx +6 -1
  48. package/dist/components/core/card/SolidCardViewConfigure.d.ts.map +1 -1
  49. package/dist/components/core/card/SolidCardViewConfigure.js +4 -1
  50. package/dist/components/core/card/SolidCardViewConfigure.js.map +1 -1
  51. package/dist/components/core/card/SolidCardViewConfigure.tsx +4 -1
  52. package/dist/components/core/common/SolidCreateButton.d.ts.map +1 -1
  53. package/dist/components/core/common/SolidCreateButton.js +2 -13
  54. package/dist/components/core/common/SolidCreateButton.js.map +1 -1
  55. package/dist/components/core/common/SolidCreateButton.tsx +2 -15
  56. package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
  57. package/dist/components/core/common/SolidGlobalSearchElement.js +34 -15
  58. package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
  59. package/dist/components/core/common/SolidGlobalSearchElement.tsx +37 -17
  60. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.js +15 -13
  61. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.js.map +1 -1
  62. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.tsx +4 -4
  63. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.js +6 -5
  64. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.js.map +1 -1
  65. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.tsx +1 -1
  66. package/dist/components/core/form/SolidFormFooter.d.ts +2 -1
  67. package/dist/components/core/form/SolidFormFooter.d.ts.map +1 -1
  68. package/dist/components/core/form/SolidFormFooter.js +48 -14
  69. package/dist/components/core/form/SolidFormFooter.js.map +1 -1
  70. package/dist/components/core/form/SolidFormFooter.tsx +50 -4
  71. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  72. package/dist/components/core/form/SolidFormView.js +52 -50
  73. package/dist/components/core/form/SolidFormView.js.map +1 -1
  74. package/dist/components/core/form/SolidFormView.tsx +16 -9
  75. package/dist/components/core/json/SolidJsonEditor.css +195 -0
  76. package/dist/components/core/json/SolidJsonEditor.d.ts +19 -0
  77. package/dist/components/core/json/SolidJsonEditor.d.ts.map +1 -0
  78. package/dist/components/core/json/SolidJsonEditor.js +109 -0
  79. package/dist/components/core/json/SolidJsonEditor.js.map +1 -0
  80. package/dist/components/core/json/SolidJsonEditor.tsx +150 -0
  81. package/dist/components/core/kanban/KanbanCard.d.ts.map +1 -1
  82. package/dist/components/core/kanban/KanbanCard.js +2 -10
  83. package/dist/components/core/kanban/KanbanCard.js.map +1 -1
  84. package/dist/components/core/kanban/KanbanCard.tsx +2 -10
  85. package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
  86. package/dist/components/core/kanban/SolidKanbanView.js +11 -4
  87. package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
  88. package/dist/components/core/kanban/SolidKanbanView.tsx +13 -5
  89. package/dist/components/core/list/SolidListView.d.ts +2 -0
  90. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  91. package/dist/components/core/list/SolidListView.js +195 -111
  92. package/dist/components/core/list/SolidListView.js.map +1 -1
  93. package/dist/components/core/list/SolidListView.tsx +136 -39
  94. package/dist/components/core/list/SolidListViewConfigure.d.ts.map +1 -1
  95. package/dist/components/core/list/SolidListViewConfigure.js +2 -0
  96. package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
  97. package/dist/components/core/list/SolidListViewConfigure.tsx +2 -0
  98. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.d.ts.map +1 -1
  99. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js +16 -19
  100. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js.map +1 -1
  101. package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.tsx +16 -22
  102. package/dist/components/core/locales/SolidChatterLocaleTabView.d.ts.map +1 -1
  103. package/dist/components/core/locales/SolidChatterLocaleTabView.js +9 -8
  104. package/dist/components/core/locales/SolidChatterLocaleTabView.js.map +1 -1
  105. package/dist/components/core/locales/SolidChatterLocaleTabView.tsx +4 -1
  106. package/dist/components/core/locales/SolidLocale.d.ts.map +1 -1
  107. package/dist/components/core/locales/SolidLocale.js +1 -2
  108. package/dist/components/core/locales/SolidLocale.js.map +1 -1
  109. package/dist/components/core/locales/SolidLocale.tsx +1 -2
  110. package/dist/components/core/model/CreateModel.d.ts.map +1 -1
  111. package/dist/components/core/model/CreateModel.js +1 -1
  112. package/dist/components/core/model/CreateModel.js.map +1 -1
  113. package/dist/components/core/model/CreateModel.tsx +0 -1
  114. package/dist/components/core/model/ModelMetaData.d.ts.map +1 -1
  115. package/dist/components/core/model/ModelMetaData.js +1 -2
  116. package/dist/components/core/model/ModelMetaData.js.map +1 -1
  117. package/dist/components/core/model/ModelMetaData.tsx +1 -3
  118. package/dist/components/core/module/CreateModule.css +70 -2
  119. package/dist/components/core/module/CreateModule.d.ts.map +1 -1
  120. package/dist/components/core/module/CreateModule.js +2 -2
  121. package/dist/components/core/module/CreateModule.js.map +1 -1
  122. package/dist/components/core/module/CreateModule.tsx +13 -1
  123. package/dist/components/core/tree/SolidTreeView.d.ts.map +1 -1
  124. package/dist/components/core/tree/SolidTreeView.js +47 -26
  125. package/dist/components/core/tree/SolidTreeView.js.map +1 -1
  126. package/dist/components/core/tree/SolidTreeView.tsx +55 -23
  127. package/dist/components/layout/AdminTopHeader.js +2 -3
  128. package/dist/components/layout/AdminTopHeader.js.map +1 -1
  129. package/dist/components/layout/AdminTopHeader.tsx +2 -2
  130. package/dist/components/layout/AppSidebar.d.ts.map +1 -1
  131. package/dist/components/layout/AppSidebar.js +5 -2
  132. package/dist/components/layout/AppSidebar.js.map +1 -1
  133. package/dist/components/layout/AppSidebar.tsx +7 -4
  134. package/dist/components/layout/navbar-two-menu.d.ts.map +1 -1
  135. package/dist/components/layout/navbar-two-menu.js +6 -4
  136. package/dist/components/layout/navbar-two-menu.js.map +1 -1
  137. package/dist/components/layout/navbar-two-menu.tsx +4 -2
  138. package/dist/components/shad-cn-ui/SolidTabs.d.ts.map +1 -1
  139. package/dist/components/shad-cn-ui/SolidTabs.js +1 -1
  140. package/dist/components/shad-cn-ui/SolidTabs.js.map +1 -1
  141. package/dist/components/shad-cn-ui/SolidTabs.tsx +1 -0
  142. package/dist/constants/error-messages.d.ts +1 -0
  143. package/dist/constants/error-messages.d.ts.map +1 -1
  144. package/dist/constants/error-messages.js +1 -0
  145. package/dist/constants/error-messages.js.map +1 -1
  146. package/dist/constants/error-messages.ts +1 -0
  147. package/dist/helpers/assetUrl.d.ts +3 -0
  148. package/dist/helpers/assetUrl.d.ts.map +1 -0
  149. package/dist/helpers/assetUrl.js +22 -0
  150. package/dist/helpers/assetUrl.js.map +1 -0
  151. package/dist/helpers/assetUrl.ts +26 -0
  152. package/dist/helpers/modelViewPersistence.d.ts +5 -0
  153. package/dist/helpers/modelViewPersistence.d.ts.map +1 -0
  154. package/dist/helpers/modelViewPersistence.js +168 -0
  155. package/dist/helpers/modelViewPersistence.js.map +1 -0
  156. package/dist/helpers/modelViewPersistence.ts +201 -0
  157. package/dist/helpers/routePaths.d.ts +6 -0
  158. package/dist/helpers/routePaths.d.ts.map +1 -1
  159. package/dist/helpers/routePaths.js +13 -0
  160. package/dist/helpers/routePaths.js.map +1 -1
  161. package/dist/helpers/routePaths.ts +25 -0
  162. package/dist/index.d.ts +3 -0
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/index.js +3 -0
  165. package/dist/index.js.map +1 -1
  166. package/dist/index.ts +14 -0
  167. package/dist/redux/api/datasourceIntrospectionApi.d.ts +203 -0
  168. package/dist/redux/api/datasourceIntrospectionApi.d.ts.map +1 -0
  169. package/dist/redux/api/datasourceIntrospectionApi.js +71 -0
  170. package/dist/redux/api/datasourceIntrospectionApi.js.map +1 -0
  171. package/dist/redux/api/datasourceIntrospectionApi.ts +261 -0
  172. package/dist/redux/api/datasourceManagementApi.d.ts +46 -0
  173. package/dist/redux/api/datasourceManagementApi.d.ts.map +1 -0
  174. package/dist/redux/api/datasourceManagementApi.js +35 -0
  175. package/dist/redux/api/datasourceManagementApi.js.map +1 -0
  176. package/dist/redux/api/datasourceManagementApi.ts +86 -0
  177. package/dist/redux/api/solidServiceApi.d.ts +10 -2
  178. package/dist/redux/api/solidServiceApi.d.ts.map +1 -1
  179. package/dist/redux/api/solidServiceApi.js +2 -4
  180. package/dist/redux/api/solidServiceApi.js.map +1 -1
  181. package/dist/redux/api/solidServiceApi.ts +4 -6
  182. package/dist/redux/store/StoreProvider.d.ts.map +1 -1
  183. package/dist/redux/store/StoreProvider.js +4 -2
  184. package/dist/redux/store/StoreProvider.js.map +1 -1
  185. package/dist/redux/store/StoreProvider.tsx +9 -1
  186. package/dist/redux/store/defaultStoreConfig.d.ts +28 -1
  187. package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
  188. package/dist/redux/store/defaultStoreConfig.js +4 -0
  189. package/dist/redux/store/defaultStoreConfig.js.map +1 -1
  190. package/dist/redux/store/defaultStoreConfig.ts +4 -0
  191. package/dist/resources/solid-custom.css +73 -16
  192. package/dist/routes/guards/AdminGuard.d.ts.map +1 -1
  193. package/dist/routes/guards/AdminGuard.js +2 -1
  194. package/dist/routes/guards/AdminGuard.js.map +1 -1
  195. package/dist/routes/guards/AdminGuard.tsx +7 -1
  196. package/dist/routes/guards/AuthGuard.d.ts.map +1 -1
  197. package/dist/routes/guards/AuthGuard.js +2 -1
  198. package/dist/routes/guards/AuthGuard.js.map +1 -1
  199. package/dist/routes/guards/AuthGuard.tsx +8 -2
  200. package/dist/routes/guards/GuestGuard.d.ts.map +1 -1
  201. package/dist/routes/guards/GuestGuard.js +2 -1
  202. package/dist/routes/guards/GuestGuard.js.map +1 -1
  203. package/dist/routes/guards/GuestGuard.tsx +8 -2
  204. package/dist/routes/pages/admin/core/CardPage.d.ts.map +1 -1
  205. package/dist/routes/pages/admin/core/CardPage.js +11 -0
  206. package/dist/routes/pages/admin/core/CardPage.js.map +1 -1
  207. package/dist/routes/pages/admin/core/CardPage.tsx +13 -0
  208. package/dist/routes/pages/admin/core/DashboardPage.d.ts.map +1 -1
  209. package/dist/routes/pages/admin/core/DashboardPage.js +7 -5
  210. package/dist/routes/pages/admin/core/DashboardPage.js.map +1 -1
  211. package/dist/routes/pages/admin/core/DashboardPage.module.css +18 -0
  212. package/dist/routes/pages/admin/core/DashboardPage.tsx +50 -32
  213. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.css +828 -0
  214. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.d.ts +3 -0
  215. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.d.ts.map +1 -0
  216. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.js +947 -0
  217. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.js.map +1 -0
  218. package/dist/routes/pages/admin/core/DatasourceIntrospectionPage.tsx +1719 -0
  219. package/dist/routes/pages/admin/core/DatasourcesPage.css +337 -0
  220. package/dist/routes/pages/admin/core/DatasourcesPage.d.ts +3 -0
  221. package/dist/routes/pages/admin/core/DatasourcesPage.d.ts.map +1 -0
  222. package/dist/routes/pages/admin/core/DatasourcesPage.js +221 -0
  223. package/dist/routes/pages/admin/core/DatasourcesPage.js.map +1 -0
  224. package/dist/routes/pages/admin/core/DatasourcesPage.tsx +540 -0
  225. package/dist/routes/pages/admin/core/KanbanPage.d.ts.map +1 -1
  226. package/dist/routes/pages/admin/core/KanbanPage.js +11 -0
  227. package/dist/routes/pages/admin/core/KanbanPage.js.map +1 -1
  228. package/dist/routes/pages/admin/core/KanbanPage.tsx +13 -0
  229. package/dist/routes/pages/admin/core/ListPage.d.ts.map +1 -1
  230. package/dist/routes/pages/admin/core/ListPage.js +25 -2
  231. package/dist/routes/pages/admin/core/ListPage.js.map +1 -1
  232. package/dist/routes/pages/admin/core/ListPage.tsx +29 -2
  233. package/dist/routes/pages/admin/core/TreePage.d.ts.map +1 -1
  234. package/dist/routes/pages/admin/core/TreePage.js +10 -2
  235. package/dist/routes/pages/admin/core/TreePage.js.map +1 -1
  236. package/dist/routes/pages/admin/core/TreePage.tsx +11 -2
  237. package/dist/routes/solidRoutes.d.ts.map +1 -1
  238. package/dist/routes/solidRoutes.js +5 -1
  239. package/dist/routes/solidRoutes.js.map +1 -1
  240. package/dist/routes/solidRoutes.tsx +4 -0
  241. package/package.json +1 -1
@@ -0,0 +1,947 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
+ if (ar || !(i in from)) {
62
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
+ ar[i] = from[i];
64
+ }
65
+ }
66
+ return to.concat(ar || Array.prototype.slice.call(from));
67
+ };
68
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
69
+ import { Cog, Database, ExternalLink, RefreshCw, Save, Search, ShieldAlert, Sparkles, } from "lucide-react";
70
+ import { camelCase } from "lodash";
71
+ import { useEffect, useMemo, useRef, useState } from "react";
72
+ import { useDispatch } from "react-redux";
73
+ import { useParams } from "react-router-dom";
74
+ import { showToast } from "../../../../redux/features/toastSlice";
75
+ import { SolidJsonEditor } from "../../../../components/core/json/SolidJsonEditor";
76
+ import { Column, SolidDataTable } from "../../../../components/core/list/SolidDataTable";
77
+ import { SolidButton, SolidCheckbox, SolidDialog, SolidDialogBody, SolidDialogClose, SolidDialogDescription, SolidDialogFooter, SolidDialogHeader, SolidDialogSeparator, SolidDialogTitle, SolidInput, SolidSelect, SolidSpinner, SolidSwitch, SolidTabGroup, SolidTextarea, } from "../../../../components/shad-cn-ui";
78
+ import { useApplyDatasourceIntrospectionMappingMutation, useGetDatasourceIntrospectionBootstrapQuery, useGetDatasourceIntrospectionTableDetailQuery, useGetDatasourceIntrospectionTablesQuery, usePreviewDatasourceIntrospectionMappingMutation, } from "../../../../redux/api/datasourceIntrospectionApi";
79
+ import { useGetmodelByIdQuery } from "../../../../redux/api/modelApi";
80
+ import "./DatasourceIntrospectionPage.css";
81
+ function providerLabel(type) {
82
+ if (type === "postgres")
83
+ return "PostgreSQL";
84
+ if (type === "mysql")
85
+ return "MySQL";
86
+ if (type === "mssql")
87
+ return "MS SQL Server";
88
+ return type;
89
+ }
90
+ var scalarFieldTypeOptions = [
91
+ { value: "shortText", label: "Short Text" },
92
+ { value: "longText", label: "Long Text" },
93
+ { value: "richText", label: "Rich Text" },
94
+ { value: "boolean", label: "Boolean" },
95
+ { value: "int", label: "Integer" },
96
+ { value: "bigint", label: "Big Integer" },
97
+ { value: "decimal", label: "Decimal" },
98
+ { value: "date", label: "Date" },
99
+ { value: "datetime", label: "Date Time" },
100
+ { value: "time", label: "Time" },
101
+ { value: "json", label: "JSON" },
102
+ { value: "uuid", label: "UUID" },
103
+ { value: "email", label: "Email" },
104
+ { value: "password", label: "Password" },
105
+ ];
106
+ var scalarFieldTypeValueSet = new Set(scalarFieldTypeOptions.map(function (option) { return option.value; }));
107
+ function getDefaultOrmTypeForSolidFieldType(dataSourceType, solidFieldType) {
108
+ var _a, _b;
109
+ var normalizedDatasourceType = dataSourceType.toLowerCase();
110
+ var ormTypesByDatasource = {
111
+ mssql: {
112
+ shortText: "varchar",
113
+ longText: "nvarchar",
114
+ richText: "nvarchar",
115
+ boolean: "bit",
116
+ int: "int",
117
+ bigint: "bigint",
118
+ decimal: "numeric",
119
+ date: "date",
120
+ datetime: "datetime",
121
+ time: "time",
122
+ json: "simple-json",
123
+ uuid: "uniqueidentifier",
124
+ email: "nvarchar",
125
+ password: "nvarchar",
126
+ },
127
+ mysql: {
128
+ shortText: "varchar",
129
+ longText: "longtext",
130
+ richText: "longtext",
131
+ boolean: "boolean",
132
+ int: "int",
133
+ bigint: "int",
134
+ decimal: "decimal",
135
+ date: "date",
136
+ datetime: "datetime",
137
+ time: "time",
138
+ json: "json",
139
+ uuid: "varchar",
140
+ email: "varchar",
141
+ password: "varchar",
142
+ },
143
+ postgres: {
144
+ shortText: "varchar",
145
+ longText: "text",
146
+ richText: "text",
147
+ boolean: "boolean",
148
+ int: "integer",
149
+ bigint: "bigint",
150
+ decimal: "decimal",
151
+ date: "date",
152
+ datetime: "timestamp",
153
+ time: "time",
154
+ json: "json",
155
+ uuid: "varchar",
156
+ email: "varchar",
157
+ password: "varchar",
158
+ },
159
+ };
160
+ return (_b = (_a = ormTypesByDatasource[normalizedDatasourceType]) === null || _a === void 0 ? void 0 : _a[solidFieldType]) !== null && _b !== void 0 ? _b : "varchar";
161
+ }
162
+ function legacyTypeLabel(value) {
163
+ if (value === "generated_id")
164
+ return "Legacy generated id";
165
+ if (value === "existing_id")
166
+ return "Legacy existing id";
167
+ return "Legacy generated id";
168
+ }
169
+ function statusLabel(record) {
170
+ return record.mapped ? "Mapped" : "Ready to map";
171
+ }
172
+ function readQueryError(error) {
173
+ var _a;
174
+ return (((_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.message)
175
+ || (error === null || error === void 0 ? void 0 : error.error)
176
+ || (error === null || error === void 0 ? void 0 : error.message)
177
+ || "Something went wrong.");
178
+ }
179
+ function normalizeName(value) {
180
+ return value.trim().toLowerCase();
181
+ }
182
+ function findMatchingModelField(column, modelFields) {
183
+ var _a;
184
+ return (_a = modelFields.find(function (field) {
185
+ var _a;
186
+ if (field === null || field === void 0 ? void 0 : field.isSystem)
187
+ return false;
188
+ var sameColumnName = normalizeName((_a = field === null || field === void 0 ? void 0 : field.columnName) !== null && _a !== void 0 ? _a : "") === normalizeName(column.columnName);
189
+ if (sameColumnName)
190
+ return true;
191
+ return Boolean(column.isAutoGenerated && column.fieldName === "id" && (field === null || field === void 0 ? void 0 : field.name) === "id");
192
+ })) !== null && _a !== void 0 ? _a : null;
193
+ }
194
+ function sanitizeExistingFieldPayload(field) {
195
+ var _a = field !== null && field !== void 0 ? field : {}, createdAt = _a.createdAt, updatedAt = _a.updatedAt, deletedAt = _a.deletedAt, model = _a.model, mediaStorageProvider = _a.mediaStorageProvider, identifier = _a.identifier, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "model", "mediaStorageProvider", "identifier"]);
196
+ if ((mediaStorageProvider === null || mediaStorageProvider === void 0 ? void 0 : mediaStorageProvider.id) && !rest.mediaStorageProviderId) {
197
+ rest.mediaStorageProviderId = mediaStorageProvider.id;
198
+ }
199
+ return rest;
200
+ }
201
+ function buildDrawerDraft(tableDetail, selectedTable, mappedModelData) {
202
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
203
+ var modelData = selectedTable.mapped ? ((_a = mappedModelData === null || mappedModelData === void 0 ? void 0 : mappedModelData.data) !== null && _a !== void 0 ? _a : null) : null;
204
+ var modelFields = (_b = modelData === null || modelData === void 0 ? void 0 : modelData.fields) !== null && _b !== void 0 ? _b : [];
205
+ var preservedFields = modelFields.map(function (field) { return sanitizeExistingFieldPayload(field); });
206
+ var modelUserKeyField = ((_c = modelData === null || modelData === void 0 ? void 0 : modelData.userKeyField) === null || _c === void 0 ? void 0 : _c.name)
207
+ || ((_d = modelFields.find(function (field) { return field === null || field === void 0 ? void 0 : field.isUserKey; })) === null || _d === void 0 ? void 0 : _d.name)
208
+ || "";
209
+ var columns = tableDetail.columns.map(function (column) {
210
+ var _a, _b, _c, _d, _e;
211
+ var matchingField = findMatchingModelField(column, modelFields);
212
+ return {
213
+ columnName: column.columnName,
214
+ fieldName: (_a = matchingField === null || matchingField === void 0 ? void 0 : matchingField.name) !== null && _a !== void 0 ? _a : column.fieldName,
215
+ dataType: column.dataType,
216
+ solidFieldType: (_b = matchingField === null || matchingField === void 0 ? void 0 : matchingField.type) !== null && _b !== void 0 ? _b : column.solidFieldType,
217
+ ormType: (_c = matchingField === null || matchingField === void 0 ? void 0 : matchingField.ormType) !== null && _c !== void 0 ? _c : column.ormType,
218
+ nullable: column.nullable,
219
+ defaultValue: (_d = matchingField === null || matchingField === void 0 ? void 0 : matchingField.defaultValue) !== null && _d !== void 0 ? _d : column.defaultValue,
220
+ characterMaximumLength: column.characterMaximumLength,
221
+ numericPrecision: column.numericPrecision,
222
+ numericScale: column.numericScale,
223
+ ordinalPosition: column.ordinalPosition,
224
+ isAutoGenerated: column.isAutoGenerated,
225
+ handledBySuperclass: column.handledBySuperclass,
226
+ superclassFieldName: column.superclassFieldName,
227
+ fieldId: (_e = matchingField === null || matchingField === void 0 ? void 0 : matchingField.id) !== null && _e !== void 0 ? _e : null,
228
+ include: column.handledBySuperclass ? false : Boolean(matchingField) || !selectedTable.mapped,
229
+ matched: Boolean(matchingField),
230
+ isPrimaryKey: Boolean(matchingField === null || matchingField === void 0 ? void 0 : matchingField.isPrimaryKey) || (column.isAutoGenerated && column.fieldName === "id"),
231
+ };
232
+ });
233
+ var draftUserKeyField = modelUserKeyField || tableDetail.suggestedMetadata.userKeyField;
234
+ return {
235
+ mapped: selectedTable.mapped,
236
+ modelId: selectedTable.mappedModelId,
237
+ mappedModuleLabel: selectedTable.mappedModuleDisplayName || selectedTable.mappedModuleName || null,
238
+ singularName: (_e = modelData === null || modelData === void 0 ? void 0 : modelData.singularName) !== null && _e !== void 0 ? _e : tableDetail.suggestedMetadata.singularName,
239
+ pluralName: (_f = modelData === null || modelData === void 0 ? void 0 : modelData.pluralName) !== null && _f !== void 0 ? _f : tableDetail.suggestedMetadata.pluralName,
240
+ displayName: (_g = modelData === null || modelData === void 0 ? void 0 : modelData.displayName) !== null && _g !== void 0 ? _g : tableDetail.suggestedMetadata.displayName,
241
+ description: (_h = modelData === null || modelData === void 0 ? void 0 : modelData.description) !== null && _h !== void 0 ? _h : tableDetail.suggestedMetadata.displayName,
242
+ tableName: (_j = modelData === null || modelData === void 0 ? void 0 : modelData.tableName) !== null && _j !== void 0 ? _j : tableDetail.suggestedMetadata.tableName,
243
+ schema: tableDetail.suggestedMetadata.schema,
244
+ dataSource: (_k = modelData === null || modelData === void 0 ? void 0 : modelData.dataSource) !== null && _k !== void 0 ? _k : tableDetail.suggestedMetadata.dataSource,
245
+ dataSourceType: (_l = modelData === null || modelData === void 0 ? void 0 : modelData.dataSourceType) !== null && _l !== void 0 ? _l : tableDetail.suggestedMetadata.dataSourceType,
246
+ legacyTableType: (_m = modelData === null || modelData === void 0 ? void 0 : modelData.legacyTableType) !== null && _m !== void 0 ? _m : tableDetail.suggestedMetadata.legacyTableType,
247
+ baseClassName: tableDetail.suggestedMetadata.baseClassName,
248
+ userKeyField: draftUserKeyField,
249
+ enableAuditTracking: (_o = modelData === null || modelData === void 0 ? void 0 : modelData.enableAuditTracking) !== null && _o !== void 0 ? _o : true,
250
+ enableSoftDelete: (_p = modelData === null || modelData === void 0 ? void 0 : modelData.enableSoftDelete) !== null && _p !== void 0 ? _p : false,
251
+ draftPublishWorkflow: (_q = modelData === null || modelData === void 0 ? void 0 : modelData.draftPublishWorkflow) !== null && _q !== void 0 ? _q : false,
252
+ internationalisation: (_r = modelData === null || modelData === void 0 ? void 0 : modelData.internationalisation) !== null && _r !== void 0 ? _r : false,
253
+ columns: columns,
254
+ preservedFields: preservedFields,
255
+ };
256
+ }
257
+ function getDrawerValidationErrors(draft) {
258
+ var errors = [];
259
+ var includedColumns = draft.columns.filter(function (column) { return !column.handledBySuperclass && column.include; });
260
+ var seenFieldNames = new Set();
261
+ if (!draft.singularName.trim()) {
262
+ errors.push("Singular name is required.");
263
+ }
264
+ if (!draft.pluralName.trim()) {
265
+ errors.push("Plural name is required.");
266
+ }
267
+ if (!draft.displayName.trim()) {
268
+ errors.push("Display name is required.");
269
+ }
270
+ if (!includedColumns.length) {
271
+ errors.push("Select at least one physical column to include in the mapping.");
272
+ }
273
+ for (var _i = 0, includedColumns_1 = includedColumns; _i < includedColumns_1.length; _i++) {
274
+ var column = includedColumns_1[_i];
275
+ var normalizedFieldName = column.fieldName.trim();
276
+ if (!normalizedFieldName) {
277
+ errors.push("Field name is required for column \"".concat(column.columnName, "\"."));
278
+ continue;
279
+ }
280
+ if (!scalarFieldTypeValueSet.has(column.solidFieldType)) {
281
+ errors.push("SolidX type \"".concat(column.solidFieldType, "\" is not allowed in step 1 for column \"").concat(column.columnName, "\"."));
282
+ continue;
283
+ }
284
+ if (seenFieldNames.has(normalizedFieldName.toLowerCase())) {
285
+ errors.push("Field name \"".concat(normalizedFieldName, "\" is duplicated in the mapping draft."));
286
+ continue;
287
+ }
288
+ seenFieldNames.add(normalizedFieldName.toLowerCase());
289
+ }
290
+ if (!draft.userKeyField.trim()) {
291
+ errors.push("Choose a user key field before saving the mapping.");
292
+ }
293
+ else {
294
+ var userKeyExists = includedColumns.some(function (column) { return column.fieldName === draft.userKeyField; });
295
+ if (!userKeyExists) {
296
+ errors.push("The chosen user key field must remain part of the mapped columns.");
297
+ }
298
+ }
299
+ if (draft.legacyTableType === "existing_id") {
300
+ var hasPrimaryKey = includedColumns.some(function (column) { return column.isPrimaryKey; });
301
+ if (!hasPrimaryKey) {
302
+ errors.push("Legacy existing-id mappings must keep the generated id column mapped to field name \"id\".");
303
+ }
304
+ }
305
+ return errors;
306
+ }
307
+ function buildMappingRequest(draft, plannedMigrationTimestamp) {
308
+ var _a;
309
+ return {
310
+ mapped: draft.mapped,
311
+ modelId: draft.modelId,
312
+ singularName: draft.singularName.trim(),
313
+ pluralName: draft.pluralName.trim(),
314
+ displayName: draft.displayName.trim(),
315
+ description: draft.description.trim() || draft.displayName.trim(),
316
+ tableName: draft.tableName,
317
+ schema: (_a = draft.schema) !== null && _a !== void 0 ? _a : null,
318
+ dataSource: draft.dataSource,
319
+ dataSourceType: draft.dataSourceType,
320
+ legacyTableType: draft.legacyTableType,
321
+ baseClassName: draft.baseClassName,
322
+ userKeyField: draft.userKeyField,
323
+ enableAuditTracking: draft.enableAuditTracking,
324
+ enableSoftDelete: draft.enableSoftDelete,
325
+ draftPublishWorkflow: draft.draftPublishWorkflow,
326
+ internationalisation: draft.internationalisation,
327
+ plannedMigrationTimestamp: plannedMigrationTimestamp !== null && plannedMigrationTimestamp !== void 0 ? plannedMigrationTimestamp : null,
328
+ columns: draft.columns.map(function (column) { return ({
329
+ columnName: column.columnName,
330
+ fieldName: column.fieldName,
331
+ dataType: column.dataType,
332
+ solidFieldType: column.solidFieldType,
333
+ ormType: column.ormType,
334
+ nullable: column.nullable,
335
+ defaultValue: column.defaultValue,
336
+ characterMaximumLength: column.characterMaximumLength,
337
+ numericPrecision: column.numericPrecision,
338
+ numericScale: column.numericScale,
339
+ ordinalPosition: column.ordinalPosition,
340
+ isAutoGenerated: column.isAutoGenerated,
341
+ handledBySuperclass: column.handledBySuperclass,
342
+ superclassFieldName: column.superclassFieldName,
343
+ fieldId: column.fieldId,
344
+ include: column.include,
345
+ matched: column.matched,
346
+ isPrimaryKey: column.isPrimaryKey,
347
+ }); }),
348
+ };
349
+ }
350
+ function parseAndValidateReviewedModelJson(metadataJsonText, draft) {
351
+ var _a, _b;
352
+ var parsed;
353
+ try {
354
+ parsed = JSON.parse(metadataJsonText);
355
+ }
356
+ catch (error) {
357
+ return {
358
+ error: "Metadata JSON is not valid JSON: ".concat((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "Unknown parse error."),
359
+ parsed: null,
360
+ };
361
+ }
362
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
363
+ return {
364
+ error: "Metadata JSON must be an object.",
365
+ parsed: null,
366
+ };
367
+ }
368
+ var requiredStringKeys = [
369
+ "singularName",
370
+ "pluralName",
371
+ "displayName",
372
+ "description",
373
+ "dataSource",
374
+ "dataSourceType",
375
+ "tableName",
376
+ "userKeyFieldUserKey",
377
+ ];
378
+ for (var _i = 0, requiredStringKeys_1 = requiredStringKeys; _i < requiredStringKeys_1.length; _i++) {
379
+ var key = requiredStringKeys_1[_i];
380
+ if (typeof parsed[key] !== "string" || !parsed[key].trim()) {
381
+ return {
382
+ error: "Metadata JSON must include a non-empty \"".concat(key, "\" string."),
383
+ parsed: null,
384
+ };
385
+ }
386
+ }
387
+ var immutableChecks = [
388
+ { key: "dataSource", expected: draft.dataSource },
389
+ { key: "dataSourceType", expected: draft.dataSourceType },
390
+ { key: "tableName", expected: draft.tableName },
391
+ { key: "legacyTableType", expected: draft.legacyTableType },
392
+ ];
393
+ for (var _c = 0, immutableChecks_1 = immutableChecks; _c < immutableChecks_1.length; _c++) {
394
+ var check = immutableChecks_1[_c];
395
+ if ("".concat((_b = parsed[check.key]) !== null && _b !== void 0 ? _b : "") !== "".concat(check.expected)) {
396
+ return {
397
+ error: "Metadata JSON cannot change immutable binding key \"".concat(check.key, "\"."),
398
+ parsed: null,
399
+ };
400
+ }
401
+ }
402
+ var requiredBooleanKeys = [
403
+ "enableAuditTracking",
404
+ "enableSoftDelete",
405
+ "draftPublishWorkflow",
406
+ "internationalisation",
407
+ ];
408
+ for (var _d = 0, requiredBooleanKeys_1 = requiredBooleanKeys; _d < requiredBooleanKeys_1.length; _d++) {
409
+ var key = requiredBooleanKeys_1[_d];
410
+ if (typeof parsed[key] !== "boolean") {
411
+ return {
412
+ error: "Metadata JSON must include a boolean \"".concat(key, "\" value."),
413
+ parsed: null,
414
+ };
415
+ }
416
+ }
417
+ if (!Array.isArray(parsed.fields)) {
418
+ return {
419
+ error: "Metadata JSON must include a fields array.",
420
+ parsed: null,
421
+ };
422
+ }
423
+ var seenFieldNames = new Set();
424
+ for (var _e = 0, _f = parsed.fields.entries(); _e < _f.length; _e++) {
425
+ var _g = _f[_e], index = _g[0], field = _g[1];
426
+ if (!field || typeof field !== "object" || Array.isArray(field)) {
427
+ return {
428
+ error: "Field at index ".concat(index, " is not a valid object."),
429
+ parsed: null,
430
+ };
431
+ }
432
+ if (typeof field.name !== "string" || !field.name.trim()) {
433
+ return {
434
+ error: "Field at index ".concat(index, " must include a non-empty \"name\"."),
435
+ parsed: null,
436
+ };
437
+ }
438
+ if (typeof field.type !== "string" || !field.type.trim()) {
439
+ return {
440
+ error: "Field \"".concat(field.name, "\" must include a non-empty \"type\"."),
441
+ parsed: null,
442
+ };
443
+ }
444
+ if (typeof field.ormType !== "string" || !field.ormType.trim()) {
445
+ return {
446
+ error: "Field \"".concat(field.name, "\" must include a non-empty \"ormType\"."),
447
+ parsed: null,
448
+ };
449
+ }
450
+ if (typeof field.columnName !== "string" || !field.columnName.trim()) {
451
+ return {
452
+ error: "Field \"".concat(field.name, "\" must include a non-empty \"columnName\"."),
453
+ parsed: null,
454
+ };
455
+ }
456
+ var normalizedFieldName = field.name.trim().toLowerCase();
457
+ if (seenFieldNames.has(normalizedFieldName)) {
458
+ return {
459
+ error: "Field name \"".concat(field.name, "\" is duplicated in metadata JSON."),
460
+ parsed: null,
461
+ };
462
+ }
463
+ seenFieldNames.add(normalizedFieldName);
464
+ }
465
+ 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); })) {
466
+ return {
467
+ error: "Metadata JSON must keep userKeyFieldUserKey present in the fields array.",
468
+ parsed: null,
469
+ };
470
+ }
471
+ return {
472
+ error: null,
473
+ parsed: parsed,
474
+ };
475
+ }
476
+ export function DatasourceIntrospectionPage() {
477
+ var _this = this;
478
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
479
+ var params = useParams();
480
+ var dispatch = useDispatch();
481
+ var moduleId = Number((_a = params.moduleId) !== null && _a !== void 0 ? _a : 0);
482
+ var isValidModuleId = Number.isFinite(moduleId) && moduleId > 0;
483
+ var _o = useGetDatasourceIntrospectionBootstrapQuery(moduleId, {
484
+ skip: !isValidModuleId,
485
+ }), bootstrap = _o.data, isBootstrapLoading = _o.isLoading, isBootstrapFetching = _o.isFetching, bootstrapError = _o.error, refetchBootstrap = _o.refetch;
486
+ var _p = useState(""), selectedDatasource = _p[0], setSelectedDatasource = _p[1];
487
+ var _q = useState(""), selectedTableKey = _q[0], setSelectedTableKey = _q[1];
488
+ var _r = useState(""), tableSearch = _r[0], setTableSearch = _r[1];
489
+ var _s = useState(false), settingsOpen = _s[0], setSettingsOpen = _s[1];
490
+ var _t = useState("datasource-info"), settingsTab = _t[0], setSettingsTab = _t[1];
491
+ var _u = useState(false), drawerOpen = _u[0], setDrawerOpen = _u[1];
492
+ var _v = useState(null), drawerDraft = _v[0], setDrawerDraft = _v[1];
493
+ var _w = useState("general-info"), drawerTab = _w[0], setDrawerTab = _w[1];
494
+ var _x = useState("edit"), drawerStep = _x[0], setDrawerStep = _x[1];
495
+ var _y = useState("metadata-json"), reviewTab = _y[0], setReviewTab = _y[1];
496
+ var _z = useState(null), mappingPreview = _z[0], setMappingPreview = _z[1];
497
+ var _0 = useState(null), reviewedMetadataJsonValue = _0[0], setReviewedMetadataJsonValue = _0[1];
498
+ var _1 = useState(""), metadataJsonText = _1[0], setMetadataJsonText = _1[1];
499
+ var _2 = useState(null), metadataJsonValidationError = _2[0], setMetadataJsonValidationError = _2[1];
500
+ var _3 = useState("initial"), metadataJsonResetToken = _3[0], setMetadataJsonResetToken = _3[1];
501
+ var _4 = useState(false), drawerBootstrapping = _4[0], setDrawerBootstrapping = _4[1];
502
+ var _5 = useState({
503
+ relationInferenceEnabled: false,
504
+ prioritizeUnmappedTables: true,
505
+ }), sessionSettings = _5[0], setSessionSettings = _5[1];
506
+ var _6 = useState(sessionSettings), draftSessionSettings = _6[0], setDraftSessionSettings = _6[1];
507
+ var drawerBootstrapTimerRef = useRef(null);
508
+ var scrollDrawerBodyToTop = function () {
509
+ if (typeof document === "undefined")
510
+ return;
511
+ window.requestAnimationFrame(function () {
512
+ var drawerBody = document.querySelector(".sdix-drawer-body");
513
+ drawerBody === null || drawerBody === void 0 ? void 0 : drawerBody.scrollTo({ top: 0, left: 0 });
514
+ });
515
+ };
516
+ var _7 = usePreviewDatasourceIntrospectionMappingMutation(), previewMapping = _7[0], isPreviewMappingLoading = _7[1].isLoading;
517
+ var _8 = useApplyDatasourceIntrospectionMappingMutation(), applyMapping = _8[0], isApplyMappingLoading = _8[1].isLoading;
518
+ var isSavingMapping = isApplyMappingLoading;
519
+ useEffect(function () {
520
+ if (!bootstrap)
521
+ return;
522
+ if (selectedDatasource)
523
+ return;
524
+ if (bootstrap.recommendedDatasourceName) {
525
+ setSelectedDatasource(bootstrap.recommendedDatasourceName);
526
+ }
527
+ }, [bootstrap, selectedDatasource]);
528
+ useEffect(function () {
529
+ setSelectedTableKey("");
530
+ setDrawerDraft(null);
531
+ setDrawerOpen(false);
532
+ setTableSearch("");
533
+ setDrawerStep("edit");
534
+ setReviewTab("metadata-json");
535
+ setMappingPreview(null);
536
+ setReviewedMetadataJsonValue(null);
537
+ setMetadataJsonText("");
538
+ setMetadataJsonValidationError(null);
539
+ setMetadataJsonResetToken("datasource-".concat(Date.now()));
540
+ }, [selectedDatasource]);
541
+ useEffect(function () { return function () {
542
+ if (drawerBootstrapTimerRef.current) {
543
+ window.clearTimeout(drawerBootstrapTimerRef.current);
544
+ }
545
+ }; }, []);
546
+ useEffect(function () {
547
+ if (!drawerOpen)
548
+ return;
549
+ scrollDrawerBodyToTop();
550
+ }, [drawerOpen, drawerStep, drawerTab, reviewTab, selectedTableKey]);
551
+ var datasourceOptions = useMemo(function () {
552
+ var _a;
553
+ return ((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.datasources) !== null && _a !== void 0 ? _a : []).map(function (datasource) { return ({
554
+ label: "".concat(datasource.displayName, " (").concat(providerLabel(datasource.type), ")"),
555
+ value: datasource.name,
556
+ }); });
557
+ }, [bootstrap]);
558
+ var _9 = useGetDatasourceIntrospectionTablesQuery({ moduleId: moduleId, datasource: selectedDatasource }, {
559
+ skip: !isValidModuleId || !selectedDatasource,
560
+ }), tablesResponse = _9.data, isTablesLoading = _9.isLoading, isTablesFetching = _9.isFetching, tablesError = _9.error, refetchTables = _9.refetch;
561
+ 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) === selectedTableKey; })) !== null && _b !== void 0 ? _b : null; }, [tablesResponse, selectedTableKey]);
562
+ var _10 = useGetDatasourceIntrospectionTableDetailQuery({
563
+ moduleId: moduleId,
564
+ datasource: selectedDatasource,
565
+ table: (_b = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.tableName) !== null && _b !== void 0 ? _b : "",
566
+ schema: (_c = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.schema) !== null && _c !== void 0 ? _c : undefined,
567
+ }, {
568
+ skip: !drawerOpen || !isValidModuleId || !selectedDatasource || !selectedTable || !!(tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.synchronizeBlocked),
569
+ }), tableDetail = _10.data, isTableDetailLoading = _10.isLoading, isTableDetailFetching = _10.isFetching, tableDetailError = _10.error, refetchTableDetail = _10.refetch;
570
+ var _11 = useGetmodelByIdQuery((_d = selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelId) !== null && _d !== void 0 ? _d : 0, {
571
+ skip: !drawerOpen || !(selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mapped) || !(selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelId),
572
+ }), mappedModelResponse = _11.data, isMappedModelLoading = _11.isLoading, isMappedModelFetching = _11.isFetching, mappedModelError = _11.error;
573
+ var mappedModelData = mappedModelResponse === null || mappedModelResponse === void 0 ? void 0 : mappedModelResponse.data;
574
+ var selectedDatasourceRecord = (_f = (_e = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.datasources) === null || _e === void 0 ? void 0 : _e.find(function (datasource) { return datasource.name === selectedDatasource; })) !== null && _f !== void 0 ? _f : null;
575
+ var drawerLoadingError = (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mapped) ? (tableDetailError || mappedModelError) : tableDetailError;
576
+ var isDrawerBlockingLoading = Boolean(selectedTable
577
+ && (drawerBootstrapping
578
+ || !drawerDraft
579
+ || isTableDetailLoading
580
+ || isTableDetailFetching
581
+ || (selectedTable.mapped && (isMappedModelLoading || isMappedModelFetching))));
582
+ useEffect(function () {
583
+ if (!drawerOpen || !selectedTable || !tableDetail)
584
+ return;
585
+ if (selectedTable.mapped && (!mappedModelData || mappedModelData.id !== selectedTable.mappedModelId))
586
+ return;
587
+ if (drawerBootstrapTimerRef.current) {
588
+ window.clearTimeout(drawerBootstrapTimerRef.current);
589
+ }
590
+ setDrawerDraft(buildDrawerDraft(tableDetail, selectedTable, selectedTable.mapped ? mappedModelResponse : undefined));
591
+ drawerBootstrapTimerRef.current = window.setTimeout(function () {
592
+ setDrawerBootstrapping(false);
593
+ }, 150);
594
+ }, [drawerOpen, selectedTable, tableDetail, mappedModelData, mappedModelResponse]);
595
+ var filteredRecords = useMemo(function () {
596
+ var _a;
597
+ var records = __spreadArray([], ((_a = tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records) !== null && _a !== void 0 ? _a : []), true);
598
+ var searchNeedle = tableSearch.trim().toLowerCase();
599
+ var filtered = searchNeedle
600
+ ? records.filter(function (record) {
601
+ var _a, _b, _c;
602
+ var haystack = "".concat(record.tableName, " ").concat((_a = record.schema) !== null && _a !== void 0 ? _a : "", " ").concat((_b = record.mappedModelSingularName) !== null && _b !== void 0 ? _b : "", " ").concat((_c = record.mappedModelDisplayName) !== null && _c !== void 0 ? _c : "").toLowerCase();
603
+ return haystack.includes(searchNeedle);
604
+ })
605
+ : records;
606
+ if (sessionSettings.prioritizeUnmappedTables) {
607
+ filtered.sort(function (left, right) {
608
+ var _a, _b;
609
+ if (left.mapped !== right.mapped) {
610
+ return left.mapped ? 1 : -1;
611
+ }
612
+ var leftLabel = "".concat((_a = left.schema) !== null && _a !== void 0 ? _a : "", ".").concat(left.tableName).toLowerCase();
613
+ var rightLabel = "".concat((_b = right.schema) !== null && _b !== void 0 ? _b : "", ".").concat(right.tableName).toLowerCase();
614
+ return leftLabel.localeCompare(rightLabel);
615
+ });
616
+ }
617
+ return filtered;
618
+ }, [sessionSettings.prioritizeUnmappedTables, tableSearch, tablesResponse === null || tablesResponse === void 0 ? void 0 : tablesResponse.records]);
619
+ var drawerUserKeyOptions = useMemo(function () {
620
+ var _a;
621
+ var options = new Map();
622
+ (_a = tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.userKeyCandidates) === null || _a === void 0 ? void 0 : _a.forEach(function (candidate) {
623
+ options.set(candidate.name, {
624
+ label: "".concat(candidate.label, " \u00B7 ").concat(candidate.reason),
625
+ value: candidate.name,
626
+ });
627
+ });
628
+ drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.filter(function (column) { return !column.handledBySuperclass && column.include; }).forEach(function (column) {
629
+ if (!options.has(column.fieldName)) {
630
+ options.set(column.fieldName, {
631
+ label: "".concat(column.fieldName, " \u00B7 mapped from ").concat(column.columnName),
632
+ value: column.fieldName,
633
+ });
634
+ }
635
+ });
636
+ return Array.from(options.values());
637
+ }, [drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns, tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.userKeyCandidates]);
638
+ var settingsTabs = [
639
+ {
640
+ value: "datasource-info",
641
+ label: "Datasource Info",
642
+ content: (_jsxs("div", { className: "sdix-settings-grid", children: [_jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Target module" }), _jsx("strong", { children: (_g = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _g === void 0 ? void 0 : _g.displayName })] }), _jsxs("div", { className: "sdix-settings-static", children: [_jsx("span", { children: "Default datasource" }), _jsx("strong", { children: ((_h = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _h === void 0 ? void 0 : _h.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: (_j = selectedDatasourceRecord === null || selectedDatasourceRecord === void 0 ? void 0 : selectedDatasourceRecord.port) !== null && _j !== void 0 ? _j : "-" })] }), _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") : "-" })] })] })),
643
+ },
644
+ {
645
+ value: "session-settings",
646
+ label: "Session Settings",
647
+ content: (_jsxs("div", { className: "sdix-settings-grid", children: [_jsxs("div", { className: "sdix-settings-row", children: [_jsxs("div", { children: [_jsx("label", { children: "Relation inference" }), _jsx("p", { children: "Keep this off until we deliberately introduce relation discovery across engines." })] }), _jsx(SolidSwitch, { checked: draftSessionSettings.relationInferenceEnabled, onChange: function (checked) { return setDraftSessionSettings(function (current) { return (__assign(__assign({}, current), { relationInferenceEnabled: checked })); }); } })] }), _jsxs("div", { className: "sdix-settings-row", children: [_jsxs("div", { children: [_jsx("label", { children: "Prioritize unmapped tables" }), _jsx("p", { children: "Bubble unmapped tables to the top of the inventory so the first pass stays focused." })] }), _jsx(SolidSwitch, { checked: draftSessionSettings.prioritizeUnmappedTables, onChange: function (checked) { return setDraftSessionSettings(function (current) { return (__assign(__assign({}, current), { prioritizeUnmappedTables: checked })); }); } })] })] })),
648
+ },
649
+ ];
650
+ var handleRefresh = function () { return __awaiter(_this, void 0, void 0, function () {
651
+ return __generator(this, function (_a) {
652
+ switch (_a.label) {
653
+ case 0: return [4 /*yield*/, refetchBootstrap()];
654
+ case 1:
655
+ _a.sent();
656
+ if (!selectedDatasource) return [3 /*break*/, 3];
657
+ return [4 /*yield*/, refetchTables()];
658
+ case 2:
659
+ _a.sent();
660
+ _a.label = 3;
661
+ case 3:
662
+ if (!selectedTable) return [3 /*break*/, 5];
663
+ return [4 /*yield*/, refetchTableDetail()];
664
+ case 4:
665
+ _a.sent();
666
+ _a.label = 5;
667
+ case 5: return [2 /*return*/];
668
+ }
669
+ });
670
+ }); };
671
+ var openTableDrawer = function (record) {
672
+ var _a, _b;
673
+ if (drawerBootstrapTimerRef.current) {
674
+ window.clearTimeout(drawerBootstrapTimerRef.current);
675
+ }
676
+ setSelectedTableKey("".concat((_a = record.schema) !== null && _a !== void 0 ? _a : "", "::").concat(record.tableName));
677
+ setDrawerDraft(null);
678
+ setDrawerTab("general-info");
679
+ setDrawerStep("edit");
680
+ setReviewTab("metadata-json");
681
+ setMappingPreview(null);
682
+ setReviewedMetadataJsonValue(null);
683
+ setMetadataJsonText("");
684
+ setMetadataJsonValidationError(null);
685
+ setMetadataJsonResetToken("table-".concat((_b = record.schema) !== null && _b !== void 0 ? _b : "default", "-").concat(record.tableName, "-").concat(Date.now()));
686
+ setDrawerBootstrapping(true);
687
+ setDrawerOpen(true);
688
+ };
689
+ var applyDraftSettings = function () {
690
+ setSessionSettings(draftSessionSettings);
691
+ setSettingsOpen(false);
692
+ };
693
+ var updateDrawerDraft = function (updater) {
694
+ setMappingPreview(null);
695
+ setDrawerDraft(function (current) { return (current ? updater(current) : current); });
696
+ };
697
+ var updateGeneralField = function (field, value) {
698
+ updateDrawerDraft(function (current) {
699
+ var _a;
700
+ return (__assign(__assign({}, current), (_a = {}, _a[field] = value, _a)));
701
+ });
702
+ };
703
+ var updateColumnFieldName = function (columnName, nextFieldName) {
704
+ updateDrawerDraft(function (current) {
705
+ var _a;
706
+ return (__assign(__assign({}, current), { columns: current.columns.map(function (column) {
707
+ if (column.columnName !== columnName)
708
+ return column;
709
+ return __assign(__assign({}, column), { fieldName: camelCase(nextFieldName) });
710
+ }), userKeyField: current.userKeyField === ((_a = current.columns.find(function (column) { return column.columnName === columnName; })) === null || _a === void 0 ? void 0 : _a.fieldName)
711
+ ? camelCase(nextFieldName)
712
+ : current.userKeyField }));
713
+ });
714
+ };
715
+ var updateColumnSolidFieldType = function (columnName, nextSolidFieldType) {
716
+ updateDrawerDraft(function (current) { return (__assign(__assign({}, current), { columns: current.columns.map(function (column) {
717
+ if (column.columnName !== columnName)
718
+ return column;
719
+ if (column.handledBySuperclass)
720
+ return column;
721
+ return __assign(__assign({}, column), { solidFieldType: nextSolidFieldType, ormType: getDefaultOrmTypeForSolidFieldType(current.dataSourceType, nextSolidFieldType) });
722
+ }) })); });
723
+ };
724
+ var setColumnIncluded = function (columnName, include) {
725
+ updateDrawerDraft(function (current) { return (__assign(__assign({}, current), { columns: current.columns.map(function (column) {
726
+ if (column.columnName !== columnName)
727
+ return column;
728
+ if (column.handledBySuperclass || column.isPrimaryKey)
729
+ return column;
730
+ return __assign(__assign({}, column), { include: include });
731
+ }) })); });
732
+ };
733
+ var changeUserKeyField = function (fieldName) {
734
+ updateDrawerDraft(function (current) { return (__assign(__assign({}, current), { userKeyField: fieldName, columns: current.columns.map(function (column) { return (column.fieldName === fieldName
735
+ ? __assign(__assign({}, column), { include: column.handledBySuperclass ? false : true }) : column); }) })); });
736
+ };
737
+ var setUnmappedColumnsIncluded = function (include) {
738
+ updateDrawerDraft(function (current) { return (__assign(__assign({}, current), { columns: current.columns.map(function (column) {
739
+ if (column.handledBySuperclass || column.matched || column.isPrimaryKey) {
740
+ return column;
741
+ }
742
+ return __assign(__assign({}, column), { include: include });
743
+ }) })); });
744
+ };
745
+ var openMappedModelForm = function () {
746
+ var _a;
747
+ var targetModelId = (_a = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.modelId) !== null && _a !== void 0 ? _a : selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.mappedModelId;
748
+ if (!targetModelId)
749
+ return;
750
+ window.open("/admin/core/solid-core/model-metadata/form/".concat(targetModelId), "_blank", "noopener,noreferrer");
751
+ };
752
+ var viewChanges = function () { return __awaiter(_this, void 0, void 0, function () {
753
+ var validationErrors, preview, error_1;
754
+ var _a;
755
+ return __generator(this, function (_b) {
756
+ switch (_b.label) {
757
+ case 0:
758
+ if (!drawerDraft || !((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id))
759
+ return [2 /*return*/];
760
+ validationErrors = getDrawerValidationErrors(drawerDraft);
761
+ if (validationErrors.length) {
762
+ validationErrors.forEach(function (detail) {
763
+ dispatch(showToast({ severity: "error", summary: "Validation", detail: detail }));
764
+ });
765
+ return [2 /*return*/];
766
+ }
767
+ _b.label = 1;
768
+ case 1:
769
+ _b.trys.push([1, 3, , 4]);
770
+ return [4 /*yield*/, previewMapping({
771
+ moduleId: bootstrap.module.id,
772
+ payload: buildMappingRequest(drawerDraft),
773
+ }).unwrap()];
774
+ case 2:
775
+ preview = _b.sent();
776
+ setMappingPreview(preview);
777
+ setReviewedMetadataJsonValue(preview.metadataJson.model);
778
+ setMetadataJsonText(JSON.stringify(preview.metadataJson.model, null, 2));
779
+ setMetadataJsonValidationError(null);
780
+ setMetadataJsonResetToken("preview-".concat(preview.metadataJson.filePath, "-").concat(Date.now()));
781
+ setReviewTab("metadata-json");
782
+ setDrawerStep("review");
783
+ return [3 /*break*/, 4];
784
+ case 3:
785
+ error_1 = _b.sent();
786
+ dispatch(showToast({
787
+ severity: "error",
788
+ summary: "Preview failed",
789
+ detail: readQueryError(error_1),
790
+ }));
791
+ return [3 /*break*/, 4];
792
+ case 4: return [2 /*return*/];
793
+ }
794
+ });
795
+ }); };
796
+ var saveMapping = function () { return __awaiter(_this, void 0, void 0, function () {
797
+ var validationErrors, reviewedModelValidation, response, error_2;
798
+ var _a, _b, _c, _d;
799
+ return __generator(this, function (_e) {
800
+ switch (_e.label) {
801
+ case 0:
802
+ if (!drawerDraft || !((_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.module) === null || _a === void 0 ? void 0 : _a.id))
803
+ return [2 /*return*/];
804
+ validationErrors = getDrawerValidationErrors(drawerDraft);
805
+ if (validationErrors.length) {
806
+ validationErrors.forEach(function (detail) {
807
+ dispatch(showToast({ severity: "error", summary: "Validation", detail: detail }));
808
+ });
809
+ setDrawerStep("edit");
810
+ return [2 /*return*/];
811
+ }
812
+ reviewedModelValidation = parseAndValidateReviewedModelJson(metadataJsonText, drawerDraft);
813
+ if (reviewedModelValidation.error || !reviewedModelValidation.parsed) {
814
+ setMetadataJsonValidationError((_b = reviewedModelValidation.error) !== null && _b !== void 0 ? _b : "Metadata JSON is invalid.");
815
+ setReviewTab("metadata-json");
816
+ setDrawerStep("review");
817
+ dispatch(showToast({
818
+ severity: "error",
819
+ summary: "Validation",
820
+ detail: (_c = reviewedModelValidation.error) !== null && _c !== void 0 ? _c : "Metadata JSON is invalid.",
821
+ }));
822
+ return [2 /*return*/];
823
+ }
824
+ setMetadataJsonValidationError(null);
825
+ _e.label = 1;
826
+ case 1:
827
+ _e.trys.push([1, 5, , 6]);
828
+ return [4 /*yield*/, applyMapping({
829
+ moduleId: bootstrap.module.id,
830
+ 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 }),
831
+ }).unwrap()];
832
+ case 2:
833
+ response = _e.sent();
834
+ dispatch(showToast({
835
+ severity: "success",
836
+ summary: "Saved",
837
+ detail: response.migration.written
838
+ ? "The mapping, metadata JSON, and migration template were written successfully."
839
+ : drawerDraft.mapped
840
+ ? "The model mapping was updated and written back to metadata JSON."
841
+ : "The model mapping was created and written to metadata JSON.",
842
+ }));
843
+ setDrawerOpen(false);
844
+ setDrawerDraft(null);
845
+ setMappingPreview(null);
846
+ setReviewedMetadataJsonValue(null);
847
+ setMetadataJsonText("");
848
+ setMetadataJsonValidationError(null);
849
+ setMetadataJsonResetToken("saved-".concat(Date.now()));
850
+ setDrawerStep("edit");
851
+ return [4 /*yield*/, refetchTables()];
852
+ case 3:
853
+ _e.sent();
854
+ return [4 /*yield*/, refetchBootstrap()];
855
+ case 4:
856
+ _e.sent();
857
+ return [3 /*break*/, 6];
858
+ case 5:
859
+ error_2 = _e.sent();
860
+ dispatch(showToast({
861
+ severity: "error",
862
+ summary: "Save failed",
863
+ detail: readQueryError(error_2),
864
+ }));
865
+ return [3 /*break*/, 6];
866
+ case 6: return [2 /*return*/];
867
+ }
868
+ });
869
+ }); };
870
+ if (!isValidModuleId) {
871
+ return (_jsx("div", { className: "sdix-page", children: _jsxs("div", { className: "sdix-empty-state", children: [_jsx(ShieldAlert, { size: 24 }), _jsx("h2", { children: "Module not found" }), _jsx("p", { children: "Open datasource introspection from a saved module so SolidX knows which module should receive the mapped models." })] }) }));
872
+ }
873
+ var selectableUnmappedColumns = (_k = drawerDraft === null || drawerDraft === void 0 ? void 0 : drawerDraft.columns.filter(function (column) { return !column.handledBySuperclass && !column.matched && !column.isPrimaryKey; })) !== null && _k !== void 0 ? _k : [];
874
+ var allSelectableUnmappedIncluded = selectableUnmappedColumns.length > 0
875
+ && selectableUnmappedColumns.every(function (column) { return column.include; });
876
+ var drawerRawDdl = (_l = tableDetail === null || tableDetail === void 0 ? void 0 : tableDetail.rawDdl) !== null && _l !== void 0 ? _l : null;
877
+ var drawerTabs = drawerDraft ? [
878
+ {
879
+ value: "general-info",
880
+ label: "General Info",
881
+ 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, { id: "sdix-description", rows: 3, 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: (_m = drawerDraft.schema) !== null && _m !== void 0 ? _m : "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: "Legacy Strategy" }), _jsx(SolidInput, { id: "sdix-legacy-type", value: legacyTypeLabel(drawerDraft.legacyTableType), disabled: true })] }), _jsxs("div", { className: "sdix-form-field", children: [_jsx("label", { htmlFor: "sdix-base-class", children: "Superclass" }), _jsx(SolidInput, { id: "sdix-base-class", value: drawerDraft.baseClassName, disabled: true })] })] })] })] })),
882
+ },
883
+ {
884
+ value: "columns-mapping",
885
+ label: "Columns Mapping",
886
+ 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", { children: "Column" }), _jsx("span", { children: "Field" }), _jsx("span", { children: "Database" }), _jsx("span", { children: "SolidX" }), _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: "Status" }), _jsx("span", { children: "Action" })] }), drawerDraft.columns.map(function (column) {
887
+ var isUserKey = drawerDraft.userKeyField === column.fieldName;
888
+ var statusClassName = column.handledBySuperclass
889
+ ? "is-superclass"
890
+ : column.include
891
+ ? column.matched
892
+ ? "is-mapped"
893
+ : "is-unmapped"
894
+ : "is-muted";
895
+ var statusText = column.handledBySuperclass
896
+ ? "System"
897
+ : column.include
898
+ ? column.matched
899
+ ? "Mapped"
900
+ : "Queued for save"
901
+ : column.matched
902
+ ? "Currently omitted"
903
+ : "Skipped for now";
904
+ return (_jsxs("div", { className: "sdix-column-row sdix-column-row--mapping", children: [_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 ? _jsx("small", { className: "sdix-inline-note", children: "User key" }) : null] }), _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", { 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, label: "Required" })) : (_jsx(SolidCheckbox, { checked: column.include, onChange: function (event) { return setColumnIncluded(column.columnName, event.target.checked); } })) }), _jsx("span", { children: _jsx("span", { className: "sdix-status-badge ".concat(statusClassName), children: statusText }) }), _jsx("span", { className: "sdix-column-action", children: column.handledBySuperclass ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, children: "Managed" })) : column.isPrimaryKey ? (_jsx(SolidButton, { size: "small", variant: "outline", disabled: true, 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));
905
+ })] })] })),
906
+ },
907
+ {
908
+ value: "raw-ddl",
909
+ label: "Raw DDL",
910
+ 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." })] })) })),
911
+ },
912
+ ] : [];
913
+ var reviewTabs = mappingPreview ? [
914
+ {
915
+ value: "metadata-json",
916
+ label: "Metadata JSON",
917
+ content: (_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) {
918
+ setReviewedMetadataJsonValue(nextValue);
919
+ if (metadataJsonValidationError) {
920
+ setMetadataJsonValidationError(null);
921
+ }
922
+ }, onTextChange: function (nextText) {
923
+ setMetadataJsonText(nextText);
924
+ }, onErrorChange: setMetadataJsonValidationError }), metadataJsonValidationError ? (_jsx("div", { className: "sdix-json-validation-error", children: _jsx("span", { children: metadataJsonValidationError }) })) : null] })),
925
+ },
926
+ {
927
+ value: "migration",
928
+ label: "Migration",
929
+ content: (_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 is read-only here. Saving the mapping will write a new template migration file to the target location." }), 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 })] })) })),
930
+ },
931
+ ] : [];
932
+ return (_jsxs("div", { className: "sdix-page", children: [_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 || isTableDetailFetching || isMappedModelFetching ? (_jsxs("div", { className: "sdix-inline-status", children: [_jsx(SolidSpinner, { size: 16 }), _jsx("span", { children: "Refreshing" })] })) : null, _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 () {
933
+ setDraftSessionSettings(sessionSettings);
934
+ setSettingsTab("datasource-info");
935
+ setSettingsOpen(true);
936
+ }, tooltip: "Session settings", "aria-label": "Session settings" })] })] }), 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: [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, _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) {
937
+ var data = _a.data;
938
+ return openTableDrawer(data);
939
+ }, rowClassName: function (rowData) { var _a; return "".concat((_a = rowData.schema) !== null && _a !== void 0 ? _a : "", "::").concat(rowData.tableName) === selectedTableKey && drawerOpen ? "sdix-table-row-selected" : ""; }, emptyMessage: "No datasource tables found", children: [_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
940
+ ? (rowData.mappedModelDisplayName || rowData.mappedModelSingularName || "-")
941
+ : _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(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" })] })] }), _jsxs(SolidDialog, { open: drawerOpen, onOpenChange: setDrawerOpen, className: "sdix-drawer", overlayClassName: "sdix-drawer-overlay", dismissible: true, children: [_jsxs(SolidDialogHeader, { className: "sdix-drawer-header", children: [_jsxs("div", { className: "sdix-drawer-header__identity", children: [_jsx(SolidDialogTitle, { children: (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.tableName) || "Table details" }), _jsx(SolidDialogDescription, { className: "sdix-drawer-header__meta", children: selectedTable
942
+ ? "".concat(selectedTable.schema || "default", " \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)) : "")
943
+ : "Review mapping details" })] }), _jsx(SolidDialogClose, {})] }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { className: "sdix-drawer-body", children: !selectedTable ? (_jsxs("div", { className: "sdix-empty-state is-inline", children: [_jsx(Sparkles, { size: 22 }), _jsx("p", { children: "Select a table row to review its structure." })] })) : drawerLoadingError ? (_jsxs("div", { className: "sdix-error is-inline", 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 is-inline", children: [_jsx(SolidSpinner, { size: 24 }), _jsx("p", { children: "Preparing column mapping preview..." })] })) : (_jsxs("div", { className: "sdix-drawer-stack", children: [drawerDraft && !drawerDraft.mapped && drawerStep === "edit" ? (_jsxs("div", { className: "sdix-detail-callout sdix-system-fields-callout", children: [_jsx("h3", { children: "SolidX system fields are added later" }), _jsxs("p", { children: ["This preview only lists the legacy table columns that already exist today.", " ", "Framework system fields from the selected superclass, including the namespaced", " ", _jsx("code", { children: "ss_*" }), " ", "columns, are introduced when you save the mapping and then generate/apply the follow-up migrations."] })] })) : null, drawerStep === "edit" ? (_jsx(SolidTabGroup, { tabs: drawerTabs, value: drawerTab, onValueChange: setDrawerTab, className: "sdix-drawer-tabs", panelClassName: "sdix-drawer-tab-panel" })) : (_jsx(SolidTabGroup, { tabs: reviewTabs, value: reviewTab, onValueChange: setReviewTab, className: "sdix-drawer-tabs", panelClassName: "sdix-drawer-tab-panel" }))] })) }), drawerDraft && !isDrawerBlockingLoading ? (_jsxs(_Fragment, { children: [_jsx(SolidDialogSeparator, {}), _jsxs(SolidDialogFooter, { className: "sdix-drawer-footer", children: [_jsx("div", { className: "sdix-drawer-footer__meta", children: drawerStep === "review" && mappingPreview ? (_jsxs("span", { children: ["Review the metadata update first, then save to apply", " ", _jsx("strong", { children: mappingPreview.summary.includedColumnNames.length }), " ", "mapped columns", mappingPreview.summary.generatedSystemColumnCount
944
+ ? " and ".concat(mappingPreview.summary.generatedSystemColumnCount, " SolidX system column migration changes")
945
+ : "", "."] })) : 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: "Saving will create the model metadata and write it to the module JSON." })) }), _jsxs("div", { className: "sdix-drawer-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, drawerStep === "review" ? (_jsxs(_Fragment, { children: [_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setDrawerStep("edit"); }, children: "Back to editing" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isSavingMapping, onClick: function () { return void saveMapping(); }, children: "Save mapping" })] })) : (_jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 14 }), loading: isPreviewMappingLoading, onClick: function () { return void viewChanges(); }, children: "View Changes" }))] })] })] })) : null] })] }))] }));
946
+ }
947
+ //# sourceMappingURL=DatasourceIntrospectionPage.js.map