@constructive-io/schema-builder 0.2.0 → 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.
- package/CHANGELOG.md +23 -0
- package/README.md +12 -4
- package/dist/card-widths-CmIxkRfh.cjs +28 -0
- package/dist/card-widths-CmIxkRfh.cjs.map +1 -0
- package/dist/card-widths-pI4Kw4Xz.js +22 -0
- package/dist/card-widths-pI4Kw4Xz.js.map +1 -0
- package/dist/core-CVxnNLs7.cjs +66 -0
- package/dist/core-CVxnNLs7.cjs.map +1 -0
- package/dist/core-DJ5kA4r-.js +49 -0
- package/dist/core-DJ5kA4r-.js.map +1 -0
- package/dist/core.cjs +14 -212
- package/dist/core.d.cts +3 -54
- package/dist/core.d.ts +3 -54
- package/dist/core.js +3 -200
- package/dist/create-table-card-B6SMrt_g.js +7691 -0
- package/dist/create-table-card-B6SMrt_g.js.map +1 -0
- package/dist/create-table-card-BrQ7pB_U.cjs +7732 -0
- package/dist/create-table-card-BrQ7pB_U.cjs.map +1 -0
- package/dist/delete-confirm-dialog-Ch4tWj6B.cjs +42 -0
- package/dist/delete-confirm-dialog-Ch4tWj6B.cjs.map +1 -0
- package/dist/delete-confirm-dialog-K0AWE643.js +37 -0
- package/dist/delete-confirm-dialog-K0AWE643.js.map +1 -0
- package/dist/empty-state-card-5t7LygTB.cjs +62 -0
- package/dist/empty-state-card-5t7LygTB.cjs.map +1 -0
- package/dist/empty-state-card-C-Nylatg.js +57 -0
- package/dist/empty-state-card-C-Nylatg.js.map +1 -0
- package/dist/fields.cjs +8 -7763
- package/dist/fields.d.cts +38 -39
- package/dist/fields.d.ts +38 -39
- package/dist/fields.js +2 -7735
- package/dist/generated-types-DZMUyNBH.d.cts +27 -0
- package/dist/generated-types-DZMUyNBH.d.ts +27 -0
- package/dist/index--9KTz1LB.d.cts +56 -0
- package/dist/index-10idAfdb.d.cts +7 -0
- package/dist/index-BcdFaKFS.d.ts +7 -0
- package/dist/index-euaSKMQK.d.ts +56 -0
- package/dist/index.cjs +392 -13730
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -10
- package/dist/index.d.ts +4 -10
- package/dist/index.js +381 -13698
- package/dist/index.js.map +1 -1
- package/dist/indexes-view-CBzYpKcd.js +736 -0
- package/dist/indexes-view-CBzYpKcd.js.map +1 -0
- package/dist/indexes-view-D1K24ts1.cjs +759 -0
- package/dist/indexes-view-D1K24ts1.cjs.map +1 -0
- package/dist/indexes.cjs +6 -1041
- package/dist/indexes.d.cts +27 -27
- package/dist/indexes.d.ts +27 -27
- package/dist/indexes.js +2 -1016
- package/dist/invalidate-database-entities-BFCWf5Zf.js +2561 -0
- package/dist/invalidate-database-entities-BFCWf5Zf.js.map +1 -0
- package/dist/invalidate-database-entities-Gs5k8A-M.cjs +2864 -0
- package/dist/invalidate-database-entities-Gs5k8A-M.cjs.map +1 -0
- package/dist/keyboard-activation-BQiV0scm.js +13 -0
- package/dist/keyboard-activation-BQiV0scm.js.map +1 -0
- package/dist/keyboard-activation-D-L0IU6Y.cjs +19 -0
- package/dist/keyboard-activation-D-L0IU6Y.cjs.map +1 -0
- package/dist/policies-view-CkvGpJBo.cjs +1023 -0
- package/dist/policies-view-CkvGpJBo.cjs.map +1 -0
- package/dist/policies-view-DTfAhX7G.js +1018 -0
- package/dist/policies-view-DTfAhX7G.js.map +1 -0
- package/dist/policies.cjs +10 -5939
- package/dist/policies.d.cts +55 -50
- package/dist/policies.d.ts +55 -50
- package/dist/policies.js +4 -5911
- package/dist/policy-config-form-EEcQ9ywL.js +2502 -0
- package/dist/policy-config-form-EEcQ9ywL.js.map +1 -0
- package/dist/policy-config-form-RP9010zj.cjs +2629 -0
- package/dist/policy-config-form-RP9010zj.cjs.map +1 -0
- package/dist/policy-types-D_sYWb-b.d.cts +81 -0
- package/dist/policy-types-D_sYWb-b.d.ts +81 -0
- package/dist/query-BGtzUV7Y.cjs +233 -0
- package/dist/query-BGtzUV7Y.cjs.map +1 -0
- package/dist/query-r6j8IjQB.js +192 -0
- package/dist/query-r6j8IjQB.js.map +1 -0
- package/dist/relationships-view-C884EvGj.js +2417 -0
- package/dist/relationships-view-C884EvGj.js.map +1 -0
- package/dist/relationships-view-DlBs-gCF.cjs +2452 -0
- package/dist/relationships-view-DlBs-gCF.cjs.map +1 -0
- package/dist/relationships.cjs +9 -4328
- package/dist/relationships.d.cts +92 -92
- package/dist/relationships.d.ts +92 -92
- package/dist/relationships.js +2 -4300
- package/dist/rolldown-runtime-D_qnwXdH.cjs +35 -0
- package/dist/schema-builder-sidebar-DAgK7ZTu.js +654 -0
- package/dist/schema-builder-sidebar-DAgK7ZTu.js.map +1 -0
- package/dist/schema-builder-sidebar-L3TcQeQr.cjs +671 -0
- package/dist/schema-builder-sidebar-L3TcQeQr.cjs.map +1 -0
- package/dist/table-editor-B-5i1M79.js +1906 -0
- package/dist/table-editor-B-5i1M79.js.map +1 -0
- package/dist/table-editor-BdLdVZfh.cjs +1935 -0
- package/dist/table-editor-BdLdVZfh.cjs.map +1 -0
- package/dist/tables.cjs +6 -5643
- package/dist/tables.d.cts +22 -21
- package/dist/tables.d.ts +22 -21
- package/dist/tables.js +3 -5618
- package/dist/testing.cjs +63 -62
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.js +62 -61
- package/dist/testing.js.map +1 -1
- package/dist/types-CXNRA22N.d.cts +450 -0
- package/dist/types-CXNRA22N.d.ts +450 -0
- package/dist/use-update-table-DlLX9fdE.js +244 -0
- package/dist/use-update-table-DlLX9fdE.js.map +1 -0
- package/dist/use-update-table-vcoHVolI.cjs +291 -0
- package/dist/use-update-table-vcoHVolI.cjs.map +1 -0
- package/package.json +8 -6
- package/dist/core.cjs.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/fields.cjs.map +0 -1
- package/dist/fields.js.map +0 -1
- package/dist/generated-types-CnAlqHU_.d.cts +0 -25
- package/dist/generated-types-CnAlqHU_.d.ts +0 -25
- package/dist/indexes.cjs.map +0 -1
- package/dist/indexes.js.map +0 -1
- package/dist/policies.cjs.map +0 -1
- package/dist/policies.js.map +0 -1
- package/dist/policy-types-CEYAR5TN.d.cts +0 -79
- package/dist/policy-types-CEYAR5TN.d.ts +0 -79
- package/dist/relationships.cjs.map +0 -1
- package/dist/relationships.js.map +0 -1
- package/dist/tables.cjs.map +0 -1
- package/dist/tables.js.map +0 -1
- package/dist/types-Du86atZ8.d.cts +0 -199
- package/dist/types-Du86atZ8.d.ts +0 -199
- package/dist/types-bX2dCrdl.d.cts +0 -52
- package/dist/types-bX2dCrdl.d.ts +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.4.0](https://github.com/constructive-io/blocks/compare/@constructive-io/schema-builder@0.2.1...@constructive-io/schema-builder@0.4.0) (2026-07-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **blocks:** polish application docs and previews ([a00d896](https://github.com/constructive-io/blocks/commit/a00d89629894f89c2063da9632836b992949197c))
|
|
12
|
+
* **registry:** add dashboard source blocks ([11483a0](https://github.com/constructive-io/blocks/commit/11483a0b5dafa501f6962186931ece2f4b02a416))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.2.1](https://github.com/constructive-io/blocks/compare/@constructive-io/schema-builder@0.2.0...@constructive-io/schema-builder@0.2.1) (2026-07-29)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **packages:** migrate builds to tsdown ([844c578](https://github.com/constructive-io/blocks/commit/844c5786e0892146805b41638e646307d377661f))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# 0.2.0 (2026-07-29)
|
|
7
30
|
|
|
8
31
|
|
package/README.md
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Schema Builder
|
|
2
2
|
|
|
3
3
|
Framework-agnostic React schema builder for Constructive applications. The host owns the TanStack Query client, authenticated data adapter, scope, color mode, navigation, active tab, and persisted preferences.
|
|
4
4
|
|
|
5
|
+
Configure the `@constructive` registry in `components.json`, then install the
|
|
6
|
+
source-owned editor:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm dlx shadcn@latest add @constructive/schema-builder
|
|
10
|
+
```
|
|
11
|
+
|
|
5
12
|
```tsx
|
|
6
13
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
7
14
|
import {
|
|
8
15
|
DEFAULT_SCHEMA_BUILDER_PREFERENCES,
|
|
9
16
|
SchemaBuilder,
|
|
10
17
|
defineSchemaBuilderAdapter
|
|
11
|
-
} from '
|
|
12
|
-
import '@constructive-io/schema-builder/styles.css';
|
|
18
|
+
} from '@/components/schema-builder';
|
|
13
19
|
|
|
14
20
|
const adapter = defineSchemaBuilderAdapter({
|
|
15
21
|
// Implement the typed core/fields/relationships/indexes/policies/tables ports.
|
|
@@ -30,4 +36,6 @@ const adapter = defineSchemaBuilderAdapter({
|
|
|
30
36
|
</QueryClientProvider>;
|
|
31
37
|
```
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
The installed root exports the full adapter, store, and editor surface. The
|
|
40
|
+
host adapter keeps generated SDKs, endpoints, authenticated operations, and
|
|
41
|
+
cache invalidation in the consuming application.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
//#region src/schema/schema-builder-core/lib/stack/card-widths.ts
|
|
4
|
+
/**
|
|
5
|
+
* Standard card widths for Stack cards.
|
|
6
|
+
* Use these for consistency across the app.
|
|
7
|
+
*/
|
|
8
|
+
const CARD_WIDTHS = {
|
|
9
|
+
/** Narrow forms, simple lists (360px) */
|
|
10
|
+
narrow: 360,
|
|
11
|
+
/** Default for most forms (480px) */
|
|
12
|
+
medium: 480,
|
|
13
|
+
/** Complex forms, editors with multiple sections (560px) */
|
|
14
|
+
wide: 560,
|
|
15
|
+
/** Large editors, multi-column layouts (720px) */
|
|
16
|
+
extraWide: 720,
|
|
17
|
+
/** Near full-width for complex UIs */
|
|
18
|
+
fullish: "90vw"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
Object.defineProperty(exports, 'CARD_WIDTHS', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return CARD_WIDTHS;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=card-widths-CmIxkRfh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-widths-CmIxkRfh.cjs","names":[],"sources":["../src/schema/schema-builder-core/lib/stack/card-widths.ts"],"mappings":";;;;;;;AAIA,MAAa,cAAc;;CAE1B,QAAQ;;CAER,QAAQ;;CAER,MAAM;;CAEN,WAAW;;CAEX,SAAS;AACV"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
//#region src/schema/schema-builder-core/lib/stack/card-widths.ts
|
|
3
|
+
/**
|
|
4
|
+
* Standard card widths for Stack cards.
|
|
5
|
+
* Use these for consistency across the app.
|
|
6
|
+
*/
|
|
7
|
+
const CARD_WIDTHS = {
|
|
8
|
+
/** Narrow forms, simple lists (360px) */
|
|
9
|
+
narrow: 360,
|
|
10
|
+
/** Default for most forms (480px) */
|
|
11
|
+
medium: 480,
|
|
12
|
+
/** Complex forms, editors with multiple sections (560px) */
|
|
13
|
+
wide: 560,
|
|
14
|
+
/** Large editors, multi-column layouts (720px) */
|
|
15
|
+
extraWide: 720,
|
|
16
|
+
/** Near full-width for complex UIs */
|
|
17
|
+
fullish: "90vw"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CARD_WIDTHS as t };
|
|
22
|
+
//# sourceMappingURL=card-widths-pI4Kw4Xz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-widths-pI4Kw4Xz.js","names":[],"sources":["../src/schema/schema-builder-core/lib/stack/card-widths.ts"],"mappings":";;;;;;AAIA,MAAa,cAAc;;CAE1B,QAAQ;;CAER,QAAQ;;CAER,MAAM;;CAEN,WAAW;;CAEX,SAAS;AACV"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
const require_query = require('./query-BGtzUV7Y.cjs');
|
|
3
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
|
+
|
|
5
|
+
//#region src/core/mutation.ts
|
|
6
|
+
function useSchemaBuilderMutation(feature, operation, options = {}) {
|
|
7
|
+
const { adapter, scope, onInvalidate } = require_query.useSchemaBuilder();
|
|
8
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
9
|
+
const operationFn = adapter[feature][operation];
|
|
10
|
+
if (typeof operationFn !== "function") throw new Error(`SchemaBuilder adapter is missing ${feature}.${operation}`);
|
|
11
|
+
const { selection, ...mutationOptions } = options;
|
|
12
|
+
const hostOnSuccess = mutationOptions.onSuccess;
|
|
13
|
+
return (0, _tanstack_react_query.useMutation)({
|
|
14
|
+
...mutationOptions,
|
|
15
|
+
mutationFn: (variables) => operationFn(variables, {
|
|
16
|
+
scope,
|
|
17
|
+
selection
|
|
18
|
+
}),
|
|
19
|
+
onSuccess: async (data, variables, onMutateResult, context) => {
|
|
20
|
+
await queryClient.invalidateQueries({ queryKey: require_query.schemaBuilderQueryKey(scope, "core", "").slice(0, 4) });
|
|
21
|
+
onInvalidate?.({
|
|
22
|
+
scope,
|
|
23
|
+
feature,
|
|
24
|
+
operation
|
|
25
|
+
});
|
|
26
|
+
await hostOnSuccess?.(data, variables, onMutateResult, context);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/types.ts
|
|
33
|
+
const DEFAULT_SCHEMA_BUILDER_PREFERENCES = {
|
|
34
|
+
sidebarSectionsExpanded: {
|
|
35
|
+
app: true,
|
|
36
|
+
system: false
|
|
37
|
+
},
|
|
38
|
+
showSystemTablesInSidebar: false,
|
|
39
|
+
showSystemTablesInVisualizer: false,
|
|
40
|
+
sidebarPinned: false,
|
|
41
|
+
typesLibraryExpanded: true
|
|
42
|
+
};
|
|
43
|
+
function defineSchemaBuilderAdapter(adapter) {
|
|
44
|
+
return adapter;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
Object.defineProperty(exports, 'DEFAULT_SCHEMA_BUILDER_PREFERENCES', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return DEFAULT_SCHEMA_BUILDER_PREFERENCES;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, 'defineSchemaBuilderAdapter', {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return defineSchemaBuilderAdapter;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, 'useSchemaBuilderMutation', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return useSchemaBuilderMutation;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=core-CVxnNLs7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-CVxnNLs7.cjs","names":["useSchemaBuilder","schemaBuilderQueryKey"],"sources":["../src/core/mutation.ts","../src/types.ts"],"mappings":";;;;;AA8BA,SAAgB,yBAKd,SACA,WACA,UAA2D,CAAC,GACf;CAC7C,MAAM,EAAE,SAAS,OAAO,iBAAiBA,+BAAiB;CAC1D,MAAM,wDAA6B;CAEnC,MAAM,cADa,QAAQ,QACG,CAAC;CAE/B,IAAI,OAAO,gBAAgB,YACzB,MAAM,IAAI,MAAM,oCAAoC,QAAQ,GAAG,WAAW;CAG5E,MAAM,EAAE,WAAW,GAAG,oBAAoB;CAC1C,MAAM,gBAAgB,gBAAgB;CAEtC,8CAAmB;EACjB,GAAG;EACH,aAAa,cACX,YAAY,WAAW;GAAE;GAAO;EAAU,CAAC;EAC7C,WAAW,OAAO,MAAM,WAAW,gBAAgB,YAAY;GAC7D,MAAM,YAAY,kBAAkB,EAClC,UAAUC,oCAAsB,OAAO,QAAQ,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAC/D,CAAC;GACD,eAAe;IAAE;IAAO;IAAS;GAAU,CAAC;GAC5C,MAAM,gBAAgB,MAAM,WAAW,gBAAgB,OAAO;EAChE;CACF,CAAC;AACH;;;;ACxCA,MAAa,qCAAyE;CACpF,yBAAyB;EACvB,KAAK;EACL,QAAQ;CACV;CACA,2BAA2B;CAC3B,8BAA8B;CAC9B,eAAe;CACf,sBAAsB;AACxB;AAmNA,SAAgB,2BAAkE,SAA6B;CAC7G,OAAO;AACT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { i as useSchemaBuilder, t as schemaBuilderQueryKey } from "./query-r6j8IjQB.js";
|
|
3
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
|
|
5
|
+
//#region src/core/mutation.ts
|
|
6
|
+
function useSchemaBuilderMutation(feature, operation, options = {}) {
|
|
7
|
+
const { adapter, scope, onInvalidate } = useSchemaBuilder();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
const operationFn = adapter[feature][operation];
|
|
10
|
+
if (typeof operationFn !== "function") throw new Error(`SchemaBuilder adapter is missing ${feature}.${operation}`);
|
|
11
|
+
const { selection, ...mutationOptions } = options;
|
|
12
|
+
const hostOnSuccess = mutationOptions.onSuccess;
|
|
13
|
+
return useMutation({
|
|
14
|
+
...mutationOptions,
|
|
15
|
+
mutationFn: (variables) => operationFn(variables, {
|
|
16
|
+
scope,
|
|
17
|
+
selection
|
|
18
|
+
}),
|
|
19
|
+
onSuccess: async (data, variables, onMutateResult, context) => {
|
|
20
|
+
await queryClient.invalidateQueries({ queryKey: schemaBuilderQueryKey(scope, "core", "").slice(0, 4) });
|
|
21
|
+
onInvalidate?.({
|
|
22
|
+
scope,
|
|
23
|
+
feature,
|
|
24
|
+
operation
|
|
25
|
+
});
|
|
26
|
+
await hostOnSuccess?.(data, variables, onMutateResult, context);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/types.ts
|
|
33
|
+
const DEFAULT_SCHEMA_BUILDER_PREFERENCES = {
|
|
34
|
+
sidebarSectionsExpanded: {
|
|
35
|
+
app: true,
|
|
36
|
+
system: false
|
|
37
|
+
},
|
|
38
|
+
showSystemTablesInSidebar: false,
|
|
39
|
+
showSystemTablesInVisualizer: false,
|
|
40
|
+
sidebarPinned: false,
|
|
41
|
+
typesLibraryExpanded: true
|
|
42
|
+
};
|
|
43
|
+
function defineSchemaBuilderAdapter(adapter) {
|
|
44
|
+
return adapter;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { defineSchemaBuilderAdapter as n, useSchemaBuilderMutation as r, DEFAULT_SCHEMA_BUILDER_PREFERENCES as t };
|
|
49
|
+
//# sourceMappingURL=core-DJ5kA4r-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-DJ5kA4r-.js","names":[],"sources":["../src/core/mutation.ts","../src/types.ts"],"mappings":";;;;;AA8BA,SAAgB,yBAKd,SACA,WACA,UAA2D,CAAC,GACf;CAC7C,MAAM,EAAE,SAAS,OAAO,iBAAiB,iBAAiB;CAC1D,MAAM,cAAc,eAAe;CAEnC,MAAM,cADa,QAAQ,QACG,CAAC;CAE/B,IAAI,OAAO,gBAAgB,YACzB,MAAM,IAAI,MAAM,oCAAoC,QAAQ,GAAG,WAAW;CAG5E,MAAM,EAAE,WAAW,GAAG,oBAAoB;CAC1C,MAAM,gBAAgB,gBAAgB;CAEtC,OAAO,YAAY;EACjB,GAAG;EACH,aAAa,cACX,YAAY,WAAW;GAAE;GAAO;EAAU,CAAC;EAC7C,WAAW,OAAO,MAAM,WAAW,gBAAgB,YAAY;GAC7D,MAAM,YAAY,kBAAkB,EAClC,UAAU,sBAAsB,OAAO,QAAQ,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAC/D,CAAC;GACD,eAAe;IAAE;IAAO;IAAS;GAAU,CAAC;GAC5C,MAAM,gBAAgB,MAAM,WAAW,gBAAgB,OAAO;EAChE;CACF,CAAC;AACH;;;;ACxCA,MAAa,qCAAyE;CACpF,yBAAyB;EACvB,KAAK;EACL,QAAQ;CACV;CACA,2BAA2B;CAC3B,8BAA8B;CAC9B,eAAe;CACf,sBAAsB;AACxB;AAmNA,SAAgB,2BAAkE,SAA6B;CAC7G,OAAO;AACT"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,213 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
selectedTableId,
|
|
17
|
-
selectedFieldId: null,
|
|
18
|
-
currentDatabaseApi: null,
|
|
19
|
-
preferences,
|
|
20
|
-
activeTab,
|
|
21
|
-
setSelectedTableId: (selectedTableId2) => set({
|
|
22
|
-
selectedTableId: selectedTableId2,
|
|
23
|
-
selectedFieldId: selectedTableId2 === get().selectedTableId ? get().selectedFieldId : null
|
|
24
|
-
}),
|
|
25
|
-
setSelectedFieldId: (selectedFieldId) => set({ selectedFieldId }),
|
|
26
|
-
setCurrentDatabaseApi: (currentDatabaseApi) => set({ currentDatabaseApi }),
|
|
27
|
-
replacePreferences: (nextPreferences) => set({ preferences: nextPreferences }),
|
|
28
|
-
replaceActiveTab: (nextActiveTab) => set({ activeTab: nextActiveTab }),
|
|
29
|
-
replaceScope: (nextScope) => {
|
|
30
|
-
const nextScopeKey = getSchemaBuilderScopeKey(nextScope);
|
|
31
|
-
if (nextScopeKey === get().scopeKey) return;
|
|
32
|
-
set({
|
|
33
|
-
scopeKey: nextScopeKey,
|
|
34
|
-
selectedTableId: null,
|
|
35
|
-
selectedFieldId: null,
|
|
36
|
-
currentDatabaseApi: null
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
var CORE_TAB_IDS = /* @__PURE__ */ new Set(["editor", "relationships", "indexes", "security"]);
|
|
42
|
-
var EMPTY_TABS = [];
|
|
43
|
-
var SchemaBuilderContext = react.createContext(null);
|
|
44
|
-
function validateExtensionTabs(tabs) {
|
|
45
|
-
const seen = new Set(CORE_TAB_IDS);
|
|
46
|
-
for (const tab of tabs) {
|
|
47
|
-
if (!tab.id.trim()) throw new Error("SchemaBuilder extension tab ids cannot be empty");
|
|
48
|
-
if (seen.has(tab.id)) {
|
|
49
|
-
throw new Error(`Duplicate SchemaBuilder tab id: ${tab.id}`);
|
|
50
|
-
}
|
|
51
|
-
seen.add(tab.id);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function SchemaBuilderProvider({
|
|
55
|
-
children,
|
|
56
|
-
tabs = EMPTY_TABS,
|
|
57
|
-
...host
|
|
58
|
-
}) {
|
|
59
|
-
const [store] = react.useState(
|
|
60
|
-
() => createSchemaBuilderStore(
|
|
61
|
-
host.scope,
|
|
62
|
-
host.preferences,
|
|
63
|
-
host.activeTab,
|
|
64
|
-
host.selectedTableId ?? null
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
const validatedTabs = react.useMemo(() => {
|
|
68
|
-
validateExtensionTabs(tabs);
|
|
69
|
-
return tabs;
|
|
70
|
-
}, [tabs]);
|
|
71
|
-
react.useEffect(() => {
|
|
72
|
-
store.getState().replaceScope(host.scope);
|
|
73
|
-
}, [host.scope, store]);
|
|
74
|
-
react.useEffect(() => {
|
|
75
|
-
store.getState().replacePreferences(host.preferences);
|
|
76
|
-
}, [host.preferences, store]);
|
|
77
|
-
react.useEffect(() => {
|
|
78
|
-
store.getState().replaceActiveTab(host.activeTab);
|
|
79
|
-
}, [host.activeTab, store]);
|
|
80
|
-
react.useEffect(() => {
|
|
81
|
-
if (host.selectedTableId !== void 0) {
|
|
82
|
-
store.getState().setSelectedTableId(host.selectedTableId);
|
|
83
|
-
}
|
|
84
|
-
}, [host.scope, host.selectedTableId, store]);
|
|
85
|
-
const setActiveTab = react.useCallback(
|
|
86
|
-
(tabId) => {
|
|
87
|
-
const extension = validatedTabs.find((tab) => tab.id === tabId);
|
|
88
|
-
if (!CORE_TAB_IDS.has(tabId) && !extension) {
|
|
89
|
-
throw new Error(`Unknown SchemaBuilder tab id: ${tabId}`);
|
|
90
|
-
}
|
|
91
|
-
void extension?.preload?.();
|
|
92
|
-
store.getState().replaceActiveTab(tabId);
|
|
93
|
-
host.onActiveTabChange(tabId);
|
|
94
|
-
},
|
|
95
|
-
[host.onActiveTabChange, store, validatedTabs]
|
|
96
|
-
);
|
|
97
|
-
const setPreferences = react.useCallback(
|
|
98
|
-
(update) => {
|
|
99
|
-
const current = store.getState().preferences;
|
|
100
|
-
const next = typeof update === "function" ? update(current) : update;
|
|
101
|
-
store.getState().replacePreferences(next);
|
|
102
|
-
host.onPreferencesChange(next);
|
|
103
|
-
},
|
|
104
|
-
[host.onPreferencesChange, store]
|
|
105
|
-
);
|
|
106
|
-
const selectTable = react.useCallback(
|
|
107
|
-
(tableId, tableName) => {
|
|
108
|
-
store.getState().setSelectedTableId(tableId);
|
|
109
|
-
host.onSelectedTableChange?.({ tableId, tableName: tableName ?? null });
|
|
110
|
-
},
|
|
111
|
-
[host.onSelectedTableChange, store]
|
|
112
|
-
);
|
|
113
|
-
const selectField = react.useCallback(
|
|
114
|
-
(fieldId) => store.getState().setSelectedFieldId(fieldId),
|
|
115
|
-
[store]
|
|
116
|
-
);
|
|
117
|
-
const value = react.useMemo(
|
|
118
|
-
() => ({
|
|
119
|
-
...host,
|
|
120
|
-
tabs: validatedTabs,
|
|
121
|
-
store,
|
|
122
|
-
setActiveTab,
|
|
123
|
-
setPreferences,
|
|
124
|
-
selectTable,
|
|
125
|
-
selectField
|
|
126
|
-
}),
|
|
127
|
-
[host, selectField, selectTable, setActiveTab, setPreferences, store, validatedTabs]
|
|
128
|
-
);
|
|
129
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SchemaBuilderContext.Provider, { value, children });
|
|
130
|
-
}
|
|
131
|
-
function useSchemaBuilder() {
|
|
132
|
-
const value = react.useContext(SchemaBuilderContext);
|
|
133
|
-
if (!value) throw new Error("SchemaBuilderProvider is missing");
|
|
134
|
-
return value;
|
|
135
|
-
}
|
|
136
|
-
function useSchemaBuilderStore(selector) {
|
|
137
|
-
const { store } = useSchemaBuilder();
|
|
138
|
-
return zustand.useStore(store, selector);
|
|
139
|
-
}
|
|
140
|
-
function schemaBuilderQueryKey(scope, feature, operation, variables = {}) {
|
|
141
|
-
return [
|
|
142
|
-
"@constructive-io/schema-builder",
|
|
143
|
-
scope.orgId,
|
|
144
|
-
scope.databaseId,
|
|
145
|
-
scope.userId ?? null,
|
|
146
|
-
feature,
|
|
147
|
-
operation,
|
|
148
|
-
variables
|
|
149
|
-
];
|
|
150
|
-
}
|
|
151
|
-
function useSchemaBuilderQuery(feature, operation, variables = {}, options = {}) {
|
|
152
|
-
const { adapter, scope } = useSchemaBuilder();
|
|
153
|
-
const capability = adapter[feature];
|
|
154
|
-
const operationFn = capability[operation];
|
|
155
|
-
if (typeof operationFn !== "function") {
|
|
156
|
-
throw new Error(`SchemaBuilder adapter is missing ${feature}.${operation}`);
|
|
157
|
-
}
|
|
158
|
-
return reactQuery.useQuery({
|
|
159
|
-
...options,
|
|
160
|
-
queryKey: schemaBuilderQueryKey(scope, feature, operation, variables),
|
|
161
|
-
queryFn: ({ signal }) => operationFn(variables, { scope, signal })
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
function useSchemaBuilderMutation(feature, operation, options = {}) {
|
|
165
|
-
const { adapter, scope, onInvalidate } = useSchemaBuilder();
|
|
166
|
-
const queryClient = reactQuery.useQueryClient();
|
|
167
|
-
const capability = adapter[feature];
|
|
168
|
-
const operationFn = capability[operation];
|
|
169
|
-
if (typeof operationFn !== "function") {
|
|
170
|
-
throw new Error(`SchemaBuilder adapter is missing ${feature}.${operation}`);
|
|
171
|
-
}
|
|
172
|
-
const { selection, ...mutationOptions } = options;
|
|
173
|
-
const hostOnSuccess = mutationOptions.onSuccess;
|
|
174
|
-
return reactQuery.useMutation({
|
|
175
|
-
...mutationOptions,
|
|
176
|
-
mutationFn: (variables) => operationFn(variables, { scope, selection }),
|
|
177
|
-
onSuccess: async (data, variables, onMutateResult, context) => {
|
|
178
|
-
await queryClient.invalidateQueries({
|
|
179
|
-
queryKey: schemaBuilderQueryKey(scope, "core", "").slice(0, 4)
|
|
180
|
-
});
|
|
181
|
-
onInvalidate?.({ scope, feature, operation });
|
|
182
|
-
await hostOnSuccess?.(data, variables, onMutateResult, context);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// src/types.ts
|
|
188
|
-
var DEFAULT_SCHEMA_BUILDER_PREFERENCES = {
|
|
189
|
-
sidebarSectionsExpanded: {
|
|
190
|
-
app: true,
|
|
191
|
-
system: false
|
|
192
|
-
},
|
|
193
|
-
showSystemTablesInSidebar: false,
|
|
194
|
-
showSystemTablesInVisualizer: false,
|
|
195
|
-
sidebarPinned: false,
|
|
196
|
-
typesLibraryExpanded: true
|
|
197
|
-
};
|
|
198
|
-
function defineSchemaBuilderAdapter(adapter) {
|
|
199
|
-
return adapter;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
exports.DEFAULT_SCHEMA_BUILDER_PREFERENCES = DEFAULT_SCHEMA_BUILDER_PREFERENCES;
|
|
203
|
-
exports.SchemaBuilderProvider = SchemaBuilderProvider;
|
|
204
|
-
exports.createSchemaBuilderStore = createSchemaBuilderStore;
|
|
205
|
-
exports.defineSchemaBuilderAdapter = defineSchemaBuilderAdapter;
|
|
206
|
-
exports.getSchemaBuilderScopeKey = getSchemaBuilderScopeKey;
|
|
207
|
-
exports.schemaBuilderQueryKey = schemaBuilderQueryKey;
|
|
208
|
-
exports.useSchemaBuilder = useSchemaBuilder;
|
|
209
|
-
exports.useSchemaBuilderMutation = useSchemaBuilderMutation;
|
|
210
|
-
exports.useSchemaBuilderQuery = useSchemaBuilderQuery;
|
|
211
|
-
exports.useSchemaBuilderStore = useSchemaBuilderStore;
|
|
212
|
-
//# sourceMappingURL=core.cjs.map
|
|
213
|
-
//# sourceMappingURL=core.cjs.map
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_query = require('./query-BGtzUV7Y.cjs');
|
|
4
|
+
const require_core = require('./core-CVxnNLs7.cjs');
|
|
5
|
+
|
|
6
|
+
exports.DEFAULT_SCHEMA_BUILDER_PREFERENCES = require_core.DEFAULT_SCHEMA_BUILDER_PREFERENCES;
|
|
7
|
+
exports.SchemaBuilderProvider = require_query.SchemaBuilderProvider;
|
|
8
|
+
exports.createSchemaBuilderStore = require_query.createSchemaBuilderStore;
|
|
9
|
+
exports.defineSchemaBuilderAdapter = require_core.defineSchemaBuilderAdapter;
|
|
10
|
+
exports.getSchemaBuilderScopeKey = require_query.getSchemaBuilderScopeKey;
|
|
11
|
+
exports.schemaBuilderQueryKey = require_query.schemaBuilderQueryKey;
|
|
12
|
+
exports.useSchemaBuilder = require_query.useSchemaBuilder;
|
|
13
|
+
exports.useSchemaBuilderMutation = require_core.useSchemaBuilderMutation;
|
|
14
|
+
exports.useSchemaBuilderQuery = require_query.useSchemaBuilderQuery;
|
|
15
|
+
exports.useSchemaBuilderStore = require_query.useSchemaBuilderStore;
|
package/dist/core.d.cts
CHANGED
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { r as SchemaBuilderPreferences, v as SchemaBuilderScope, i as SchemaBuilderHostOptions, f as SchemaBuilderFeature, C as SchemaBuilderVariables, a as SchemaBuilderAdapter, o as SchemaBuilderOperationContext } from './types-Du86atZ8.cjs';
|
|
5
|
-
export { D as DEFAULT_SCHEMA_BUILDER_PREFERENCES, b as SchemaBuilderCollection, c as SchemaBuilderColorMode, d as SchemaBuilderCoreCapabilities, e as SchemaBuilderCoreTabId, g as SchemaBuilderField, j as SchemaBuilderIndex, l as SchemaBuilderInvalidationEvent, m as SchemaBuilderNavigationTarget, n as SchemaBuilderOperation, q as SchemaBuilderPolicy, s as SchemaBuilderRelationship, u as SchemaBuilderSchema, w as SchemaBuilderSidebarSections, x as SchemaBuilderTab, y as SchemaBuilderTabRenderContext, z as SchemaBuilderTable, E as defineSchemaBuilderAdapter } from './types-Du86atZ8.cjs';
|
|
6
|
-
import { UseQueryOptions, UseQueryResult, UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
7
|
-
|
|
8
|
-
interface SchemaBuilderStoreState {
|
|
9
|
-
scopeKey: string;
|
|
10
|
-
selectedTableId: string | null;
|
|
11
|
-
selectedFieldId: string | null;
|
|
12
|
-
currentDatabaseApi: unknown | null;
|
|
13
|
-
preferences: SchemaBuilderPreferences;
|
|
14
|
-
activeTab: string;
|
|
15
|
-
setSelectedTableId: (tableId: string | null) => void;
|
|
16
|
-
setSelectedFieldId: (fieldId: string | null) => void;
|
|
17
|
-
setCurrentDatabaseApi: (api: unknown | null) => void;
|
|
18
|
-
replacePreferences: (preferences: SchemaBuilderPreferences) => void;
|
|
19
|
-
replaceActiveTab: (tabId: string) => void;
|
|
20
|
-
replaceScope: (scope: SchemaBuilderScope) => void;
|
|
21
|
-
}
|
|
22
|
-
declare function getSchemaBuilderScopeKey(scope: SchemaBuilderScope): string;
|
|
23
|
-
declare function createSchemaBuilderStore(scope: SchemaBuilderScope, preferences: SchemaBuilderPreferences, activeTab: string, selectedTableId?: string | null): StoreApi<SchemaBuilderStoreState>;
|
|
24
|
-
|
|
25
|
-
interface SchemaBuilderContextValue extends SchemaBuilderHostOptions {
|
|
26
|
-
store: StoreApi<SchemaBuilderStoreState>;
|
|
27
|
-
setActiveTab: (tabId: string) => void;
|
|
28
|
-
setPreferences: (preferences: SchemaBuilderPreferences | ((current: SchemaBuilderPreferences) => SchemaBuilderPreferences)) => void;
|
|
29
|
-
selectTable: (tableId: string | null, tableName?: string | null) => void;
|
|
30
|
-
selectField: (fieldId: string | null) => void;
|
|
31
|
-
}
|
|
32
|
-
interface SchemaBuilderProviderProps extends SchemaBuilderHostOptions {
|
|
33
|
-
children: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
declare function SchemaBuilderProvider({ children, tabs, ...host }: SchemaBuilderProviderProps): react.JSX.Element;
|
|
36
|
-
declare function useSchemaBuilder(): SchemaBuilderContextValue;
|
|
37
|
-
declare function useSchemaBuilderStore<T>(selector: (state: SchemaBuilderStoreState) => T): T;
|
|
38
|
-
|
|
39
|
-
type FeatureOperation$1<TFeature extends SchemaBuilderFeature> = Extract<keyof SchemaBuilderAdapter[TFeature], string>;
|
|
40
|
-
declare function schemaBuilderQueryKey(scope: {
|
|
41
|
-
orgId: string;
|
|
42
|
-
databaseId: string;
|
|
43
|
-
userId?: string | null;
|
|
44
|
-
}, feature: SchemaBuilderFeature, operation: string, variables?: SchemaBuilderVariables): readonly ["@constructive-io/schema-builder", string, string, string | null, keyof SchemaBuilderAdapter, string, object];
|
|
45
|
-
declare function useSchemaBuilderQuery<TData = unknown, TFeature extends SchemaBuilderFeature = SchemaBuilderFeature>(feature: TFeature, operation: FeatureOperation$1<TFeature>, variables?: SchemaBuilderVariables, options?: Omit<UseQueryOptions<TData, Error, TData, ReturnType<typeof schemaBuilderQueryKey>>, 'queryKey' | 'queryFn'>): UseQueryResult<TData, Error>;
|
|
46
|
-
|
|
47
|
-
type FeatureOperation<TFeature extends SchemaBuilderFeature> = Extract<keyof SchemaBuilderAdapter[TFeature], string>;
|
|
48
|
-
type SchemaBuilderMutationOptions<TData, TVariables, TContext = unknown> = UseMutationOptions<TData, Error, TVariables, TContext> & {
|
|
49
|
-
/** Result fields required by generated GraphQL adapters for this mutation. */
|
|
50
|
-
selection?: SchemaBuilderOperationContext['selection'];
|
|
51
|
-
};
|
|
52
|
-
declare function useSchemaBuilderMutation<TData = unknown, TVariables extends SchemaBuilderVariables = SchemaBuilderVariables, TFeature extends SchemaBuilderFeature = SchemaBuilderFeature>(feature: TFeature, operation: FeatureOperation<TFeature>, options?: SchemaBuilderMutationOptions<TData, TVariables>): UseMutationResult<TData, Error, TVariables>;
|
|
53
|
-
|
|
54
|
-
export { SchemaBuilderAdapter, type SchemaBuilderContextValue, SchemaBuilderFeature, SchemaBuilderHostOptions, type SchemaBuilderMutationOptions, SchemaBuilderOperationContext, SchemaBuilderPreferences, SchemaBuilderProvider, type SchemaBuilderProviderProps, SchemaBuilderScope, type SchemaBuilderStoreState, SchemaBuilderVariables, createSchemaBuilderStore, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
|
|
1
|
+
import { C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, O as SchemaBuilderTable, T as SchemaBuilderSidebarSections, a as SchemaBuilderCoreCapabilities, c as SchemaBuilderField, d as SchemaBuilderIndex, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, 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
|
+
export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPolicy, type SchemaBuilderPreferences, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { r as SchemaBuilderPreferences, v as SchemaBuilderScope, i as SchemaBuilderHostOptions, f as SchemaBuilderFeature, C as SchemaBuilderVariables, a as SchemaBuilderAdapter, o as SchemaBuilderOperationContext } from './types-Du86atZ8.js';
|
|
5
|
-
export { D as DEFAULT_SCHEMA_BUILDER_PREFERENCES, b as SchemaBuilderCollection, c as SchemaBuilderColorMode, d as SchemaBuilderCoreCapabilities, e as SchemaBuilderCoreTabId, g as SchemaBuilderField, j as SchemaBuilderIndex, l as SchemaBuilderInvalidationEvent, m as SchemaBuilderNavigationTarget, n as SchemaBuilderOperation, q as SchemaBuilderPolicy, s as SchemaBuilderRelationship, u as SchemaBuilderSchema, w as SchemaBuilderSidebarSections, x as SchemaBuilderTab, y as SchemaBuilderTabRenderContext, z as SchemaBuilderTable, E as defineSchemaBuilderAdapter } from './types-Du86atZ8.js';
|
|
6
|
-
import { UseQueryOptions, UseQueryResult, UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
7
|
-
|
|
8
|
-
interface SchemaBuilderStoreState {
|
|
9
|
-
scopeKey: string;
|
|
10
|
-
selectedTableId: string | null;
|
|
11
|
-
selectedFieldId: string | null;
|
|
12
|
-
currentDatabaseApi: unknown | null;
|
|
13
|
-
preferences: SchemaBuilderPreferences;
|
|
14
|
-
activeTab: string;
|
|
15
|
-
setSelectedTableId: (tableId: string | null) => void;
|
|
16
|
-
setSelectedFieldId: (fieldId: string | null) => void;
|
|
17
|
-
setCurrentDatabaseApi: (api: unknown | null) => void;
|
|
18
|
-
replacePreferences: (preferences: SchemaBuilderPreferences) => void;
|
|
19
|
-
replaceActiveTab: (tabId: string) => void;
|
|
20
|
-
replaceScope: (scope: SchemaBuilderScope) => void;
|
|
21
|
-
}
|
|
22
|
-
declare function getSchemaBuilderScopeKey(scope: SchemaBuilderScope): string;
|
|
23
|
-
declare function createSchemaBuilderStore(scope: SchemaBuilderScope, preferences: SchemaBuilderPreferences, activeTab: string, selectedTableId?: string | null): StoreApi<SchemaBuilderStoreState>;
|
|
24
|
-
|
|
25
|
-
interface SchemaBuilderContextValue extends SchemaBuilderHostOptions {
|
|
26
|
-
store: StoreApi<SchemaBuilderStoreState>;
|
|
27
|
-
setActiveTab: (tabId: string) => void;
|
|
28
|
-
setPreferences: (preferences: SchemaBuilderPreferences | ((current: SchemaBuilderPreferences) => SchemaBuilderPreferences)) => void;
|
|
29
|
-
selectTable: (tableId: string | null, tableName?: string | null) => void;
|
|
30
|
-
selectField: (fieldId: string | null) => void;
|
|
31
|
-
}
|
|
32
|
-
interface SchemaBuilderProviderProps extends SchemaBuilderHostOptions {
|
|
33
|
-
children: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
declare function SchemaBuilderProvider({ children, tabs, ...host }: SchemaBuilderProviderProps): react.JSX.Element;
|
|
36
|
-
declare function useSchemaBuilder(): SchemaBuilderContextValue;
|
|
37
|
-
declare function useSchemaBuilderStore<T>(selector: (state: SchemaBuilderStoreState) => T): T;
|
|
38
|
-
|
|
39
|
-
type FeatureOperation$1<TFeature extends SchemaBuilderFeature> = Extract<keyof SchemaBuilderAdapter[TFeature], string>;
|
|
40
|
-
declare function schemaBuilderQueryKey(scope: {
|
|
41
|
-
orgId: string;
|
|
42
|
-
databaseId: string;
|
|
43
|
-
userId?: string | null;
|
|
44
|
-
}, feature: SchemaBuilderFeature, operation: string, variables?: SchemaBuilderVariables): readonly ["@constructive-io/schema-builder", string, string, string | null, keyof SchemaBuilderAdapter, string, object];
|
|
45
|
-
declare function useSchemaBuilderQuery<TData = unknown, TFeature extends SchemaBuilderFeature = SchemaBuilderFeature>(feature: TFeature, operation: FeatureOperation$1<TFeature>, variables?: SchemaBuilderVariables, options?: Omit<UseQueryOptions<TData, Error, TData, ReturnType<typeof schemaBuilderQueryKey>>, 'queryKey' | 'queryFn'>): UseQueryResult<TData, Error>;
|
|
46
|
-
|
|
47
|
-
type FeatureOperation<TFeature extends SchemaBuilderFeature> = Extract<keyof SchemaBuilderAdapter[TFeature], string>;
|
|
48
|
-
type SchemaBuilderMutationOptions<TData, TVariables, TContext = unknown> = UseMutationOptions<TData, Error, TVariables, TContext> & {
|
|
49
|
-
/** Result fields required by generated GraphQL adapters for this mutation. */
|
|
50
|
-
selection?: SchemaBuilderOperationContext['selection'];
|
|
51
|
-
};
|
|
52
|
-
declare function useSchemaBuilderMutation<TData = unknown, TVariables extends SchemaBuilderVariables = SchemaBuilderVariables, TFeature extends SchemaBuilderFeature = SchemaBuilderFeature>(feature: TFeature, operation: FeatureOperation<TFeature>, options?: SchemaBuilderMutationOptions<TData, TVariables>): UseMutationResult<TData, Error, TVariables>;
|
|
53
|
-
|
|
54
|
-
export { SchemaBuilderAdapter, type SchemaBuilderContextValue, SchemaBuilderFeature, SchemaBuilderHostOptions, type SchemaBuilderMutationOptions, SchemaBuilderOperationContext, SchemaBuilderPreferences, SchemaBuilderProvider, type SchemaBuilderProviderProps, SchemaBuilderScope, type SchemaBuilderStoreState, SchemaBuilderVariables, createSchemaBuilderStore, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
|
|
1
|
+
import { C as SchemaBuilderSchema, D as SchemaBuilderTabRenderContext, E as SchemaBuilderTab, M as defineSchemaBuilderAdapter, O as SchemaBuilderTable, T as SchemaBuilderSidebarSections, a as SchemaBuilderCoreCapabilities, c as SchemaBuilderField, d as SchemaBuilderIndex, g as SchemaBuilderOperationContext, h as SchemaBuilderOperation, i as SchemaBuilderColorMode, j as SchemaBuilderVariables, 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
|
+
export { DEFAULT_SCHEMA_BUILDER_PREFERENCES, type SchemaBuilderAdapter, type SchemaBuilderCollection, type SchemaBuilderColorMode, type SchemaBuilderContextValue, type SchemaBuilderCoreCapabilities, type SchemaBuilderCoreTabId, type SchemaBuilderFeature, type SchemaBuilderField, type SchemaBuilderHostOptions, type SchemaBuilderIndex, type SchemaBuilderInvalidationEvent, type SchemaBuilderMutationOptions, type SchemaBuilderNavigationTarget, type SchemaBuilderOperation, type SchemaBuilderOperationContext, type SchemaBuilderPolicy, type SchemaBuilderPreferences, SchemaBuilderProvider, type SchemaBuilderProviderProps, type SchemaBuilderRelationship, type SchemaBuilderSchema, type SchemaBuilderScope, type SchemaBuilderSidebarSections, type SchemaBuilderStoreState, type SchemaBuilderTab, type SchemaBuilderTabRenderContext, type SchemaBuilderTable, type SchemaBuilderVariables, createSchemaBuilderStore, defineSchemaBuilderAdapter, getSchemaBuilderScopeKey, schemaBuilderQueryKey, useSchemaBuilder, useSchemaBuilderMutation, useSchemaBuilderQuery, useSchemaBuilderStore };
|