@constructive-io/schema-builder 0.8.0 → 0.9.0
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.
- package/CHANGELOG.md +17 -0
- package/dist/{create-table-card-COzwEhdq.js → create-table-card-Cp96Mwkr.js} +13 -13
- package/dist/{create-table-card-COzwEhdq.js.map → create-table-card-Cp96Mwkr.js.map} +1 -1
- package/dist/{create-table-card--0VzN5yH.cjs → create-table-card-DXN0SCsn.cjs} +13 -13
- package/dist/{create-table-card--0VzN5yH.cjs.map → create-table-card-DXN0SCsn.cjs.map} +1 -1
- package/dist/editor-view-C5z6x0St.js +100 -0
- package/dist/editor-view-C5z6x0St.js.map +1 -0
- package/dist/editor-view-CKrOtZX_.cjs +141 -0
- package/dist/editor-view-CKrOtZX_.cjs.map +1 -0
- package/dist/{empty-state-card-5t7LygTB.cjs → empty-state-card-CV7DnIsA.cjs} +25 -17
- package/dist/empty-state-card-CV7DnIsA.cjs.map +1 -0
- package/dist/{empty-state-card-C-Nylatg.js → empty-state-card-sYoB01xr.js} +25 -17
- package/dist/empty-state-card-sYoB01xr.js.map +1 -0
- package/dist/fields.cjs +1 -1
- package/dist/fields.js +1 -1
- package/dist/index.cjs +70 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -48
- package/dist/index.js.map +1 -1
- package/dist/{indexes-view-CVZLjX89.cjs → indexes-view-BhRQc36j.cjs} +96 -125
- package/dist/indexes-view-BhRQc36j.cjs.map +1 -0
- package/dist/{indexes-view-C459lTHp.js → indexes-view-BkRtR8bd.js} +97 -126
- package/dist/indexes-view-BkRtR8bd.js.map +1 -0
- package/dist/indexes.cjs +1 -1
- package/dist/indexes.js +1 -1
- package/dist/{policies-view-CQP9A-ag.cjs → policies-view-DJTfKoYr.cjs} +192 -175
- package/dist/policies-view-DJTfKoYr.cjs.map +1 -0
- package/dist/{policies-view-A-FmHKS3.js → policies-view-OPigTnq3.js} +195 -178
- package/dist/policies-view-OPigTnq3.js.map +1 -0
- package/dist/policies.cjs +3 -3
- package/dist/policies.js +3 -3
- package/dist/{policy-config-form-BdbAHY7a.cjs → policy-config-form-CvHIN2iR.cjs} +5 -5
- package/dist/{policy-config-form-BdbAHY7a.cjs.map → policy-config-form-CvHIN2iR.cjs.map} +1 -1
- package/dist/{policy-config-form-Bx7TWk3Q.js → policy-config-form-PuVpbmcl.js} +5 -5
- package/dist/{policy-config-form-Bx7TWk3Q.js.map → policy-config-form-PuVpbmcl.js.map} +1 -1
- package/dist/{relationships-view-BQc_AHUo.cjs → relationships-view-CtPwFiIi.cjs} +210 -267
- package/dist/relationships-view-CtPwFiIi.cjs.map +1 -0
- package/dist/{relationships-view-QhPgBPiK.js → relationships-view-Db7zZAyz.js} +211 -268
- package/dist/relationships-view-Db7zZAyz.js.map +1 -0
- package/dist/relationships.cjs +1 -1
- package/dist/relationships.js +1 -1
- package/dist/{schema-builder-sidebar-Dv99hNGo.cjs → schema-builder-sidebar-BwpMkqyr.cjs} +135 -94
- package/dist/schema-builder-sidebar-BwpMkqyr.cjs.map +1 -0
- package/dist/{schema-builder-sidebar-CRwUC03L.js → schema-builder-sidebar-C3MMtjfg.js} +136 -95
- package/dist/schema-builder-sidebar-C3MMtjfg.js.map +1 -0
- package/dist/{table-editor-tS9seYfW.cjs → table-editor-CruD2mZQ.cjs} +414 -477
- package/dist/table-editor-CruD2mZQ.cjs.map +1 -0
- package/dist/{table-editor-5bkA0pji.js → table-editor-D80Qu4QF.js} +415 -478
- package/dist/table-editor-D80Qu4QF.js.map +1 -0
- package/dist/tables.cjs +1 -1
- package/dist/tables.d.cts +3 -1
- package/dist/tables.d.ts +3 -1
- package/dist/tables.js +1 -1
- package/package.json +8 -8
- package/dist/empty-state-card-5t7LygTB.cjs.map +0 -1
- package/dist/empty-state-card-C-Nylatg.js.map +0 -1
- package/dist/indexes-view-C459lTHp.js.map +0 -1
- package/dist/indexes-view-CVZLjX89.cjs.map +0 -1
- package/dist/policies-view-A-FmHKS3.js.map +0 -1
- package/dist/policies-view-CQP9A-ag.cjs.map +0 -1
- package/dist/relationships-view-BQc_AHUo.cjs.map +0 -1
- package/dist/relationships-view-QhPgBPiK.js.map +0 -1
- package/dist/schema-builder-sidebar-CRwUC03L.js.map +0 -1
- package/dist/schema-builder-sidebar-Dv99hNGo.cjs.map +0 -1
- package/dist/table-editor-5bkA0pji.js.map +0 -1
- package/dist/table-editor-tS9seYfW.cjs.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
const require_query = require('./query-BGtzUV7Y.cjs');
|
|
3
3
|
const require_invalidate_database_entities = require('./invalidate-database-entities-Gs5k8A-M.cjs');
|
|
4
|
-
const require_policy_config_form = require('./policy-config-form-
|
|
4
|
+
const require_policy_config_form = require('./policy-config-form-CvHIN2iR.cjs');
|
|
5
5
|
const require_keyboard_activation = require('./keyboard-activation-D-L0IU6Y.cjs');
|
|
6
|
-
const require_empty_state_card = require('./empty-state-card-
|
|
6
|
+
const require_empty_state_card = require('./empty-state-card-CV7DnIsA.cjs');
|
|
7
7
|
const require_delete_confirm_dialog = require('./delete-confirm-dialog-Ch4tWj6B.cjs');
|
|
8
|
+
const require_editor_view = require('./editor-view-CKrOtZX_.cjs');
|
|
8
9
|
let _constructive_io_ui_stack = require("@constructive-io/ui/stack");
|
|
9
10
|
let react = require("react");
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -14,8 +15,8 @@ let _constructive_io_ui_button = require("@constructive-io/ui/button");
|
|
|
14
15
|
let _constructive_io_ui_toast = require("@constructive-io/ui/toast");
|
|
15
16
|
let _constructive_io_ui_combobox = require("@constructive-io/ui/combobox");
|
|
16
17
|
let _constructive_io_ui_input = require("@constructive-io/ui/input");
|
|
17
|
-
let _constructive_io_ui_label = require("@constructive-io/ui/label");
|
|
18
18
|
let _constructive_io_ui_scroll_area = require("@constructive-io/ui/scroll-area");
|
|
19
|
+
let _constructive_io_ui_label = require("@constructive-io/ui/label");
|
|
19
20
|
let _constructive_io_ui_responsive_diagram = require("@constructive-io/ui/responsive-diagram");
|
|
20
21
|
let node_type_registry = require("node-type-registry");
|
|
21
22
|
let _constructive_io_ui_select = require("@constructive-io/ui/select");
|
|
@@ -1075,7 +1076,7 @@ function RelationshipTypeSelector({ value, onChange, disabled }) {
|
|
|
1075
1076
|
onClick: () => onChange(option.type),
|
|
1076
1077
|
disabled,
|
|
1077
1078
|
className: require_invalidate_database_entities.cn(`border-border relative flex min-h-10 items-center gap-2 rounded-lg border px-3 py-2.5 text-left
|
|
1078
|
-
transition-[background-color,border-color,box-shadow,scale] duration-
|
|
1079
|
+
transition-[background-color,border-color,box-shadow,scale] duration-(--duration-moderate) ease-out motion-safe:active:scale-[0.96]`, !isSelected && "disabled:pointer-events-none disabled:opacity-70", isSelected && "disabled:pointer-events-none", isSelected ? [option.colors.selectedBorder, option.colors.selectedBg] : "hover:border-border/80 hover:bg-muted/30"),
|
|
1079
1080
|
children: [
|
|
1080
1081
|
isSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1081
1082
|
className: "absolute top-2 right-2",
|
|
@@ -1559,7 +1560,7 @@ const RelationshipCard = ({ editingRelationship, sourceTable: directSourceTable,
|
|
|
1559
1560
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1560
1561
|
type: "button",
|
|
1561
1562
|
onClick: () => setShowAdvanced(!showAdvanced),
|
|
1562
|
-
className: "flex min-h-10 w-full items-center gap-2 rounded-lg px-4 py-3 text-left text-sm font-medium\n transition-[
|
|
1563
|
+
className: "flex min-h-10 w-full items-center gap-2 rounded-lg px-4 py-3 text-left text-sm font-medium\n transition-[scale] duration-(--duration-moderate) ease-out hover:bg-muted/40 motion-safe:active:scale-[0.96]",
|
|
1563
1564
|
"aria-expanded": showAdvanced,
|
|
1564
1565
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: require_invalidate_database_entities.cn("text-muted-foreground h-4 w-4 transition-transform", showAdvanced && "rotate-90") }), "Advanced"]
|
|
1565
1566
|
}), showAdvanced && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1850,38 +1851,31 @@ function getTableRelationships(currentTable, tables, provisions = []) {
|
|
|
1850
1851
|
//#region src/schema/schema-builder-relationships/components/table-editor/relationships/relationships-view.tsx
|
|
1851
1852
|
const RELATIONSHIP_STYLES = {
|
|
1852
1853
|
"one-to-one": {
|
|
1853
|
-
|
|
1854
|
-
border: "border-purple-500/30",
|
|
1854
|
+
badge: "bg-purple-500/10 text-purple-700 dark:text-purple-300",
|
|
1855
1855
|
text: "text-purple-600 dark:text-purple-400",
|
|
1856
|
-
label: "One to
|
|
1857
|
-
shortLabel: "1:1"
|
|
1856
|
+
label: "One to one"
|
|
1858
1857
|
},
|
|
1859
1858
|
"belongs-to": {
|
|
1860
|
-
|
|
1861
|
-
border: "border-green-500/30",
|
|
1859
|
+
badge: "bg-green-500/10 text-green-700 dark:text-green-300",
|
|
1862
1860
|
text: "text-green-600 dark:text-green-400",
|
|
1863
|
-
label: "Belongs
|
|
1864
|
-
shortLabel: "BT"
|
|
1861
|
+
label: "Belongs to"
|
|
1865
1862
|
},
|
|
1866
1863
|
"one-to-many": {
|
|
1867
|
-
|
|
1868
|
-
border: "border-blue-500/30",
|
|
1864
|
+
badge: "bg-blue-500/10 text-blue-700 dark:text-blue-300",
|
|
1869
1865
|
text: "text-blue-600 dark:text-blue-400",
|
|
1870
|
-
label: "One to
|
|
1871
|
-
shortLabel: "1:N"
|
|
1866
|
+
label: "One to many"
|
|
1872
1867
|
},
|
|
1873
1868
|
"many-to-many": {
|
|
1874
|
-
|
|
1875
|
-
border: "border-amber-500/30",
|
|
1869
|
+
badge: "bg-amber-500/10 text-amber-700 dark:text-amber-300",
|
|
1876
1870
|
text: "text-amber-600 dark:text-amber-400",
|
|
1877
|
-
label: "Many to
|
|
1878
|
-
shortLabel: "N:M"
|
|
1871
|
+
label: "Many to many"
|
|
1879
1872
|
}
|
|
1880
1873
|
};
|
|
1881
1874
|
function MiniConnector({ type }) {
|
|
1882
1875
|
if (type === "one-to-one") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1883
|
-
|
|
1884
|
-
|
|
1876
|
+
"aria-hidden": "true",
|
|
1877
|
+
width: "28",
|
|
1878
|
+
height: "14",
|
|
1885
1879
|
viewBox: "0 0 32 16",
|
|
1886
1880
|
fill: "none",
|
|
1887
1881
|
className: "shrink-0",
|
|
@@ -1916,8 +1910,9 @@ function MiniConnector({ type }) {
|
|
|
1916
1910
|
]
|
|
1917
1911
|
});
|
|
1918
1912
|
if (type === "belongs-to") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1919
|
-
|
|
1920
|
-
|
|
1913
|
+
"aria-hidden": "true",
|
|
1914
|
+
width: "28",
|
|
1915
|
+
height: "14",
|
|
1921
1916
|
viewBox: "0 0 32 16",
|
|
1922
1917
|
fill: "none",
|
|
1923
1918
|
className: "shrink-0",
|
|
@@ -1967,8 +1962,9 @@ function MiniConnector({ type }) {
|
|
|
1967
1962
|
]
|
|
1968
1963
|
});
|
|
1969
1964
|
if (type === "one-to-many") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1970
|
-
|
|
1971
|
-
|
|
1965
|
+
"aria-hidden": "true",
|
|
1966
|
+
width: "28",
|
|
1967
|
+
height: "14",
|
|
1972
1968
|
viewBox: "0 0 32 16",
|
|
1973
1969
|
fill: "none",
|
|
1974
1970
|
className: "shrink-0",
|
|
@@ -2018,8 +2014,9 @@ function MiniConnector({ type }) {
|
|
|
2018
2014
|
]
|
|
2019
2015
|
});
|
|
2020
2016
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
2021
|
-
|
|
2022
|
-
|
|
2017
|
+
"aria-hidden": "true",
|
|
2018
|
+
width: "28",
|
|
2019
|
+
height: "14",
|
|
2023
2020
|
viewBox: "0 0 32 16",
|
|
2024
2021
|
fill: "none",
|
|
2025
2022
|
className: "shrink-0",
|
|
@@ -2071,25 +2068,6 @@ function MiniConnector({ type }) {
|
|
|
2071
2068
|
]
|
|
2072
2069
|
});
|
|
2073
2070
|
}
|
|
2074
|
-
function NoTableSelectedState() {
|
|
2075
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2076
|
-
className: "flex min-h-0 flex-1 flex-col items-center justify-center p-6",
|
|
2077
|
-
children: [
|
|
2078
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2079
|
-
className: "bg-muted/50 mb-4 flex h-16 w-16 items-center justify-center rounded-full",
|
|
2080
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Table2, { className: "text-muted-foreground h-8 w-8" })
|
|
2081
|
-
}),
|
|
2082
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2083
|
-
className: "mb-1 text-balance text-lg font-semibold",
|
|
2084
|
-
children: "No table selected"
|
|
2085
|
-
}),
|
|
2086
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2087
|
-
className: "text-muted-foreground max-w-sm text-center text-sm",
|
|
2088
|
-
children: "Select a table from the sidebar to view and manage its relationships."
|
|
2089
|
-
})
|
|
2090
|
-
]
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
2071
|
function RelationshipsView() {
|
|
2094
2072
|
const [deleteTarget, setDeleteTarget] = (0, react.useState)(null);
|
|
2095
2073
|
const [isDeleting, setIsDeleting] = (0, react.useState)(false);
|
|
@@ -2180,227 +2158,43 @@ function RelationshipsView() {
|
|
|
2180
2158
|
setIsDeleting(false);
|
|
2181
2159
|
}
|
|
2182
2160
|
};
|
|
2183
|
-
if (!currentTable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NoTableSelectedState, {
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
let junctionTargetFieldName;
|
|
2189
|
-
let targetPkFieldName;
|
|
2190
|
-
if (isM2M && rel.targetTable) {
|
|
2191
|
-
const junction = rel.targetTable;
|
|
2192
|
-
const actualTarget = tables.find((t) => t.name === rel.withTableName);
|
|
2193
|
-
if (actualTarget) {
|
|
2194
|
-
const junctionFk = (junction.constraints || []).find((c) => c.type === "foreign_key" && c.referencedTable === actualTarget.id);
|
|
2195
|
-
if (junctionFk) {
|
|
2196
|
-
junctionTargetFieldName = junction.fields.find((f) => f.id === junctionFk.fields[0])?.name;
|
|
2197
|
-
targetPkFieldName = actualTarget.fields.find((f) => f.id === junctionFk.referencedFields?.[0])?.name;
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2202
|
-
role: "button",
|
|
2203
|
-
tabIndex: 0,
|
|
2204
|
-
"data-testid": "relationship-row",
|
|
2205
|
-
onClick: () => handleOpenEdit(rel),
|
|
2206
|
-
onKeyDown: (event) => {
|
|
2207
|
-
require_keyboard_activation.handleActivationKeyDown(event, () => handleOpenEdit(rel));
|
|
2208
|
-
},
|
|
2209
|
-
className: require_invalidate_database_entities.cn(`group relative cursor-pointer rounded-xl border p-4 transition-[background-color,border-color,box-shadow,scale]
|
|
2210
|
-
duration-150 ease-out motion-safe:active:scale-[0.96]`, "border-border/60 hover:border-border/80 hover:bg-muted/30"),
|
|
2211
|
-
children: [
|
|
2212
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2213
|
-
className: "flex items-center justify-between gap-2",
|
|
2214
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2215
|
-
className: "flex min-w-0 flex-wrap items-center gap-2",
|
|
2216
|
-
children: [
|
|
2217
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Link2, { className: "text-muted-foreground h-4 w-4 shrink-0" }),
|
|
2218
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2219
|
-
className: "truncate text-sm font-semibold",
|
|
2220
|
-
children: rel.constraint.name
|
|
2221
|
-
}),
|
|
2222
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2223
|
-
className: require_invalidate_database_entities.cn("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide uppercase", style.bg, style.text, "border", style.border),
|
|
2224
|
-
children: style.label
|
|
2225
|
-
})
|
|
2226
|
-
]
|
|
2227
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_button.Button, {
|
|
2228
|
-
variant: "ghost",
|
|
2229
|
-
size: "sm",
|
|
2230
|
-
"aria-label": "Delete relationship",
|
|
2231
|
-
className: "text-muted-foreground hover:text-destructive hover:bg-destructive/10 h-8 w-8 shrink-0 p-0",
|
|
2232
|
-
onClick: (e) => {
|
|
2233
|
-
e.stopPropagation();
|
|
2234
|
-
handleDeleteRequest(rel.constraint.id, rel.constraint.name || "this relationship");
|
|
2235
|
-
},
|
|
2236
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { className: "h-4 w-4" })
|
|
2237
|
-
})]
|
|
2238
|
-
}),
|
|
2239
|
-
isM2M ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2240
|
-
className: "mt-3 space-y-2",
|
|
2241
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2242
|
-
className: "flex items-center gap-2",
|
|
2243
|
-
children: [
|
|
2244
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2245
|
-
className: "bg-background truncate rounded-md border px-3 py-1.5 font-mono text-sm",
|
|
2246
|
-
children: [
|
|
2247
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2248
|
-
className: "text-foreground",
|
|
2249
|
-
children: rel.sourceTable?.name || "?"
|
|
2250
|
-
}),
|
|
2251
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2252
|
-
className: "text-muted-foreground",
|
|
2253
|
-
children: "."
|
|
2254
|
-
}),
|
|
2255
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2256
|
-
className: style.text,
|
|
2257
|
-
children: rel.sourceFieldName || "?"
|
|
2258
|
-
})
|
|
2259
|
-
]
|
|
2260
|
-
}),
|
|
2261
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2262
|
-
className: style.text,
|
|
2263
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniConnector, { type: "many-to-many" })
|
|
2264
|
-
}),
|
|
2265
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2266
|
-
className: "bg-muted/50 truncate rounded-md border border-dashed px-3 py-1.5 font-mono text-sm",
|
|
2267
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2268
|
-
className: "text-muted-foreground",
|
|
2269
|
-
children: rel.targetTable?.name || "?"
|
|
2270
|
-
})
|
|
2271
|
-
}),
|
|
2272
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2273
|
-
className: style.text,
|
|
2274
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniConnector, { type: "many-to-many" })
|
|
2275
|
-
}),
|
|
2276
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2277
|
-
className: "bg-background truncate rounded-md border px-3 py-1.5 font-mono text-sm",
|
|
2278
|
-
children: [
|
|
2279
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2280
|
-
className: "text-foreground",
|
|
2281
|
-
children: rel.withTableName
|
|
2282
|
-
}),
|
|
2283
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2284
|
-
className: "text-muted-foreground",
|
|
2285
|
-
children: "."
|
|
2286
|
-
}),
|
|
2287
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2288
|
-
className: style.text,
|
|
2289
|
-
children: targetPkFieldName || "id"
|
|
2290
|
-
})
|
|
2291
|
-
]
|
|
2292
|
-
})
|
|
2293
|
-
]
|
|
2294
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2295
|
-
className: "text-muted-foreground flex items-center gap-1.5 pl-1 font-mono text-[10px]",
|
|
2296
|
-
children: [
|
|
2297
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "via" }),
|
|
2298
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2299
|
-
className: "bg-muted rounded px-1.5 py-0.5",
|
|
2300
|
-
children: rel.targetFieldName || "?"
|
|
2301
|
-
}),
|
|
2302
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "&" }),
|
|
2303
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2304
|
-
className: "bg-muted rounded px-1.5 py-0.5",
|
|
2305
|
-
children: junctionTargetFieldName || "?"
|
|
2306
|
-
})
|
|
2307
|
-
]
|
|
2308
|
-
})]
|
|
2309
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2310
|
-
className: "mt-3 flex items-center gap-3",
|
|
2311
|
-
children: [
|
|
2312
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2313
|
-
className: "bg-background truncate rounded-md border px-3 py-1.5 font-mono text-sm",
|
|
2314
|
-
children: [
|
|
2315
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2316
|
-
className: "text-foreground",
|
|
2317
|
-
children: rel.sourceTable?.name || "?"
|
|
2318
|
-
}),
|
|
2319
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2320
|
-
className: "text-muted-foreground",
|
|
2321
|
-
children: "."
|
|
2322
|
-
}),
|
|
2323
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2324
|
-
className: style.text,
|
|
2325
|
-
children: rel.sourceFieldName || "?"
|
|
2326
|
-
})
|
|
2327
|
-
]
|
|
2328
|
-
}),
|
|
2329
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2330
|
-
className: style.text,
|
|
2331
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniConnector, { type: rel.relationshipType })
|
|
2332
|
-
}),
|
|
2333
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2334
|
-
className: "bg-background truncate rounded-md border px-3 py-1.5 font-mono text-sm",
|
|
2335
|
-
children: [
|
|
2336
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2337
|
-
className: "text-foreground",
|
|
2338
|
-
children: rel.targetTable?.name || "?"
|
|
2339
|
-
}),
|
|
2340
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2341
|
-
className: "text-muted-foreground",
|
|
2342
|
-
children: "."
|
|
2343
|
-
}),
|
|
2344
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2345
|
-
className: style.text,
|
|
2346
|
-
children: rel.targetFieldName || "?"
|
|
2347
|
-
})
|
|
2348
|
-
]
|
|
2349
|
-
})
|
|
2350
|
-
]
|
|
2351
|
-
}),
|
|
2352
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2353
|
-
className: "mt-3 flex items-center justify-between gap-4 border-t pt-3",
|
|
2354
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2355
|
-
className: "text-muted-foreground flex items-center gap-1.5 text-xs",
|
|
2356
|
-
children: [
|
|
2357
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CornerDownRight, { className: "h-3 w-3" }),
|
|
2358
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "On Delete:" }),
|
|
2359
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2360
|
-
className: "text-foreground/70 font-medium",
|
|
2361
|
-
children: require_invalidate_database_entities.ForeignKeyActionLabels[rel.constraint.onDelete ?? require_invalidate_database_entities.ForeignKeyActions.NO_ACTION]
|
|
2362
|
-
})
|
|
2363
|
-
]
|
|
2364
|
-
})
|
|
2365
|
-
})
|
|
2366
|
-
]
|
|
2367
|
-
}, rel.constraint.id);
|
|
2368
|
-
}
|
|
2369
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2370
|
-
"data-chat-component": "relationships-view",
|
|
2371
|
-
"data-chat-relationship-count": String(relationships.length),
|
|
2161
|
+
if (!currentTable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_view.NoTableSelectedState, {
|
|
2162
|
+
icon: lucide_react.Link2,
|
|
2163
|
+
subject: "relationships"
|
|
2164
|
+
});
|
|
2165
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [!(relationships.length > 0) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2372
2166
|
className: "flex min-h-0 flex-1 flex-col overflow-auto p-6",
|
|
2373
|
-
children:
|
|
2167
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RelationshipEmptyState, {
|
|
2374
2168
|
onCreateClick: handleOpenCreate,
|
|
2375
2169
|
tableName: currentTable.name
|
|
2376
|
-
})
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
})
|
|
2170
|
+
})
|
|
2171
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_view.EditorView, {
|
|
2172
|
+
actions: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_button.Button, {
|
|
2173
|
+
onClick: handleOpenCreate,
|
|
2174
|
+
size: "sm",
|
|
2175
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Link2, {
|
|
2176
|
+
"aria-hidden": "true",
|
|
2177
|
+
"data-icon": "inline-start"
|
|
2178
|
+
}), "Add relationship"]
|
|
2179
|
+
}),
|
|
2180
|
+
"data-chat-component": "relationships-view",
|
|
2181
|
+
"data-chat-relationship-count": String(relationships.length),
|
|
2182
|
+
description: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2183
|
+
relationships.length,
|
|
2184
|
+
" connection",
|
|
2185
|
+
relationships.length !== 1 ? "s" : "",
|
|
2186
|
+
" for ",
|
|
2187
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_view.InlineCode, { children: currentTable.name })
|
|
2188
|
+
] }),
|
|
2189
|
+
title: "Relationships",
|
|
2190
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2191
|
+
className: "flex flex-col gap-2",
|
|
2192
|
+
children: relationships.map((rel) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RelationshipRow, {
|
|
2193
|
+
onDelete: () => handleDeleteRequest(rel.constraint.id, rel.constraint.name || "this relationship"),
|
|
2194
|
+
onOpen: () => handleOpenEdit(rel),
|
|
2195
|
+
relationship: rel,
|
|
2196
|
+
tables
|
|
2197
|
+
}, rel.constraint.id))
|
|
2404
2198
|
})
|
|
2405
2199
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_delete_confirm_dialog.DeleteConfirmDialog, {
|
|
2406
2200
|
entityType: "Relationship",
|
|
@@ -2411,6 +2205,155 @@ function RelationshipsView() {
|
|
|
2411
2205
|
isPending: isDeleting
|
|
2412
2206
|
})] });
|
|
2413
2207
|
}
|
|
2208
|
+
/** Which end of a connection a chip is: the hovered one, a lit counterpart, or at rest. */
|
|
2209
|
+
function chipState(hovered, end) {
|
|
2210
|
+
if (hovered === null) return "idle";
|
|
2211
|
+
return hovered === end ? "source" : "linked";
|
|
2212
|
+
}
|
|
2213
|
+
function TableChip({ table, field, fieldClass, end, hovered, onHover, muted = false }) {
|
|
2214
|
+
const state = chipState(hovered, end);
|
|
2215
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2216
|
+
className: require_invalidate_database_entities.cn(require_editor_view.linkedChipClass(state), muted && state === "idle" && "bg-transparent ring-0 outline-1 -outline-offset-1 outline-dashed outline-foreground/20"),
|
|
2217
|
+
onPointerEnter: () => onHover(end),
|
|
2218
|
+
onPointerLeave: () => onHover(null),
|
|
2219
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2220
|
+
className: require_invalidate_database_entities.cn("truncate", state === "linked" ? "text-primary" : muted ? "text-muted-foreground" : "text-foreground"),
|
|
2221
|
+
children: table
|
|
2222
|
+
}), field ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2223
|
+
className: "text-muted-foreground",
|
|
2224
|
+
children: "."
|
|
2225
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2226
|
+
className: require_invalidate_database_entities.cn("truncate", fieldClass),
|
|
2227
|
+
children: field
|
|
2228
|
+
})] }) : null]
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* One foreign key as a card: its name and type, the joined ends as chips,
|
|
2233
|
+
* and the delete rule. Pointing at one end lights the other end (and the
|
|
2234
|
+
* connector) in the Constructive blue, so the pair reads at a glance.
|
|
2235
|
+
*/
|
|
2236
|
+
function RelationshipRow({ relationship: rel, tables, onOpen, onDelete: onDeleteRequest }) {
|
|
2237
|
+
const [hovered, setHovered] = (0, react.useState)(null);
|
|
2238
|
+
const style = RELATIONSHIP_STYLES[rel.relationshipType];
|
|
2239
|
+
const isM2M = Boolean(rel.withTableName);
|
|
2240
|
+
const connectorClass = require_invalidate_database_entities.cn("shrink-0", hovered ? "text-primary" : style.text);
|
|
2241
|
+
const onDelete = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: ["On delete ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2242
|
+
className: "text-foreground/80",
|
|
2243
|
+
children: require_invalidate_database_entities.ForeignKeyActionLabels[rel.constraint.onDelete ?? require_invalidate_database_entities.ForeignKeyActions.NO_ACTION]
|
|
2244
|
+
})] });
|
|
2245
|
+
let junctionTargetFieldName;
|
|
2246
|
+
let targetPkFieldName;
|
|
2247
|
+
if (isM2M && rel.targetTable) {
|
|
2248
|
+
const junction = rel.targetTable;
|
|
2249
|
+
const actualTarget = tables.find((t) => t.name === rel.withTableName);
|
|
2250
|
+
const junctionFk = actualTarget ? (junction.constraints || []).find((c) => c.type === "foreign_key" && c.referencedTable === actualTarget.id) : void 0;
|
|
2251
|
+
if (actualTarget && junctionFk) {
|
|
2252
|
+
junctionTargetFieldName = junction.fields.find((f) => f.id === junctionFk.fields[0])?.name;
|
|
2253
|
+
targetPkFieldName = actualTarget.fields.find((f) => f.id === junctionFk.referencedFields?.[0])?.name;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2257
|
+
className: require_editor_view.editorCardClass,
|
|
2258
|
+
"data-testid": "relationship-row",
|
|
2259
|
+
onClick: onOpen,
|
|
2260
|
+
onKeyDown: (event) => require_keyboard_activation.handleActivationKeyDown(event, onOpen),
|
|
2261
|
+
role: "button",
|
|
2262
|
+
tabIndex: 0,
|
|
2263
|
+
children: [
|
|
2264
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2265
|
+
className: "flex items-center gap-2",
|
|
2266
|
+
children: [
|
|
2267
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Link2, {
|
|
2268
|
+
"aria-hidden": "true",
|
|
2269
|
+
className: "text-muted-foreground size-3.5 shrink-0"
|
|
2270
|
+
}),
|
|
2271
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2272
|
+
className: "text-foreground min-w-0 truncate text-[13px] font-medium",
|
|
2273
|
+
children: rel.constraint.name
|
|
2274
|
+
}),
|
|
2275
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_view.KindBadge, {
|
|
2276
|
+
className: style.badge,
|
|
2277
|
+
children: style.label
|
|
2278
|
+
}),
|
|
2279
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2280
|
+
className: "text-muted-foreground ml-auto hidden shrink-0 text-xs sm:inline",
|
|
2281
|
+
children: onDelete
|
|
2282
|
+
}),
|
|
2283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_view.CardDeleteButton, {
|
|
2284
|
+
label: "Delete relationship",
|
|
2285
|
+
onDelete: onDeleteRequest
|
|
2286
|
+
})
|
|
2287
|
+
]
|
|
2288
|
+
}),
|
|
2289
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2290
|
+
className: "mt-2.5 flex min-w-0 flex-wrap items-center gap-1.5",
|
|
2291
|
+
children: [
|
|
2292
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableChip, {
|
|
2293
|
+
end: "source",
|
|
2294
|
+
field: rel.sourceFieldName || "?",
|
|
2295
|
+
fieldClass: style.text,
|
|
2296
|
+
hovered,
|
|
2297
|
+
onHover: setHovered,
|
|
2298
|
+
table: rel.sourceTable?.name || "?"
|
|
2299
|
+
}),
|
|
2300
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2301
|
+
className: connectorClass,
|
|
2302
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniConnector, { type: isM2M ? "many-to-many" : rel.relationshipType })
|
|
2303
|
+
}),
|
|
2304
|
+
isM2M ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2305
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableChip, {
|
|
2306
|
+
end: "junction",
|
|
2307
|
+
fieldClass: style.text,
|
|
2308
|
+
hovered,
|
|
2309
|
+
muted: true,
|
|
2310
|
+
onHover: setHovered,
|
|
2311
|
+
table: rel.targetTable?.name || "?"
|
|
2312
|
+
}),
|
|
2313
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2314
|
+
className: connectorClass,
|
|
2315
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniConnector, { type: "many-to-many" })
|
|
2316
|
+
}),
|
|
2317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableChip, {
|
|
2318
|
+
end: "target",
|
|
2319
|
+
field: targetPkFieldName || "id",
|
|
2320
|
+
fieldClass: style.text,
|
|
2321
|
+
hovered,
|
|
2322
|
+
onHover: setHovered,
|
|
2323
|
+
table: rel.withTableName ?? "?"
|
|
2324
|
+
})
|
|
2325
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableChip, {
|
|
2326
|
+
end: "target",
|
|
2327
|
+
field: rel.targetFieldName || "?",
|
|
2328
|
+
fieldClass: style.text,
|
|
2329
|
+
hovered,
|
|
2330
|
+
onHover: setHovered,
|
|
2331
|
+
table: rel.targetTable?.name || "?"
|
|
2332
|
+
})
|
|
2333
|
+
]
|
|
2334
|
+
}),
|
|
2335
|
+
isM2M ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2336
|
+
className: "text-muted-foreground mt-2 flex items-center gap-1 text-[11px]",
|
|
2337
|
+
children: [
|
|
2338
|
+
"via",
|
|
2339
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2340
|
+
className: "bg-muted/70 rounded px-1 font-mono",
|
|
2341
|
+
children: rel.targetFieldName || "?"
|
|
2342
|
+
}),
|
|
2343
|
+
"and",
|
|
2344
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2345
|
+
className: "bg-muted/70 rounded px-1 font-mono",
|
|
2346
|
+
children: junctionTargetFieldName || "?"
|
|
2347
|
+
})
|
|
2348
|
+
]
|
|
2349
|
+
}) : null,
|
|
2350
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2351
|
+
className: "text-muted-foreground mt-2 text-xs sm:hidden",
|
|
2352
|
+
children: onDelete
|
|
2353
|
+
})
|
|
2354
|
+
]
|
|
2355
|
+
}) });
|
|
2356
|
+
}
|
|
2414
2357
|
|
|
2415
2358
|
//#endregion
|
|
2416
2359
|
Object.defineProperty(exports, 'RelationshipsView', {
|
|
@@ -2449,4 +2392,4 @@ Object.defineProperty(exports, 'useUpdateForeignKey', {
|
|
|
2449
2392
|
return useUpdateForeignKey;
|
|
2450
2393
|
}
|
|
2451
2394
|
});
|
|
2452
|
-
//# sourceMappingURL=relationships-view-
|
|
2395
|
+
//# sourceMappingURL=relationships-view-CtPwFiIi.cjs.map
|