@rebasepro/studio 0.35.0 → 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,69 @@
|
|
|
1
|
+
import { useRebaseClient, useRebaseContext } from "@rebasepro/app";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { hasAdminRole } from "@rebasepro/types";
|
|
4
|
+
//#region src/components/useRunAsUsers.ts
|
|
5
|
+
/** How many users one search of a "Run as" picker lists. */
|
|
6
|
+
var USER_PAGE_SIZE = 50;
|
|
7
|
+
/** The fields a picker row shows, copied off an account or the signed-in user. */
|
|
8
|
+
function toSelectableUser(user) {
|
|
9
|
+
return {
|
|
10
|
+
uid: user.uid,
|
|
11
|
+
displayName: user.displayName,
|
|
12
|
+
email: user.email,
|
|
13
|
+
photoURL: user.photoURL,
|
|
14
|
+
roles: user.roles
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The users a "Run as" picker offers.
|
|
19
|
+
*
|
|
20
|
+
* The signed-in user, and — for an administrator, the only caller the server
|
|
21
|
+
* lets run a request as someone else — the project's users, searched on the
|
|
22
|
+
* server. Disabled accounts are left out: nothing can run as them, and the
|
|
23
|
+
* server refuses them.
|
|
24
|
+
*/
|
|
25
|
+
function useRunAsUsers() {
|
|
26
|
+
const signedIn = useRebaseContext().authController?.user;
|
|
27
|
+
const client = useRebaseClient();
|
|
28
|
+
const adminApi = hasAdminRole(signedIn?.roles) ? client?.admin : void 0;
|
|
29
|
+
const [search, setSearch] = useState("");
|
|
30
|
+
const [listed, setListed] = useState([]);
|
|
31
|
+
const [totalCount, setTotalCount] = useState(void 0);
|
|
32
|
+
const [loading, setLoading] = useState(false);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!adminApi) return;
|
|
35
|
+
let cancelled = false;
|
|
36
|
+
setLoading(true);
|
|
37
|
+
adminApi.listUsersPaginated({
|
|
38
|
+
search: search || void 0,
|
|
39
|
+
limit: USER_PAGE_SIZE
|
|
40
|
+
}).then(({ users, total }) => {
|
|
41
|
+
if (cancelled) return;
|
|
42
|
+
setListed(users.filter((u) => !u.disabled).map(toSelectableUser));
|
|
43
|
+
setTotalCount(total > users.length ? total : void 0);
|
|
44
|
+
}).catch((err) => {
|
|
45
|
+
console.warn("Could not list users for the \"Run as\" picker", err);
|
|
46
|
+
if (!cancelled) {
|
|
47
|
+
setListed([]);
|
|
48
|
+
setTotalCount(void 0);
|
|
49
|
+
}
|
|
50
|
+
}).finally(() => {
|
|
51
|
+
if (!cancelled) setLoading(false);
|
|
52
|
+
});
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
};
|
|
56
|
+
}, [adminApi, search]);
|
|
57
|
+
const currentUser = useMemo(() => signedIn ? toSelectableUser(signedIn) : null, [signedIn]);
|
|
58
|
+
return {
|
|
59
|
+
users: useMemo(() => [...currentUser ? [currentUser] : [], ...listed.filter((u) => u.uid !== currentUser?.uid)], [currentUser, listed]),
|
|
60
|
+
currentUser,
|
|
61
|
+
loading,
|
|
62
|
+
onSearchTextChange: setSearch,
|
|
63
|
+
totalCount
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { useRunAsUsers as t };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=useRunAsUsers-GPFCxcBC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunAsUsers-GPFCxcBC.js","names":[],"sources":["../src/components/useRunAsUsers.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { useRebaseClient, useRebaseContext, type SelectableUser } from \"@rebasepro/app\";\nimport { hasAdminRole, type RebaseClient } from \"@rebasepro/types\";\n\n/** How many users one search of a \"Run as\" picker lists. */\nconst USER_PAGE_SIZE = 50;\n\n/** The fields a picker row shows, copied off an account or the signed-in user. */\nfunction toSelectableUser(user: SelectableUser): SelectableUser {\n return {\n uid: user.uid,\n displayName: user.displayName,\n email: user.email,\n photoURL: user.photoURL,\n roles: user.roles\n };\n}\n\nexport interface RunAsUsers {\n /** The signed-in user first, then the users the latest search found. */\n users: SelectableUser[];\n /** The signed-in user, the picker's \"self\" row. */\n currentUser: SelectableUser | null;\n loading: boolean;\n /** Search the project's users on the server. */\n onSearchTextChange: (searchText: string) => void;\n /**\n * How many users the latest search matched on the server, set only when\n * that is more than the one page listed — so the picker can say so rather\n * than present the page as everyone.\n */\n totalCount?: number;\n}\n\n/**\n * The users a \"Run as\" picker offers.\n *\n * The signed-in user, and — for an administrator, the only caller the server\n * lets run a request as someone else — the project's users, searched on the\n * server. Disabled accounts are left out: nothing can run as them, and the\n * server refuses them.\n */\nexport function useRunAsUsers(): RunAsUsers {\n const signedIn = useRebaseContext().authController?.user;\n const client = useRebaseClient<RebaseClient>();\n const adminApi = hasAdminRole(signedIn?.roles) ? client?.admin : undefined;\n\n const [search, setSearch] = useState(\"\");\n const [listed, setListed] = useState<SelectableUser[]>([]);\n const [totalCount, setTotalCount] = useState<number | undefined>(undefined);\n const [loading, setLoading] = useState(false);\n\n useEffect(() => {\n if (!adminApi) return;\n let cancelled = false;\n setLoading(true);\n adminApi.listUsersPaginated({ search: search || undefined, limit: USER_PAGE_SIZE })\n .then(({ users, total }) => {\n if (cancelled) return;\n setListed(users.filter((u) => !u.disabled).map(toSelectableUser));\n setTotalCount(total > users.length ? total : undefined);\n })\n .catch((err: unknown) => {\n console.warn(\"Could not list users for the \\\"Run as\\\" picker\", err);\n if (!cancelled) {\n setListed([]);\n setTotalCount(undefined);\n }\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n return () => {\n cancelled = true;\n };\n }, [adminApi, search]);\n\n const currentUser = useMemo((): SelectableUser | null => (signedIn ? toSelectableUser(signedIn) : null), [signedIn]);\n\n const users = useMemo(\n () => [...(currentUser ? [currentUser] : []), ...listed.filter((u) => u.uid !== currentUser?.uid)],\n [currentUser, listed]\n );\n\n return { users, currentUser, loading, onSearchTextChange: setSearch, totalCount };\n}\n"],"mappings":";;;;;AAKA,IAAM,iBAAiB;;AAGvB,SAAS,iBAAiB,MAAsC;CAC5D,OAAO;EACH,KAAK,KAAK;EACV,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EACf,OAAO,KAAK;CAChB;AACJ;;;;;;;;;AA0BA,SAAgB,gBAA4B;CACxC,MAAM,WAAW,iBAAiB,CAAC,CAAC,gBAAgB;CACpD,MAAM,SAAS,gBAA8B;CAC7C,MAAM,WAAW,aAAa,UAAU,KAAK,IAAI,QAAQ,QAAQ,KAAA;CAEjE,MAAM,CAAC,QAAQ,aAAa,SAAS,EAAE;CACvC,MAAM,CAAC,QAAQ,aAAa,SAA2B,CAAC,CAAC;CACzD,MAAM,CAAC,YAAY,iBAAiB,SAA6B,KAAA,CAAS;CAC1E,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,gBAAgB;EACZ,IAAI,CAAC,UAAU;EACf,IAAI,YAAY;EAChB,WAAW,IAAI;EACf,SAAS,mBAAmB;GAAE,QAAQ,UAAU,KAAA;GAAW,OAAO;EAAe,CAAC,CAAC,CAC9E,MAAM,EAAE,OAAO,YAAY;GACxB,IAAI,WAAW;GACf,UAAU,MAAM,QAAQ,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,gBAAgB,CAAC;GAChE,cAAc,QAAQ,MAAM,SAAS,QAAQ,KAAA,CAAS;EAC1D,CAAC,CAAC,CACD,OAAO,QAAiB;GACrB,QAAQ,KAAK,kDAAkD,GAAG;GAClE,IAAI,CAAC,WAAW;IACZ,UAAU,CAAC,CAAC;IACZ,cAAc,KAAA,CAAS;GAC3B;EACJ,CAAC,CAAC,CACD,cAAc;GACX,IAAI,CAAC,WAAW,WAAW,KAAK;EACpC,CAAC;EACL,aAAa;GACT,YAAY;EAChB;CACJ,GAAG,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,cAAc,cAAsC,WAAW,iBAAiB,QAAQ,IAAI,MAAO,CAAC,QAAQ,CAAC;CAOnH,OAAO;EAAE,OALK,cACJ,CAAC,GAAI,cAAc,CAAC,WAAW,IAAI,CAAC,GAAI,GAAG,OAAO,QAAQ,MAAM,EAAE,QAAQ,aAAa,GAAG,CAAC,GACjG,CAAC,aAAa,MAAM,CAGf;EAAO;EAAa;EAAS,oBAAoB;EAAW;CAAW;AACpF"}
|
|
@@ -22,4 +22,5 @@ export interface AdminFetchOptions {
|
|
|
22
22
|
export declare function useAdminFetch(): {
|
|
23
23
|
apiBase: string | undefined;
|
|
24
24
|
requestJson: (path: string, options?: AdminFetchOptions) => Promise<unknown>;
|
|
25
|
+
requestRaw: (path: string, options?: AdminFetchOptions) => Promise<Response>;
|
|
25
26
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 4180 CSV, read back: quoted fields may hold commas, line breaks and
|
|
3
|
+
* doubled quotes; a record ends at CRLF or LF. An empty unquoted field is
|
|
4
|
+
* `null` (the export writes NULL as nothing), an empty quoted one `""`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseCsv(text: string): (string | null)[][];
|
|
7
|
+
/** The first record as column names, the rest as rows keyed by them. */
|
|
8
|
+
export declare function parseCsvWithHeader(text: string): {
|
|
9
|
+
columns: string[];
|
|
10
|
+
rows: Record<string, string | null>[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading an `EXPLAIN (FORMAT JSON)` result — with or without `ANALYZE` —
|
|
3
|
+
* into what the plan view draws: the plan tree, the run's planning and
|
|
4
|
+
* execution time, and how much of the time each node spent on its own.
|
|
5
|
+
*/
|
|
6
|
+
/** One node of a plan, as `EXPLAIN (FORMAT JSON)` writes it. Only the fields the view reads are named. */
|
|
7
|
+
export interface ExplainPlanNode {
|
|
8
|
+
"Node Type": string;
|
|
9
|
+
"Relation Name"?: string;
|
|
10
|
+
"Alias"?: string;
|
|
11
|
+
"Startup Cost": number;
|
|
12
|
+
"Total Cost": number;
|
|
13
|
+
"Plan Rows": number;
|
|
14
|
+
"Plan Width": number;
|
|
15
|
+
"Actual Startup Time"?: number;
|
|
16
|
+
"Actual Total Time"?: number;
|
|
17
|
+
"Actual Rows"?: number;
|
|
18
|
+
"Actual Loops"?: number;
|
|
19
|
+
"Shared Hit Blocks"?: number;
|
|
20
|
+
"Shared Read Blocks"?: number;
|
|
21
|
+
"Shared Dirtied Blocks"?: number;
|
|
22
|
+
"Shared Written Blocks"?: number;
|
|
23
|
+
"Temp Read Blocks"?: number;
|
|
24
|
+
"Temp Written Blocks"?: number;
|
|
25
|
+
"Filter"?: string;
|
|
26
|
+
"Rows Removed by Filter"?: number;
|
|
27
|
+
"Index Cond"?: string;
|
|
28
|
+
"Hash Cond"?: string;
|
|
29
|
+
"Plans"?: ExplainPlanNode[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** A whole explained statement. */
|
|
33
|
+
export interface ExplainResult {
|
|
34
|
+
plan: ExplainPlanNode;
|
|
35
|
+
/** Present for `ANALYZE`: milliseconds. */
|
|
36
|
+
planningTime?: number;
|
|
37
|
+
executionTime?: number;
|
|
38
|
+
/** The node was timed: the statement ran (`ANALYZE`). */
|
|
39
|
+
analyzed: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The plan in a result's `QUERY PLAN` value — an array (an admin read parses
|
|
43
|
+
* json) or the JSON text the console's script door returns — or `null` when
|
|
44
|
+
* the value is not one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readExplainResult(value: unknown): ExplainResult | null;
|
|
47
|
+
/** The `QUERY PLAN` cell of a result, when the rows are a single plan. */
|
|
48
|
+
export declare function explainResultOfRows(rows: readonly Record<string, unknown>[] | null): ExplainResult | null;
|
|
49
|
+
/**
|
|
50
|
+
* Milliseconds the node spent on its own, over all its loops: its total time
|
|
51
|
+
* less its children's. Postgres reports `Actual Total Time` per loop, so each
|
|
52
|
+
* is multiplied by its loops first. Never below zero — a parallel node's
|
|
53
|
+
* children can add up to more than it, timed on other workers.
|
|
54
|
+
*/
|
|
55
|
+
export declare function exclusiveTime(node: ExplainPlanNode): number;
|
|
56
|
+
/**
|
|
57
|
+
* The nodes that took the most time of their own, slowest first: at most
|
|
58
|
+
* `count`, and only ones that took at least `minShare` of the whole run — a
|
|
59
|
+
* sort that took a fraction of a millisecond beside a 40 ms scan is not one of
|
|
60
|
+
* "the slowest" however few nodes there are. Empty for a plan that did not run.
|
|
61
|
+
*/
|
|
62
|
+
export declare function slowestNodes(plan: ExplainPlanNode, count?: number, minShare?: number): ExplainPlanNode[];
|
|
63
|
+
/** The shared and temp blocks a node touched, as `BUFFERS` reports them; `null` when it reported none. */
|
|
64
|
+
export declare function nodeBuffers(node: ExplainPlanNode): {
|
|
65
|
+
hit: number;
|
|
66
|
+
read: number;
|
|
67
|
+
dirtied: number;
|
|
68
|
+
written: number;
|
|
69
|
+
temp: number;
|
|
70
|
+
} | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `:name` placeholders in the SQL console: found by a tokenizer that knows
|
|
3
|
+
* where a `:name` is SQL text and where it is not, and filled in with
|
|
4
|
+
* literals the database reads back exactly.
|
|
5
|
+
*
|
|
6
|
+
* A placeholder is a colon and an identifier (`:user_id`, `:From`) outside a
|
|
7
|
+
* string, a quoted identifier, a dollar-quoted body, a comment and an array
|
|
8
|
+
* subscript — and not the second colon of a `::` cast, so `created_at::date`
|
|
9
|
+
* names no parameter. Matching is case-sensitive, as the text is.
|
|
10
|
+
*/
|
|
11
|
+
/** One `:name` in the text, by its position. */
|
|
12
|
+
export interface SqlParameterOccurrence {
|
|
13
|
+
name: string;
|
|
14
|
+
/** Offset of the colon. */
|
|
15
|
+
start: number;
|
|
16
|
+
/** Offset just past the name. */
|
|
17
|
+
end: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* What a parameter is filled in with: a quoted literal of `value` (`text`),
|
|
21
|
+
* SQL `NULL` (`null`), or `value` exactly as written (`raw`) — a number, an
|
|
22
|
+
* identifier, an expression.
|
|
23
|
+
*/
|
|
24
|
+
export interface SqlParameterValue {
|
|
25
|
+
mode: "text" | "null" | "raw";
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
/** Every `:name` placeholder in `sql`, in order. */
|
|
29
|
+
export declare function findSqlParameters(sql: string): SqlParameterOccurrence[];
|
|
30
|
+
/** The distinct parameter names of `sql`, in the order they first appear. */
|
|
31
|
+
export declare function sqlParameterNames(sql: string): string[];
|
|
32
|
+
/**
|
|
33
|
+
* `value` as a SQL string literal: single quotes doubled, and an `E''`
|
|
34
|
+
* literal with its backslashes doubled when it holds one, so the database
|
|
35
|
+
* reads the same characters whatever `standard_conforming_strings` says.
|
|
36
|
+
*/
|
|
37
|
+
export declare function quoteSqlLiteral(value: string): string;
|
|
38
|
+
/** What `parameter` is written as in the SQL that runs. */
|
|
39
|
+
export declare function sqlParameterText(parameter: SqlParameterValue): string;
|
|
40
|
+
/**
|
|
41
|
+
* `sql` with every placeholder replaced by its value's text. A placeholder
|
|
42
|
+
* with no value is a mistake the caller asks about first —
|
|
43
|
+
* {@link missingSqlParameters} — and is left as written here.
|
|
44
|
+
*/
|
|
45
|
+
export declare function substituteSqlParameters(sql: string, values: Readonly<Record<string, SqlParameterValue>>): string;
|
|
46
|
+
/**
|
|
47
|
+
* The placeholders of `sql` that `values` gives nothing for: no entry, or an
|
|
48
|
+
* empty one that is not NULL. An empty string is written as the raw `''`, so
|
|
49
|
+
* a field left blank is never run as one by accident.
|
|
50
|
+
*/
|
|
51
|
+
export declare function missingSqlParameters(sql: string, values: Readonly<Record<string, SqlParameterValue>>): string[];
|
|
@@ -12,6 +12,22 @@ import type { TableInfo } from "../components/SQLEditor/sql_editor_types.js";
|
|
|
12
12
|
* second statement in it.
|
|
13
13
|
*/
|
|
14
14
|
export declare function buildExplainSql(sqlText: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* The script that times one statement for real — `EXPLAIN (ANALYZE, BUFFERS,
|
|
17
|
+
* FORMAT JSON)` — inside a transaction that is rolled back, or `null` when
|
|
18
|
+
* `sqlText` is not exactly one statement.
|
|
19
|
+
*
|
|
20
|
+
* ANALYZE executes the statement, so a `DELETE` deletes; the `ROLLBACK`
|
|
21
|
+
* undoes what the transaction did. What no transaction undoes is not undone:
|
|
22
|
+
* a sequence advanced by an `INSERT`, a notification sent, a row written
|
|
23
|
+
* through `dblink`. The console says so beside the button. Only one
|
|
24
|
+
* statement, for the reason {@link buildExplainSql} gives: a second one would
|
|
25
|
+
* run inside the transaction and be rolled back with it, or end it early.
|
|
26
|
+
*
|
|
27
|
+
* The statement's last line may be a `--` comment, so the `;` after it goes
|
|
28
|
+
* on a line of its own.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildExplainAnalyzeScript(sqlText: string): string | null;
|
|
15
31
|
/**
|
|
16
32
|
* Whether the console's automatic `LIMIT` may be appended to `sqlText`: one
|
|
17
33
|
* top-level SELECT that has no limit of its own.
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/studio",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Rebase Studio —
|
|
3
|
+
"version": "0.36.0",
|
|
4
|
+
"description": "Rebase Studio — SQL editor, schema visualiser, RLS policy editor and API explorer for Rebase, the open-source Postgres BaaS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebase",
|
|
7
7
|
"studio",
|
|
8
8
|
"sql",
|
|
9
9
|
"rls",
|
|
10
|
-
"postgres"
|
|
10
|
+
"postgres",
|
|
11
|
+
"baas",
|
|
12
|
+
"backend-as-a-service"
|
|
11
13
|
],
|
|
12
14
|
"homepage": "https://rebase.pro",
|
|
13
15
|
"bugs": {
|
|
@@ -35,12 +37,12 @@
|
|
|
35
37
|
"pgsql-ast-parser": "12.0.2",
|
|
36
38
|
"prism-react-renderer": "^2.4.1",
|
|
37
39
|
"react-dropzone": "^19.1.1",
|
|
38
|
-
"@rebasepro/
|
|
39
|
-
"@rebasepro/
|
|
40
|
-
"@rebasepro/common": "0.
|
|
41
|
-
"@rebasepro/types": "0.
|
|
42
|
-
"@rebasepro/ui": "0.
|
|
43
|
-
"@rebasepro/utils": "0.
|
|
40
|
+
"@rebasepro/app": "0.36.0",
|
|
41
|
+
"@rebasepro/client": "0.36.0",
|
|
42
|
+
"@rebasepro/common": "0.36.0",
|
|
43
|
+
"@rebasepro/types": "0.36.0",
|
|
44
|
+
"@rebasepro/ui": "0.36.0",
|
|
45
|
+
"@rebasepro/utils": "0.36.0"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|
|
46
48
|
"react": "^19.2.7",
|