@constructive-io/schema-builder 0.2.1 → 0.4.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +12 -4
  3. package/dist/{core-WwCS0CKu.cjs → core-CVxnNLs7.cjs} +2 -2
  4. package/dist/{core-WwCS0CKu.cjs.map → core-CVxnNLs7.cjs.map} +1 -1
  5. package/dist/{core-kx6KjxE5.js → core-DJ5kA4r-.js} +2 -2
  6. package/dist/{core-kx6KjxE5.js.map → core-DJ5kA4r-.js.map} +1 -1
  7. package/dist/core.cjs +2 -2
  8. package/dist/core.d.cts +2 -2
  9. package/dist/core.d.ts +2 -2
  10. package/dist/core.js +2 -2
  11. package/dist/{create-table-card-pZ0Aq6rr.js → create-table-card-B6SMrt_g.js} +13 -7
  12. package/dist/{create-table-card-pZ0Aq6rr.js.map → create-table-card-B6SMrt_g.js.map} +1 -1
  13. package/dist/{create-table-card-BzNKfpXO.cjs → create-table-card-BrQ7pB_U.cjs} +13 -7
  14. package/dist/{create-table-card-BzNKfpXO.cjs.map → create-table-card-BrQ7pB_U.cjs.map} +1 -1
  15. package/dist/{empty-state-card-DMn8ADRq.cjs → empty-state-card-5t7LygTB.cjs} +2 -2
  16. package/dist/{empty-state-card-DMn8ADRq.cjs.map → empty-state-card-5t7LygTB.cjs.map} +1 -1
  17. package/dist/{empty-state-card-Dnn36JVH.js → empty-state-card-C-Nylatg.js} +2 -2
  18. package/dist/{empty-state-card-Dnn36JVH.js.map → empty-state-card-C-Nylatg.js.map} +1 -1
  19. package/dist/fields.cjs +1 -1
  20. package/dist/fields.d.cts +1 -2
  21. package/dist/fields.d.ts +1 -2
  22. package/dist/fields.js +1 -1
  23. package/dist/{index-p_NegPQ5.d.ts → index--9KTz1LB.d.cts} +3 -3
  24. package/dist/index-10idAfdb.d.cts +7 -0
  25. package/dist/index-BcdFaKFS.d.ts +7 -0
  26. package/dist/{index-9h0EROdb.d.cts → index-euaSKMQK.d.ts} +3 -3
  27. package/dist/index.cjs +79 -441
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +4 -4
  30. package/dist/index.d.ts +4 -4
  31. package/dist/index.js +79 -441
  32. package/dist/index.js.map +1 -1
  33. package/dist/{indexes-view-CJ1WQKdp.js → indexes-view-CBzYpKcd.js} +3 -3
  34. package/dist/{indexes-view-CJ1WQKdp.js.map → indexes-view-CBzYpKcd.js.map} +1 -1
  35. package/dist/{indexes-view-peIv6QUZ.cjs → indexes-view-D1K24ts1.cjs} +3 -3
  36. package/dist/{indexes-view-peIv6QUZ.cjs.map → indexes-view-D1K24ts1.cjs.map} +1 -1
  37. package/dist/indexes.cjs +1 -1
  38. package/dist/indexes.d.cts +1 -1
  39. package/dist/indexes.d.ts +1 -1
  40. package/dist/indexes.js +1 -1
  41. package/dist/{invalidate-database-entities-CmmOT3S0.js → invalidate-database-entities-BFCWf5Zf.js} +10 -8
  42. package/dist/{invalidate-database-entities-CmmOT3S0.js.map → invalidate-database-entities-BFCWf5Zf.js.map} +1 -1
  43. package/dist/{invalidate-database-entities-9DsT5NlP.cjs → invalidate-database-entities-Gs5k8A-M.cjs} +9 -7
  44. package/dist/invalidate-database-entities-Gs5k8A-M.cjs.map +1 -0
  45. package/dist/{policies-view-H1HTjpmv.cjs → policies-view-CkvGpJBo.cjs} +5 -5
  46. package/dist/{policies-view-H1HTjpmv.cjs.map → policies-view-CkvGpJBo.cjs.map} +1 -1
  47. package/dist/{policies-view-BRbpbyB6.js → policies-view-DTfAhX7G.js} +5 -5
  48. package/dist/{policies-view-BRbpbyB6.js.map → policies-view-DTfAhX7G.js.map} +1 -1
  49. package/dist/policies.cjs +3 -3
  50. package/dist/policies.d.cts +3 -3
  51. package/dist/policies.d.ts +3 -3
  52. package/dist/policies.js +3 -3
  53. package/dist/{policy-config-form-BwyK7DGV.js → policy-config-form-EEcQ9ywL.js} +3 -3
  54. package/dist/{policy-config-form-BwyK7DGV.js.map → policy-config-form-EEcQ9ywL.js.map} +1 -1
  55. package/dist/{policy-config-form-CefFo6Fw.cjs → policy-config-form-RP9010zj.cjs} +3 -3
  56. package/dist/{policy-config-form-CefFo6Fw.cjs.map → policy-config-form-RP9010zj.cjs.map} +1 -1
  57. package/dist/{query-DU-KZleN.cjs → query-BGtzUV7Y.cjs} +41 -20
  58. package/dist/query-BGtzUV7Y.cjs.map +1 -0
  59. package/dist/{query-BmN_qO0W.js → query-r6j8IjQB.js} +41 -20
  60. package/dist/query-r6j8IjQB.js.map +1 -0
  61. package/dist/{relationships-view-DbwFh5r-.js → relationships-view-C884EvGj.js} +5 -5
  62. package/dist/{relationships-view-DbwFh5r-.js.map → relationships-view-C884EvGj.js.map} +1 -1
  63. package/dist/{relationships-view-B5TAcPHU.cjs → relationships-view-DlBs-gCF.cjs} +5 -5
  64. package/dist/{relationships-view-B5TAcPHU.cjs.map → relationships-view-DlBs-gCF.cjs.map} +1 -1
  65. package/dist/relationships.cjs +1 -1
  66. package/dist/relationships.d.cts +1 -2
  67. package/dist/relationships.d.ts +1 -2
  68. package/dist/relationships.js +1 -1
  69. package/dist/{schema-builder-sidebar-VR-Ctidc.js → schema-builder-sidebar-DAgK7ZTu.js} +77 -16
  70. package/dist/schema-builder-sidebar-DAgK7ZTu.js.map +1 -0
  71. package/dist/{schema-builder-sidebar-Ctu621Vw.cjs → schema-builder-sidebar-L3TcQeQr.cjs} +81 -14
  72. package/dist/schema-builder-sidebar-L3TcQeQr.cjs.map +1 -0
  73. package/dist/{table-editor-IVp3B4nG.js → table-editor-B-5i1M79.js} +9 -9
  74. package/dist/{table-editor-IVp3B4nG.js.map → table-editor-B-5i1M79.js.map} +1 -1
  75. package/dist/{table-editor-C-hHz3DJ.cjs → table-editor-BdLdVZfh.cjs} +9 -9
  76. package/dist/{table-editor-C-hHz3DJ.cjs.map → table-editor-BdLdVZfh.cjs.map} +1 -1
  77. package/dist/tables.cjs +2 -2
  78. package/dist/tables.d.cts +1 -1
  79. package/dist/tables.d.ts +1 -1
  80. package/dist/tables.js +2 -2
  81. package/dist/testing.d.cts +1 -1
  82. package/dist/testing.d.ts +1 -1
  83. package/dist/types-CXNRA22N.d.cts +450 -0
  84. package/dist/types-CXNRA22N.d.ts +450 -0
  85. package/dist/{use-update-table-Dz6knGoH.js → use-update-table-DlLX9fdE.js} +2 -2
  86. package/dist/{use-update-table-Dz6knGoH.js.map → use-update-table-DlLX9fdE.js.map} +1 -1
  87. package/dist/{use-update-table-C7v3gRyG.cjs → use-update-table-vcoHVolI.cjs} +2 -2
  88. package/dist/{use-update-table-C7v3gRyG.cjs.map → use-update-table-vcoHVolI.cjs.map} +1 -1
  89. package/package.json +5 -3
  90. package/dist/index-CwQ9QpxA.d.ts +0 -7
  91. package/dist/index-DOWB1UBK.d.cts +0 -56
  92. package/dist/index-DOWB1UBK.d.ts +0 -56
  93. package/dist/index-Dgb_e3AP.d.cts +0 -7
  94. package/dist/invalidate-database-entities-9DsT5NlP.cjs.map +0 -1
  95. package/dist/query-BmN_qO0W.js.map +0 -1
  96. package/dist/query-DU-KZleN.cjs.map +0 -1
  97. package/dist/schema-builder-sidebar-Ctu621Vw.cjs.map +0 -1
  98. package/dist/schema-builder-sidebar-VR-Ctidc.js.map +0 -1
  99. package/dist/types-GUrH1Qny.d.cts +0 -200
  100. package/dist/types-GUrH1Qny.d.ts +0 -200
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SchemaBuilderTablesCapabilities, C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, O as SchemaBuilderTable, S as SchemaBuilderRelationshipsCapabilities, T as SchemaBuilderSidebarSections, _ as SchemaBuilderPoliciesCapabilities, a as SchemaBuilderCoreCapabilities, b as SchemaBuilderProps, c as SchemaBuilderField, d as SchemaBuilderIndex, f as SchemaBuilderIndexesCapabilities, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, k as SchemaBuilderTableSelection, l as SchemaBuilderFieldsCapabilities, m as SchemaBuilderNavigationTarget, n as SchemaBuilderAdapter, o as SchemaBuilderCoreTabId, p as SchemaBuilderInvalidationEvent, r as SchemaBuilderCollection, s as SchemaBuilderFeature, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES, u as SchemaBuilderHostOptions, v as SchemaBuilderPolicy, w as SchemaBuilderScope, x as SchemaBuilderRelationship, y as SchemaBuilderPreferences } from "./types-GUrH1Qny.cjs";
2
- import { a as SchemaBuilderContextValue, c as useSchemaBuilder, d as createSchemaBuilderStore, f as getSchemaBuilderScopeKey, i as useSchemaBuilderQuery, l as useSchemaBuilderStore, n as useSchemaBuilderMutation, o as SchemaBuilderProvider, r as schemaBuilderQueryKey, s as SchemaBuilderProviderProps, t as SchemaBuilderMutationOptions, u as SchemaBuilderStoreState } from "./index-9h0EROdb.cjs";
3
- import { t as SchemaBuilder } from "./index-Dgb_e3AP.cjs";
4
- export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, SchemaBuilder, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderFieldsCapabilities, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderIndexesCapabilities, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPoliciesCapabilities, type SchemaBuilderPolicy, type SchemaBuilderPreferences, type SchemaBuilderProps, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderRelationshipsCapabilities, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderTableSelection, type SchemaBuilderTablesCapabilities, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
1
+ import { A as SchemaBuilderTablesCapabilities, C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, N as SchemaBuilderDataState, O as SchemaBuilderTable, S as SchemaBuilderRelationshipsCapabilities, T as SchemaBuilderSidebarSections, _ as SchemaBuilderPoliciesCapabilities, a as SchemaBuilderCoreCapabilities, b as SchemaBuilderProps, c as SchemaBuilderField, d as SchemaBuilderIndex, f as SchemaBuilderIndexesCapabilities, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, k as SchemaBuilderTableSelection, l as SchemaBuilderFieldsCapabilities, m as SchemaBuilderNavigationTarget, n as SchemaBuilderAdapter, o as SchemaBuilderCoreTabId, p as SchemaBuilderInvalidationEvent, r as SchemaBuilderCollection, s as SchemaBuilderFeature, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES, u as SchemaBuilderHostOptions, v as SchemaBuilderPolicy, w as SchemaBuilderScope, x as SchemaBuilderRelationship, y as SchemaBuilderPreferences } from "./types-CXNRA22N.cjs";
2
+ import { a as SchemaBuilderContextValue, c as useSchemaBuilder, d as createSchemaBuilderStore, f as getSchemaBuilderScopeKey, i as useSchemaBuilderQuery, l as useSchemaBuilderStore, n as useSchemaBuilderMutation, o as SchemaBuilderProvider, r as schemaBuilderQueryKey, s as SchemaBuilderProviderProps, t as SchemaBuilderMutationOptions, u as SchemaBuilderStoreState } from "./index--9KTz1LB.cjs";
3
+ import { t as SchemaBuilder } from "./index-10idAfdb.cjs";
4
+ export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, SchemaBuilder, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderDataState, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderFieldsCapabilities, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderIndexesCapabilities, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPoliciesCapabilities, type SchemaBuilderPolicy, type SchemaBuilderPreferences, type SchemaBuilderProps, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderRelationshipsCapabilities, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderTableSelection, type SchemaBuilderTablesCapabilities, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SchemaBuilderTablesCapabilities, C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, O as SchemaBuilderTable, S as SchemaBuilderRelationshipsCapabilities, T as SchemaBuilderSidebarSections, _ as SchemaBuilderPoliciesCapabilities, a as SchemaBuilderCoreCapabilities, b as SchemaBuilderProps, c as SchemaBuilderField, d as SchemaBuilderIndex, f as SchemaBuilderIndexesCapabilities, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, k as SchemaBuilderTableSelection, l as SchemaBuilderFieldsCapabilities, m as SchemaBuilderNavigationTarget, n as SchemaBuilderAdapter, o as SchemaBuilderCoreTabId, p as SchemaBuilderInvalidationEvent, r as SchemaBuilderCollection, s as SchemaBuilderFeature, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES, u as SchemaBuilderHostOptions, v as SchemaBuilderPolicy, w as SchemaBuilderScope, x as SchemaBuilderRelationship, y as SchemaBuilderPreferences } from "./types-GUrH1Qny.js";
2
- import { a as SchemaBuilderContextValue, c as useSchemaBuilder, d as createSchemaBuilderStore, f as getSchemaBuilderScopeKey, i as useSchemaBuilderQuery, l as useSchemaBuilderStore, n as useSchemaBuilderMutation, o as SchemaBuilderProvider, r as schemaBuilderQueryKey, s as SchemaBuilderProviderProps, t as SchemaBuilderMutationOptions, u as SchemaBuilderStoreState } from "./index-p_NegPQ5.js";
3
- import { t as SchemaBuilder } from "./index-CwQ9QpxA.js";
4
- export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, SchemaBuilder, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderFieldsCapabilities, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderIndexesCapabilities, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPoliciesCapabilities, type SchemaBuilderPolicy, type SchemaBuilderPreferences, type SchemaBuilderProps, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderRelationshipsCapabilities, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderTableSelection, type SchemaBuilderTablesCapabilities, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
1
+ import { A as SchemaBuilderTablesCapabilities, C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, N as SchemaBuilderDataState, O as SchemaBuilderTable, S as SchemaBuilderRelationshipsCapabilities, T as SchemaBuilderSidebarSections, _ as SchemaBuilderPoliciesCapabilities, a as SchemaBuilderCoreCapabilities, b as SchemaBuilderProps, c as SchemaBuilderField, d as SchemaBuilderIndex, f as SchemaBuilderIndexesCapabilities, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, k as SchemaBuilderTableSelection, l as SchemaBuilderFieldsCapabilities, m as SchemaBuilderNavigationTarget, n as SchemaBuilderAdapter, o as SchemaBuilderCoreTabId, p as SchemaBuilderInvalidationEvent, r as SchemaBuilderCollection, s as SchemaBuilderFeature, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES, u as SchemaBuilderHostOptions, v as SchemaBuilderPolicy, w as SchemaBuilderScope, x as SchemaBuilderRelationship, y as SchemaBuilderPreferences } from "./types-CXNRA22N.js";
2
+ import { a as SchemaBuilderContextValue, c as useSchemaBuilder, d as createSchemaBuilderStore, f as getSchemaBuilderScopeKey, i as useSchemaBuilderQuery, l as useSchemaBuilderStore, n as useSchemaBuilderMutation, o as SchemaBuilderProvider, r as schemaBuilderQueryKey, s as SchemaBuilderProviderProps, t as SchemaBuilderMutationOptions, u as SchemaBuilderStoreState } from "./index-euaSKMQK.js";
3
+ import { t as SchemaBuilder } from "./index-BcdFaKFS.js";
4
+ export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, SchemaBuilder, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderDataState, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderFieldsCapabilities, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderIndexesCapabilities, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPoliciesCapabilities, type SchemaBuilderPolicy, type SchemaBuilderPreferences, type SchemaBuilderProps, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderRelationshipsCapabilities, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderTableSelection, type SchemaBuilderTablesCapabilities, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  'use client';
2
- import { a as useSchemaBuilderStore, i as useSchemaBuilder, n as useSchemaBuilderQuery, o as createSchemaBuilderStore, r as SchemaBuilderProvider, s as getSchemaBuilderScopeKey, t as schemaBuilderQueryKey } from "./query-BmN_qO0W.js";
3
- import { Y as cn, c as SchemaBuilderDataProvider, g as useSchemaBuilderRuntimeStore, h as useSchemaBuilderRuntime, l as useSchemaBuilderSelectors } from "./invalidate-database-entities-CmmOT3S0.js";
4
- import { t as TableEditor } from "./table-editor-IVp3B4nG.js";
5
- import { t as SchemaBuilderSidebar } from "./schema-builder-sidebar-VR-Ctidc.js";
6
- import { t as PoliciesView } from "./policies-view-BRbpbyB6.js";
7
- import { t as RelationshipsView } from "./relationships-view-DbwFh5r-.js";
8
- import { t as IndexesView } from "./indexes-view-CJ1WQKdp.js";
9
- import { n as defineSchemaBuilderAdapter, r as useSchemaBuilderMutation, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES } from "./core-kx6KjxE5.js";
2
+ import { a as useSchemaBuilderStore, i as useSchemaBuilder, n as useSchemaBuilderQuery, o as createSchemaBuilderStore, r as SchemaBuilderProvider, s as getSchemaBuilderScopeKey, t as schemaBuilderQueryKey } from "./query-r6j8IjQB.js";
3
+ import { Y as cn, c as SchemaBuilderDataProvider, g as useSchemaBuilderRuntimeStore, h as useSchemaBuilderRuntime, l as useSchemaBuilderSelectors } from "./invalidate-database-entities-BFCWf5Zf.js";
4
+ import { t as TableEditor } from "./table-editor-B-5i1M79.js";
5
+ import { n as SchemaBuilderSidebar, t as SchemaBuilderMobileNavigation } from "./schema-builder-sidebar-DAgK7ZTu.js";
6
+ import { t as PoliciesView } from "./policies-view-DTfAhX7G.js";
7
+ import { t as RelationshipsView } from "./relationships-view-C884EvGj.js";
8
+ import { t as IndexesView } from "./indexes-view-CBzYpKcd.js";
9
+ import { n as defineSchemaBuilderAdapter, r as useSchemaBuilderMutation, t as DEFAULT_SCHEMA_BUILDER_PREFERENCES } from "./core-DJ5kA4r-.js";
10
10
  import { CardStackProvider, CardStackViewport } from "@constructive-io/ui/stack";
11
11
  import { MotionConfig } from "motion/react";
12
12
  import { memo, useEffect, useMemo, useState } from "react";
@@ -16,6 +16,7 @@ import { RiAlertLine, RiDatabase2Line, RiLockLine, RiRefreshLine } from "@remixi
16
16
  import { Eye, EyeOff, PanelLeftClose, PanelLeftOpen } from "lucide-react";
17
17
  import { useQueryClient } from "@tanstack/react-query";
18
18
  import { Button } from "@constructive-io/ui/button";
19
+ import { ConstructiveError, isAuthenticationError, parseError } from "@constructive-io/data";
19
20
  import { Tabs, TabsList, TabsTrigger } from "@constructive-io/ui/tabs";
20
21
 
21
22
  //#region src/schema/schema-builder/components/client-only.tsx
@@ -78,416 +79,23 @@ function SchemaBuilderEditorSkeletonFaded() {
78
79
  return /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full opacity-60" });
79
80
  }
80
81
 
81
- //#endregion
82
- //#region src/schema/schema-builder-core/lib/data/error-handler.ts
83
- /**
84
- * Centralized error handling for the data layer
85
- * Provides consistent error types, messages, and handling patterns
86
- */
87
- const DataErrorType = {
88
- NETWORK_ERROR: "NETWORK_ERROR",
89
- TIMEOUT_ERROR: "TIMEOUT_ERROR",
90
- VALIDATION_FAILED: "VALIDATION_FAILED",
91
- REQUIRED_FIELD_MISSING: "REQUIRED_FIELD_MISSING",
92
- INVALID_MUTATION_DATA: "INVALID_MUTATION_DATA",
93
- QUERY_GENERATION_FAILED: "QUERY_GENERATION_FAILED",
94
- QUERY_EXECUTION_FAILED: "QUERY_EXECUTION_FAILED",
95
- UNAUTHORIZED: "UNAUTHORIZED",
96
- FORBIDDEN: "FORBIDDEN",
97
- TABLE_NOT_FOUND: "TABLE_NOT_FOUND",
98
- BAD_REQUEST: "BAD_REQUEST",
99
- NOT_FOUND: "NOT_FOUND",
100
- GRAPHQL_ERROR: "GRAPHQL_ERROR",
101
- UNIQUE_VIOLATION: "UNIQUE_VIOLATION",
102
- FOREIGN_KEY_VIOLATION: "FOREIGN_KEY_VIOLATION",
103
- NOT_NULL_VIOLATION: "NOT_NULL_VIOLATION",
104
- CHECK_VIOLATION: "CHECK_VIOLATION",
105
- EXCLUSION_VIOLATION: "EXCLUSION_VIOLATION",
106
- UNKNOWN_ERROR: "UNKNOWN_ERROR"
107
- };
108
- const errorWithCaptureStackTrace = Error;
109
- /**
110
- * Standard data layer error class
111
- */
112
- var DataError = class DataError extends Error {
113
- type;
114
- code;
115
- originalError;
116
- context;
117
- tableName;
118
- fieldName;
119
- constraint;
120
- constructor(type, message, options = {}) {
121
- super(message);
122
- this.name = "DataError";
123
- this.type = type;
124
- this.code = options.code;
125
- this.originalError = options.originalError;
126
- this.context = options.context;
127
- this.tableName = options.tableName;
128
- this.fieldName = options.fieldName;
129
- this.constraint = options.constraint;
130
- if (errorWithCaptureStackTrace.captureStackTrace) errorWithCaptureStackTrace.captureStackTrace(this, DataError);
131
- }
132
- /**
133
- * Get a user-friendly error message.
134
- * Checks constraint-specific messages first, then falls back to generic messages.
135
- */
136
- getUserMessage() {
137
- if (this.constraint) {
138
- const constraintMsg = getConstraintMessage(this.constraint);
139
- if (constraintMsg) return constraintMsg;
140
- }
141
- switch (this.type) {
142
- case DataErrorType.NETWORK_ERROR: return "Network error. Please check your connection and try again.";
143
- case DataErrorType.TIMEOUT_ERROR: return "Request timed out. Please try again.";
144
- case DataErrorType.UNAUTHORIZED: return "You are not authorized. Please log in and try again.";
145
- case DataErrorType.FORBIDDEN: return "You do not have permission to access this resource.";
146
- case DataErrorType.VALIDATION_FAILED: return "Validation failed. Please check your input and try again.";
147
- case DataErrorType.REQUIRED_FIELD_MISSING: return this.fieldName ? `The field "${this.fieldName}" is required.` : "A required field is missing. Please check your input.";
148
- case DataErrorType.INVALID_MUTATION_DATA: return "Invalid input. Please check your data and try again.";
149
- case DataErrorType.QUERY_GENERATION_FAILED: return "Query validation failed. Please check your request.";
150
- case DataErrorType.QUERY_EXECUTION_FAILED: return "Query execution failed. Please try again.";
151
- case DataErrorType.TABLE_NOT_FOUND: return "The requested table was not found.";
152
- case DataErrorType.BAD_REQUEST: return this.message || "Invalid request.";
153
- case DataErrorType.NOT_FOUND: return "The requested resource was not found.";
154
- case DataErrorType.UNIQUE_VIOLATION: return this.fieldName ? `A record with this ${this.fieldName} already exists.` : "A record with this value already exists.";
155
- case DataErrorType.FOREIGN_KEY_VIOLATION: return "This record cannot be saved because it references a record that does not exist.";
156
- case DataErrorType.NOT_NULL_VIOLATION: return this.fieldName ? `The field "${this.fieldName}" cannot be empty.` : "A required field cannot be empty.";
157
- case DataErrorType.CHECK_VIOLATION: return this.fieldName ? `The value for "${this.fieldName}" is not valid.` : "The value does not meet the required constraints.";
158
- case DataErrorType.EXCLUSION_VIOLATION: return "This record conflicts with an existing record.";
159
- default: return this.message || "An unexpected error occurred.";
160
- }
161
- }
162
- /**
163
- * Check if this error is retryable
164
- */
165
- isRetryable() {
166
- return this.type === DataErrorType.NETWORK_ERROR || this.type === DataErrorType.TIMEOUT_ERROR;
167
- }
168
- /**
169
- * Get error details for logging
170
- */
171
- getLogDetails() {
172
- return {
173
- type: this.type,
174
- message: this.message,
175
- code: this.code,
176
- tableName: this.tableName,
177
- fieldName: this.fieldName,
178
- context: this.context,
179
- stack: this.stack,
180
- originalError: this.originalError ? {
181
- name: this.originalError.name,
182
- message: this.originalError.message
183
- } : void 0
184
- };
185
- }
186
- };
187
- const createDataError = {
188
- networkError: (originalError, tableName) => new DataError(DataErrorType.NETWORK_ERROR, "Network error occurred", {
189
- originalError,
190
- tableName
191
- }),
192
- timeoutError: (originalError, tableName) => new DataError(DataErrorType.TIMEOUT_ERROR, "Request timed out", {
193
- originalError,
194
- tableName
195
- }),
196
- validationFailed: (tableName, validationErrors) => new DataError(DataErrorType.VALIDATION_FAILED, `Validation failed: ${validationErrors.join(", ")}`, {
197
- tableName,
198
- context: { validationErrors }
199
- }),
200
- requiredFieldMissing: (fieldName, tableName) => new DataError(DataErrorType.REQUIRED_FIELD_MISSING, `Required field ${fieldName} is missing`, {
201
- tableName,
202
- fieldName
203
- }),
204
- unauthorized: (message = "Authentication required", tableName) => new DataError(DataErrorType.UNAUTHORIZED, message, { tableName }),
205
- forbidden: (tableName) => new DataError(DataErrorType.FORBIDDEN, "Access forbidden", { tableName }),
206
- queryGenerationFailed: (message, tableName, code) => new DataError(DataErrorType.QUERY_GENERATION_FAILED, message, {
207
- tableName,
208
- code
209
- }),
210
- queryExecutionFailed: (message, tableName, code) => new DataError(DataErrorType.QUERY_EXECUTION_FAILED, message, {
211
- tableName,
212
- code
213
- }),
214
- tableNotFound: (message = "Table not found", tableName, code) => new DataError(DataErrorType.TABLE_NOT_FOUND, message, {
215
- tableName,
216
- code
217
- }),
218
- invalidMutationData: (message, tableName, code, context) => new DataError(DataErrorType.INVALID_MUTATION_DATA, message, {
219
- tableName,
220
- code,
221
- context
222
- }),
223
- uniqueViolation: (message, tableName, fieldName, constraint) => new DataError(DataErrorType.UNIQUE_VIOLATION, message, {
224
- tableName,
225
- fieldName,
226
- constraint,
227
- code: "23505"
228
- }),
229
- foreignKeyViolation: (message, tableName, fieldName, constraint) => new DataError(DataErrorType.FOREIGN_KEY_VIOLATION, message, {
230
- tableName,
231
- fieldName,
232
- constraint,
233
- code: "23503"
234
- }),
235
- notNullViolation: (message, tableName, fieldName, constraint) => new DataError(DataErrorType.NOT_NULL_VIOLATION, message, {
236
- tableName,
237
- fieldName,
238
- constraint,
239
- code: "23502"
240
- }),
241
- checkViolation: (message, tableName, fieldName, constraint) => new DataError(DataErrorType.CHECK_VIOLATION, message, {
242
- tableName,
243
- fieldName,
244
- constraint,
245
- code: "23514"
246
- }),
247
- exclusionViolation: (message, tableName, constraint) => new DataError(DataErrorType.EXCLUSION_VIOLATION, message, {
248
- tableName,
249
- constraint,
250
- code: "23P01"
251
- }),
252
- unknown: (originalError, tableName) => new DataError(DataErrorType.UNKNOWN_ERROR, originalError.message, {
253
- originalError,
254
- tableName
255
- })
256
- };
257
- /**
258
- * PostgreSQL SQLSTATE error codes
259
- * https://www.postgresql.org/docs/current/errcodes-appendix.html
260
- */
261
- const PG_ERROR_CODES = {
262
- UNIQUE_VIOLATION: "23505",
263
- FOREIGN_KEY_VIOLATION: "23503",
264
- NOT_NULL_VIOLATION: "23502",
265
- CHECK_VIOLATION: "23514",
266
- EXCLUSION_VIOLATION: "23P01",
267
- NUMERIC_VALUE_OUT_OF_RANGE: "22003",
268
- STRING_DATA_RIGHT_TRUNCATION: "22001",
269
- INVALID_TEXT_REPRESENTATION: "22P02",
270
- DATETIME_FIELD_OVERFLOW: "22008",
271
- UNDEFINED_TABLE: "42P01",
272
- UNDEFINED_COLUMN: "42703",
273
- INSUFFICIENT_PRIVILEGE: "42501",
274
- DISK_FULL: "53100",
275
- OUT_OF_MEMORY: "53200",
276
- TOO_MANY_CONNECTIONS: "53300"
277
- };
278
- function parseGraphQLErrorCode(code) {
279
- if (!code) return DataErrorType.UNKNOWN_ERROR;
280
- const normalized = code.toUpperCase();
281
- if (normalized === "UNAUTHENTICATED") return DataErrorType.UNAUTHORIZED;
282
- if (normalized === "BAD_TOKEN_DEFINITION") return DataErrorType.UNAUTHORIZED;
283
- if (normalized === "FORBIDDEN") return DataErrorType.FORBIDDEN;
284
- if (normalized === "GRAPHQL_VALIDATION_FAILED") return DataErrorType.QUERY_GENERATION_FAILED;
285
- if (normalized === "INTERNAL_ERROR" || normalized === "INTERNAL_SERVER_ERROR") return DataErrorType.QUERY_EXECUTION_FAILED;
286
- if (normalized === "NOT_FOUND") return DataErrorType.TABLE_NOT_FOUND;
287
- if (normalized === "INVALID_INPUT") return DataErrorType.INVALID_MUTATION_DATA;
288
- if (code === PG_ERROR_CODES.UNIQUE_VIOLATION) return DataErrorType.UNIQUE_VIOLATION;
289
- if (code === PG_ERROR_CODES.FOREIGN_KEY_VIOLATION) return DataErrorType.FOREIGN_KEY_VIOLATION;
290
- if (code === PG_ERROR_CODES.NOT_NULL_VIOLATION) return DataErrorType.NOT_NULL_VIOLATION;
291
- if (code === PG_ERROR_CODES.CHECK_VIOLATION) return DataErrorType.CHECK_VIOLATION;
292
- if (code === PG_ERROR_CODES.EXCLUSION_VIOLATION) return DataErrorType.EXCLUSION_VIOLATION;
293
- if (code === PG_ERROR_CODES.INSUFFICIENT_PRIVILEGE) return DataErrorType.FORBIDDEN;
294
- if (code === PG_ERROR_CODES.UNDEFINED_TABLE) return DataErrorType.TABLE_NOT_FOUND;
295
- if (code === PG_ERROR_CODES.UNDEFINED_COLUMN) return DataErrorType.INVALID_MUTATION_DATA;
296
- if (code === PG_ERROR_CODES.NUMERIC_VALUE_OUT_OF_RANGE) return DataErrorType.VALIDATION_FAILED;
297
- if (code === PG_ERROR_CODES.STRING_DATA_RIGHT_TRUNCATION) return DataErrorType.VALIDATION_FAILED;
298
- if (code === PG_ERROR_CODES.INVALID_TEXT_REPRESENTATION) return DataErrorType.VALIDATION_FAILED;
299
- if (code === PG_ERROR_CODES.DATETIME_FIELD_OVERFLOW) return DataErrorType.VALIDATION_FAILED;
300
- return DataErrorType.UNKNOWN_ERROR;
301
- }
302
- /**
303
- * Generic error matching API.
304
- * Works with any DataErrorType — no need for per-type helper functions.
305
- */
306
- const Errors = {
307
- /** Map a raw extensions.code to its DataErrorType */
308
- parse(code) {
309
- return parseGraphQLErrorCode(code);
310
- },
311
- /** Check if a raw extensions.code matches a DataErrorType */
312
- is(code, type) {
313
- if (typeof code !== "string") return false;
314
- return parseGraphQLErrorCode(code) === type;
315
- },
316
- /** Check if any error object matches a DataErrorType */
317
- match(error, type) {
318
- if (error instanceof DataError) return error.type === type;
319
- return parseGraphQLError(error).type === type;
320
- },
321
- /** Parse any error into a classified DataError */
322
- from(error, tableName) {
323
- return parseGraphQLError(error, tableName);
324
- }
325
- };
326
- function isGraphQLRequestErrorLike(error) {
327
- return error instanceof Error && error.name === "GraphQLRequestError" && Array.isArray(error.errors);
328
- }
329
- function isGraphQLErrorLike(value) {
330
- return !!value && typeof value === "object" && "message" in value && typeof value.message === "string" && !(value instanceof Error);
331
- }
332
- function extractCodeFromMessage(message) {
333
- return message.match(/\(\s*Code:\s*([A-Za-z0-9_]+)\s*\)/)?.[1];
334
- }
335
- function classifyByMessage(message) {
336
- const lower = message.toLowerCase();
337
- if (lower.includes("timeout") || lower.includes("timed out") || lower.includes("aborted")) return DataErrorType.TIMEOUT_ERROR;
338
- if (lower.includes("network") || lower.includes("fetch") || lower.includes("failed to fetch")) return DataErrorType.NETWORK_ERROR;
339
- if (lower.includes("unauthenticated") || lower.includes("unauthorized") || lower.includes("not authorized") || lower.includes("authentication")) return DataErrorType.UNAUTHORIZED;
340
- if (lower.includes("forbidden") || lower.includes("access denied") || lower.includes("permission")) return DataErrorType.FORBIDDEN;
341
- if (lower.includes("validation")) return DataErrorType.VALIDATION_FAILED;
342
- if (lower.includes("duplicate key") || lower.includes("already exists") || lower.includes("unique constraint")) return DataErrorType.UNIQUE_VIOLATION;
343
- if (lower.includes("foreign key constraint") || lower.includes("violates foreign key")) return DataErrorType.FOREIGN_KEY_VIOLATION;
344
- if (lower.includes("not-null constraint") || lower.includes("null value in column")) return DataErrorType.NOT_NULL_VIOLATION;
345
- if (lower.includes("check constraint")) return DataErrorType.CHECK_VIOLATION;
346
- return DataErrorType.UNKNOWN_ERROR;
347
- }
348
- function extractPostgresDetails(extensions) {
349
- if (!extensions) return {};
350
- return {
351
- constraint: typeof extensions.constraint === "string" ? extensions.constraint : void 0,
352
- column: typeof extensions.column === "string" ? extensions.column : void 0,
353
- table: typeof extensions.table === "string" ? extensions.table : void 0,
354
- detail: typeof extensions.detail === "string" ? extensions.detail : void 0
355
- };
356
- }
357
- /**
358
- * Try to extract the field name from a PostgreSQL error message or constraint name.
359
- */
360
- function extractFieldFromError(message, constraint, column) {
361
- if (column) return column;
362
- const columnMatch = message.match(/column\s+"?([a-z_][a-z0-9_]*)"?/i);
363
- if (columnMatch) return columnMatch[1];
364
- if (constraint) {
365
- const constraintMatch = constraint.match(/_([a-z_][a-z0-9_]*)_(?:key|fkey|check|pkey)$/i);
366
- if (constraintMatch) return constraintMatch[1];
367
- }
368
- const keyMatch = message.match(/Key\s+\(([a-z_][a-z0-9_]*)\)/i);
369
- if (keyMatch) return keyMatch[1];
370
- }
371
- /**
372
- * Parse any error into a DataError.
373
- * Optional tableName adds context for data-layer operations.
374
- */
375
- function parseGraphQLError(error, tableName) {
376
- if (error instanceof DataError) return error;
377
- if (isGraphQLRequestErrorLike(error) && error.errors.length > 0) return parseGraphQLError(error.errors[0], tableName);
378
- if (isGraphQLErrorLike(error)) {
379
- const extCode = error.extensions?.code;
380
- const mappedFromExt = parseGraphQLErrorCode(extCode);
381
- const pgDetails = extractPostgresDetails(error.extensions);
382
- const effectiveTable = tableName || pgDetails.table;
383
- const fieldName = extractFieldFromError(error.message, pgDetails.constraint, pgDetails.column);
384
- if (mappedFromExt !== DataErrorType.UNKNOWN_ERROR) switch (mappedFromExt) {
385
- case DataErrorType.UNAUTHORIZED: return createDataError.unauthorized(error.message, effectiveTable);
386
- case DataErrorType.FORBIDDEN: return createDataError.forbidden(effectiveTable);
387
- case DataErrorType.QUERY_GENERATION_FAILED: return createDataError.queryGenerationFailed(error.message, effectiveTable, extCode);
388
- case DataErrorType.QUERY_EXECUTION_FAILED: return createDataError.queryExecutionFailed(error.message, effectiveTable, extCode);
389
- case DataErrorType.TABLE_NOT_FOUND: return createDataError.tableNotFound(error.message, effectiveTable, extCode);
390
- case DataErrorType.INVALID_MUTATION_DATA: return createDataError.invalidMutationData(error.message, effectiveTable, extCode, error.extensions);
391
- case DataErrorType.UNIQUE_VIOLATION: return createDataError.uniqueViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
392
- case DataErrorType.FOREIGN_KEY_VIOLATION: return createDataError.foreignKeyViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
393
- case DataErrorType.NOT_NULL_VIOLATION: return createDataError.notNullViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
394
- case DataErrorType.CHECK_VIOLATION: return createDataError.checkViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
395
- case DataErrorType.EXCLUSION_VIOLATION: return createDataError.exclusionViolation(error.message, effectiveTable, pgDetails.constraint);
396
- case DataErrorType.VALIDATION_FAILED: return createDataError.validationFailed(effectiveTable, [error.message]);
397
- default: break;
398
- }
399
- switch (classifyByMessage(error.message)) {
400
- case DataErrorType.VALIDATION_FAILED: return createDataError.validationFailed(effectiveTable, [error.message]);
401
- case DataErrorType.FORBIDDEN: return createDataError.forbidden(effectiveTable);
402
- case DataErrorType.UNAUTHORIZED: return createDataError.unauthorized("Authentication required", effectiveTable);
403
- case DataErrorType.TIMEOUT_ERROR: return createDataError.timeoutError(new Error(error.message), effectiveTable);
404
- case DataErrorType.NETWORK_ERROR: return createDataError.networkError(new Error(error.message), effectiveTable);
405
- case DataErrorType.UNIQUE_VIOLATION: return createDataError.uniqueViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
406
- case DataErrorType.FOREIGN_KEY_VIOLATION: return createDataError.foreignKeyViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
407
- case DataErrorType.NOT_NULL_VIOLATION: return createDataError.notNullViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
408
- case DataErrorType.CHECK_VIOLATION: return createDataError.checkViolation(error.message, effectiveTable, fieldName, pgDetails.constraint);
409
- default: return createDataError.unknown(new Error(error.message), effectiveTable);
410
- }
411
- }
412
- if (error instanceof Error) {
413
- const embeddedCode = extractCodeFromMessage(error.message);
414
- const mappedFromMessageCode = parseGraphQLErrorCode(embeddedCode);
415
- if (mappedFromMessageCode !== DataErrorType.UNKNOWN_ERROR) switch (mappedFromMessageCode) {
416
- case DataErrorType.UNAUTHORIZED: return createDataError.unauthorized("Authentication required. Please log in again.", tableName);
417
- case DataErrorType.FORBIDDEN: return createDataError.forbidden(tableName);
418
- default: return new DataError(mappedFromMessageCode, error.message, {
419
- tableName,
420
- code: embeddedCode,
421
- originalError: error
422
- });
423
- }
424
- const type = classifyByMessage(error.message);
425
- const fieldName = extractFieldFromError(error.message);
426
- switch (type) {
427
- case DataErrorType.NETWORK_ERROR: return createDataError.networkError(error, tableName);
428
- case DataErrorType.TIMEOUT_ERROR: return createDataError.timeoutError(error, tableName);
429
- case DataErrorType.UNAUTHORIZED: return createDataError.unauthorized(error.message, tableName);
430
- case DataErrorType.FORBIDDEN: return createDataError.forbidden(tableName);
431
- case DataErrorType.VALIDATION_FAILED: return createDataError.validationFailed(tableName, [error.message]);
432
- case DataErrorType.UNIQUE_VIOLATION: return createDataError.uniqueViolation(error.message, tableName, fieldName);
433
- case DataErrorType.FOREIGN_KEY_VIOLATION: return createDataError.foreignKeyViolation(error.message, tableName, fieldName);
434
- case DataErrorType.NOT_NULL_VIOLATION: return createDataError.notNullViolation(error.message, tableName, fieldName);
435
- case DataErrorType.CHECK_VIOLATION: return createDataError.checkViolation(error.message, tableName, fieldName);
436
- default: return createDataError.unknown(error, tableName);
437
- }
438
- }
439
- const errorMessage = typeof error === "string" ? error : "Unknown error occurred";
440
- return createDataError.unknown(new Error(errorMessage), tableName);
441
- }
442
- function parseError(error) {
443
- return parseGraphQLError(error);
444
- }
445
- /**
446
- * Constraint-specific human-friendly messages.
447
- * Keys can be:
448
- * - Exact constraint name: "database_schema_hash_key"
449
- * - Pattern with wildcard prefix: "*_name_key" (matches any table's name unique constraint)
450
- */
451
- const CONSTRAINT_MESSAGES = {
452
- database_schema_hash_key: "This database name is already taken. Please choose a different name.",
453
- database_name_key: "This database name is already taken. Please choose a different name.",
454
- database_provision_module_name_length_min: "Database name must be at least 3 characters.",
455
- database_provision_module_name_length_max: "Database name must be 63 characters or less.",
456
- database_provision_module_name_format: "Database name must start with a letter and use only letters, numbers, underscores, or hyphens.",
457
- domain_subdomain_domain_key: "This subdomain is already in use for this domain.",
458
- api_name_database_id_key: "An API with this name already exists in this database.",
459
- "*_email_key": "This email address is already registered.",
460
- "*_name_key": "This name is already taken.",
461
- "*_slug_key": "This URL slug is already in use."
462
- };
463
- /**
464
- * Get human-friendly message for a constraint violation.
465
- * Checks exact match first, then pattern matches with * prefix.
466
- */
467
- function getConstraintMessage(constraint) {
468
- if (!constraint) return void 0;
469
- if (CONSTRAINT_MESSAGES[constraint]) return CONSTRAINT_MESSAGES[constraint];
470
- for (const [pattern, message] of Object.entries(CONSTRAINT_MESSAGES)) if (pattern.startsWith("*")) {
471
- const suffix = pattern.slice(1);
472
- if (constraint.endsWith(suffix)) return message;
473
- }
474
- }
475
-
476
82
  //#endregion
477
83
  //#region src/schema/schema-builder/components/schema-builder-header.tsx
478
84
  function SchemaBuilderHeader({ leftPanelVisible, setLeftPanelVisible, activeTab, setActiveTab, showSystemTablesInSidebar, setShowSystemTablesInSidebar, hasSystemTablesInCurrentSchema, tabs = [] }) {
479
85
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
480
86
  "data-testid": "schema-builder-header",
481
- className: "bg-card border-border/60 flex h-14 items-center justify-between border-b px-4",
87
+ className: "bg-card border-border/60 flex min-h-14 items-center justify-between gap-2 overflow-hidden border-b px-2 sm:px-4",
482
88
  children: [/* @__PURE__ */ jsxs("div", {
483
- className: "flex items-center gap-4",
89
+ className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-4",
484
90
  children: [/* @__PURE__ */ jsx(Button, {
485
91
  variant: "ghost",
486
92
  size: "sm",
487
93
  onClick: () => setLeftPanelVisible(!leftPanelVisible),
488
- className: "h-8 w-8 p-0",
94
+ className: "hidden size-8 p-0 sm:inline-flex",
95
+ "aria-label": leftPanelVisible ? "Hide table sidebar" : "Show table sidebar",
489
96
  children: leftPanelVisible ? /* @__PURE__ */ jsx(PanelLeftClose, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(PanelLeftOpen, { className: "h-4 w-4" })
490
97
  }), /* @__PURE__ */ jsx(Tabs, {
98
+ className: "min-w-0 flex-1 overflow-x-auto",
491
99
  value: activeTab,
492
100
  onValueChange: setActiveTab,
493
101
  children: /* @__PURE__ */ jsxs(TabsList, { children: [
@@ -515,9 +123,10 @@ function SchemaBuilderHeader({ leftPanelVisible, setLeftPanelVisible, activeTab,
515
123
  ] })
516
124
  })]
517
125
  }), hasSystemTablesInCurrentSchema && /* @__PURE__ */ jsxs(Button, {
126
+ "aria-label": showSystemTablesInSidebar ? "Hide system tables" : "Show system tables",
518
127
  variant: "ghost",
519
128
  size: "sm",
520
- className: "text-muted-foreground hover:text-foreground h-8 gap-1.5",
129
+ className: "text-muted-foreground hover:text-foreground hidden h-8 shrink-0 gap-1.5 px-3 sm:inline-flex",
521
130
  onClick: () => setShowSystemTablesInSidebar(!showSystemTablesInSidebar),
522
131
  "aria-pressed": showSystemTablesInSidebar,
523
132
  children: [showSystemTablesInSidebar ? /* @__PURE__ */ jsx(Eye, { className: "size-4" }) : /* @__PURE__ */ jsx(EyeOff, { className: "size-4" }), /* @__PURE__ */ jsx("span", {
@@ -534,7 +143,7 @@ function SchemaBuilderHeader({ leftPanelVisible, setLeftPanelVisible, activeTab,
534
143
  * Check if an error is an authentication error (expired/missing session).
535
144
  */
536
145
  function isAuthError(error) {
537
- return Errors.match(error, DataErrorType.UNAUTHORIZED);
146
+ return isAuthenticationError(error);
538
147
  }
539
148
  /**
540
149
  * Inline banner shown when a request fails auth. The block owns no router, so
@@ -546,8 +155,8 @@ function AuthErrorBanner({ error, message, className }) {
546
155
  useEffect(() => {
547
156
  queryClient.clear();
548
157
  }, [queryClient]);
549
- const dataError = error instanceof DataError ? error : parseError(error);
550
- const displayMessage = message || dataError.getUserMessage();
158
+ const normalizedError = error instanceof ConstructiveError ? error : parseError(error);
159
+ const displayMessage = message || normalizedError.message;
551
160
  return /* @__PURE__ */ jsx("div", {
552
161
  className: cn("rounded-lg border overflow-hidden", "bg-amber-50 dark:bg-amber-950/30 border-amber-200/60 dark:border-amber-900/50", className),
553
162
  children: /* @__PURE__ */ jsxs("div", {
@@ -709,29 +318,37 @@ function SchemasRoute({ emptyState } = {}) {
709
318
  className: "flex min-h-0 min-w-0 flex-1",
710
319
  children: [leftPanelVisible && /* @__PURE__ */ jsx(SchemaBuilderSidebar, { showSystemTables: showSystemTablesInSidebar }), /* @__PURE__ */ jsxs("div", {
711
320
  className: "flex min-h-0 min-w-0 flex-1 flex-col",
712
- children: [/* @__PURE__ */ jsx(SchemaBuilderHeader, {
713
- leftPanelVisible,
714
- setLeftPanelVisible,
715
- activeTab,
716
- setActiveTab,
717
- showSystemTablesInSidebar,
718
- setShowSystemTablesInSidebar,
719
- hasSystemTablesInCurrentSchema,
720
- tabs
721
- }), /* @__PURE__ */ jsxs("div", {
722
- className: "flex min-h-0 flex-1 flex-col overflow-hidden",
723
- children: [
724
- activeTab === "editor" && /* @__PURE__ */ jsx(TableEditor, {}),
725
- activeTab === "relationships" && /* @__PURE__ */ jsx(RelationshipsView, {}),
726
- activeTab === "indexes" && /* @__PURE__ */ jsx(IndexesView, {}),
727
- activeTab === "security" && /* @__PURE__ */ jsx(PoliciesView, {}),
728
- extensionTab?.render({
729
- scope,
730
- colorMode,
731
- selectedTableId: currentTable?.id ?? null
732
- })
733
- ]
734
- })]
321
+ children: [
322
+ /* @__PURE__ */ jsx(SchemaBuilderMobileNavigation, {
323
+ hasSystemTables: hasSystemTablesInCurrentSchema,
324
+ onShowSystemTablesChange: setShowSystemTablesInSidebar,
325
+ showSystemTables: showSystemTablesInSidebar
326
+ }),
327
+ /* @__PURE__ */ jsx(SchemaBuilderHeader, {
328
+ leftPanelVisible,
329
+ setLeftPanelVisible,
330
+ activeTab,
331
+ setActiveTab,
332
+ showSystemTablesInSidebar,
333
+ setShowSystemTablesInSidebar,
334
+ hasSystemTablesInCurrentSchema,
335
+ tabs
336
+ }),
337
+ /* @__PURE__ */ jsxs("div", {
338
+ className: "flex min-h-0 flex-1 flex-col overflow-hidden",
339
+ children: [
340
+ activeTab === "editor" && /* @__PURE__ */ jsx(TableEditor, {}),
341
+ activeTab === "relationships" && /* @__PURE__ */ jsx(RelationshipsView, {}),
342
+ activeTab === "indexes" && /* @__PURE__ */ jsx(IndexesView, {}),
343
+ activeTab === "security" && /* @__PURE__ */ jsx(PoliciesView, {}),
344
+ extensionTab?.render({
345
+ scope,
346
+ colorMode,
347
+ selectedTableId: currentTable?.id ?? null
348
+ })
349
+ ]
350
+ })
351
+ ]
735
352
  })]
736
353
  })
737
354
  ]
@@ -741,20 +358,41 @@ function SchemasRoute({ emptyState } = {}) {
741
358
 
742
359
  //#endregion
743
360
  //#region src/components/schema-builder.tsx
744
- function SchemaBuilder({ className, emptyState, ...host }) {
361
+ function assertDataStateMatchesScope(props) {
362
+ if (!props.dataState) return;
363
+ const matchesOrganization = props.dataState.routeOrgId === props.scope.orgId;
364
+ const matchesDatabase = props.dataState.routeDatabaseId === props.scope.databaseId;
365
+ if (!matchesOrganization || !matchesDatabase) throw new Error("SchemaBuilder dataState must match the configured organization and database scope");
366
+ }
367
+ function SchemaBuilder(props) {
368
+ assertDataStateMatchesScope(props);
745
369
  return /* @__PURE__ */ jsx(MotionConfig, {
746
370
  reducedMotion: "user",
747
371
  children: /* @__PURE__ */ jsx(SchemaBuilderProvider, {
748
- ...host,
372
+ adapter: props.adapter,
373
+ scope: props.scope,
374
+ colorMode: props.colorMode,
375
+ preferences: props.preferences,
376
+ onPreferencesChange: props.onPreferencesChange,
377
+ activeTab: props.activeTab,
378
+ onActiveTabChange: props.onActiveTabChange,
379
+ selectedTableId: props.selectedTableId,
380
+ onSelectedTableChange: props.onSelectedTableChange,
381
+ onNavigate: props.onNavigate,
382
+ onInvalidate: props.onInvalidate,
383
+ tabs: props.tabs,
749
384
  children: /* @__PURE__ */ jsx(CardStackProvider, {
750
385
  layoutMode: "side-by-side",
751
386
  defaultPeekOffset: 48,
752
- children: /* @__PURE__ */ jsx(SchemaBuilderDataProvider, { children: /* @__PURE__ */ jsxs("div", {
753
- className: cn("relative flex h-full min-h-0 w-full flex-col", className),
754
- "data-color-mode": host.colorMode,
755
- "data-schema-builder": "root",
756
- children: [/* @__PURE__ */ jsx(SchemasRoute, { emptyState }), /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(CardStackViewport, { peekDepth: 3 }) })]
757
- }) })
387
+ children: /* @__PURE__ */ jsx(SchemaBuilderDataProvider, {
388
+ value: props.dataState,
389
+ children: /* @__PURE__ */ jsxs("div", {
390
+ className: cn("relative flex h-full min-h-0 w-full flex-col", props.className),
391
+ "data-color-mode": props.colorMode,
392
+ "data-schema-builder": "root",
393
+ children: [/* @__PURE__ */ jsx(SchemasRoute, { emptyState: props.emptyState }), /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsx(CardStackViewport, { peekDepth: 3 }) })]
394
+ })
395
+ })
758
396
  })
759
397
  })
760
398
  });