@rebasepro/cms 0.29.2 → 0.29.3

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.
Files changed (33) hide show
  1. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +1 -1
  2. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  3. package/dist/components/EntityPreviewBinding.d.ts +20 -0
  4. package/dist/components/EntityPreviewBinding.js +121 -18
  5. package/dist/components/EntityPreviewBinding.js.map +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +3 -1
  8. package/dist/mcp_view/bridge.d.ts +21 -1
  9. package/dist/mcp_view/bridge.js.map +1 -1
  10. package/dist/mcp_view/index.d.ts +7 -7
  11. package/dist/mcp_view/index.js +6 -1
  12. package/dist/mcp_view/index.js.map +1 -1
  13. package/dist/mcp_view/screen.d.ts +6 -4
  14. package/dist/mcp_view/screen.js +14 -42
  15. package/dist/mcp_view/screen.js.map +1 -1
  16. package/dist/mcp_view/tool_driver.d.ts +33 -0
  17. package/dist/mcp_view/tool_driver.js +186 -85
  18. package/dist/mcp_view/tool_driver.js.map +1 -1
  19. package/dist/mcp_view/write_review.d.ts +35 -0
  20. package/dist/mcp_view/write_review.js +144 -0
  21. package/dist/mcp_view/write_review.js.map +1 -0
  22. package/dist/preview/components/RelationPreview.js +7 -2
  23. package/dist/preview/components/RelationPreview.js.map +1 -1
  24. package/dist/saved_apps/SavedAppsView.d.ts +17 -0
  25. package/dist/saved_apps/SavedAppsView.js +167 -0
  26. package/dist/saved_apps/SavedAppsView.js.map +1 -0
  27. package/dist/saved_apps/admin_apps_client.d.ts +24 -0
  28. package/dist/saved_apps/admin_apps_client.js +46 -0
  29. package/dist/saved_apps/admin_apps_client.js.map +1 -0
  30. package/dist/saved_apps/saved_app_frame.d.ts +20 -0
  31. package/dist/saved_apps/saved_app_frame.js +143 -0
  32. package/dist/saved_apps/saved_app_frame.js.map +1 -0
  33. package/package.json +9 -9
@@ -0,0 +1,143 @@
1
+ import { isRecord, toolText } from "./admin_apps_client.js";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Alert, CircularProgress, Typography } from "@rebasepro/ui";
5
+ //#region src/saved_apps/saved_app_frame.tsx
6
+ /**
7
+ * EXPERIMENTAL. A saved app in the admin panel, run as Claude runs it: the
8
+ * MCP App view in a frame, with this page as its host.
9
+ *
10
+ * The frame is sandboxed without `allow-same-origin`, so it has an opaque
11
+ * origin: no cookies, no storage of the admin panel's, no reach into this
12
+ * page. Its policy allows no network at all. Every read and write the app
13
+ * makes is a message to this page, which relays it to the admin panel's MCP
14
+ * endpoint as the person signed in, where it runs under their RLS — so stored
15
+ * code someone else wrote can do nothing the viewer could not, and cannot
16
+ * send their session anywhere.
17
+ */
18
+ /** The view document's address (`MCP_APP_URI` in `@rebasepro/server`). */
19
+ var VIEW_URI = "ui://rebase/app.html";
20
+ /** No network, no frames, no forms posted anywhere: only the document's own inline code and data. */
21
+ var FRAME_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:; connect-src 'none'; frame-src 'none'; form-action 'none'; base-uri 'none'";
22
+ /** The view document with the frame's policy at the top of its head. */
23
+ function sandboxedViewDocument(html) {
24
+ const meta = `<meta http-equiv="Content-Security-Policy" content="${FRAME_POLICY}">`;
25
+ return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}${meta}`) : `${meta}${html}`;
26
+ }
27
+ function SavedAppFrame({ client, appId }) {
28
+ const frame = useRef(null);
29
+ const [document, setDocument] = useState();
30
+ const [opened, setOpened] = useState();
31
+ const [error, setError] = useState();
32
+ const [height, setHeight] = useState(640);
33
+ useEffect(() => {
34
+ let cancelled = false;
35
+ setError(void 0);
36
+ Promise.all([client.request("resources/read", { uri: VIEW_URI }), client.callTool("open_app", { id: appId })]).then(([read, result]) => {
37
+ if (cancelled) return;
38
+ const html = (isRecord(read) && Array.isArray(read.contents) ? read.contents : []).find(isRecord)?.text;
39
+ if (typeof html !== "string") throw new Error("This backend serves no app view.");
40
+ if (result.isError) throw new Error(toolText(result) ?? "The app could not be opened.");
41
+ setOpened(result);
42
+ setDocument(sandboxedViewDocument(html));
43
+ }).catch((reason) => {
44
+ if (!cancelled) setError(reason instanceof Error ? reason.message : String(reason));
45
+ });
46
+ return () => {
47
+ cancelled = true;
48
+ };
49
+ }, [client, appId]);
50
+ useEffect(() => {
51
+ if (!opened) return;
52
+ const target = () => frame.current?.contentWindow ?? null;
53
+ const send = (message) => target()?.postMessage({
54
+ jsonrpc: "2.0",
55
+ ...message
56
+ }, "*");
57
+ const theme = () => window.document.documentElement.classList.contains("dark") ? "dark" : "light";
58
+ const receive = (event) => {
59
+ if (event.source === null || event.source !== target()) return;
60
+ const message = event.data;
61
+ if (!isRecord(message) || message.jsonrpc !== "2.0" || typeof message.method !== "string") return;
62
+ const id = typeof message.id === "string" || typeof message.id === "number" ? message.id : void 0;
63
+ const params = isRecord(message.params) ? message.params : {};
64
+ const answer = (result) => id !== void 0 && send({
65
+ id,
66
+ result
67
+ });
68
+ const refuse = (text) => id !== void 0 && send({
69
+ id,
70
+ error: {
71
+ code: -32e3,
72
+ message: text
73
+ }
74
+ });
75
+ switch (message.method) {
76
+ case "ui/initialize":
77
+ answer({
78
+ protocolVersion: params.protocolVersion,
79
+ hostInfo: {
80
+ name: "rebase-admin",
81
+ version: "0.1.0"
82
+ },
83
+ hostCapabilities: {},
84
+ hostContext: {
85
+ theme: theme(),
86
+ displayMode: "inline",
87
+ availableDisplayModes: ["inline"]
88
+ }
89
+ });
90
+ return;
91
+ case "ui/notifications/initialized":
92
+ send({
93
+ method: "ui/notifications/tool-result",
94
+ params: opened
95
+ });
96
+ return;
97
+ case "tools/call": {
98
+ const name = typeof params.name === "string" ? params.name : "";
99
+ const args = isRecord(params.arguments) ? params.arguments : {};
100
+ client.callTool(name, args).then(answer, (reason) => refuse(reason instanceof Error ? reason.message : String(reason)));
101
+ return;
102
+ }
103
+ case "ui/notifications/size-changed":
104
+ if (typeof params.height === "number" && params.height > 0) setHeight(Math.ceil(params.height));
105
+ return;
106
+ case "ui/request-display-mode":
107
+ answer({ mode: "inline" });
108
+ return;
109
+ case "ui/update-model-context":
110
+ answer({});
111
+ return;
112
+ default: refuse(`The admin panel does not answer ${message.method}.`);
113
+ }
114
+ };
115
+ window.addEventListener("message", receive);
116
+ return () => window.removeEventListener("message", receive);
117
+ }, [opened, client]);
118
+ if (error) return /* @__PURE__ */ jsx(Alert, {
119
+ color: "error",
120
+ size: "small",
121
+ children: error
122
+ });
123
+ if (!document) return /* @__PURE__ */ jsxs("div", {
124
+ className: "flex items-center gap-2 p-4",
125
+ children: [/* @__PURE__ */ jsx(CircularProgress, { size: "small" }), /* @__PURE__ */ jsx(Typography, {
126
+ variant: "body2",
127
+ color: "secondary",
128
+ children: "Opening the app…"
129
+ })]
130
+ });
131
+ return /* @__PURE__ */ jsx("iframe", {
132
+ ref: frame,
133
+ title: "Saved app",
134
+ sandbox: "allow-scripts allow-forms",
135
+ srcDoc: document,
136
+ className: "w-full rounded-xl border-0",
137
+ style: { height }
138
+ });
139
+ }
140
+ //#endregion
141
+ export { SavedAppFrame, sandboxedViewDocument };
142
+
143
+ //# sourceMappingURL=saved_app_frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved_app_frame.js","names":[],"sources":["../../src/saved_apps/saved_app_frame.tsx"],"sourcesContent":["/**\n * EXPERIMENTAL. A saved app in the admin panel, run as Claude runs it: the\n * MCP App view in a frame, with this page as its host.\n *\n * The frame is sandboxed without `allow-same-origin`, so it has an opaque\n * origin: no cookies, no storage of the admin panel's, no reach into this\n * page. Its policy allows no network at all. Every read and write the app\n * makes is a message to this page, which relays it to the admin panel's MCP\n * endpoint as the person signed in, where it runs under their RLS — so stored\n * code someone else wrote can do nothing the viewer could not, and cannot\n * send their session anywhere.\n */\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Alert, CircularProgress, Typography } from \"@rebasepro/ui\";\nimport { isRecord, toolText, type AdminAppsClient, type AdminToolResult } from \"./admin_apps_client\";\n\n/** The view document's address (`MCP_APP_URI` in `@rebasepro/server`). */\nconst VIEW_URI = \"ui://rebase/app.html\";\n\n/** No network, no frames, no forms posted anywhere: only the document's own inline code and data. */\nconst FRAME_POLICY = \"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; \"\n + \"font-src data:; media-src data: blob:; connect-src 'none'; frame-src 'none'; form-action 'none'; base-uri 'none'\";\n\n/** The view document with the frame's policy at the top of its head. */\nexport function sandboxedViewDocument(html: string): string {\n const meta = `<meta http-equiv=\"Content-Security-Policy\" content=\"${FRAME_POLICY}\">`;\n return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, match => `${match}${meta}`) : `${meta}${html}`;\n}\n\nexport function SavedAppFrame({ client, appId }: { client: AdminAppsClient; appId: string }) {\n const frame = useRef<HTMLIFrameElement>(null);\n const [document, setDocument] = useState<string>();\n const [opened, setOpened] = useState<AdminToolResult>();\n const [error, setError] = useState<string>();\n const [height, setHeight] = useState(640);\n\n // The view, and the app as open_app answers it.\n useEffect(() => {\n let cancelled = false;\n setError(undefined);\n Promise.all([\n client.request(\"resources/read\", { uri: VIEW_URI }),\n client.callTool(\"open_app\", { id: appId })\n ]).then(([read, result]) => {\n if (cancelled) return;\n const contents = isRecord(read) && Array.isArray(read.contents) ? read.contents : [];\n const html = contents.find(isRecord)?.text;\n if (typeof html !== \"string\") throw new Error(\"This backend serves no app view.\");\n if (result.isError) throw new Error(toolText(result) ?? \"The app could not be opened.\");\n setOpened(result);\n setDocument(sandboxedViewDocument(html));\n }).catch((reason: unknown) => {\n if (!cancelled) setError(reason instanceof Error ? reason.message : String(reason));\n });\n return () => {\n cancelled = true;\n };\n }, [client, appId]);\n\n // The host's half of the MCP Apps protocol, for the one frame.\n useEffect(() => {\n if (!opened) return;\n const target = () => frame.current?.contentWindow ?? null;\n const send = (message: Record<string, unknown>) => target()?.postMessage({ jsonrpc: \"2.0\", ...message }, \"*\");\n const theme = () => window.document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\";\n\n const receive = (event: MessageEvent) => {\n // Only the frame speaks to this host; its origin is opaque, so the window is the check.\n if (event.source === null || event.source !== target()) return;\n const message: unknown = event.data;\n if (!isRecord(message) || message.jsonrpc !== \"2.0\" || typeof message.method !== \"string\") return;\n const id = typeof message.id === \"string\" || typeof message.id === \"number\" ? message.id : undefined;\n const params = isRecord(message.params) ? message.params : {};\n const answer = (result: unknown) => id !== undefined && send({ id, result });\n const refuse = (text: string) => id !== undefined && send({ id, error: { code: -32000, message: text } });\n\n switch (message.method) {\n case \"ui/initialize\":\n answer({\n protocolVersion: params.protocolVersion,\n hostInfo: { name: \"rebase-admin\", version: \"0.1.0\" },\n hostCapabilities: {},\n hostContext: { theme: theme(), displayMode: \"inline\", availableDisplayModes: [\"inline\"] }\n });\n return;\n case \"ui/notifications/initialized\":\n send({ method: \"ui/notifications/tool-result\", params: opened });\n return;\n case \"tools/call\": {\n const name = typeof params.name === \"string\" ? params.name : \"\";\n const args = isRecord(params.arguments) ? params.arguments : {};\n client.callTool(name, args).then(answer, (reason: unknown) => refuse(reason instanceof Error ? reason.message : String(reason)));\n return;\n }\n case \"ui/notifications/size-changed\":\n if (typeof params.height === \"number\" && params.height > 0) setHeight(Math.ceil(params.height));\n return;\n case \"ui/request-display-mode\":\n answer({ mode: \"inline\" });\n return;\n case \"ui/update-model-context\":\n // No conversation to tell here.\n answer({});\n return;\n default:\n refuse(`The admin panel does not answer ${message.method}.`);\n }\n };\n window.addEventListener(\"message\", receive);\n return () => window.removeEventListener(\"message\", receive);\n }, [opened, client]);\n\n if (error) return <Alert color=\"error\" size=\"small\">{error}</Alert>;\n if (!document) {\n return (\n <div className=\"flex items-center gap-2 p-4\">\n <CircularProgress size=\"small\"/>\n <Typography variant=\"body2\" color=\"secondary\">Opening the app…</Typography>\n </div>\n );\n }\n return (\n <iframe\n ref={frame}\n title=\"Saved app\"\n sandbox=\"allow-scripts allow-forms\"\n srcDoc={document}\n className=\"w-full rounded-xl border-0\"\n style={{ height }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,IAAM,WAAW;;AAGjB,IAAM,eAAe;;AAIrB,SAAgB,sBAAsB,MAAsB;CACxD,MAAM,OAAO,uDAAuD,aAAa;CACjF,OAAO,eAAe,KAAK,IAAI,IAAI,KAAK,QAAQ,iBAAgB,UAAS,GAAG,QAAQ,MAAM,IAAI,GAAG,OAAO;AAC5G;AAEA,SAAgB,cAAc,EAAE,QAAQ,SAAqD;CACzF,MAAM,QAAQ,OAA0B,IAAI;CAC5C,MAAM,CAAC,UAAU,eAAe,SAAiB;CACjD,MAAM,CAAC,QAAQ,aAAa,SAA0B;CACtD,MAAM,CAAC,OAAO,YAAY,SAAiB;CAC3C,MAAM,CAAC,QAAQ,aAAa,SAAS,GAAG;CAGxC,gBAAgB;EACZ,IAAI,YAAY;EAChB,SAAS,KAAA,CAAS;EAClB,QAAQ,IAAI,CACR,OAAO,QAAQ,kBAAkB,EAAE,KAAK,SAAS,CAAC,GAClD,OAAO,SAAS,YAAY,EAAE,IAAI,MAAM,CAAC,CAC7C,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,YAAY;GACxB,IAAI,WAAW;GAEf,MAAM,QADW,SAAS,IAAI,KAAK,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAK,WAAW,CAAC,EAAA,CAC7D,KAAK,QAAQ,CAAC,EAAE;GACtC,IAAI,OAAO,SAAS,UAAU,MAAM,IAAI,MAAM,kCAAkC;GAChF,IAAI,OAAO,SAAS,MAAM,IAAI,MAAM,SAAS,MAAM,KAAK,8BAA8B;GACtF,UAAU,MAAM;GAChB,YAAY,sBAAsB,IAAI,CAAC;EAC3C,CAAC,CAAC,CAAC,OAAO,WAAoB;GAC1B,IAAI,CAAC,WAAW,SAAS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OAAO,SAAS,WAAW,OAAO,OAAO;KAC7D,MAAM,OAAO,SAAS,OAAO,SAAS,IAAI,OAAO,YAAY,CAAC;KAC9D,OAAO,SAAS,MAAM,IAAI,CAAC,CAAC,KAAK,SAAS,WAAoB,OAAO,kBAAkB,QAAQ,OAAO,UAAU,OAAO,MAAM,CAAC,CAAC;KAC/H;IACJ;IACA,KAAK;KACD,IAAI,OAAO,OAAO,WAAW,YAAY,OAAO,SAAS,GAAG,UAAU,KAAK,KAAK,OAAO,MAAM,CAAC;KAC9F;IACJ,KAAK;KACD,OAAO,EAAE,MAAM,SAAS,CAAC;KACzB;IACJ,KAAK;KAED,OAAO,CAAC,CAAC;KACT;IACJ,SACI,OAAO,mCAAmC,QAAQ,OAAO,EAAE;GACnE;EACJ;EACA,OAAO,iBAAiB,WAAW,OAAO;EAC1C,aAAa,OAAO,oBAAoB,WAAW,OAAO;CAC9D,GAAG,CAAC,QAAQ,MAAM,CAAC;CAEnB,IAAI,OAAO,OAAO,oBAAC,OAAD;EAAO,OAAM;EAAQ,MAAK;YAAS;CAAa,CAAA;CAClE,IAAI,CAAC,UACD,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf,CACI,oBAAC,kBAAD,EAAkB,MAAK,QAAQ,CAAA,GAC/B,oBAAC,YAAD;GAAY,SAAQ;GAAQ,OAAM;aAAY;EAA4B,CAAA,CACzE;;CAGb,OACI,oBAAC,UAAD;EACI,KAAK;EACL,OAAM;EACN,SAAQ;EACR,QAAQ;EACR,WAAU;EACV,OAAO,EAAE,OAAO;CACnB,CAAA;AAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/cms",
3
- "version": "0.29.2",
3
+ "version": "0.29.3",
4
4
  "description": "Rebase CMS — content management views, forms, and routing",
5
5
  "keywords": [
6
6
  "rebase",
@@ -99,14 +99,14 @@
99
99
  "react-use-measure": "^2.1.7",
100
100
  "read-excel-file": "^9.3.10",
101
101
  "zod": "^4.4.3",
102
- "@rebasepro/app": "0.29.2",
103
- "@rebasepro/common": "0.29.2",
104
- "@rebasepro/inference": "0.29.2",
105
- "@rebasepro/forms": "0.29.2",
106
- "@rebasepro/types": "0.29.2",
107
- "@rebasepro/ui": "0.29.2",
108
- "@rebasepro/cms-types": "0.29.2",
109
- "@rebasepro/utils": "0.29.2"
102
+ "@rebasepro/app": "0.29.3",
103
+ "@rebasepro/cms-types": "0.29.3",
104
+ "@rebasepro/common": "0.29.3",
105
+ "@rebasepro/forms": "0.29.3",
106
+ "@rebasepro/inference": "0.29.3",
107
+ "@rebasepro/types": "0.29.3",
108
+ "@rebasepro/utils": "0.29.3",
109
+ "@rebasepro/ui": "0.29.3"
110
110
  },
111
111
  "peerDependencies": {
112
112
  "react": "^19.2.7",