@burdenoff/microfe-bigconsole 2026.1119.10 → 2026.1121.1

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.
@@ -0,0 +1,228 @@
1
+ import { useTr as e } from "../../../../shared/hooks/useTr.js";
2
+ import { useQueryAccessMutations as t, useQueryAccessSinks as n, useQueryRelations as r } from "../../../hooks/useQueryAccess.js";
3
+ import { formatPath as i, sinkRows as a } from "../../../utils/queryAccess.js";
4
+ import { GrantsPanel as o } from "./GrantsPanel.js";
5
+ import { RelationEditor as s } from "./RelationEditor.js";
6
+ import { ErrorLine as c, buttonClass as l, cellClass as u, dangerButtonClass as d, headerCellClass as f, useQueryAccessErrorText as p } from "./shared.js";
7
+ import { useMemo as m, useState as h } from "react";
8
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
9
+ // src/bigconsole/components/explore/queryAccess/QueryAccessAdmin.tsx
10
+ var y = ({ workspaceId: y }) => {
11
+ let b = e(), x = p(), S = r(y), C = n(y), { remove: w } = t(y), [T, E] = h(null), [D, O] = h(null), [k, A] = h(null), [j, M] = h(null), N = m(() => a(C.data ?? [], S.data ?? []), [C.data, S.data]), P = T ? N.find((e) => e.sink.id === T.dataSinkId) : void 0, F = S.error ?? C.error, I = (e) => e.status === "unregistered" ? /* @__PURE__ */ _("span", {
12
+ className: "text-text-muted",
13
+ children: b("bigconsole.queryAccess.status.unregistered", "Not registered")
14
+ }) : e.status === "invalid" ? /* @__PURE__ */ _("span", {
15
+ className: "rounded-pill bg-[var(--color-status-warning-bg)] px-2 py-0.5 text-xs text-[var(--color-status-warning-text)]",
16
+ children: b("bigconsole.queryAccess.status.invalid", "Needs repair")
17
+ }) : /* @__PURE__ */ _("span", {
18
+ className: "rounded-pill bg-status-success-bg px-2 py-0.5 text-xs text-status-success-text",
19
+ children: b("bigconsole.queryAccess.status.registered", "Registered")
20
+ }), L = (e) => {
21
+ A(null), M(null), w.mutate({ dataSinkId: e.sink.id }, {
22
+ onSuccess: () => {
23
+ O(null), M(b("bigconsole.queryAccess.remove.done", "{{name}} was removed with its grants.", { name: e.relation?.name ?? e.sink.name })), T?.dataSinkId === e.sink.id && E(null);
24
+ },
25
+ onError: (e) => A(x(e))
26
+ });
27
+ };
28
+ return F ? /* @__PURE__ */ v("div", {
29
+ role: "alert",
30
+ className: "mt-4 flex flex-wrap items-center gap-form-gap text-body-sm text-status-error-text",
31
+ children: [/* @__PURE__ */ v("span", { children: [
32
+ b("bigconsole.queryAccess.loadFailed", "Query access could not be loaded."),
33
+ " ",
34
+ x(F)
35
+ ] }), /* @__PURE__ */ _("button", {
36
+ type: "button",
37
+ className: l,
38
+ onClick: () => {
39
+ S.refetch(), C.refetch();
40
+ },
41
+ children: b("bigconsole.queryAccess.retry", "Retry")
42
+ })]
43
+ }) : S.isPending || C.isPending ? /* @__PURE__ */ _("p", {
44
+ role: "status",
45
+ className: "mt-4 text-body-sm text-text-muted",
46
+ children: b("bigconsole.queryAccess.loadingList", "Loading data sinks and relations…")
47
+ }) : /* @__PURE__ */ v("div", {
48
+ className: "mt-4 flex flex-col gap-[var(--space-formGap)]",
49
+ children: [
50
+ /* @__PURE__ */ _(c, { message: k }),
51
+ j && /* @__PURE__ */ _("p", {
52
+ role: "status",
53
+ className: "text-body-sm text-status-success-text",
54
+ children: j
55
+ }),
56
+ N.length === 0 ? /* @__PURE__ */ _("p", {
57
+ className: "text-body-sm text-text-muted",
58
+ children: b("bigconsole.queryAccess.empty", "This workspace has no data sinks yet. Create a data sink first.")
59
+ }) : /* @__PURE__ */ _("div", {
60
+ className: "overflow-x-auto",
61
+ children: /* @__PURE__ */ v("table", {
62
+ className: "w-full min-w-[720px] border-collapse",
63
+ "data-testid": "bigconsole-query-access-sinks",
64
+ children: [/* @__PURE__ */ _("thead", { children: /* @__PURE__ */ v("tr", {
65
+ className: "border-b border-border-seam",
66
+ children: [
67
+ /* @__PURE__ */ _("th", {
68
+ scope: "col",
69
+ className: f,
70
+ children: b("bigconsole.queryAccess.columns.sink", "Data sink")
71
+ }),
72
+ /* @__PURE__ */ _("th", {
73
+ scope: "col",
74
+ className: f,
75
+ children: b("bigconsole.queryAccess.columns.relation", "SQL relation")
76
+ }),
77
+ /* @__PURE__ */ _("th", {
78
+ scope: "col",
79
+ className: f,
80
+ children: b("bigconsole.queryAccess.columns.status", "Status")
81
+ }),
82
+ /* @__PURE__ */ _("th", {
83
+ scope: "col",
84
+ className: f,
85
+ children: b("bigconsole.queryAccess.columns.fields", "Fields")
86
+ }),
87
+ /* @__PURE__ */ _("th", {
88
+ scope: "col",
89
+ className: f,
90
+ children: b("bigconsole.queryAccess.columns.grants", "Grants")
91
+ }),
92
+ /* @__PURE__ */ _("th", {
93
+ scope: "col",
94
+ className: f,
95
+ children: /* @__PURE__ */ _("span", {
96
+ className: "sr-only",
97
+ children: b("bigconsole.queryAccess.columns.actions", "Actions")
98
+ })
99
+ })
100
+ ]
101
+ }) }), /* @__PURE__ */ _("tbody", { children: N.map((e) => {
102
+ let t = e.relation, n = D === e.sink.id;
103
+ return /* @__PURE__ */ v("tr", {
104
+ "data-sink-id": e.sink.id,
105
+ "data-status": e.status,
106
+ className: "border-b border-border-seam last:border-b-0",
107
+ children: [
108
+ /* @__PURE__ */ v("td", {
109
+ className: u,
110
+ children: [/* @__PURE__ */ _("div", {
111
+ className: "font-medium text-text-primary",
112
+ children: e.sink.name
113
+ }), e.sink.key && /* @__PURE__ */ _("div", {
114
+ className: "text-xs text-text-muted",
115
+ children: e.sink.key
116
+ })]
117
+ }),
118
+ /* @__PURE__ */ _("td", {
119
+ className: `${u} font-mono text-text-secondary`,
120
+ children: t?.name ?? "—"
121
+ }),
122
+ /* @__PURE__ */ v("td", {
123
+ className: u,
124
+ children: [I(e), e.status === "invalid" && /* @__PURE__ */ _("div", {
125
+ className: "mt-1 text-xs text-[var(--color-status-warning-text)]",
126
+ children: b("bigconsole.queryAccess.status.invalidHint", "The query reader would refuse this declaration. Edit and save the fields to repair it.")
127
+ })]
128
+ }),
129
+ /* @__PURE__ */ _("td", {
130
+ className: `${u} text-text-secondary`,
131
+ children: t ? /* @__PURE__ */ _("span", {
132
+ title: t.fields.map((e) => i(e.path)).join(", "),
133
+ children: t.fields.map((e) => e.name).join(", ")
134
+ }) : "—"
135
+ }),
136
+ /* @__PURE__ */ _("td", {
137
+ className: `${u} text-text-secondary`,
138
+ children: t ? t.grantCount : "—"
139
+ }),
140
+ /* @__PURE__ */ _("td", {
141
+ className: `${u} text-right`,
142
+ children: n && t ? /* @__PURE__ */ v("div", {
143
+ className: "flex flex-col items-end gap-2",
144
+ role: "group",
145
+ children: [/* @__PURE__ */ _("span", {
146
+ className: "text-body-sm text-text-primary",
147
+ children: b("bigconsole.queryAccess.remove.confirm", "Remove {{name}} and its {{count}} grant(s)? Members lose SQL and Explore access to this sink.", {
148
+ name: t.name,
149
+ count: t.grantCount
150
+ })
151
+ }), /* @__PURE__ */ v("div", {
152
+ className: "flex gap-2",
153
+ children: [/* @__PURE__ */ _("button", {
154
+ type: "button",
155
+ className: d,
156
+ disabled: w.isPending,
157
+ onClick: () => L(e),
158
+ children: w.isPending ? b("bigconsole.queryAccess.remove.removing", "Removing…") : b("bigconsole.queryAccess.remove.action", "Remove relation")
159
+ }), /* @__PURE__ */ _("button", {
160
+ type: "button",
161
+ className: l,
162
+ disabled: w.isPending,
163
+ onClick: () => O(null),
164
+ children: b("bigconsole.queryAccess.cancel", "Cancel")
165
+ })]
166
+ })]
167
+ }) : /* @__PURE__ */ v("div", {
168
+ className: "flex flex-wrap justify-end gap-2",
169
+ children: [/* @__PURE__ */ _("button", {
170
+ type: "button",
171
+ className: l,
172
+ "aria-label": `${t ? b("bigconsole.queryAccess.actions.editFields", "Edit fields") : b("bigconsole.queryAccess.actions.register", "Register")} ${e.sink.name}`,
173
+ onClick: () => {
174
+ A(null), M(null), E({
175
+ kind: "relation",
176
+ dataSinkId: e.sink.id
177
+ });
178
+ },
179
+ children: t ? b("bigconsole.queryAccess.actions.editFields", "Edit fields") : b("bigconsole.queryAccess.actions.register", "Register")
180
+ }), t && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _("button", {
181
+ type: "button",
182
+ className: l,
183
+ "aria-label": `${b("bigconsole.queryAccess.actions.grants", "Grants")} ${e.sink.name}`,
184
+ onClick: () => {
185
+ A(null), M(null), E({
186
+ kind: "grants",
187
+ dataSinkId: e.sink.id
188
+ });
189
+ },
190
+ children: b("bigconsole.queryAccess.actions.grants", "Grants")
191
+ }), /* @__PURE__ */ _("button", {
192
+ type: "button",
193
+ className: d,
194
+ "aria-label": `${b("bigconsole.queryAccess.actions.remove", "Remove")} ${e.sink.name}`,
195
+ onClick: () => {
196
+ A(null), O(e.sink.id);
197
+ },
198
+ children: b("bigconsole.queryAccess.actions.remove", "Remove")
199
+ })] })]
200
+ })
201
+ })
202
+ ]
203
+ }, e.sink.id);
204
+ }) })]
205
+ })
206
+ }),
207
+ T && P && T.kind === "relation" && /* @__PURE__ */ _(s, {
208
+ workspaceId: y,
209
+ sink: P.sink,
210
+ relation: P.relation,
211
+ onClose: () => E(null),
212
+ onSaved: (e) => {
213
+ M(b("bigconsole.queryAccess.relation.saved", "{{name}} is saved. Grant members access below.", { name: e.name })), E({
214
+ kind: "grants",
215
+ dataSinkId: e.dataSinkId
216
+ });
217
+ }
218
+ }, `relation-${P.sink.id}`),
219
+ T && P?.relation && T.kind === "grants" && /* @__PURE__ */ _(o, {
220
+ workspaceId: y,
221
+ sinkName: P.sink.name,
222
+ relation: P.relation,
223
+ onClose: () => E(null)
224
+ }, `grants-${P.sink.id}`)
225
+ ]
226
+ });
227
+ };
228
+ export { y as default };
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ export declare const QueryAccessEntry: FC<{
3
+ workspaceId: string;
4
+ }>;
5
+ export default QueryAccessEntry;
@@ -0,0 +1,39 @@
1
+ import { BIGCONSOLE_PERMISSIONS as e } from "../../../../constants/permissions.js";
2
+ import { useTr as t } from "../../../../shared/hooks/useTr.js";
3
+ import { SECTION_FOCUS_RING as n } from "../../common/sectionStyles.js";
4
+ import { Suspense as r, lazy as i, useState as a } from "react";
5
+ import { usePermissions as o } from "@burdenoff/fe-libs/shared/providers/shell";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ // src/bigconsole/components/explore/queryAccess/QueryAccessEntry.tsx
8
+ var l = i(() => import("./QueryAccessAdmin.js")), u = ({ workspaceId: t }) => {
9
+ let { hasPermission: n, isLoading: r } = o();
10
+ return r || !n(e.DATASINK_MANAGE) ? null : /* @__PURE__ */ s(d, { workspaceId: t }, t);
11
+ }, d = ({ workspaceId: e }) => {
12
+ let i = t(), [o, u] = a(!1);
13
+ return /* @__PURE__ */ c("details", {
14
+ "data-testid": "bigconsole-query-access",
15
+ className: "rounded-card border border-border-default bg-bg-surface p-4",
16
+ onToggle: (e) => {
17
+ e.currentTarget.open && u(!0);
18
+ },
19
+ children: [
20
+ /* @__PURE__ */ s("summary", {
21
+ className: `cursor-pointer font-medium text-text-primary ${n}`,
22
+ children: i("bigconsole.queryAccess.title", "Query access for SQL and Explore")
23
+ }),
24
+ /* @__PURE__ */ s("p", {
25
+ className: "mt-2 text-body-sm text-text-muted",
26
+ children: i("bigconsole.queryAccess.subtitle", "Register data sinks for the SQL editor and Explore, then grant workspace members access to all rows or a filtered subset, field by field. Registration alone grants nobody access.")
27
+ }),
28
+ o && /* @__PURE__ */ s(r, {
29
+ fallback: /* @__PURE__ */ s("p", {
30
+ role: "status",
31
+ className: "mt-4 text-body-sm text-text-muted",
32
+ children: i("bigconsole.queryAccess.loading", "Loading query access…")
33
+ }),
34
+ children: /* @__PURE__ */ s(l, { workspaceId: e })
35
+ })
36
+ ]
37
+ });
38
+ };
39
+ export { u as QueryAccessEntry, u as default };
@@ -0,0 +1,11 @@
1
+ import { FC } from 'react';
2
+ import { QueryRelation, SinkSummary } from '../../../utils/queryAccess';
3
+ interface RelationEditorProps {
4
+ workspaceId: string;
5
+ sink: SinkSummary;
6
+ relation: QueryRelation | undefined;
7
+ onClose: () => void;
8
+ onSaved: (relation: QueryRelation) => void;
9
+ }
10
+ export declare const RelationEditor: FC<RelationEditorProps>;
11
+ export {};
@@ -0,0 +1,279 @@
1
+ import { useTr as e } from "../../../../shared/hooks/useTr.js";
2
+ import { loadSinkSample as t, useQueryAccessMutations as n } from "../../../hooks/useQueryAccess.js";
3
+ import { QUERY_ACCESS_LIMITS as r, SCALAR_TYPES as i, emptyFieldDraft as a, inferFieldDrafts as o, relationInput as s, relationToDraft as c, validateRelationDraft as l } from "../../../utils/queryAccess.js";
4
+ import { ErrorLine as u, buttonClass as d, cellClass as f, headerCellClass as p, hintClass as m, inputClass as h, labelClass as g, primaryButtonClass as _, useProblemText as v, useQueryAccessErrorText as y } from "./shared.js";
5
+ import { useId as b, useState as x } from "react";
6
+ import { useApolloClient as S } from "@apollo/client/react";
7
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
8
+ // src/bigconsole/components/explore/queryAccess/RelationEditor.tsx
9
+ var E = [...i, "DECIMAL"], D = ({ workspaceId: i, sink: D, relation: O, onClose: k, onSaved: A }) => {
10
+ let j = e(), M = S(), N = y(), P = v(), { register: F } = n(i), I = b(), L = b(), [R, z] = x(() => c(O, D.key || D.name)), [B, V] = x(null), [H, U] = x(null), [W, G] = x(!1), K = (e, t) => z((n) => ({
11
+ ...n,
12
+ fields: n.fields.map((n) => n.key === e ? {
13
+ ...n,
14
+ ...t
15
+ } : n)
16
+ })), q = async () => {
17
+ V(null), U(null), G(!0);
18
+ try {
19
+ let e = o(await t(M, i, D.id));
20
+ if (!e.length) {
21
+ U(j("bigconsole.queryAccess.relation.suggestEmpty", "No scalar fields were found in the stored data. Declare the fields by hand."));
22
+ return;
23
+ }
24
+ z((t) => ({
25
+ ...t,
26
+ fields: e
27
+ })), U(j("bigconsole.queryAccess.relation.suggested", "{{count}} field(s) proposed from the stored data. Check each type and nullability before saving.", { count: e.length }));
28
+ } catch (e) {
29
+ V(N(e));
30
+ } finally {
31
+ G(!1);
32
+ }
33
+ };
34
+ return /* @__PURE__ */ T("section", {
35
+ "aria-labelledby": I,
36
+ "data-testid": "bigconsole-query-relation-editor",
37
+ className: "rounded-card border border-border-seam bg-bg-canvas p-4",
38
+ children: [
39
+ /* @__PURE__ */ T("div", {
40
+ className: "mb-3 flex items-start justify-between gap-2",
41
+ children: [/* @__PURE__ */ T("div", {
42
+ className: "min-w-0 flex-1",
43
+ children: [/* @__PURE__ */ w("h3", {
44
+ id: I,
45
+ className: "text-body-md font-semibold text-text-primary",
46
+ children: O ? j("bigconsole.queryAccess.relation.editTitle", "Edit fields of {{sink}}", { sink: D.name }) : j("bigconsole.queryAccess.relation.registerTitle", "Register {{sink}} for SQL and Explore", { sink: D.name })
47
+ }), /* @__PURE__ */ w("p", {
48
+ className: m,
49
+ children: j("bigconsole.queryAccess.relation.rules", "Names are lowercase SQL identifiers. Paths name one value inside a record, with segments separated by dots (for example location.region). Supported types: VARCHAR, BOOLEAN, BIGINT, TIMESTAMPTZ and DECIMAL(p,s). Up to {{max}} fields.", { max: r.fields })
50
+ })]
51
+ }), /* @__PURE__ */ w("button", {
52
+ type: "button",
53
+ className: `${d} shrink-0`,
54
+ onClick: k,
55
+ children: j("bigconsole.queryAccess.close", "Close")
56
+ })]
57
+ }),
58
+ /* @__PURE__ */ T("div", {
59
+ className: "mb-3 max-w-md",
60
+ children: [
61
+ /* @__PURE__ */ w("label", {
62
+ htmlFor: L,
63
+ className: g,
64
+ children: j("bigconsole.queryAccess.relation.name", "SQL relation name")
65
+ }),
66
+ /* @__PURE__ */ w("input", {
67
+ id: L,
68
+ className: `${h} font-mono`,
69
+ value: R.name,
70
+ autoComplete: "off",
71
+ spellCheck: !1,
72
+ onChange: (e) => z((t) => ({
73
+ ...t,
74
+ name: e.target.value
75
+ }))
76
+ }),
77
+ /* @__PURE__ */ w("p", {
78
+ className: m,
79
+ children: j("bigconsole.queryAccess.relation.nameHint", "Queries use this name in FROM. It must be unique in the workspace.")
80
+ })
81
+ ]
82
+ }),
83
+ /* @__PURE__ */ w("div", {
84
+ className: "overflow-x-auto",
85
+ children: /* @__PURE__ */ T("table", {
86
+ className: "w-full min-w-[860px] border-collapse",
87
+ children: [/* @__PURE__ */ w("thead", { children: /* @__PURE__ */ T("tr", {
88
+ className: "border-b border-border-seam",
89
+ children: [
90
+ /* @__PURE__ */ w("th", {
91
+ scope: "col",
92
+ className: p,
93
+ children: j("bigconsole.queryAccess.relation.fieldId", "Field ID")
94
+ }),
95
+ /* @__PURE__ */ w("th", {
96
+ scope: "col",
97
+ className: p,
98
+ children: j("bigconsole.queryAccess.relation.fieldName", "SQL name")
99
+ }),
100
+ /* @__PURE__ */ w("th", {
101
+ scope: "col",
102
+ className: p,
103
+ children: j("bigconsole.queryAccess.relation.fieldPath", "Path")
104
+ }),
105
+ /* @__PURE__ */ w("th", {
106
+ scope: "col",
107
+ className: p,
108
+ children: j("bigconsole.queryAccess.relation.fieldType", "Type")
109
+ }),
110
+ /* @__PURE__ */ w("th", {
111
+ scope: "col",
112
+ className: p,
113
+ children: j("bigconsole.queryAccess.relation.fieldNullable", "Nullable")
114
+ }),
115
+ /* @__PURE__ */ w("th", {
116
+ scope: "col",
117
+ className: p,
118
+ children: /* @__PURE__ */ w("span", {
119
+ className: "sr-only",
120
+ children: j("bigconsole.queryAccess.columns.actions", "Actions")
121
+ })
122
+ })
123
+ ]
124
+ }) }), /* @__PURE__ */ w("tbody", { children: R.fields.map((e, t) => {
125
+ let n = t + 1;
126
+ return /* @__PURE__ */ T("tr", {
127
+ className: "border-b border-border-seam last:border-b-0",
128
+ children: [
129
+ /* @__PURE__ */ w("td", {
130
+ className: f,
131
+ children: /* @__PURE__ */ w("input", {
132
+ className: `${h} font-mono`,
133
+ "aria-label": j("bigconsole.queryAccess.relation.fieldIdOf", "Field ID, row {{row}}", { row: n }),
134
+ value: e.id,
135
+ spellCheck: !1,
136
+ onChange: (t) => K(e.key, { id: t.target.value })
137
+ })
138
+ }),
139
+ /* @__PURE__ */ w("td", {
140
+ className: f,
141
+ children: /* @__PURE__ */ w("input", {
142
+ className: `${h} font-mono`,
143
+ "aria-label": j("bigconsole.queryAccess.relation.fieldNameOf", "SQL name, row {{row}}", { row: n }),
144
+ value: e.name,
145
+ spellCheck: !1,
146
+ onChange: (t) => K(e.key, { name: t.target.value })
147
+ })
148
+ }),
149
+ /* @__PURE__ */ w("td", {
150
+ className: f,
151
+ children: /* @__PURE__ */ w("input", {
152
+ className: `${h} font-mono`,
153
+ "aria-label": j("bigconsole.queryAccess.relation.fieldPathOf", "Path, row {{row}}", { row: n }),
154
+ value: e.path,
155
+ spellCheck: !1,
156
+ placeholder: "location.region",
157
+ onChange: (t) => K(e.key, { path: t.target.value })
158
+ })
159
+ }),
160
+ /* @__PURE__ */ w("td", {
161
+ className: f,
162
+ children: /* @__PURE__ */ T("div", {
163
+ className: "flex items-center gap-1",
164
+ children: [/* @__PURE__ */ w("select", {
165
+ className: `${h} min-w-[9rem]`,
166
+ "aria-label": j("bigconsole.queryAccess.relation.fieldTypeOf", "Type, row {{row}}", { row: n }),
167
+ value: e.baseType,
168
+ onChange: (t) => K(e.key, { baseType: t.target.value }),
169
+ children: E.map((e) => /* @__PURE__ */ w("option", {
170
+ value: e,
171
+ children: e
172
+ }, e))
173
+ }), e.baseType === "DECIMAL" && /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("input", {
174
+ className: `${h} w-14`,
175
+ inputMode: "numeric",
176
+ "aria-label": j("bigconsole.queryAccess.relation.precisionOf", "Precision, row {{row}}", { row: n }),
177
+ value: e.precision,
178
+ onChange: (t) => K(e.key, { precision: t.target.value })
179
+ }), /* @__PURE__ */ w("input", {
180
+ className: `${h} w-14`,
181
+ inputMode: "numeric",
182
+ "aria-label": j("bigconsole.queryAccess.relation.scaleOf", "Scale, row {{row}}", { row: n }),
183
+ value: e.scale,
184
+ onChange: (t) => K(e.key, { scale: t.target.value })
185
+ })] })]
186
+ })
187
+ }),
188
+ /* @__PURE__ */ w("td", {
189
+ className: f,
190
+ children: /* @__PURE__ */ w("input", {
191
+ type: "checkbox",
192
+ "aria-label": j("bigconsole.queryAccess.relation.nullableOf", "Nullable, row {{row}}", { row: n }),
193
+ checked: e.nullable,
194
+ onChange: (t) => K(e.key, { nullable: t.target.checked })
195
+ })
196
+ }),
197
+ /* @__PURE__ */ w("td", {
198
+ className: `${f} text-right`,
199
+ children: /* @__PURE__ */ w("button", {
200
+ type: "button",
201
+ className: d,
202
+ "aria-label": j("bigconsole.queryAccess.relation.removeFieldOf", "Remove field, row {{row}}", { row: n }),
203
+ disabled: R.fields.length <= 1,
204
+ onClick: () => z((t) => ({
205
+ ...t,
206
+ fields: t.fields.filter((t) => t.key !== e.key)
207
+ })),
208
+ children: j("bigconsole.queryAccess.relation.removeField", "Remove")
209
+ })
210
+ })
211
+ ]
212
+ }, e.key);
213
+ }) })]
214
+ })
215
+ }),
216
+ /* @__PURE__ */ T("div", {
217
+ className: "mt-3 flex flex-wrap items-center gap-2",
218
+ children: [/* @__PURE__ */ w("button", {
219
+ type: "button",
220
+ className: d,
221
+ disabled: R.fields.length >= r.fields,
222
+ onClick: () => z((e) => ({
223
+ ...e,
224
+ fields: [...e.fields, a()]
225
+ })),
226
+ children: j("bigconsole.queryAccess.relation.addField", "Add field")
227
+ }), /* @__PURE__ */ w("button", {
228
+ type: "button",
229
+ className: d,
230
+ disabled: W,
231
+ onClick: () => void q(),
232
+ children: W ? j("bigconsole.queryAccess.relation.suggesting", "Reading stored data…") : j("bigconsole.queryAccess.relation.suggest", "Suggest fields from stored data")
233
+ })]
234
+ }),
235
+ O && O.grantCount > 0 && /* @__PURE__ */ w("p", {
236
+ className: "mt-2 text-xs text-text-muted",
237
+ children: j("bigconsole.queryAccess.relation.grantWarning", "{{count}} grant(s) use this relation. Removing or retyping a field a grant uses is refused until that grant is changed.", { count: O.grantCount })
238
+ }),
239
+ /* @__PURE__ */ T("div", {
240
+ className: "mt-3 flex flex-col gap-2",
241
+ children: [
242
+ H && /* @__PURE__ */ w("p", {
243
+ role: "status",
244
+ className: "text-body-sm text-text-secondary",
245
+ children: H
246
+ }),
247
+ /* @__PURE__ */ w(u, { message: B }),
248
+ /* @__PURE__ */ T("div", {
249
+ className: "flex gap-2",
250
+ children: [/* @__PURE__ */ w("button", {
251
+ type: "button",
252
+ className: _,
253
+ disabled: F.isPending,
254
+ onClick: () => {
255
+ V(null), U(null);
256
+ let e = l(R);
257
+ e ? V(P(e)) : F.mutate({
258
+ dataSinkId: D.id,
259
+ input: s(R)
260
+ }, {
261
+ onSuccess: (e) => A(e),
262
+ onError: (e) => V(N(e))
263
+ });
264
+ },
265
+ children: F.isPending ? j("bigconsole.queryAccess.saving", "Saving…") : O ? j("bigconsole.queryAccess.relation.saveChanges", "Save fields") : j("bigconsole.queryAccess.relation.register", "Register relation")
266
+ }), /* @__PURE__ */ w("button", {
267
+ type: "button",
268
+ className: d,
269
+ disabled: F.isPending,
270
+ onClick: k,
271
+ children: j("bigconsole.queryAccess.cancel", "Cancel")
272
+ })]
273
+ })
274
+ ]
275
+ })
276
+ ]
277
+ });
278
+ };
279
+ export { D as RelationEditor };
@@ -0,0 +1,16 @@
1
+ import { FC } from 'react';
2
+ import { DraftProblem } from '../../../utils/queryAccess';
3
+ export declare const cellClass = "px-3 py-2 text-left align-top text-body-sm";
4
+ export declare const headerCellClass = "px-3 py-2 text-left text-body-sm font-medium text-text-secondary";
5
+ export declare const buttonClass = "rounded-button border border-[var(--color-border-default)] px-3 py-1 text-body-sm text-text-primary hover:border-action-primary-bg disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-bg-surface";
6
+ export declare const primaryButtonClass = "rounded-button bg-action-primary-bg px-3 py-1 text-body-sm font-medium text-action-primary-text disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-bg-surface";
7
+ export declare const dangerButtonClass = "rounded-button border border-[var(--color-status-error-text)] px-3 py-1 text-body-sm text-status-error-text disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-bg-surface";
8
+ export declare const inputClass = "w-full rounded-button border border-[var(--color-border-default)] bg-bg-canvas px-2 py-1 text-body-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-bg-surface";
9
+ export declare const labelClass = "block text-body-sm font-medium text-text-primary";
10
+ export declare const hintClass = "text-xs text-text-muted";
11
+ /** The message to show for a failed request: the service's own text where it is meant for the administrator. */
12
+ export declare function useQueryAccessErrorText(): (error: unknown) => string;
13
+ export declare function useProblemText(): (problem: DraftProblem) => string;
14
+ export declare const ErrorLine: FC<{
15
+ message: string | null;
16
+ }>;
@@ -0,0 +1,26 @@
1
+ import { useTr as e } from "../../../../shared/hooks/useTr.js";
2
+ import { SECTION_FOCUS_RING as t } from "../../common/sectionStyles.js";
3
+ import { firstErrorCode as n, verbatimServiceMessage as r } from "../../../utils/queryAccess.js";
4
+ import { useCallback as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ // src/bigconsole/components/explore/queryAccess/shared.tsx
7
+ var o = "px-3 py-2 text-left align-top text-body-sm", s = "px-3 py-2 text-left text-body-sm font-medium text-text-secondary", c = `rounded-button border border-[var(--color-border-default)] px-3 py-1 text-body-sm text-text-primary hover:border-action-primary-bg disabled:cursor-not-allowed disabled:opacity-60 ${t}`, l = `rounded-button bg-action-primary-bg px-3 py-1 text-body-sm font-medium text-action-primary-text disabled:cursor-not-allowed disabled:opacity-60 ${t}`, u = `rounded-button border border-[var(--color-status-error-text)] px-3 py-1 text-body-sm text-status-error-text disabled:cursor-not-allowed disabled:opacity-60 ${t}`, d = `w-full rounded-button border border-[var(--color-border-default)] bg-bg-canvas px-2 py-1 text-body-sm text-text-primary ${t}`, f = "block text-body-sm font-medium text-text-primary", p = "text-xs text-text-muted";
8
+ function m() {
9
+ let t = e();
10
+ return i((e) => {
11
+ let i = r(e);
12
+ if (i) return i;
13
+ let a = n(e);
14
+ return a === "FORBIDDEN" || a === "PERMISSION_DENIED" || a === "UNAUTHORIZED" ? t("bigconsole.queryAccess.error.forbidden", "Only a workspace administrator can manage query access in this workspace.") : t("bigconsole.queryAccess.error.generic", "The request could not be completed. Try again.");
15
+ }, [t]);
16
+ }
17
+ function h() {
18
+ let t = e();
19
+ return i((e) => t(e.key, e.fallback, e.params), [t]);
20
+ }
21
+ var g = ({ message: e }) => e ? /* @__PURE__ */ a("p", {
22
+ role: "alert",
23
+ className: "text-body-sm text-status-error-text",
24
+ children: e
25
+ }) : null;
26
+ export { g as ErrorLine, c as buttonClass, o as cellClass, u as dangerButtonClass, s as headerCellClass, p as hintClass, d as inputClass, f as labelClass, l as primaryButtonClass, h as useProblemText, m as useQueryAccessErrorText };
@@ -0,0 +1,50 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ import { BigConsoleQueryFieldAccess as ApiFieldAccess } from '../../generated/wspace-types';
3
+ import { QueryGrant, QueryRelation, SinkSummary, grantInput, relationInput } from '../utils/queryAccess';
4
+ type RelationInput = ReturnType<typeof relationInput>;
5
+ type GrantInput = ReturnType<typeof grantInput>;
6
+ /** The API enum for a field decision; the codegen emits a TypeScript enum, not a string union. */
7
+ export declare function apiFieldAccess(access: GrantInput['fields'][number]['access']): ApiFieldAccess;
8
+ export interface WorkspaceMember {
9
+ userId: string;
10
+ displayName: string;
11
+ email?: string;
12
+ }
13
+ export declare const queryAccessKeys: {
14
+ all: (workspaceId: string) => readonly ["bigconsole", "query-access", string];
15
+ relations: (workspaceId: string) => readonly ["bigconsole", "query-access", string, "relations"];
16
+ grants: (workspaceId: string, dataSinkId: string) => readonly ["bigconsole", "query-access", string, "grants", string];
17
+ sinks: (workspaceId: string) => readonly ["bigconsole", "query-access", string, "sinks"];
18
+ members: (workspaceId: string) => readonly ["bigconsole", "query-access", string, "members"];
19
+ };
20
+ export declare function loadRelations(client: ApolloClient, workspaceId: string): Promise<QueryRelation[]>;
21
+ export declare function loadGrants(client: ApolloClient, workspaceId: string, dataSinkId: string): Promise<QueryGrant[]>;
22
+ /** Every live sink in the workspace (id, name, key), up to {@link MAX_PAGES} pages. */
23
+ export declare function loadSinks(client: ApolloClient, workspaceId: string): Promise<SinkSummary[]>;
24
+ /** Active user members of the workspace with their display names, never a global directory. */
25
+ export declare function loadMembers(client: ApolloClient, workspaceId: string): Promise<WorkspaceMember[]>;
26
+ /** A small sample of a sink's stored records, used only to propose field declarations. */
27
+ export declare function loadSinkSample(client: ApolloClient, workspaceId: string, dataSinkId: string): Promise<unknown>;
28
+ export declare function useQueryRelations(workspaceId: string): import('@tanstack/react-query').UseQueryResult<QueryRelation[], Error>;
29
+ export declare function useQueryAccessSinks(workspaceId: string): import('@tanstack/react-query').UseQueryResult<SinkSummary[], Error>;
30
+ export declare function useQueryGrants(workspaceId: string, dataSinkId: string | null): import('@tanstack/react-query').UseQueryResult<QueryGrant[], Error>;
31
+ export declare function useWorkspaceMemberDirectory(workspaceId: string, enabled: boolean): import('@tanstack/react-query').UseQueryResult<WorkspaceMember[], Error>;
32
+ /** The relation and grant mutations. Each one refreshes the lists it changes. */
33
+ export declare function useQueryAccessMutations(workspaceId: string): {
34
+ register: import('@tanstack/react-query').UseMutationResult<QueryRelation, Error, {
35
+ dataSinkId: string;
36
+ input: RelationInput;
37
+ }, unknown>;
38
+ remove: import('@tanstack/react-query').UseMutationResult<boolean, Error, {
39
+ dataSinkId: string;
40
+ }, unknown>;
41
+ setGrant: import('@tanstack/react-query').UseMutationResult<QueryGrant, Error, {
42
+ dataSinkId: string;
43
+ input: GrantInput;
44
+ }, unknown>;
45
+ revokeGrant: import('@tanstack/react-query').UseMutationResult<boolean, Error, {
46
+ dataSinkId: string;
47
+ actorId: string;
48
+ }, unknown>;
49
+ };
50
+ export {};