@rebasepro/studio 0.35.1 → 0.36.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/README.md +1 -1
- package/dist/{ApiExplorer-C61w8gCc.js → ApiExplorer-BVQHAjHB.js} +3 -2
- package/dist/{ApiExplorer-C61w8gCc.js.map → ApiExplorer-BVQHAjHB.js.map} +1 -1
- package/dist/{useRunAsUsers-CF7tkGzj.js → AuthSimulationSelector-XogpkeXC.js} +4 -68
- package/dist/AuthSimulationSelector-XogpkeXC.js.map +1 -0
- package/dist/{CronJobsView-DUuyzkJK.js → CronJobsView-DyX9MINh.js} +2 -2
- package/dist/{CronJobsView-DUuyzkJK.js.map → CronJobsView-DyX9MINh.js.map} +1 -1
- package/dist/DatabaseView-Bi0NZS90.js +1897 -0
- package/dist/DatabaseView-Bi0NZS90.js.map +1 -0
- package/dist/{JSEditor-Bi2Aol-Y.js → JSEditor-B4Lazm-z.js} +4 -3
- package/dist/{JSEditor-Bi2Aol-Y.js.map → JSEditor-B4Lazm-z.js.map} +1 -1
- package/dist/RLSEditor-CcHkWFNg.js +973 -0
- package/dist/RLSEditor-CcHkWFNg.js.map +1 -0
- package/dist/{SQLEditor-DRo5kW1h.js → SQLEditorRoute-f5j_ZKdj.js} +1472 -320
- package/dist/SQLEditorRoute-f5j_ZKdj.js.map +1 -0
- package/dist/SchemaDiagramView-CckQobIZ.js +98 -0
- package/dist/SchemaDiagramView-CckQobIZ.js.map +1 -0
- package/dist/{StorageView-D0D8z4lI.js → StorageView-B7QHjEGY.js} +2 -2
- package/dist/{StorageView-D0D8z4lI.js.map → StorageView-B7QHjEGY.js.map} +1 -1
- package/dist/TableEditorView-BRZNvD6U.js +3615 -0
- package/dist/TableEditorView-BRZNvD6U.js.map +1 -0
- package/dist/TablePolicies-C1-tbC8x.js +1740 -0
- package/dist/TablePolicies-C1-tbC8x.js.map +1 -0
- package/dist/{SchemaVisualizer-Dy4kWKT5.js → TablesDiagram-RTJfwVEN.js} +651 -489
- package/dist/TablesDiagram-RTJfwVEN.js.map +1 -0
- package/dist/{UsersAndRolesView-CKw4SJPj.js → UsersAndRolesView-Cx6xtMVH.js} +2 -2
- package/dist/{UsersAndRolesView-CKw4SJPj.js.map → UsersAndRolesView-Cx6xtMVH.js.map} +1 -1
- package/dist/{WebhooksView-CFPY-N9h.js → WebhooksView-Bn9KB7xG.js} +2 -2
- package/dist/{WebhooksView-CFPY-N9h.js.map → WebhooksView-Bn9KB7xG.js.map} +1 -1
- package/dist/{adminFetch-BfOnfRgU.js → adminFetch-C7Ra8rpP.js} +26 -1
- package/dist/{adminFetch-BfOnfRgU.js.map → adminFetch-C7Ra8rpP.js.map} +1 -1
- package/dist/components/Database/ActivitySection.d.ts +9 -0
- package/dist/components/Database/AdvisorsSection.d.ts +17 -0
- package/dist/components/Database/DatabaseView.d.ts +13 -0
- package/dist/components/Database/ExtensionsSection.d.ts +2 -0
- package/dist/components/Database/FunctionsSection.d.ts +2 -0
- package/dist/components/Database/QueriesSection.d.ts +3 -0
- package/dist/components/Database/TriggersSection.d.ts +2 -0
- package/dist/components/Database/TypesSection.d.ts +2 -0
- package/dist/components/Database/format.d.ts +6 -0
- package/dist/components/Database/links.d.ts +11 -0
- package/dist/components/Database/shared.d.ts +35 -0
- package/dist/components/Database/source.d.ts +12 -0
- package/dist/components/Database/useCatalogList.d.ts +13 -0
- package/dist/components/RLSEditor/RLSEditor.d.ts +2 -0
- package/dist/components/RLSEditor/TablePolicies.d.ts +54 -0
- package/dist/components/SQLEditor/ExplainVisualizer.d.ts +8 -20
- package/dist/components/SQLEditor/ResultChart.d.ts +18 -0
- package/dist/components/SQLEditor/SQLEditor.d.ts +13 -1
- package/dist/components/SQLEditor/SQLEditorRoute.d.ts +13 -0
- package/dist/components/SQLEditor/SQLEditorSidebar.d.ts +7 -1
- package/dist/components/SQLEditor/SqlParamsPanel.d.ts +16 -0
- package/dist/components/SQLEditor/useSqlSnippets.d.ts +47 -0
- package/dist/components/SchemaVisualizer/SchemaDiagramView.d.ts +12 -0
- package/dist/components/SchemaVisualizer/TablesDiagram.d.ts +23 -0
- package/dist/components/SchemaVisualizer/useSchemaGraph.d.ts +32 -1
- package/dist/components/TableEditor/CreateTableDialog.d.ts +8 -0
- package/dist/components/TableEditor/DdlConfirm.d.ts +23 -0
- package/dist/components/TableEditor/SqlBlock.d.ts +7 -0
- package/dist/components/TableEditor/TableDdlSheet.d.ts +9 -0
- package/dist/components/TableEditor/TableEditorView.d.ts +7 -0
- package/dist/components/TableEditor/tableModel.d.ts +210 -0
- package/dist/components/TableEditor/tabs/DataTab.d.ts +12 -0
- package/dist/components/TableEditor/tabs/PoliciesTab.d.ts +8 -0
- package/dist/components/TableEditor/tabs/RelationsTab.d.ts +8 -0
- package/dist/components/TableEditor/tabs/SettingsTab.d.ts +11 -0
- package/dist/components/TableEditor/tabs/StatsTab.d.ts +8 -0
- package/dist/components/TableEditor/tabs/StructureTab.d.ts +12 -0
- package/dist/index.es.js +29 -15
- package/dist/index.es.js.map +1 -1
- package/dist/{sql_utils-CYcgpgam.js → sql_utils-DkMYltfq.js} +27 -3
- package/dist/sql_utils-DkMYltfq.js.map +1 -0
- package/dist/useRunAsUsers-GPFCxcBC.js +69 -0
- package/dist/useRunAsUsers-GPFCxcBC.js.map +1 -0
- package/dist/utils/adminFetch.d.ts +1 -0
- package/dist/utils/csv_parse.d.ts +11 -0
- package/dist/utils/explain_plan.d.ts +70 -0
- package/dist/utils/sql_params.d.ts +51 -0
- package/dist/utils/sql_utils.d.ts +16 -0
- package/package.json +11 -9
- package/dist/RLSEditor-CTG3jLE7.js +0 -2572
- package/dist/RLSEditor-CTG3jLE7.js.map +0 -1
- package/dist/SQLEditor-DRo5kW1h.js.map +0 -1
- package/dist/SchemaVisualizer-Dy4kWKT5.js.map +0 -1
- package/dist/TableEditorView-BKhSBG-K.js +0 -1694
- package/dist/TableEditorView-BKhSBG-K.js.map +0 -1
- package/dist/components/SchemaVisualizer/SchemaVisualizer.d.ts +0 -3
- package/dist/policy-presets-CJKzAvQp.js +0 -167
- package/dist/policy-presets-CJKzAvQp.js.map +0 -1
- package/dist/sql_utils-CYcgpgam.js.map +0 -1
- package/dist/useRunAsUsers-CF7tkGzj.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Snippet, SnippetVisibility } from "./SQLEditorSidebar.js";
|
|
2
|
+
/**
|
|
3
|
+
* Where saved snippets live when the project keeps them: the server's
|
|
4
|
+
* `/api/admin/sql/snippets`. Handed to the console by its route, which knows
|
|
5
|
+
* how to reach the server; without it, snippets stay in this browser.
|
|
6
|
+
*/
|
|
7
|
+
export interface SqlSnippetRemote {
|
|
8
|
+
list(): Promise<Snippet[]>;
|
|
9
|
+
create(input: {
|
|
10
|
+
name: string;
|
|
11
|
+
sql: string;
|
|
12
|
+
visibility: SnippetVisibility;
|
|
13
|
+
favorite: boolean;
|
|
14
|
+
}): Promise<Snippet>;
|
|
15
|
+
update(id: string, patch: {
|
|
16
|
+
name?: string;
|
|
17
|
+
sql?: string;
|
|
18
|
+
visibility?: SnippetVisibility;
|
|
19
|
+
favorite?: boolean;
|
|
20
|
+
}): Promise<Snippet>;
|
|
21
|
+
remove(id: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `server`: the project keeps the snippets. `local`: this browser does,
|
|
25
|
+
* because there is no server store to reach (an older server, a data source
|
|
26
|
+
* without SQL, a role that may not read it). `loading` until that is known.
|
|
27
|
+
*/
|
|
28
|
+
export type SnippetStorage = "loading" | "server" | "local";
|
|
29
|
+
/**
|
|
30
|
+
* The console's saved snippets, from the project's store when it has one.
|
|
31
|
+
*
|
|
32
|
+
* Snippets this browser kept before the project could are uploaded once,
|
|
33
|
+
* each removed from local storage only when the server has confirmed it: an
|
|
34
|
+
* upload cut short leaves the rest local, shown beside the server's and
|
|
35
|
+
* uploaded on the next visit.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useSqlSnippets(projectPrefix: string, remote: SqlSnippetRemote | undefined): {
|
|
38
|
+
snippets: Snippet[];
|
|
39
|
+
storage: SnippetStorage;
|
|
40
|
+
createSnippet: (input: {
|
|
41
|
+
name: string;
|
|
42
|
+
sql: string;
|
|
43
|
+
visibility: SnippetVisibility;
|
|
44
|
+
}) => Promise<void>;
|
|
45
|
+
setFavorite: (id: string, favorite: boolean) => Promise<void>;
|
|
46
|
+
deleteSnippet: (id: string) => Promise<void>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The schema diagram as a page of its own: for a host without the Tables view
|
|
4
|
+
* (the hosted console), and for links to the diagram's own route.
|
|
5
|
+
*
|
|
6
|
+
* The database's catalog is read from `/api/admin/db/tables` when the backend
|
|
7
|
+
* serves it; a backend that does not still gets the diagram of the tables it
|
|
8
|
+
* declares.
|
|
9
|
+
*/
|
|
10
|
+
export declare function SchemaDiagramView({ linksToTables }: {
|
|
11
|
+
linksToTables: boolean;
|
|
12
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "@xyflow/react/dist/style.css";
|
|
3
|
+
import { type CatalogGraphTable } from "./useSchemaGraph.js";
|
|
4
|
+
export interface TablesDiagramProps {
|
|
5
|
+
/** Every table of the schema as the database's catalog reports it. */
|
|
6
|
+
catalog: readonly CatalogGraphTable[];
|
|
7
|
+
/** A table name: drawn with its neighbourhood (always, with `alwaysFocus`; on a large schema otherwise). */
|
|
8
|
+
focusTable?: string | null;
|
|
9
|
+
/** Draw `focusTable`'s neighbourhood whatever the schema's size — the Relations tab. */
|
|
10
|
+
alwaysFocus?: boolean;
|
|
11
|
+
/** A table name to centre the canvas on when it changes — the table list's selection in diagram mode. */
|
|
12
|
+
highlightTable?: string | null;
|
|
13
|
+
/** A table node was clicked. */
|
|
14
|
+
onOpenTable?: (tableName: string) => void;
|
|
15
|
+
/** No minimap: the canvas sits inside a tab, not across the whole view. */
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The schema as a diagram: the tables the server declares — with their
|
|
20
|
+
* many-to-many relations drawn through junctions — and every other table and
|
|
21
|
+
* foreign key the database's catalog holds.
|
|
22
|
+
*/
|
|
23
|
+
export declare function TablesDiagram(props: TablesDiagramProps): React.JSX.Element;
|
|
@@ -34,6 +34,37 @@ export interface TableNodeData {
|
|
|
34
34
|
icon?: string;
|
|
35
35
|
[key: string]: unknown;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A table as the database's catalog reports it (`GET /api/admin/db/tables`):
|
|
39
|
+
* what the diagram draws for a table the server does not serve, and the
|
|
40
|
+
* foreign keys the code never declared.
|
|
41
|
+
*/
|
|
42
|
+
export interface CatalogGraphTable {
|
|
43
|
+
schema: string;
|
|
44
|
+
name: string;
|
|
45
|
+
kind: "table" | "view";
|
|
46
|
+
rlsEnabled: boolean;
|
|
47
|
+
columns: readonly {
|
|
48
|
+
name: string;
|
|
49
|
+
dataType: string;
|
|
50
|
+
nullable: boolean;
|
|
51
|
+
primaryKey: boolean;
|
|
52
|
+
unique: boolean;
|
|
53
|
+
}[];
|
|
54
|
+
foreignKeys: readonly {
|
|
55
|
+
name: string;
|
|
56
|
+
fromColumns: readonly string[];
|
|
57
|
+
toSchema: string;
|
|
58
|
+
toTable: string;
|
|
59
|
+
toColumns: readonly string[];
|
|
60
|
+
}[];
|
|
61
|
+
}
|
|
62
|
+
export interface SchemaGraphOptions {
|
|
63
|
+
/** The live catalog: its undeclared tables are drawn as unmanaged nodes and its foreign keys as relations. */
|
|
64
|
+
catalog?: readonly CatalogGraphTable[];
|
|
65
|
+
/** Draw `focus`'s neighbourhood whatever the schema's size (the table inspector's Relations tab). */
|
|
66
|
+
alwaysFocus?: boolean;
|
|
67
|
+
}
|
|
37
68
|
/**
|
|
38
69
|
* Above this many tables the diagram draws one table's neighbourhood, not
|
|
39
70
|
* the whole schema. Laying out 300 cross-linked tables takes dagre several
|
|
@@ -83,4 +114,4 @@ liveRls?: Set<string> | null,
|
|
|
83
114
|
* read for a schema of {@link LARGE_SCHEMA_TABLES} tables or fewer, which
|
|
84
115
|
* is drawn whole.
|
|
85
116
|
*/
|
|
86
|
-
focus?: string | null, depth?: NeighbourhoodDepth) => UseSchemaGraphResult;
|
|
117
|
+
focus?: string | null, depth?: NeighbourhoodDepth, options?: SchemaGraphOptions) => UseSchemaGraphResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare function CreateTableDialog({ open, onOpenChange, schema, onCreated }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
schema: string;
|
|
6
|
+
/** The table was created: the shell reloads the list and reports whether it is served. */
|
|
7
|
+
onCreated: (name: string) => void;
|
|
8
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type AdminFetchOptions } from "../../utils/adminFetch.js";
|
|
3
|
+
export interface DdlChange {
|
|
4
|
+
/** The dialog's title: what is about to happen, in words. */
|
|
5
|
+
title: string;
|
|
6
|
+
path: string;
|
|
7
|
+
method: NonNullable<AdminFetchOptions["method"]>;
|
|
8
|
+
body: Record<string, unknown>;
|
|
9
|
+
/** The snackbar's sentence once it ran. */
|
|
10
|
+
done: string;
|
|
11
|
+
/** Draws the run button in the error ink. */
|
|
12
|
+
destructive?: boolean;
|
|
13
|
+
onDone?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A schema change, shown as the SQL it will run before it runs: the route is
|
|
17
|
+
* asked with `dryRun: true` first, the statements are shown, and only "Run"
|
|
18
|
+
* sends it for real. Every DDL route under `/api/admin/db` answers a dry run.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useDdlConfirm(): {
|
|
21
|
+
confirm: (change: DdlChange) => Promise<void>;
|
|
22
|
+
dialog: React.JSX.Element;
|
|
23
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** SQL to read and copy: a well with the statements in the mono face and a copy button. */
|
|
3
|
+
export declare function SqlBlock({ sql, className, maxHeight }: {
|
|
4
|
+
sql: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
maxHeight?: string;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** The table's definition as one SQL script, to read, copy, or take to the SQL editor. */
|
|
3
|
+
export declare function TableDdlSheet({ open, onOpenChange, title, ddl, loading }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
title: string;
|
|
7
|
+
ddl: string | null;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
}): React.JSX.Element;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The Tables view: every table of the schema, and for the one selected its
|
|
4
|
+
* rows, structure, policies, relations, statistics and settings — or the
|
|
5
|
+
* whole schema as a diagram. The selection, tab and mode live in the URL
|
|
6
|
+
* (`?table=schema.name&tableTab=…`, `?tablesView=diagram`), so any view can
|
|
7
|
+
* link straight to them.
|
|
8
|
+
*/
|
|
2
9
|
export declare function TableEditorView(): React.JSX.Element;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { PostgresPolicy } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* What the table inspector reads from `/api/admin/db`: the table list (one
|
|
4
|
+
* call for every table of a schema) and one table's catalog details. Parsed
|
|
5
|
+
* defensively, so a server one version behind never draws `undefined`.
|
|
6
|
+
*/
|
|
7
|
+
export interface DbColumnInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
/** The column's name on the wire (`/api/data`), which may be camelCased. */
|
|
10
|
+
key: string;
|
|
11
|
+
dataType: string;
|
|
12
|
+
udtName: string;
|
|
13
|
+
nullable: boolean;
|
|
14
|
+
defaultExpr: string | null;
|
|
15
|
+
primaryKey: boolean;
|
|
16
|
+
unique: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DbPolicyInfo {
|
|
19
|
+
name: string;
|
|
20
|
+
mode: "permissive" | "restrictive";
|
|
21
|
+
operation: string;
|
|
22
|
+
roles: string[];
|
|
23
|
+
using: string | null;
|
|
24
|
+
withCheck: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface DbIndexInfo {
|
|
27
|
+
name: string;
|
|
28
|
+
definition: string;
|
|
29
|
+
unique: boolean;
|
|
30
|
+
primary: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface DbForeignKey {
|
|
33
|
+
name: string;
|
|
34
|
+
definition: string;
|
|
35
|
+
fromSchema: string;
|
|
36
|
+
fromTable: string;
|
|
37
|
+
fromColumns: string[];
|
|
38
|
+
toSchema: string;
|
|
39
|
+
toTable: string;
|
|
40
|
+
toColumns: string[];
|
|
41
|
+
onDelete: string;
|
|
42
|
+
onUpdate: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DbTableMeta {
|
|
45
|
+
slug: string | null;
|
|
46
|
+
exposed: boolean;
|
|
47
|
+
description: string | null;
|
|
48
|
+
softDelete: boolean;
|
|
49
|
+
softDeleteColumn: string | null;
|
|
50
|
+
history: boolean;
|
|
51
|
+
readOnly: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface DbTableInfo {
|
|
54
|
+
schema: string;
|
|
55
|
+
name: string;
|
|
56
|
+
/** `schema.name` — the one identity every Studio view uses for a table. */
|
|
57
|
+
key: string;
|
|
58
|
+
slug: string;
|
|
59
|
+
kind: "table" | "view";
|
|
60
|
+
materialized: boolean;
|
|
61
|
+
rlsEnabled: boolean;
|
|
62
|
+
rlsForced: boolean;
|
|
63
|
+
exposed: boolean;
|
|
64
|
+
served: boolean;
|
|
65
|
+
comment: string | null;
|
|
66
|
+
rowEstimate: number | null;
|
|
67
|
+
columns: DbColumnInfo[];
|
|
68
|
+
policies: DbPolicyInfo[];
|
|
69
|
+
indexes: DbIndexInfo[];
|
|
70
|
+
foreignKeys: DbForeignKey[];
|
|
71
|
+
meta: DbTableMeta | null;
|
|
72
|
+
}
|
|
73
|
+
export declare function tableKey(schema: string, name: string): string;
|
|
74
|
+
export declare function parseForeignKey(raw: unknown): DbForeignKey | null;
|
|
75
|
+
export declare function parseTablesResponse(raw: unknown): DbTableInfo[];
|
|
76
|
+
/** A table's live policies in the shape the RLS editor compares against declarations. */
|
|
77
|
+
export declare function asPostgresPolicies(table: DbTableInfo): PostgresPolicy[];
|
|
78
|
+
/**
|
|
79
|
+
* Why a table is not on `/api/data`, from what the server reported about it —
|
|
80
|
+
* the one reason that holds. The translation key of the sentence.
|
|
81
|
+
*/
|
|
82
|
+
export declare function notServedReasonKey(table: DbTableInfo): string;
|
|
83
|
+
export interface CatalogColumn {
|
|
84
|
+
name: string;
|
|
85
|
+
type: string;
|
|
86
|
+
udt: string;
|
|
87
|
+
category: string;
|
|
88
|
+
notNull: boolean;
|
|
89
|
+
default: string | null;
|
|
90
|
+
identity: "always" | "by_default" | null;
|
|
91
|
+
generated: "stored" | "virtual" | null;
|
|
92
|
+
primaryKey: boolean;
|
|
93
|
+
comment: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface CatalogConstraint {
|
|
96
|
+
name: string;
|
|
97
|
+
kind: "primary_key" | "unique" | "check" | "foreign_key" | "exclusion" | "other";
|
|
98
|
+
definition: string;
|
|
99
|
+
columns: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface CatalogTrigger {
|
|
102
|
+
name: string;
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
definition: string;
|
|
105
|
+
functionSchema: string;
|
|
106
|
+
functionName: string;
|
|
107
|
+
}
|
|
108
|
+
export interface CatalogGrant {
|
|
109
|
+
grantee: string;
|
|
110
|
+
grantor: string;
|
|
111
|
+
privilege: string;
|
|
112
|
+
grantable: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface CatalogIndex {
|
|
115
|
+
name: string;
|
|
116
|
+
definition: string;
|
|
117
|
+
method: string;
|
|
118
|
+
unique: boolean;
|
|
119
|
+
primary: boolean;
|
|
120
|
+
valid: boolean;
|
|
121
|
+
backsConstraint: boolean;
|
|
122
|
+
bytes: number | null;
|
|
123
|
+
scans: number | null;
|
|
124
|
+
tuplesRead: number | null;
|
|
125
|
+
tuplesFetched: number | null;
|
|
126
|
+
}
|
|
127
|
+
export interface CatalogTableStats {
|
|
128
|
+
totalBytes: number | null;
|
|
129
|
+
tableBytes: number | null;
|
|
130
|
+
indexBytes: number | null;
|
|
131
|
+
toastBytes: number | null;
|
|
132
|
+
rowEstimate: number | null;
|
|
133
|
+
liveTuples: number | null;
|
|
134
|
+
deadTuples: number | null;
|
|
135
|
+
seqScans: number | null;
|
|
136
|
+
seqTuplesRead: number | null;
|
|
137
|
+
indexScans: number | null;
|
|
138
|
+
indexTuplesFetched: number | null;
|
|
139
|
+
inserts: number | null;
|
|
140
|
+
updates: number | null;
|
|
141
|
+
deletes: number | null;
|
|
142
|
+
lastVacuum: string | null;
|
|
143
|
+
lastAutovacuum: string | null;
|
|
144
|
+
lastAnalyze: string | null;
|
|
145
|
+
lastAutoanalyze: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface TableDetails {
|
|
148
|
+
relation: {
|
|
149
|
+
schema: string;
|
|
150
|
+
name: string;
|
|
151
|
+
kind: "table" | "partitioned_table" | "view" | "materialized_view" | "foreign_table";
|
|
152
|
+
owner: string;
|
|
153
|
+
rlsEnabled: boolean;
|
|
154
|
+
rlsForced: boolean;
|
|
155
|
+
comment: string | null;
|
|
156
|
+
defaultPrivileges: boolean;
|
|
157
|
+
};
|
|
158
|
+
columns: CatalogColumn[];
|
|
159
|
+
constraints: CatalogConstraint[];
|
|
160
|
+
foreignKeys: {
|
|
161
|
+
outgoing: DbForeignKey[];
|
|
162
|
+
incoming: DbForeignKey[];
|
|
163
|
+
};
|
|
164
|
+
triggers: CatalogTrigger[];
|
|
165
|
+
grants: CatalogGrant[];
|
|
166
|
+
indexes: CatalogIndex[];
|
|
167
|
+
stats: CatalogTableStats | null;
|
|
168
|
+
ddl: string;
|
|
169
|
+
}
|
|
170
|
+
export declare function parseTableDetails(raw: unknown): TableDetails | null;
|
|
171
|
+
export type RowValue = string | null;
|
|
172
|
+
export type TableRow = Record<string, RowValue>;
|
|
173
|
+
export interface RowsPage {
|
|
174
|
+
columns: CatalogColumn[];
|
|
175
|
+
rows: TableRow[];
|
|
176
|
+
count: {
|
|
177
|
+
value: number;
|
|
178
|
+
exact: boolean;
|
|
179
|
+
};
|
|
180
|
+
primaryKey: string[];
|
|
181
|
+
readOnly: boolean;
|
|
182
|
+
readOnlyReason: "view" | "no_primary_key" | null;
|
|
183
|
+
}
|
|
184
|
+
export declare function parseRowsPage(raw: unknown): RowsPage;
|
|
185
|
+
/** `?table=schema.name` — the selected table. */
|
|
186
|
+
export declare const TABLE_PARAM = "table";
|
|
187
|
+
/** `?tableTab=policies` — the inspector tab (the hosted console owns `?tab=`). */
|
|
188
|
+
export declare const TABLE_TAB_PARAM = "tableTab";
|
|
189
|
+
/** `?tablesView=diagram` — the schema diagram instead of a table. */
|
|
190
|
+
export declare const TABLES_VIEW_PARAM = "tablesView";
|
|
191
|
+
/** `?tableFilter=[...]` — the Data tab's filters, as JSON. */
|
|
192
|
+
export declare const TABLE_FILTER_PARAM = "tableFilter";
|
|
193
|
+
export declare const INSPECTOR_TABS: readonly ["data", "structure", "policies", "relations", "stats", "settings"];
|
|
194
|
+
export type InspectorTab = typeof INSPECTOR_TABS[number];
|
|
195
|
+
export declare function isInspectorTab(value: unknown): value is InspectorTab;
|
|
196
|
+
/** Opens a table in the Tables view, optionally on one tab and with Data filters. */
|
|
197
|
+
export declare function tablesLink(key: string, tab?: InspectorTab, filters?: readonly RowFilterValue[]): string;
|
|
198
|
+
/** Opens the SQL editor with `sql` in a new tab. */
|
|
199
|
+
export declare function sqlDraftLink(sql: string): string;
|
|
200
|
+
export declare const ROW_FILTER_OPERATORS: readonly ["eq", "neq", "lt", "lte", "gt", "gte", "like", "ilike", "in", "is_null", "not_null"];
|
|
201
|
+
export type RowFilterOperator = typeof ROW_FILTER_OPERATORS[number];
|
|
202
|
+
export interface RowFilterValue {
|
|
203
|
+
column: string;
|
|
204
|
+
op: RowFilterOperator;
|
|
205
|
+
value?: string | string[];
|
|
206
|
+
}
|
|
207
|
+
export declare function parseFilterParam(raw: string | null): RowFilterValue[];
|
|
208
|
+
/** Bytes as a reader says them: 1.2 MB, 830 kB. */
|
|
209
|
+
export declare function formatBytes(bytes: number | null): string;
|
|
210
|
+
export declare function formatCount(value: number | null, locale?: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DbTableInfo } from "../tableModel.js";
|
|
3
|
+
interface DataTabProps {
|
|
4
|
+
table: DbTableInfo;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The table's rows, read as the database owner through `/api/admin/db`
|
|
8
|
+
* (unserved tables and views included), or — "View as" — through the data
|
|
9
|
+
* API as one user, under the row level security that user gets.
|
|
10
|
+
*/
|
|
11
|
+
export declare function DataTab({ table }: DataTabProps): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DbTableInfo, type TableDetails } from "../tableModel.js";
|
|
3
|
+
/** Row level security for the table — the same editor as the RLS view — and who holds which privilege on it. */
|
|
4
|
+
export declare function PoliciesTab({ table, details, onChanged }: {
|
|
5
|
+
table: DbTableInfo;
|
|
6
|
+
details: TableDetails | null;
|
|
7
|
+
onChanged: () => void;
|
|
8
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DbTableInfo, type TableDetails } from "../tableModel.js";
|
|
3
|
+
/** What the table points at and what points at it: the foreign keys both ways, and its neighbourhood drawn. */
|
|
4
|
+
export declare function RelationsTab({ table, tables, details }: {
|
|
5
|
+
table: DbTableInfo;
|
|
6
|
+
tables: readonly DbTableInfo[];
|
|
7
|
+
details: TableDetails | null;
|
|
8
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DbTableInfo } from "../tableModel.js";
|
|
3
|
+
interface SettingsTabProps {
|
|
4
|
+
table: DbTableInfo;
|
|
5
|
+
onChanged: () => void;
|
|
6
|
+
/** After a rename or drop: the table the shell should select next (`null` for none). */
|
|
7
|
+
onTableReplaced: (key: string | null) => void;
|
|
8
|
+
}
|
|
9
|
+
/** How the API serves the table (`rebase.table_meta`), its name, and dropping it. */
|
|
10
|
+
export declare function SettingsTab({ table, onChanged, onTableReplaced }: SettingsTabProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DbTableInfo, type TableDetails } from "../tableModel.js";
|
|
3
|
+
/** Storage and access statistics, and the maintenance that keeps them honest. */
|
|
4
|
+
export declare function StatsTab({ table, details, onChanged }: {
|
|
5
|
+
table: DbTableInfo;
|
|
6
|
+
details: TableDetails | null;
|
|
7
|
+
onChanged: () => void;
|
|
8
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DbTableInfo, type TableDetails } from "../tableModel.js";
|
|
3
|
+
export declare const SQL_TYPES: readonly ["text", "varchar(255)", "integer", "bigint", "smallint", "numeric", "double precision", "real", "boolean", "uuid", "timestamptz", "timestamp", "date", "time", "jsonb", "json", "bytea", "text[]", "integer[]", "uuid[]"];
|
|
4
|
+
interface StructureTabProps {
|
|
5
|
+
table: DbTableInfo;
|
|
6
|
+
tables: readonly DbTableInfo[];
|
|
7
|
+
details: TableDetails | null;
|
|
8
|
+
onChanged: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** Columns, indexes, constraints and triggers: everything the table is made of. */
|
|
11
|
+
export declare function StructureTab({ table, tables, details, onChanged }: StructureTabProps): React.JSX.Element;
|
|
12
|
+
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as isRecord, s as useAdminFetch } from "./adminFetch-
|
|
1
|
+
import { o as isRecord, s as useAdminFetch } from "./adminFetch-C7Ra8rpP.js";
|
|
2
2
|
import { IconForView, Rebase, SchemaDriftBanner, StudioBridgeContext, StudioBridgeProvider, useApiConfig, useModeController, useNavigationGroupLabel, useRebaseAuthController, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useRebaseRegistryDispatch, useRestoreScroll, useSlot, useStudioBreadcrumbs, useStudioBreadcrumbs as useStudioBreadcrumbs$1, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation } from "@rebasepro/app";
|
|
3
3
|
import React, { Suspense, useEffect, useLayoutEffect, useMemo, useState } from "react";
|
|
4
4
|
import { Alert, ArrowRightIcon, Button, Card, CircularProgressCenter, Container, ExpandablePanel, HomeIcon, IconButton, LogOutIcon, MoonIcon, SearchBar, StatusDot, SunIcon, TextField, Tooltip, Typography, cls, defaultBorderMixin, iconSize, lazyChunk } from "@rebasepro/ui";
|
|
@@ -921,20 +921,21 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
|
|
|
921
921
|
}
|
|
922
922
|
//#endregion
|
|
923
923
|
//#region src/components/RebaseStudio.tsx
|
|
924
|
-
var
|
|
925
|
-
var
|
|
926
|
-
var
|
|
927
|
-
var
|
|
928
|
-
var
|
|
929
|
-
var
|
|
930
|
-
var
|
|
924
|
+
var SchemaDiagramView = lazyChunk(() => import("./SchemaDiagramView-CckQobIZ.js").then((m) => ({ default: m.SchemaDiagramView })));
|
|
925
|
+
var TableEditorView = lazyChunk(() => import("./TableEditorView-BRZNvD6U.js").then((m) => ({ default: m.TableEditorView })));
|
|
926
|
+
var SQLEditor = lazyChunk(() => import("./SQLEditorRoute-f5j_ZKdj.js").then((m) => ({ default: m.SQLEditorRoute })));
|
|
927
|
+
var JSEditor = lazyChunk(() => import("./JSEditor-B4Lazm-z.js").then((m) => ({ default: m.JSEditor })));
|
|
928
|
+
var RLSEditor = lazyChunk(() => import("./RLSEditor-CcHkWFNg.js").then((m) => ({ default: m.RLSEditor })));
|
|
929
|
+
var StorageView = lazyChunk(() => import("./StorageView-B7QHjEGY.js").then((m) => ({ default: m.StorageView })));
|
|
930
|
+
var CronJobsView = lazyChunk(() => import("./CronJobsView-DyX9MINh.js").then((m) => ({ default: m.CronJobsView })));
|
|
931
931
|
var BranchesView = lazyChunk(() => import("./BranchesView-Bh5lq9T_.js").then((m) => ({ default: m.BranchesView })));
|
|
932
932
|
var BackupsView = lazyChunk(() => import("./BackupsView-DJlYhWBy.js").then((m) => ({ default: m.BackupsView })));
|
|
933
|
-
var ApiExplorer = lazyChunk(() => import("./ApiExplorer-
|
|
934
|
-
var WebhooksView = lazyChunk(() => import("./WebhooksView-
|
|
933
|
+
var ApiExplorer = lazyChunk(() => import("./ApiExplorer-BVQHAjHB.js").then((m) => ({ default: m.ApiExplorer })));
|
|
934
|
+
var WebhooksView = lazyChunk(() => import("./WebhooksView-Bn9KB7xG.js").then((m) => ({ default: m.WebhooksView })));
|
|
935
935
|
var LogsExplorer = lazyChunk(() => import("./LogsExplorer-BA8RfTwd.js").then((m) => ({ default: m.LogsExplorer })));
|
|
936
|
-
var UsersAndRolesView = lazyChunk(() => import("./UsersAndRolesView-
|
|
936
|
+
var UsersAndRolesView = lazyChunk(() => import("./UsersAndRolesView-Cx6xtMVH.js").then((m) => ({ default: m.UsersAndRolesView })));
|
|
937
937
|
var ApiKeysView = lazyChunk(() => import("./ApiKeysView-BdqASL_2.js").then((m) => ({ default: m.ApiKeysView })));
|
|
938
|
+
var DatabaseView = lazyChunk(() => import("./DatabaseView-Bi0NZS90.js").then((m) => ({ default: m.DatabaseView })));
|
|
938
939
|
/**
|
|
939
940
|
* Declarative component to configure the Studio in Rebase.
|
|
940
941
|
* Renders nothing — purely registers config into the RebaseRegistry.
|
|
@@ -966,6 +967,7 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
|
|
|
966
967
|
"schema-visualizer",
|
|
967
968
|
"branches",
|
|
968
969
|
"backups",
|
|
970
|
+
"database",
|
|
969
971
|
"api",
|
|
970
972
|
"webhooks",
|
|
971
973
|
"logs",
|
|
@@ -976,7 +978,8 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
|
|
|
976
978
|
fallback: /* @__PURE__ */ jsx(CircularProgressCenter, {}),
|
|
977
979
|
children: el
|
|
978
980
|
});
|
|
979
|
-
|
|
981
|
+
const hasTables = activeTools.includes("tables");
|
|
982
|
+
if (hasTables) views.push({
|
|
980
983
|
slug: "tables",
|
|
981
984
|
name: t("studio_tool_tables"),
|
|
982
985
|
group: "Database",
|
|
@@ -1029,8 +1032,9 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
|
|
|
1029
1032
|
name: t("studio_tool_schema_visualizer"),
|
|
1030
1033
|
group: "Database",
|
|
1031
1034
|
icon: "Network",
|
|
1035
|
+
hideFromNavigation: hasTables,
|
|
1032
1036
|
description: t("studio_tool_schema_visualizer_description"),
|
|
1033
|
-
view: suspense(/* @__PURE__ */ jsx(
|
|
1037
|
+
view: suspense(/* @__PURE__ */ jsx(SchemaDiagramView, { linksToTables: hasTables }))
|
|
1034
1038
|
});
|
|
1035
1039
|
if (activeTools.includes("branches")) views.push({
|
|
1036
1040
|
slug: "branches",
|
|
@@ -1048,6 +1052,14 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
|
|
|
1048
1052
|
description: t("studio_tool_backups_description"),
|
|
1049
1053
|
view: suspense(/* @__PURE__ */ jsx(BackupsView, {}))
|
|
1050
1054
|
});
|
|
1055
|
+
if (activeTools.includes("database")) views.push({
|
|
1056
|
+
slug: "database",
|
|
1057
|
+
name: t("studio_tool_database"),
|
|
1058
|
+
group: "Database",
|
|
1059
|
+
icon: "ServerCog",
|
|
1060
|
+
description: t("studio_tool_database_description"),
|
|
1061
|
+
view: suspense(/* @__PURE__ */ jsx(DatabaseView, {}))
|
|
1062
|
+
});
|
|
1051
1063
|
if (activeTools.includes("api")) views.push({
|
|
1052
1064
|
slug: "api",
|
|
1053
1065
|
name: t("studio_tool_api"),
|
|
@@ -1223,7 +1235,9 @@ function StudioStandaloneShell({ name, auth }) {
|
|
|
1223
1235
|
const modeController = useModeController();
|
|
1224
1236
|
const labelGroup = useNavigationGroupLabel();
|
|
1225
1237
|
const { t } = useTranslation();
|
|
1226
|
-
|
|
1238
|
+
/** Every view gets a route; only the ones not hidden from navigation are listed in the rail. */
|
|
1239
|
+
const routedViews = useMemo(() => registry.studioConfig?.devViews ?? [], [registry.studioConfig?.devViews]);
|
|
1240
|
+
const views = useMemo(() => routedViews.filter((v) => !v.hideFromNavigation), [routedViews]);
|
|
1227
1241
|
const groupedViews = useMemo(() => {
|
|
1228
1242
|
const map = /* @__PURE__ */ new Map();
|
|
1229
1243
|
for (const v of views) {
|
|
@@ -1344,7 +1358,7 @@ function StudioStandaloneShell({ name, auth }) {
|
|
|
1344
1358
|
path: "/",
|
|
1345
1359
|
element: registry.studioConfig?.homePage ?? /* @__PURE__ */ jsx(StudioHomePage, {})
|
|
1346
1360
|
}),
|
|
1347
|
-
|
|
1361
|
+
routedViews.map((view) => {
|
|
1348
1362
|
const ViewEl = view.view;
|
|
1349
1363
|
const element = typeof ViewEl === "function" ? /* @__PURE__ */ jsx(ViewEl, {}) : ViewEl;
|
|
1350
1364
|
return /* @__PURE__ */ jsx(Route, {
|