@lunora/studio 1.0.0-alpha.4 → 1.0.0-alpha.41
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.ts +33 -18
- package/dist/index.js +29 -29
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +3 -2
- package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
- package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +29 -41
- package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +16 -11
- package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
- package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
- package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +153 -208
- package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
- package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +108 -69
- package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +46 -58
- package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +45 -139
- package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
- package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +44 -51
- package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
- package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +17 -16
- package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +47 -31
- package/dist/packem_chunks/SettingsPanel.js +391 -0
- package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +158 -387
- package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
- package/dist/packem_chunks/analytics-panel.js +261 -0
- package/dist/packem_chunks/auth-config-panel.js +365 -0
- package/dist/packem_chunks/auth-sessions-panel.js +175 -0
- package/dist/packem_chunks/containers-panel.js +247 -0
- package/dist/packem_chunks/dashboards-panel.js +780 -0
- package/dist/packem_chunks/fanout-panel.js +482 -0
- package/dist/packem_chunks/flags-panel.js +176 -0
- package/dist/packem_chunks/kv-browser.js +1896 -0
- package/dist/packem_chunks/log-drains-panel.js +273 -0
- package/dist/packem_chunks/organizations-panel.js +3178 -0
- package/dist/packem_chunks/payments-panel.js +186 -0
- package/dist/packem_chunks/permissions-panel.js +805 -0
- package/dist/packem_chunks/queues-panel.js +1075 -0
- package/dist/packem_chunks/rls-panel.js +315 -0
- package/dist/packem_chunks/schedule-panel.js +831 -0
- package/dist/packem_chunks/sparkline.js +79 -0
- package/dist/packem_chunks/storage-rules-panel.js +140 -0
- package/dist/packem_chunks/subscriptions-panel.js +238 -0
- package/dist/packem_chunks/users-panel.js +1731 -0
- package/dist/packem_chunks/vector-browser.js +281 -0
- package/dist/packem_chunks/workflows-panel.js +562 -0
- package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-BHHJi3Gb.js} +7 -0
- package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-CBma-lnp.js} +2 -2
- package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-CQM3pPN7.js} +2 -1
- package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-X2tkbyHk.js} +1 -1
- package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-D2ywrdId.js} +198 -247
- package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-BkTPLzAY.js} +37 -66
- package/dist/packem_shared/HomePanel-D1Q9LZgK.js +14 -0
- package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-Dno-hfDb.js} +2 -1
- package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-Ctw4jYtU.js} +163 -60
- package/dist/packem_shared/Studio-lJhzDAze.js +16 -0
- package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-DiMkupvZ.js} +276 -11
- package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-BX8OhG0w.js} +6 -6
- package/dist/packem_shared/alert-CdAET2K_.js +68 -0
- package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-CNLRTrWw.d.ts} +1 -1
- package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-DSwcWIRy.js} +5 -4
- package/dist/packem_shared/browser-storage-BTrX4y3B.js +215 -0
- package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
- package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-CdXztApG.js} +1 -1
- package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
- package/dist/packem_shared/error-alert-CXjqyGw9.js +114 -0
- package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-BF-KBDFz.js} +131 -163
- package/dist/packem_shared/home-panel-TFcRf9Ui.js +1889 -0
- package/dist/packem_shared/{internal-rXJEAhXS.js → internal-CYcbqMjX.js} +44 -3
- package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
- package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-DUiJcILV.js} +6 -45
- package/dist/packem_shared/scroll-area-DLhcy-ml.js +93 -0
- package/dist/packem_shared/select-UkNYCT3s.js +273 -0
- package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
- package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-BnA1kC9X.js} +1 -1
- package/dist/packem_shared/studio-Dh9UlaF_.js +4015 -0
- package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-UVIXQJdU.js} +1 -1
- package/dist/packem_shared/use-admin-query-CfHYWx5n.js +106 -0
- package/dist/packem_shared/use-async-submit-DJQiPc-_.js +91 -0
- package/dist/standalone/chunk-25AYY4H7.js +2 -0
- package/dist/standalone/chunk-2ANAF4ZM.js +1 -0
- package/dist/standalone/chunk-2K47A3P6.js +1 -0
- package/dist/standalone/chunk-2NGUNNGW.js +1 -0
- package/dist/standalone/chunk-3CJW6NWG.js +4 -0
- package/dist/standalone/chunk-3OA7PECS.js +6 -0
- package/dist/standalone/chunk-3OIHOXVV.js +1 -0
- package/dist/standalone/chunk-447TAUFD.js +1 -0
- package/dist/standalone/chunk-4QHKBC77.js +1 -0
- package/dist/standalone/chunk-5C4TSNE6.js +1 -0
- package/dist/standalone/chunk-5OIBXYZM.js +1 -0
- package/dist/standalone/chunk-6HSHEMZV.js +76 -0
- package/dist/standalone/chunk-6JIZ34MB.js +3 -0
- package/dist/standalone/chunk-6VO23MMW.js +4 -0
- package/dist/standalone/chunk-7MVSQS7B.js +1 -0
- package/dist/standalone/chunk-7TJJXVSE.js +1 -0
- package/dist/standalone/chunk-7YXOPTWI.js +1 -0
- package/dist/standalone/chunk-AHILM3ZP.js +1 -0
- package/dist/standalone/chunk-BGXOXASQ.js +1 -0
- package/dist/standalone/chunk-BJGBHGK3.js +1 -0
- package/dist/standalone/chunk-BOXSWNXZ.js +1 -0
- package/dist/standalone/chunk-BX5MKYOC.js +1 -0
- package/dist/standalone/chunk-CKSHCYGC.js +2 -0
- package/dist/standalone/chunk-DWDILV2E.js +1 -0
- package/dist/standalone/chunk-E75ANNWX.js +19 -0
- package/dist/standalone/chunk-EQZQOTJY.js +1 -0
- package/dist/standalone/chunk-GTLEWM5Y.js +1 -0
- package/dist/standalone/chunk-GTM65MVX.js +1 -0
- package/dist/standalone/chunk-GUI5GFFI.js +1 -0
- package/dist/standalone/chunk-HN6KJXYQ.js +1 -0
- package/dist/standalone/chunk-HV7G6DFP.js +5 -0
- package/dist/standalone/chunk-HYDJNCGW.js +1 -0
- package/dist/standalone/chunk-HZK5RQHG.js +1 -0
- package/dist/standalone/chunk-IN2SYVJB.js +1 -0
- package/dist/standalone/chunk-IOANPSJN.js +1 -0
- package/dist/standalone/chunk-ISDZPW3V.js +1 -0
- package/dist/standalone/chunk-IXDH4GL5.js +1 -0
- package/dist/standalone/chunk-J6J54MBP.js +1 -0
- package/dist/standalone/chunk-J73VHFCL.js +1 -0
- package/dist/standalone/chunk-JHKMUTIF.js +13 -0
- package/dist/standalone/chunk-JPRH6DPK.js +1 -0
- package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
- package/dist/standalone/chunk-KA5YB3VP.js +1 -0
- package/dist/standalone/chunk-KBB75WNT.js +1 -0
- package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
- package/dist/standalone/chunk-KJJ3WM6H.js +4 -0
- package/dist/standalone/chunk-KQV4NGH3.js +1 -0
- package/dist/standalone/chunk-KSKXW5PX.js +1 -0
- package/dist/standalone/chunk-KUH4P5F5.js +1 -0
- package/dist/standalone/chunk-KYJPPVGB.js +1 -0
- package/dist/standalone/chunk-KZ6INM5M.js +1 -0
- package/dist/standalone/chunk-L2TJVSDQ.js +1 -0
- package/dist/standalone/chunk-L7SK4ZZD.js +1 -0
- package/dist/standalone/chunk-LAK5VSPI.js +1 -0
- package/dist/standalone/chunk-LBN7LPVK.js +1 -0
- package/dist/standalone/chunk-LNZIB2MD.js +1 -0
- package/dist/standalone/chunk-MJWVMKQ4.js +6 -0
- package/dist/standalone/chunk-MLZYX5CQ.js +1 -0
- package/dist/standalone/chunk-N2X2OO4V.js +1 -0
- package/dist/standalone/chunk-NGKITPQP.js +13 -0
- package/dist/standalone/chunk-O3NAGRTR.js +1 -0
- package/dist/standalone/chunk-OZACQNKG.js +1 -0
- package/dist/standalone/chunk-PNDNXS5Z.js +1 -0
- package/dist/standalone/chunk-Q7DMUTUE.js +1 -0
- package/dist/standalone/chunk-QAFAJBAW.js +1 -0
- package/dist/standalone/chunk-QBAT52GB.js +1 -0
- package/dist/standalone/chunk-RHZ4M2NZ.js +1 -0
- package/dist/standalone/chunk-RRCPZMC2.js +22 -0
- package/dist/standalone/chunk-SEU5V7I6.js +1 -0
- package/dist/standalone/chunk-TAD43CG5.js +1 -0
- package/dist/standalone/chunk-TBMYIZIO.js +1 -0
- package/dist/standalone/chunk-TDZ44E5I.js +4 -0
- package/dist/standalone/chunk-THNBTMUF.js +1 -0
- package/dist/standalone/chunk-TIQISBGK.js +1 -0
- package/dist/standalone/chunk-TMYVNQ66.js +1 -0
- package/dist/standalone/chunk-TQ36RWOP.js +1 -0
- package/dist/standalone/chunk-UGUEC6BC.js +1 -0
- package/dist/standalone/chunk-UJB2LEI4.js +4 -0
- package/dist/standalone/chunk-UK64ZSUW.js +1 -0
- package/dist/standalone/chunk-UKDJ4H7I.js +1 -0
- package/dist/standalone/chunk-VLXV72QE.js +1 -0
- package/dist/standalone/chunk-VON7JUPG.js +1 -0
- package/dist/standalone/chunk-W3JK4YWR.js +1 -0
- package/dist/standalone/chunk-W3SHEIAL.js +3 -0
- package/dist/standalone/chunk-WI7GWFEG.js +1 -0
- package/dist/standalone/chunk-WIHXMNUY.js +1 -0
- package/dist/standalone/chunk-WLDVXVI2.js +1 -0
- package/dist/standalone/chunk-XLXNLJ4N.js +1 -0
- package/dist/standalone/chunk-XNJNSCLM.js +1 -0
- package/dist/standalone/chunk-YAECF5LW.js +1 -0
- package/dist/standalone/chunk-YBGC4PPD.js +1 -0
- package/dist/standalone/chunk-YJAPWSDC.js +4 -0
- package/dist/standalone/chunk-ZEJB6DXU.js +8 -0
- package/dist/standalone/chunk-ZFNBPAIZ.js +1 -0
- package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
- package/dist/standalone/chunk-ZIGWVHCS.js +1 -0
- package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
- package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
- package/dist/standalone/studio.js +104 -246
- package/dist/styles.css +2 -2
- package/package.json +15 -13
- package/dist/packem_shared/HomePanel-Cw16stjq.js +0 -1273
- package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
- package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
- package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
- package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { C as Card, b as CardHeader, c as CardTitle, d as CardDescription, a as CardContent } from '../packem_shared/card-DURq3ElK.js';
|
|
3
|
+
import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
|
|
4
|
+
import { c } from 'react/compiler-runtime';
|
|
5
|
+
import { E as ErrorAlert } from '../packem_shared/error-alert-CXjqyGw9.js';
|
|
6
|
+
import { L as LiveError } from '../packem_shared/live-status-FZ0psC1z.js';
|
|
7
|
+
import { B as Badge } from '../packem_shared/badge-B2PKA1-5.js';
|
|
8
|
+
import { B as Button } from '../packem_shared/button-BhsN2uZH.js';
|
|
9
|
+
import { E as EmptyState } from '../packem_shared/empty-state-DY_oe0k6.js';
|
|
10
|
+
import { T as Table, a as TableHeader, b as TableRow, c as TableHead, d as TableBody, e as TableCell } from '../packem_shared/table-DsCa9Qp9.js';
|
|
11
|
+
import { u as useAdminQuery } from '../packem_shared/use-admin-query-CfHYWx5n.js';
|
|
12
|
+
import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-BHHJi3Gb.js';
|
|
13
|
+
import { jsxDEV } from 'react/jsx-dev-runtime';
|
|
14
|
+
import { useLunora } from '@lunora/react';
|
|
15
|
+
import { ShardInput } from '../packem_shared/ShardInput-gx_DZXXn.js';
|
|
16
|
+
import { I as Input } from '../packem_shared/input-XH4r1Pt1.js';
|
|
17
|
+
import { L as Label } from '../packem_shared/label-D8ykjn5J.js';
|
|
18
|
+
import { T as Textarea } from '../packem_shared/textarea-D3gaCU_-.js';
|
|
19
|
+
import { c as callOptions, a as adminRef, e as errorMessage, f as fireAndForget } from '../packem_shared/internal-CYcbqMjX.js';
|
|
20
|
+
|
|
21
|
+
const OPERATIONS = ["read", "insert", "update", "delete"];
|
|
22
|
+
const operationLabel = (t, operation) => ({
|
|
23
|
+
delete: t("Delete"),
|
|
24
|
+
insert: t("Insert"),
|
|
25
|
+
read: t("Read"),
|
|
26
|
+
update: t("Update")
|
|
27
|
+
})[operation];
|
|
28
|
+
const uncoveredTables = (advisories) => {
|
|
29
|
+
const set = /* @__PURE__ */ new Set();
|
|
30
|
+
for (const advisory of advisories?.advisories ?? []) {
|
|
31
|
+
if (advisory.name === "rls_uncovered_table") {
|
|
32
|
+
const {
|
|
33
|
+
table
|
|
34
|
+
} = advisory.metadata;
|
|
35
|
+
if (typeof table === "string" && table !== "") {
|
|
36
|
+
set.add(table);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return set;
|
|
41
|
+
};
|
|
42
|
+
const buildRows = (policies, maskColumns, uncovered) => {
|
|
43
|
+
const byTable = /* @__PURE__ */ new Map();
|
|
44
|
+
const ensure = (table) => {
|
|
45
|
+
const existing = byTable.get(table);
|
|
46
|
+
if (existing !== void 0) {
|
|
47
|
+
return existing;
|
|
48
|
+
}
|
|
49
|
+
const row = {
|
|
50
|
+
cells: {
|
|
51
|
+
delete: {},
|
|
52
|
+
insert: {},
|
|
53
|
+
read: {},
|
|
54
|
+
update: {}
|
|
55
|
+
},
|
|
56
|
+
maskedColumns: [],
|
|
57
|
+
table,
|
|
58
|
+
uncovered: uncovered.has(table)
|
|
59
|
+
};
|
|
60
|
+
byTable.set(table, row);
|
|
61
|
+
return row;
|
|
62
|
+
};
|
|
63
|
+
for (const policy of policies) {
|
|
64
|
+
ensure(policy.table).cells[policy.on] = {
|
|
65
|
+
procedure: policy.procedure
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
for (const column of maskColumns) {
|
|
69
|
+
const row = ensure(column.table);
|
|
70
|
+
if (!row.maskedColumns.includes(column.column)) {
|
|
71
|
+
row.maskedColumns.push(column.column);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const table of uncovered) {
|
|
75
|
+
ensure(table);
|
|
76
|
+
}
|
|
77
|
+
return [...byTable.values()].toSorted((a, b) => a.table.localeCompare(b.table));
|
|
78
|
+
};
|
|
79
|
+
const PermissionsMatrix = (t0) => {
|
|
80
|
+
const $ = c(17);
|
|
81
|
+
let t1;
|
|
82
|
+
if ($[0] !== t0) {
|
|
83
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
84
|
+
$[0] = t0;
|
|
85
|
+
$[1] = t1;
|
|
86
|
+
} else {
|
|
87
|
+
t1 = $[1];
|
|
88
|
+
}
|
|
89
|
+
const {
|
|
90
|
+
onProbe
|
|
91
|
+
} = t1;
|
|
92
|
+
const t = useT();
|
|
93
|
+
let t2;
|
|
94
|
+
let t3;
|
|
95
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
96
|
+
t2 = {};
|
|
97
|
+
t3 = {
|
|
98
|
+
live: true
|
|
99
|
+
};
|
|
100
|
+
$[2] = t2;
|
|
101
|
+
$[3] = t3;
|
|
102
|
+
} else {
|
|
103
|
+
t2 = $[2];
|
|
104
|
+
t3 = $[3];
|
|
105
|
+
}
|
|
106
|
+
const policiesQuery = useAdminQuery(ADMIN_FUNCTIONS.rlsPolicies, t2, t3);
|
|
107
|
+
let t4;
|
|
108
|
+
if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
109
|
+
t4 = {};
|
|
110
|
+
$[4] = t4;
|
|
111
|
+
} else {
|
|
112
|
+
t4 = $[4];
|
|
113
|
+
}
|
|
114
|
+
const masksQuery = useAdminQuery(ADMIN_FUNCTIONS.maskPolicies, t4);
|
|
115
|
+
let t5;
|
|
116
|
+
if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
117
|
+
t5 = {};
|
|
118
|
+
$[5] = t5;
|
|
119
|
+
} else {
|
|
120
|
+
t5 = $[5];
|
|
121
|
+
}
|
|
122
|
+
const advisoriesQuery = useAdminQuery(ADMIN_FUNCTIONS.getAdvisories, t5);
|
|
123
|
+
let t6;
|
|
124
|
+
if ($[6] !== advisoriesQuery.data || $[7] !== masksQuery.data || $[8] !== onProbe || $[9] !== policiesQuery || $[10] !== t) {
|
|
125
|
+
let policies = null;
|
|
126
|
+
if (policiesQuery.data !== void 0) {
|
|
127
|
+
policies = Array.isArray(policiesQuery.data.policies) ? policiesQuery.data.policies : [];
|
|
128
|
+
}
|
|
129
|
+
const maskColumns = Array.isArray(masksQuery.data?.columns) ? masksQuery.data.columns : [];
|
|
130
|
+
const advisories = advisoriesQuery.data ?? null;
|
|
131
|
+
const {
|
|
132
|
+
error,
|
|
133
|
+
errorSource,
|
|
134
|
+
liveError
|
|
135
|
+
} = policiesQuery;
|
|
136
|
+
const rows = policies === null ? [] : buildRows(policies, maskColumns, uncoveredTables(advisories));
|
|
137
|
+
let t7;
|
|
138
|
+
if ($[12] !== liveError) {
|
|
139
|
+
t7 = /* @__PURE__ */ jsxDEV("div", {
|
|
140
|
+
className: "flex items-center justify-end",
|
|
141
|
+
children: /* @__PURE__ */ jsxDEV(LiveError, {
|
|
142
|
+
message: liveError,
|
|
143
|
+
prefix: "pm"
|
|
144
|
+
}, void 0, false)
|
|
145
|
+
}, void 0, false);
|
|
146
|
+
$[12] = liveError;
|
|
147
|
+
$[13] = t7;
|
|
148
|
+
} else {
|
|
149
|
+
t7 = $[13];
|
|
150
|
+
}
|
|
151
|
+
let t8;
|
|
152
|
+
if ($[14] !== error || $[15] !== errorSource) {
|
|
153
|
+
t8 = error !== null && /* @__PURE__ */ jsxDEV(ErrorAlert, {
|
|
154
|
+
error: errorSource,
|
|
155
|
+
testId: "pm-error"
|
|
156
|
+
}, void 0, false);
|
|
157
|
+
$[14] = error;
|
|
158
|
+
$[15] = errorSource;
|
|
159
|
+
$[16] = t8;
|
|
160
|
+
} else {
|
|
161
|
+
t8 = $[16];
|
|
162
|
+
}
|
|
163
|
+
t6 = /* @__PURE__ */ jsxDEV("div", {
|
|
164
|
+
className: "flex flex-col gap-3",
|
|
165
|
+
"data-testid": "lunora-permissions-matrix",
|
|
166
|
+
children: [t7, t8, policies !== null && rows.length === 0 ? /* @__PURE__ */ jsxDEV(EmptyState, {
|
|
167
|
+
description: t("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),
|
|
168
|
+
testId: "pm-empty",
|
|
169
|
+
title: t("No policy")
|
|
170
|
+
}, void 0, false) : /* @__PURE__ */ jsxDEV(Table, {
|
|
171
|
+
"data-testid": "pm-table",
|
|
172
|
+
children: [/* @__PURE__ */ jsxDEV(TableHeader, {
|
|
173
|
+
children: /* @__PURE__ */ jsxDEV(TableRow, {
|
|
174
|
+
children: [/* @__PURE__ */ jsxDEV(TableHead, {
|
|
175
|
+
children: t("Table")
|
|
176
|
+
}, void 0, false), OPERATIONS.map((operation) => /* @__PURE__ */ jsxDEV(TableHead, {
|
|
177
|
+
children: operationLabel(t, operation)
|
|
178
|
+
}, operation, false)), /* @__PURE__ */ jsxDEV(TableHead, {
|
|
179
|
+
children: t("Masked columns")
|
|
180
|
+
}, void 0, false)]
|
|
181
|
+
}, void 0, true)
|
|
182
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
|
|
183
|
+
children: rows.map((row) => /* @__PURE__ */ jsxDEV(TableRow, {
|
|
184
|
+
"data-testid": `pm-row-${row.table}`,
|
|
185
|
+
children: [/* @__PURE__ */ jsxDEV(TableCell, {
|
|
186
|
+
className: "font-mono text-xs",
|
|
187
|
+
children: /* @__PURE__ */ jsxDEV("span", {
|
|
188
|
+
className: "flex items-center gap-1.5",
|
|
189
|
+
children: [row.table, row.uncovered && /* @__PURE__ */ jsxDEV(Badge, {
|
|
190
|
+
"data-testid": `pm-uncovered-${row.table}`,
|
|
191
|
+
title: t("Uncovered — reachable without a policy"),
|
|
192
|
+
variant: "destructive",
|
|
193
|
+
children: t("Uncovered — reachable without a policy")
|
|
194
|
+
}, void 0, false)]
|
|
195
|
+
}, void 0, true)
|
|
196
|
+
}, void 0, false), OPERATIONS.map((operation_0) => {
|
|
197
|
+
const cell = row.cells[operation_0];
|
|
198
|
+
return /* @__PURE__ */ jsxDEV(TableCell, {
|
|
199
|
+
"data-testid": `pm-cell-${row.table}-${operation_0}`,
|
|
200
|
+
children: cell.procedure === void 0 ? /* @__PURE__ */ jsxDEV("span", {
|
|
201
|
+
className: "text-xs text-muted-foreground",
|
|
202
|
+
children: t("No policy")
|
|
203
|
+
}, void 0, false) : /* @__PURE__ */ jsxDEV("span", {
|
|
204
|
+
className: "flex flex-col gap-1",
|
|
205
|
+
children: [/* @__PURE__ */ jsxDEV(Badge, {
|
|
206
|
+
variant: "secondary",
|
|
207
|
+
children: t("Covered by {procedure}", {
|
|
208
|
+
procedure: cell.procedure
|
|
209
|
+
})
|
|
210
|
+
}, void 0, false), onProbe !== void 0 && /* @__PURE__ */ jsxDEV(Button, {
|
|
211
|
+
className: "h-auto justify-start p-0 text-[11px]",
|
|
212
|
+
"data-testid": `pm-probe-${row.table}-${operation_0}`,
|
|
213
|
+
onClick: () => {
|
|
214
|
+
onProbe(row.table, operation_0, cell.procedure ?? "");
|
|
215
|
+
},
|
|
216
|
+
size: "xs",
|
|
217
|
+
type: "button",
|
|
218
|
+
variant: "ghost",
|
|
219
|
+
children: t("Probe this")
|
|
220
|
+
}, void 0, false)]
|
|
221
|
+
}, void 0, true)
|
|
222
|
+
}, operation_0, false);
|
|
223
|
+
}), /* @__PURE__ */ jsxDEV(TableCell, {
|
|
224
|
+
children: row.maskedColumns.length === 0 ? /* @__PURE__ */ jsxDEV("span", {
|
|
225
|
+
"aria-hidden": "true",
|
|
226
|
+
className: "text-muted-foreground",
|
|
227
|
+
children: "—"
|
|
228
|
+
}, void 0, false) : /* @__PURE__ */ jsxDEV("span", {
|
|
229
|
+
className: "flex flex-wrap gap-1",
|
|
230
|
+
children: row.maskedColumns.map(_temp)
|
|
231
|
+
}, void 0, false)
|
|
232
|
+
}, void 0, false)]
|
|
233
|
+
}, row.table, true))
|
|
234
|
+
}, void 0, false)]
|
|
235
|
+
}, void 0, true)]
|
|
236
|
+
}, void 0, true);
|
|
237
|
+
$[6] = advisoriesQuery.data;
|
|
238
|
+
$[7] = masksQuery.data;
|
|
239
|
+
$[8] = onProbe;
|
|
240
|
+
$[9] = policiesQuery;
|
|
241
|
+
$[10] = t;
|
|
242
|
+
$[11] = t6;
|
|
243
|
+
} else {
|
|
244
|
+
t6 = $[11];
|
|
245
|
+
}
|
|
246
|
+
return t6;
|
|
247
|
+
};
|
|
248
|
+
function _temp(column) {
|
|
249
|
+
return /* @__PURE__ */ jsxDEV(Badge, {
|
|
250
|
+
variant: "outline",
|
|
251
|
+
children: column
|
|
252
|
+
}, column, false);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const RUN_AS = adminRef(ADMIN_FUNCTIONS.runAs);
|
|
256
|
+
const useRunAsProbe = () => {
|
|
257
|
+
const client = useLunora();
|
|
258
|
+
return async ({
|
|
259
|
+
args,
|
|
260
|
+
functionPath,
|
|
261
|
+
shardKey = "",
|
|
262
|
+
userId
|
|
263
|
+
}) => {
|
|
264
|
+
const reference = RUN_AS;
|
|
265
|
+
try {
|
|
266
|
+
const value = await client.query(reference, {
|
|
267
|
+
args,
|
|
268
|
+
functionPath,
|
|
269
|
+
userId
|
|
270
|
+
}, callOptions(shardKey));
|
|
271
|
+
return {
|
|
272
|
+
kind: "allowed",
|
|
273
|
+
value
|
|
274
|
+
};
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return {
|
|
277
|
+
kind: "denied",
|
|
278
|
+
message: error instanceof Error ? error.message : String(error)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const formatValue = (value) => value === void 0 ? "undefined" : JSON.stringify(value, null, 2);
|
|
285
|
+
const PermissionsPlayground = ({
|
|
286
|
+
functions: functionsProp,
|
|
287
|
+
prefill,
|
|
288
|
+
runAsIdentity = false
|
|
289
|
+
} = {}) => {
|
|
290
|
+
const client = useLunora();
|
|
291
|
+
const t = useT();
|
|
292
|
+
const probe = useRunAsProbe();
|
|
293
|
+
const [discovered, setDiscovered] = useState(null);
|
|
294
|
+
const [discoverError, setDiscoverError] = useState(null);
|
|
295
|
+
const functions = functionsProp ?? discovered ?? [];
|
|
296
|
+
const [selectedPath, setSelectedPath] = useState("");
|
|
297
|
+
const [argsText, setArgsText] = useState("{}");
|
|
298
|
+
const [shardKey, setShardKey] = useState("");
|
|
299
|
+
const [runAsUserId, setRunAsUserId] = useState("");
|
|
300
|
+
const [running, setRunning] = useState(false);
|
|
301
|
+
const [outcome, setOutcome] = useState(null);
|
|
302
|
+
const [argsError, setArgsError] = useState(null);
|
|
303
|
+
const appliedNonce = useRef(-1);
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
if (functionsProp !== void 0) {
|
|
306
|
+
return void 0;
|
|
307
|
+
}
|
|
308
|
+
let cancelled = false;
|
|
309
|
+
client.listFunctions().then((list) => {
|
|
310
|
+
if (!cancelled) {
|
|
311
|
+
setDiscovered(list);
|
|
312
|
+
}
|
|
313
|
+
return list;
|
|
314
|
+
}).catch((error_) => {
|
|
315
|
+
if (!cancelled) {
|
|
316
|
+
setDiscoverError(errorMessage(error_));
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return () => {
|
|
320
|
+
cancelled = true;
|
|
321
|
+
};
|
|
322
|
+
}, [client, functionsProp]);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (prefill === void 0 || appliedNonce.current === prefill.nonce) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
appliedNonce.current = prefill.nonce;
|
|
328
|
+
const target = prefill.functionPath;
|
|
329
|
+
queueMicrotask(() => {
|
|
330
|
+
setSelectedPath(target);
|
|
331
|
+
setOutcome(null);
|
|
332
|
+
});
|
|
333
|
+
}, [prefill]);
|
|
334
|
+
const effectivePath = selectedPath === "" ? functions[0]?.path ?? "" : selectedPath;
|
|
335
|
+
const run = async () => {
|
|
336
|
+
if (effectivePath === "") {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
let parsedArgs;
|
|
340
|
+
try {
|
|
341
|
+
parsedArgs = argsText.trim() === "" ? {} : JSON.parse(argsText);
|
|
342
|
+
} catch (parseError) {
|
|
343
|
+
setArgsError(t("Invalid JSON args: {message}", {
|
|
344
|
+
message: parseError.message
|
|
345
|
+
}));
|
|
346
|
+
setOutcome(null);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
setArgsError(null);
|
|
350
|
+
setRunning(true);
|
|
351
|
+
try {
|
|
352
|
+
const result = await probe({
|
|
353
|
+
args: parsedArgs,
|
|
354
|
+
functionPath: effectivePath,
|
|
355
|
+
shardKey: shardKey.trim(),
|
|
356
|
+
userId: runAsUserId.trim()
|
|
357
|
+
});
|
|
358
|
+
setOutcome(result);
|
|
359
|
+
} finally {
|
|
360
|
+
setRunning(false);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
const runOnce = () => {
|
|
364
|
+
fireAndForget(run());
|
|
365
|
+
};
|
|
366
|
+
const onSelectChange = (event) => {
|
|
367
|
+
setSelectedPath(event.target.value);
|
|
368
|
+
};
|
|
369
|
+
const onArgsChange = (event_0) => {
|
|
370
|
+
setArgsText(event_0.target.value);
|
|
371
|
+
};
|
|
372
|
+
const onUserIdChange = (event_1) => {
|
|
373
|
+
setRunAsUserId(event_1.target.value);
|
|
374
|
+
};
|
|
375
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
376
|
+
className: "flex flex-col gap-3",
|
|
377
|
+
"data-testid": "lunora-permissions-playground",
|
|
378
|
+
children: [discoverError !== null && /* @__PURE__ */ jsxDEV("p", {
|
|
379
|
+
className: "text-sm text-destructive",
|
|
380
|
+
"data-testid": "pp-discover-error",
|
|
381
|
+
role: "alert",
|
|
382
|
+
children: discoverError
|
|
383
|
+
}, void 0, false), !runAsIdentity && /* @__PURE__ */ jsxDEV(EmptyState, {
|
|
384
|
+
description: t("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),
|
|
385
|
+
testId: "pp-gate",
|
|
386
|
+
title: t("Set `runAsIdentity` to forge an identity and probe access.")
|
|
387
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV("div", {
|
|
388
|
+
className: "flex flex-col gap-3 rounded-md border border-border p-3",
|
|
389
|
+
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
390
|
+
className: "flex flex-col gap-1.5",
|
|
391
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
392
|
+
htmlFor: "pp-function",
|
|
393
|
+
children: t("Function")
|
|
394
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV("select", {
|
|
395
|
+
"aria-label": t("Function"),
|
|
396
|
+
className: "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
397
|
+
"data-testid": "pp-function",
|
|
398
|
+
id: "pp-function",
|
|
399
|
+
onChange: onSelectChange,
|
|
400
|
+
value: effectivePath,
|
|
401
|
+
children: functions.map((descriptor) => /* @__PURE__ */ jsxDEV("option", {
|
|
402
|
+
value: descriptor.path,
|
|
403
|
+
children: [descriptor.path, " (", descriptor.kind, ")"]
|
|
404
|
+
}, descriptor.path, true))
|
|
405
|
+
}, void 0, false)]
|
|
406
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("div", {
|
|
407
|
+
className: "flex flex-col gap-1.5",
|
|
408
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
409
|
+
htmlFor: "pp-args",
|
|
410
|
+
children: t("Arguments")
|
|
411
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Textarea, {
|
|
412
|
+
"aria-label": t("Arguments"),
|
|
413
|
+
className: "font-mono text-xs",
|
|
414
|
+
"data-testid": "pp-args",
|
|
415
|
+
id: "pp-args",
|
|
416
|
+
onChange: onArgsChange,
|
|
417
|
+
value: argsText
|
|
418
|
+
}, void 0, false)]
|
|
419
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV(ShardInput, {
|
|
420
|
+
onChange: setShardKey,
|
|
421
|
+
testId: "pp-shard",
|
|
422
|
+
value: shardKey
|
|
423
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV("div", {
|
|
424
|
+
className: "flex flex-col gap-1.5",
|
|
425
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
426
|
+
htmlFor: "pp-user",
|
|
427
|
+
children: t("Run as (userId)")
|
|
428
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
429
|
+
"aria-label": t("Identity (userId) to run as"),
|
|
430
|
+
className: "font-mono text-xs",
|
|
431
|
+
"data-testid": "pp-user",
|
|
432
|
+
id: "pp-user",
|
|
433
|
+
onChange: onUserIdChange,
|
|
434
|
+
placeholder: t("Leave empty to run as admin"),
|
|
435
|
+
value: runAsUserId
|
|
436
|
+
}, void 0, false)]
|
|
437
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("div", {
|
|
438
|
+
className: "flex items-center gap-2",
|
|
439
|
+
children: [/* @__PURE__ */ jsxDEV(Button, {
|
|
440
|
+
"data-testid": "pp-run",
|
|
441
|
+
disabled: !runAsIdentity || running || effectivePath === "",
|
|
442
|
+
onClick: runOnce,
|
|
443
|
+
type: "button",
|
|
444
|
+
children: running ? t("Probing…") : t("Run probe")
|
|
445
|
+
}, void 0, false), runAsUserId.trim() !== "" && /* @__PURE__ */ jsxDEV(Badge, {
|
|
446
|
+
"data-testid": "pp-as-badge",
|
|
447
|
+
variant: "secondary",
|
|
448
|
+
children: t("as {userId}", {
|
|
449
|
+
userId: runAsUserId.trim()
|
|
450
|
+
})
|
|
451
|
+
}, void 0, false)]
|
|
452
|
+
}, void 0, true)]
|
|
453
|
+
}, void 0, true), argsError !== null && /* @__PURE__ */ jsxDEV("p", {
|
|
454
|
+
className: "text-sm text-destructive",
|
|
455
|
+
"data-testid": "pp-args-error",
|
|
456
|
+
role: "alert",
|
|
457
|
+
children: argsError
|
|
458
|
+
}, void 0, false), outcome !== null && outcome.kind === "allowed" && /* @__PURE__ */ jsxDEV("div", {
|
|
459
|
+
className: "flex flex-col gap-2",
|
|
460
|
+
"data-testid": "pp-outcome-allowed",
|
|
461
|
+
children: [/* @__PURE__ */ jsxDEV(Badge, {
|
|
462
|
+
variant: "secondary",
|
|
463
|
+
children: t("Allowed")
|
|
464
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV("pre", {
|
|
465
|
+
className: "overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs",
|
|
466
|
+
"data-testid": "pp-result",
|
|
467
|
+
children: formatValue(outcome.value)
|
|
468
|
+
}, void 0, false)]
|
|
469
|
+
}, void 0, true), outcome !== null && outcome.kind === "denied" && /* @__PURE__ */ jsxDEV("div", {
|
|
470
|
+
className: "flex flex-col gap-2",
|
|
471
|
+
"data-testid": "pp-outcome-denied",
|
|
472
|
+
children: [/* @__PURE__ */ jsxDEV(Badge, {
|
|
473
|
+
variant: "destructive",
|
|
474
|
+
children: t("Denied")
|
|
475
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV("pre", {
|
|
476
|
+
className: "overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive",
|
|
477
|
+
"data-testid": "pp-denied",
|
|
478
|
+
role: "alert",
|
|
479
|
+
children: outcome.message
|
|
480
|
+
}, void 0, false)]
|
|
481
|
+
}, void 0, true)]
|
|
482
|
+
}, void 0, true);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
486
|
+
const FAILURE_MESSAGES = {
|
|
487
|
+
"already-wired": "That procedure already has an rls(...) policy wired in.",
|
|
488
|
+
"file-exists": "A policy file with that name already exists — pick another name or edit it by hand.",
|
|
489
|
+
"invalid-identifier": "Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).",
|
|
490
|
+
"unknown-procedure": "No exported procedure was found at that file path.",
|
|
491
|
+
"unsupported-procedure-shape": "That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."
|
|
492
|
+
};
|
|
493
|
+
const applyPolicyScaffold = async (request) => {
|
|
494
|
+
const response = await fetch(POLICY_SCAFFOLD_ENDPOINT, {
|
|
495
|
+
body: JSON.stringify(request),
|
|
496
|
+
headers: {
|
|
497
|
+
"Content-Type": "application/json"
|
|
498
|
+
},
|
|
499
|
+
method: "POST"
|
|
500
|
+
});
|
|
501
|
+
const body = await response.json();
|
|
502
|
+
if (body.needsManualEdit === true) {
|
|
503
|
+
return {
|
|
504
|
+
kind: "needs-manual-edit",
|
|
505
|
+
message: body.message ?? "This change must be made by hand."
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
if (response.ok) {
|
|
509
|
+
return {
|
|
510
|
+
diagnostics: body.diagnostics ?? [],
|
|
511
|
+
kind: "ok",
|
|
512
|
+
label: body.fileName ?? body.exportName ?? ""
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
const token = body.error;
|
|
516
|
+
const message = token === void 0 ? `policy scaffold failed (${String(response.status)})` : FAILURE_MESSAGES[token] ?? token;
|
|
517
|
+
return {
|
|
518
|
+
kind: "error",
|
|
519
|
+
message
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
const EMPTY_FORM = {
|
|
524
|
+
exportName: "",
|
|
525
|
+
filePath: "",
|
|
526
|
+
policyName: "",
|
|
527
|
+
policies: "",
|
|
528
|
+
tableName: ""
|
|
529
|
+
};
|
|
530
|
+
const PolicyScaffolder = () => {
|
|
531
|
+
const t = useT();
|
|
532
|
+
const [mode, setMode] = useState(null);
|
|
533
|
+
const [busy, setBusy] = useState(false);
|
|
534
|
+
const [result, setResult] = useState(null);
|
|
535
|
+
const [form, setForm] = useState(EMPTY_FORM);
|
|
536
|
+
const onFieldChange = (event) => {
|
|
537
|
+
const field = event.target.name;
|
|
538
|
+
const {
|
|
539
|
+
value
|
|
540
|
+
} = event.target;
|
|
541
|
+
setForm((previous) => {
|
|
542
|
+
return {
|
|
543
|
+
...previous,
|
|
544
|
+
[field]: value
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
const reset = () => {
|
|
549
|
+
setMode(null);
|
|
550
|
+
setForm(EMPTY_FORM);
|
|
551
|
+
};
|
|
552
|
+
const submit = async (request) => {
|
|
553
|
+
setBusy(true);
|
|
554
|
+
setResult(null);
|
|
555
|
+
try {
|
|
556
|
+
const outcome = await applyPolicyScaffold(request);
|
|
557
|
+
setResult(outcome);
|
|
558
|
+
if (outcome.kind === "ok") {
|
|
559
|
+
reset();
|
|
560
|
+
}
|
|
561
|
+
} catch (error) {
|
|
562
|
+
setResult({
|
|
563
|
+
kind: "error",
|
|
564
|
+
message: error instanceof Error ? error.message : String(error)
|
|
565
|
+
});
|
|
566
|
+
} finally {
|
|
567
|
+
setBusy(false);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
const onSubmitScaffold = () => {
|
|
571
|
+
fireAndForget(submit({
|
|
572
|
+
kind: "scaffoldPolicy",
|
|
573
|
+
name: form.policyName.trim(),
|
|
574
|
+
table: form.tableName.trim()
|
|
575
|
+
}));
|
|
576
|
+
};
|
|
577
|
+
const onSubmitWire = () => {
|
|
578
|
+
fireAndForget(submit({
|
|
579
|
+
exportName: form.exportName.trim(),
|
|
580
|
+
filePath: form.filePath.trim(),
|
|
581
|
+
kind: "wireRls",
|
|
582
|
+
policies: form.policies.trim()
|
|
583
|
+
}));
|
|
584
|
+
};
|
|
585
|
+
const openScaffold = () => {
|
|
586
|
+
setResult(null);
|
|
587
|
+
setMode("scaffold");
|
|
588
|
+
};
|
|
589
|
+
const openWire = () => {
|
|
590
|
+
setResult(null);
|
|
591
|
+
setMode("wire");
|
|
592
|
+
};
|
|
593
|
+
return /* @__PURE__ */ jsxDEV(Card, {
|
|
594
|
+
"data-testid": "policy-scaffolder",
|
|
595
|
+
size: "sm",
|
|
596
|
+
children: [/* @__PURE__ */ jsxDEV(CardHeader, {
|
|
597
|
+
children: [/* @__PURE__ */ jsxDEV(CardTitle, {
|
|
598
|
+
children: t("Scaffold access rules")
|
|
599
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(CardDescription, {
|
|
600
|
+
children: t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")
|
|
601
|
+
}, void 0, false)]
|
|
602
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV(CardContent, {
|
|
603
|
+
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
604
|
+
className: "flex flex-wrap gap-2",
|
|
605
|
+
children: [/* @__PURE__ */ jsxDEV(Button, {
|
|
606
|
+
"data-testid": "policy-scaffolder-new",
|
|
607
|
+
onClick: openScaffold,
|
|
608
|
+
size: "xs",
|
|
609
|
+
type: "button",
|
|
610
|
+
variant: mode === "scaffold" ? "default" : "outline",
|
|
611
|
+
children: t("New policy file")
|
|
612
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
|
|
613
|
+
"data-testid": "policy-scaffolder-wire",
|
|
614
|
+
onClick: openWire,
|
|
615
|
+
size: "xs",
|
|
616
|
+
type: "button",
|
|
617
|
+
variant: mode === "wire" ? "default" : "outline",
|
|
618
|
+
children: t("Wire into a procedure")
|
|
619
|
+
}, void 0, false)]
|
|
620
|
+
}, void 0, true), mode === "scaffold" && /* @__PURE__ */ jsxDEV("div", {
|
|
621
|
+
className: "mt-3 flex flex-wrap items-end gap-2",
|
|
622
|
+
"data-testid": "policy-scaffolder-new-form",
|
|
623
|
+
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
624
|
+
className: "flex flex-col gap-1 text-xs",
|
|
625
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
626
|
+
htmlFor: "policy-scaffolder-name",
|
|
627
|
+
children: t("Policy name")
|
|
628
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
629
|
+
"data-testid": "policy-scaffolder-name",
|
|
630
|
+
id: "policy-scaffolder-name",
|
|
631
|
+
name: "policyName",
|
|
632
|
+
onChange: onFieldChange,
|
|
633
|
+
value: form.policyName
|
|
634
|
+
}, void 0, false)]
|
|
635
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("div", {
|
|
636
|
+
className: "flex flex-col gap-1 text-xs",
|
|
637
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
638
|
+
htmlFor: "policy-scaffolder-table",
|
|
639
|
+
children: t("Table name")
|
|
640
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
641
|
+
"data-testid": "policy-scaffolder-table",
|
|
642
|
+
id: "policy-scaffolder-table",
|
|
643
|
+
name: "tableName",
|
|
644
|
+
onChange: onFieldChange,
|
|
645
|
+
value: form.tableName
|
|
646
|
+
}, void 0, false)]
|
|
647
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV(Button, {
|
|
648
|
+
"data-testid": "policy-scaffolder-create",
|
|
649
|
+
disabled: busy || form.policyName.trim() === "" || form.tableName.trim() === "",
|
|
650
|
+
onClick: onSubmitScaffold,
|
|
651
|
+
size: "xs",
|
|
652
|
+
type: "button",
|
|
653
|
+
children: busy ? t("Creating…") : t("Create policy file")
|
|
654
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
|
|
655
|
+
onClick: reset,
|
|
656
|
+
size: "xs",
|
|
657
|
+
type: "button",
|
|
658
|
+
variant: "ghost",
|
|
659
|
+
children: t("Cancel")
|
|
660
|
+
}, void 0, false)]
|
|
661
|
+
}, void 0, true), mode === "wire" && /* @__PURE__ */ jsxDEV("div", {
|
|
662
|
+
className: "mt-3 flex flex-wrap items-end gap-2",
|
|
663
|
+
"data-testid": "policy-scaffolder-wire-form",
|
|
664
|
+
children: [/* @__PURE__ */ jsxDEV("div", {
|
|
665
|
+
className: "flex flex-col gap-1 text-xs",
|
|
666
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
667
|
+
htmlFor: "policy-scaffolder-file",
|
|
668
|
+
children: t("Procedure file path")
|
|
669
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
670
|
+
"data-testid": "policy-scaffolder-file",
|
|
671
|
+
id: "policy-scaffolder-file",
|
|
672
|
+
name: "filePath",
|
|
673
|
+
onChange: onFieldChange,
|
|
674
|
+
value: form.filePath
|
|
675
|
+
}, void 0, false)]
|
|
676
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("div", {
|
|
677
|
+
className: "flex flex-col gap-1 text-xs",
|
|
678
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
679
|
+
htmlFor: "policy-scaffolder-export",
|
|
680
|
+
children: t("Exported procedure")
|
|
681
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
682
|
+
"data-testid": "policy-scaffolder-export",
|
|
683
|
+
id: "policy-scaffolder-export",
|
|
684
|
+
name: "exportName",
|
|
685
|
+
onChange: onFieldChange,
|
|
686
|
+
value: form.exportName
|
|
687
|
+
}, void 0, false)]
|
|
688
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("div", {
|
|
689
|
+
className: "flex flex-col gap-1 text-xs",
|
|
690
|
+
children: [/* @__PURE__ */ jsxDEV(Label, {
|
|
691
|
+
htmlFor: "policy-scaffolder-policies",
|
|
692
|
+
children: t("Policy set identifier")
|
|
693
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
|
|
694
|
+
"data-testid": "policy-scaffolder-policies",
|
|
695
|
+
id: "policy-scaffolder-policies",
|
|
696
|
+
name: "policies",
|
|
697
|
+
onChange: onFieldChange,
|
|
698
|
+
value: form.policies
|
|
699
|
+
}, void 0, false)]
|
|
700
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV(Button, {
|
|
701
|
+
"data-testid": "policy-scaffolder-apply",
|
|
702
|
+
disabled: busy || form.filePath.trim() === "" || form.exportName.trim() === "" || form.policies.trim() === "",
|
|
703
|
+
onClick: onSubmitWire,
|
|
704
|
+
size: "xs",
|
|
705
|
+
type: "button",
|
|
706
|
+
children: busy ? t("Wiring…") : t("Wire RLS")
|
|
707
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
|
|
708
|
+
onClick: reset,
|
|
709
|
+
size: "xs",
|
|
710
|
+
type: "button",
|
|
711
|
+
variant: "ghost",
|
|
712
|
+
children: t("Cancel")
|
|
713
|
+
}, void 0, false)]
|
|
714
|
+
}, void 0, true), result?.kind === "error" && /* @__PURE__ */ jsxDEV("p", {
|
|
715
|
+
className: "mt-3 text-sm text-destructive",
|
|
716
|
+
"data-testid": "policy-scaffolder-error",
|
|
717
|
+
role: "alert",
|
|
718
|
+
children: result.message
|
|
719
|
+
}, void 0, false), result?.kind === "needs-manual-edit" && /* @__PURE__ */ jsxDEV("p", {
|
|
720
|
+
className: "mt-3 text-sm text-amber-600 dark:text-amber-500",
|
|
721
|
+
"data-testid": "policy-scaffolder-manual",
|
|
722
|
+
role: "alert",
|
|
723
|
+
children: t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")
|
|
724
|
+
}, void 0, false), result?.kind === "ok" && /* @__PURE__ */ jsxDEV("div", {
|
|
725
|
+
className: "mt-3 flex flex-col gap-1",
|
|
726
|
+
"data-testid": "policy-scaffolder-ok",
|
|
727
|
+
children: [/* @__PURE__ */ jsxDEV("p", {
|
|
728
|
+
className: "text-sm text-emerald-600 dark:text-emerald-500",
|
|
729
|
+
children: t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.", {
|
|
730
|
+
label: result.label
|
|
731
|
+
})
|
|
732
|
+
}, void 0, false), result.diagnostics.length > 0 && /* @__PURE__ */ jsxDEV("ul", {
|
|
733
|
+
className: "flex flex-col gap-0.5",
|
|
734
|
+
"data-testid": "policy-scaffolder-diagnostics",
|
|
735
|
+
children: result.diagnostics.map((diagnostic) => /* @__PURE__ */ jsxDEV("li", {
|
|
736
|
+
className: "font-mono text-[11px] text-destructive",
|
|
737
|
+
children: diagnostic
|
|
738
|
+
}, diagnostic, false))
|
|
739
|
+
}, void 0, false)]
|
|
740
|
+
}, void 0, true)]
|
|
741
|
+
}, void 0, true)]
|
|
742
|
+
}, void 0, true);
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
const PermissionsPanel = ({
|
|
746
|
+
functions,
|
|
747
|
+
runAsIdentity = false,
|
|
748
|
+
schemaEditable = false
|
|
749
|
+
} = {}) => {
|
|
750
|
+
const t = useT();
|
|
751
|
+
const [prefill, setPrefill] = useState(void 0);
|
|
752
|
+
const onProbe = (_table, _operation, procedure) => {
|
|
753
|
+
if (procedure !== "") {
|
|
754
|
+
setPrefill((previous) => {
|
|
755
|
+
return {
|
|
756
|
+
functionPath: procedure,
|
|
757
|
+
nonce: (previous?.nonce ?? 0) + 1
|
|
758
|
+
};
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
763
|
+
className: "flex flex-col gap-8",
|
|
764
|
+
"data-testid": "lunora-permissions",
|
|
765
|
+
children: [/* @__PURE__ */ jsxDEV("section", {
|
|
766
|
+
className: "flex flex-col gap-3",
|
|
767
|
+
children: [/* @__PURE__ */ jsxDEV("header", {
|
|
768
|
+
className: "border-b border-border px-4 py-3",
|
|
769
|
+
children: /* @__PURE__ */ jsxDEV("span", {
|
|
770
|
+
className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
|
|
771
|
+
children: t("Permissions")
|
|
772
|
+
}, void 0, false)
|
|
773
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(PermissionsMatrix, {
|
|
774
|
+
onProbe
|
|
775
|
+
}, void 0, false)]
|
|
776
|
+
}, void 0, true), /* @__PURE__ */ jsxDEV("section", {
|
|
777
|
+
className: "flex flex-col gap-3",
|
|
778
|
+
children: /* @__PURE__ */ jsxDEV(Card, {
|
|
779
|
+
className: "gap-0 py-0",
|
|
780
|
+
children: [/* @__PURE__ */ jsxDEV("header", {
|
|
781
|
+
className: "border-b border-border px-4 py-3",
|
|
782
|
+
children: /* @__PURE__ */ jsxDEV("span", {
|
|
783
|
+
className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
|
|
784
|
+
children: t("Probe")
|
|
785
|
+
}, void 0, false)
|
|
786
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(CardContent, {
|
|
787
|
+
className: "px-4 py-4",
|
|
788
|
+
children: [/* @__PURE__ */ jsxDEV("p", {
|
|
789
|
+
className: "mb-3 text-sm text-muted-foreground",
|
|
790
|
+
children: t("Pick a function and an identity, then run it to see the access outcome.")
|
|
791
|
+
}, void 0, false), /* @__PURE__ */ jsxDEV(PermissionsPlayground, {
|
|
792
|
+
functions,
|
|
793
|
+
prefill,
|
|
794
|
+
runAsIdentity
|
|
795
|
+
}, void 0, false)]
|
|
796
|
+
}, void 0, true)]
|
|
797
|
+
}, void 0, true)
|
|
798
|
+
}, void 0, false), schemaEditable && /* @__PURE__ */ jsxDEV("section", {
|
|
799
|
+
className: "flex flex-col gap-2",
|
|
800
|
+
children: /* @__PURE__ */ jsxDEV(PolicyScaffolder, {}, void 0, false)
|
|
801
|
+
}, void 0, false)]
|
|
802
|
+
}, void 0, true);
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
export { PermissionsPanel };
|