@rebasepro/studio 0.34.1 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/{ApiExplorer-BhQFd_iR.js → ApiExplorer-C61w8gCc.js} +73 -58
  3. package/dist/ApiExplorer-C61w8gCc.js.map +1 -0
  4. package/dist/{ApiKeysView-CLBXUCgu.js → ApiKeysView-BdqASL_2.js} +33 -32
  5. package/dist/ApiKeysView-BdqASL_2.js.map +1 -0
  6. package/dist/{BranchesView-BKGhk-PC.js → BranchesView-Bh5lq9T_.js} +5 -5
  7. package/dist/BranchesView-Bh5lq9T_.js.map +1 -0
  8. package/dist/{CronJobsView-CwF_m6ZB.js → CronJobsView-DUuyzkJK.js} +392 -8
  9. package/dist/CronJobsView-DUuyzkJK.js.map +1 -0
  10. package/dist/FixedEditorOverlay-DtgPBSjq.js +93 -0
  11. package/dist/FixedEditorOverlay-DtgPBSjq.js.map +1 -0
  12. package/dist/{JSEditor-Br22PfLh.js → JSEditor-Bi2Aol-Y.js} +27 -21
  13. package/dist/JSEditor-Bi2Aol-Y.js.map +1 -0
  14. package/dist/{LogsExplorer-DOLRFQaW.js → LogsExplorer-BA8RfTwd.js} +46 -67
  15. package/dist/LogsExplorer-BA8RfTwd.js.map +1 -0
  16. package/dist/{RLSEditor-RE4YpN_z.js → RLSEditor-CTG3jLE7.js} +478 -224
  17. package/dist/RLSEditor-CTG3jLE7.js.map +1 -0
  18. package/dist/{SQLEditor-Dj5INEUZ.js → SQLEditor-DRo5kW1h.js} +15 -96
  19. package/dist/SQLEditor-DRo5kW1h.js.map +1 -0
  20. package/dist/{SchemaVisualizer-D2_cck4I.js → SchemaVisualizer-Dy4kWKT5.js} +15 -14
  21. package/dist/SchemaVisualizer-Dy4kWKT5.js.map +1 -0
  22. package/dist/{StorageView-DHm22S7y.js → StorageView-D0D8z4lI.js} +497 -4
  23. package/dist/StorageView-D0D8z4lI.js.map +1 -0
  24. package/dist/TableEditorView-BKhSBG-K.js +1694 -0
  25. package/dist/TableEditorView-BKhSBG-K.js.map +1 -0
  26. package/dist/UsersAndRolesView-CKw4SJPj.js +689 -0
  27. package/dist/UsersAndRolesView-CKw4SJPj.js.map +1 -0
  28. package/dist/WebhooksView-CFPY-N9h.js +465 -0
  29. package/dist/WebhooksView-CFPY-N9h.js.map +1 -0
  30. package/dist/adminFetch-BfOnfRgU.js +108 -0
  31. package/dist/adminFetch-BfOnfRgU.js.map +1 -0
  32. package/dist/components/ApiExplorer/TryItPanel.d.ts +6 -0
  33. package/dist/components/ApiKeys/scope-words.d.ts +1 -1
  34. package/dist/components/AuthSimulationSelector.d.ts +9 -1
  35. package/dist/components/CronJobs/DbCronJobsPanel.d.ts +2 -0
  36. package/dist/components/RLSEditor/DirectRlsPoliciesPanel.d.ts +7 -0
  37. package/dist/components/RebaseStudio.d.ts +1 -1
  38. package/dist/components/RebaseStudioApp.d.ts +28 -0
  39. package/dist/components/SQLEditor/FixedEditorOverlay.d.ts +12 -0
  40. package/dist/components/SQLEditor/SQLEditor.d.ts +2 -11
  41. package/dist/components/StorageView/StoragePoliciesPanel.d.ts +2 -0
  42. package/dist/components/StudioHomePage.d.ts +3 -1
  43. package/dist/components/TableEditor/TableEditorView.d.ts +2 -0
  44. package/dist/components/UsersAndRoles/UsersAndRolesView.d.ts +2 -0
  45. package/dist/components/Webhooks/WebhooksView.d.ts +2 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.es.js +739 -109
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/policy-presets-CJKzAvQp.js +167 -0
  50. package/dist/policy-presets-CJKzAvQp.js.map +1 -0
  51. package/dist/{useRunAsUsers-CLaAtXt6.js → useRunAsUsers-CF7tkGzj.js} +22 -3
  52. package/dist/useRunAsUsers-CF7tkGzj.js.map +1 -0
  53. package/dist/utils/adminFetch.d.ts +25 -0
  54. package/package.json +12 -16
  55. package/dist/ApiExplorer-BhQFd_iR.js.map +0 -1
  56. package/dist/ApiKeysView-CLBXUCgu.js.map +0 -1
  57. package/dist/BranchesView-BKGhk-PC.js.map +0 -1
  58. package/dist/CronJobsView-CwF_m6ZB.js.map +0 -1
  59. package/dist/JSEditor-Br22PfLh.js.map +0 -1
  60. package/dist/LogsExplorer-DOLRFQaW.js.map +0 -1
  61. package/dist/RLSEditor-RE4YpN_z.js.map +0 -1
  62. package/dist/SQLEditor-Dj5INEUZ.js.map +0 -1
  63. package/dist/SchemaVisualizer-D2_cck4I.js.map +0 -1
  64. package/dist/StorageView-DHm22S7y.js.map +0 -1
  65. package/dist/useRunAsUsers-CLaAtXt6.js.map +0 -1
package/README.md CHANGED
@@ -39,7 +39,7 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
39
39
  | `logs` | Logs Explorer | Database | Real-time system and query logs |
40
40
  | `api-keys` | API Keys | Access Control | Create and manage scoped API keys |
41
41
 
42
- All 11 tools are enabled by default. The `schema` tool (collection editor) is auto-injected by the CMS when `collectionEditor` is enabled — it is **not** registered here.
42
+ All 11 tools are enabled by default. A table declared with `defineTable` in `backend/schema/` is edited in code; in development, the RLS editor saves the table's policies into that file.
43
43
 
44
44
  ## Key Exports
45
45
 
@@ -1,5 +1,5 @@
1
- import { n as AuthSimulationSelector, t as useRunAsUsers } from "./useRunAsUsers-CLaAtXt6.js";
2
- import { useApiBase, useApiConfig, useAuthController, useTranslation } from "@rebasepro/app";
1
+ import { n as AuthSimulationSelector, t as useRunAsUsers } from "./useRunAsUsers-CF7tkGzj.js";
2
+ import { toPublicApiUrl, useApiBase, useApiConfig, useAuthController, useStudioCapabilities, useTranslation } from "@rebasepro/app";
3
3
  import React, { useCallback, useEffect, useMemo, useState } from "react";
4
4
  import { Alert, ArrowRightFromLineIcon, BookOpenIcon, Button, Chip, CircularProgress, IconButton, LoaderIcon, PlayIcon, PlusIcon, SearchBar, SendIcon, SlidersHorizontalIcon, TextField, Typography, UploadIcon, XIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -350,8 +350,17 @@ function StatusBadge({ code }) {
350
350
  * own token and the {@link IMPERSONATE_HEADER} header, and the server runs it
351
351
  * as that user — their uid and roles, under row-level security — or refuses
352
352
  * it. It never runs as the administrator instead.
353
+ *
354
+ * Under a host whose requests all run as a service key
355
+ * ({@link StudioCapabilities.requestIdentity}, the hosted console), neither
356
+ * choice exists: a request without a credential is refused by the proxy, and
357
+ * the server refuses impersonation from a service key. The panel says what the
358
+ * request runs as instead, and shows the project's public URL.
353
359
  */
354
360
  function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
361
+ const { t } = useTranslation();
362
+ const capabilities = useStudioCapabilities();
363
+ const serviceIdentity = capabilities.requestIdentity !== void 0;
355
364
  const storageKey = `rebase_apiexplorer_${endpoint.method}_${endpoint.path}`;
356
365
  const [pathParams, setPathParams] = useState(() => {
357
366
  try {
@@ -383,10 +392,12 @@ function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
383
392
  });
384
393
  const [response, setResponse] = useState(null);
385
394
  const [loading, setLoading] = useState(false);
386
- const [authMode, setAuthMode] = useState("jwt");
395
+ const [chosenAuthMode, setAuthMode] = useState("jwt");
396
+ const authMode = serviceIdentity ? "jwt" : chosenAuthMode;
387
397
  const [validationError, setValidationError] = useState(null);
388
398
  const { users, currentUser, loading: usersLoading, onSearchTextChange, totalCount: userTotalCount } = useRunAsUsers();
389
- const [selectedUser, setSelectedUser] = useState(null);
399
+ const [chosenUser, setSelectedUser] = useState(null);
400
+ const selectedUser = serviceIdentity ? null : chosenUser;
390
401
  useEffect(() => {
391
402
  localStorage.setItem(`${storageKey}_path`, JSON.stringify(pathParams));
392
403
  localStorage.setItem(`${storageKey}_query`, JSON.stringify(queryParams));
@@ -414,6 +425,7 @@ function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
414
425
  pathParams,
415
426
  queryParams
416
427
  ]);
428
+ const displayedUrl = toPublicApiUrl(resolvedUrl, apiUrl, capabilities);
417
429
  const pathParamDefs = endpoint.parameters.filter((p) => p.in === "path");
418
430
  const queryParamDefs = endpoint.parameters.filter((p) => p.in === "query");
419
431
  const hasBody = [
@@ -495,7 +507,9 @@ function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
495
507
  loading: usersLoading,
496
508
  onUserSearchTextChange: onSearchTextChange,
497
509
  userTotalCount,
498
- currentUser
510
+ currentUser,
511
+ fixedIdentityLabel: serviceIdentity ? t("studio_auth_service_key") : void 0,
512
+ fixedIdentityHint: serviceIdentity ? t("studio_auth_service_key_hint") : void 0
499
513
  }),
500
514
  pathParamDefs.length > 0 && /* @__PURE__ */ jsx(ParamSection, {
501
515
  title: "Path Parameters",
@@ -570,7 +584,7 @@ function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
570
584
  children: "Request URL"
571
585
  }), /* @__PURE__ */ jsx("code", {
572
586
  className: "text-xs font-mono text-text-primary dark:text-text-primary-dark break-all",
573
- children: resolvedUrl
587
+ children: displayedUrl
574
588
  })]
575
589
  }),
576
590
  /* @__PURE__ */ jsx(Button, {
@@ -882,71 +896,72 @@ function ApiExplorer() {
882
896
  className: "flex h-full w-full overflow-hidden",
883
897
  children: [/* @__PURE__ */ jsxs("div", {
884
898
  className: cls("w-72 min-w-[272px] flex flex-col h-full overflow-hidden border-r", defaultBorderMixin, "bg-surface-sheet"),
885
- children: [/* @__PURE__ */ jsxs("div", {
886
- className: "p-4 space-y-3",
887
- children: [
888
- /* @__PURE__ */ jsxs("div", {
889
- className: "flex items-center gap-2",
899
+ children: [
900
+ /* @__PURE__ */ jsxs("div", {
901
+ className: cls("h-12 px-4 border-b bg-surface-sheet flex items-center justify-between gap-2 shrink-0", defaultBorderMixin),
902
+ children: [/* @__PURE__ */ jsxs("div", {
903
+ className: "flex items-center gap-2 min-w-0",
890
904
  children: [/* @__PURE__ */ jsx(BookOpenIcon, {
891
905
  size: iconSize.medium,
892
- className: "text-primary dark:text-primary-dark"
906
+ className: "text-primary dark:text-primary-dark shrink-0"
893
907
  }), /* @__PURE__ */ jsx(Typography, {
894
908
  variant: "subtitle2",
895
- className: "font-semibold",
909
+ className: "font-semibold truncate",
896
910
  children: spec.info?.title ?? "API Reference"
897
911
  })]
898
- }),
899
- spec.info?.version && /* @__PURE__ */ jsxs(Chip, {
912
+ }), spec.info?.version && /* @__PURE__ */ jsxs(Chip, {
900
913
  size: "smallest",
901
914
  colorScheme: "cyanDarker",
915
+ className: "shrink-0",
902
916
  children: ["v", spec.info.version]
903
- }),
904
- /* @__PURE__ */ jsx("div", {
905
- className: "mb-2",
906
- children: /* @__PURE__ */ jsx(SearchBar, {
907
- placeholder: "Filter endpoints…",
908
- size: "small",
909
- onTextSearch: (val) => setSidebarFilter(val ?? "")
910
- })
917
+ })]
918
+ }),
919
+ /* @__PURE__ */ jsx("div", {
920
+ className: cls("p-2 border-b shrink-0", defaultBorderMixin),
921
+ children: /* @__PURE__ */ jsx(SearchBar, {
922
+ placeholder: "Filter endpoints…",
923
+ size: "small",
924
+ onTextSearch: (val) => setSidebarFilter(val ?? "")
911
925
  })
912
- ]
913
- }), /* @__PURE__ */ jsxs("div", {
914
- className: "flex-1 overflow-y-auto px-2 pb-4",
915
- children: [filteredGroups.map((group) => /* @__PURE__ */ jsxs("div", {
916
- className: "mb-3",
917
- children: [/* @__PURE__ */ jsx(Typography, {
918
- variant: "caption",
919
- className: "px-2 py-1.5 text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider font-semibold text-[10px]",
920
- children: group.tag
921
- }), group.endpoints.map((ep) => {
922
- return /* @__PURE__ */ jsxs(Button, {
923
- variant: "text",
924
- color: "neutral",
925
- fullWidth: true,
926
- onClick: () => {
927
- setSelectedEndpoint(ep);
928
- setTryItOpen(false);
929
- },
930
- className: cls("!justify-between !px-2.5 !py-1.5 !text-left !text-sm", selectedEndpoint?.id === ep.id ? "bg-surface-raised font-medium" : "text-text-primary dark:text-text-primary-dark"),
931
- children: [/* @__PURE__ */ jsx("span", {
932
- className: "truncate text-[13px] opacity-90",
933
- children: ep.summary || ep.shortPath
934
- }), /* @__PURE__ */ jsx("span", {
935
- className: cls("text-[10px] font-semibold uppercase shrink-0", METHOD_COLORS[ep.method] ?? "text-text-secondary"),
936
- children: ep.method
937
- })]
938
- }, ep.id);
926
+ }),
927
+ /* @__PURE__ */ jsxs("div", {
928
+ className: "flex-1 overflow-y-auto px-2 pb-4",
929
+ children: [filteredGroups.map((group) => /* @__PURE__ */ jsxs("div", {
930
+ className: "mb-3",
931
+ children: [/* @__PURE__ */ jsx(Typography, {
932
+ variant: "caption",
933
+ className: "px-2 py-1.5 text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider font-semibold text-[10px]",
934
+ children: group.tag
935
+ }), group.endpoints.map((ep) => {
936
+ return /* @__PURE__ */ jsxs(Button, {
937
+ variant: "text",
938
+ color: "neutral",
939
+ fullWidth: true,
940
+ onClick: () => {
941
+ setSelectedEndpoint(ep);
942
+ setTryItOpen(false);
943
+ },
944
+ className: cls("!justify-between !px-2.5 !py-1.5 !text-left !text-sm", selectedEndpoint?.id === ep.id ? "bg-surface-raised font-medium" : "text-text-primary dark:text-text-primary-dark"),
945
+ children: [/* @__PURE__ */ jsx("span", {
946
+ className: "truncate text-[13px] opacity-90",
947
+ children: ep.summary || ep.shortPath
948
+ }), /* @__PURE__ */ jsx("span", {
949
+ className: cls("text-[10px] font-semibold uppercase shrink-0", METHOD_COLORS[ep.method] ?? "text-text-secondary"),
950
+ children: ep.method
951
+ })]
952
+ }, ep.id);
953
+ })]
954
+ }, group.tag)), filteredGroups.length === 0 && /* @__PURE__ */ jsx(Typography, {
955
+ variant: "body2",
956
+ className: "text-center text-text-secondary dark:text-text-secondary-dark py-8",
957
+ children: "No endpoints match"
939
958
  })]
940
- }, group.tag)), filteredGroups.length === 0 && /* @__PURE__ */ jsx(Typography, {
941
- variant: "body2",
942
- className: "text-center text-text-secondary dark:text-text-secondary-dark py-8",
943
- children: "No endpoints match"
944
- })]
945
- })]
959
+ })
960
+ ]
946
961
  }), /* @__PURE__ */ jsx("div", {
947
962
  className: "flex-1 flex flex-col h-full overflow-hidden",
948
963
  children: selectedEndpoint ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
949
- className: cls("flex items-center justify-between px-5 py-3 gap-4 shrink-0 border-b z-10", defaultBorderMixin, "bg-surface-sheet/90 backdrop-blur-md sticky top-0"),
964
+ className: cls("flex items-center justify-between px-5 h-12 gap-4 shrink-0 border-b z-10", defaultBorderMixin, "bg-surface-sheet/90 backdrop-blur-md sticky top-0"),
950
965
  children: [/* @__PURE__ */ jsxs("div", {
951
966
  className: "flex items-center gap-3 min-w-0",
952
967
  children: [/* @__PURE__ */ jsx("span", {
@@ -992,4 +1007,4 @@ ApiExplorer.displayName = "ApiExplorer";
992
1007
  //#endregion
993
1008
  export { ApiExplorer };
994
1009
 
995
- //# sourceMappingURL=ApiExplorer-BhQFd_iR.js.map
1010
+ //# sourceMappingURL=ApiExplorer-C61w8gCc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiExplorer-C61w8gCc.js","names":[],"sources":["../src/components/ApiExplorer/parseSpec.ts","../src/components/ApiExplorer/EndpointDetail.tsx","../src/components/ApiExplorer/TryItPanel.tsx","../src/components/ApiExplorer/ApiExplorer.tsx"],"sourcesContent":["import type { OpenApiSpec, ParsedEndpoint, EndpointGroup } from \"./types\";\n\n/** The methods the explorer lists; a path item's other keys are shared fields or methods it does not show. */\ntype ListedMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\nconst LISTED_METHODS = new Set<string>([\"get\", \"post\", \"put\", \"patch\", \"delete\"]);\n\nfunction isListedMethod(key: string): key is ListedMethod {\n return LISTED_METHODS.has(key);\n}\n\n/**\n * Parse an OpenAPI 3.x spec into grouped, sorted endpoints for the sidebar.\n */\nexport function parseOpenApiSpec(spec: OpenApiSpec): {\n groups: EndpointGroup[];\n allEndpoints: ParsedEndpoint[];\n} {\n const allEndpoints: ParsedEndpoint[] = [];\n const tagMap = new Map<string, ParsedEndpoint[]>();\n\n // Build tag description lookup\n const tagDescriptions = new Map<string, string>();\n for (const t of spec.tags ?? []) {\n tagDescriptions.set(t.name, t.description ?? \"\");\n }\n\n for (const [path, item] of Object.entries(spec.paths ?? {})) {\n for (const method of Object.keys(item)) {\n if (!isListedMethod(method)) continue;\n const op = item[method];\n if (!op) continue;\n\n const tags = op.tags?.length ? op.tags : [\"Other\"];\n const shortPath = path.replace(/^\\/api\\/data/, \"\");\n\n const endpoint: ParsedEndpoint = {\n id: `${method}:${path}`,\n method,\n path,\n shortPath: shortPath || \"/\",\n summary: op.summary ?? \"\",\n description: op.description ?? \"\",\n tags,\n parameters: op.parameters ?? [],\n requestBody: op.requestBody,\n responses: op.responses ?? {},\n security: op.security,\n operationId: op.operationId\n };\n\n allEndpoints.push(endpoint);\n for (const tag of tags) {\n if (!tagMap.has(tag)) tagMap.set(tag, []);\n tagMap.get(tag)!.push(endpoint);\n }\n }\n }\n\n // Method sort order\n const ORDER: Record<string, number> = { get: 0,\npost: 1,\nput: 2,\npatch: 3,\ndelete: 4 };\n\n const groups: EndpointGroup[] = [];\n // Sort tags: use spec.tags order if available, else alphabetical\n const tagOrder = (spec.tags ?? []).map((t) => t.name);\n const sortedTags = [...tagMap.keys()].sort((a, b) => {\n const ai = tagOrder.indexOf(a);\n const bi = tagOrder.indexOf(b);\n if (ai !== -1 && bi !== -1) return ai - bi;\n if (ai !== -1) return -1;\n if (bi !== -1) return 1;\n return a.localeCompare(b);\n });\n\n for (const tag of sortedTags) {\n const endpoints = tagMap.get(tag)!;\n endpoints.sort((a, b) => {\n const pa = a.path.localeCompare(b.path);\n if (pa !== 0) return pa;\n return (ORDER[a.method] ?? 99) - (ORDER[b.method] ?? 99);\n });\n groups.push({\n tag,\n description: tagDescriptions.get(tag),\n endpoints\n });\n }\n\n return { groups,\nallEndpoints };\n}\n\n/**\n * Resolve a $ref string (e.g. \"#/components/schemas/Author\") to a schema name.\n */\nexport function resolveRefName(ref: string): string {\n const parts = ref.split(\"/\");\n return parts[parts.length - 1];\n}\n\n/**\n * Resolve a $ref to its actual schema from the spec.\n */\nexport function resolveRef(spec: OpenApiSpec, ref: string): unknown {\n const parts = ref.replace(\"#/\", \"\").split(\"/\");\n let current: unknown = spec;\n for (const part of parts) {\n current = (current as Record<string, unknown>)?.[part];\n }\n return current ?? {};\n}\n","import React from \"react\";\nimport {\n ArrowRightFromLineIcon,\n Chip,\n cls,\n defaultBorderMixin,\n iconSize,\n SlidersHorizontalIcon,\n Typography,\n UploadIcon\n} from \"@rebasepro/ui\";\nimport type { ParsedEndpoint, OpenApiSpec, OpenApiSchema } from \"./types\";\nimport { resolveRef, resolveRefName } from \"./parseSpec\";\n\n/**\n * Renders the documentation view for a single API endpoint:\n * parameters, request body schema, response schemas.\n */\nexport function EndpointDetail({ endpoint, spec }: { endpoint: ParsedEndpoint; spec: OpenApiSpec }) {\n return (\n <div className=\"p-6 space-y-8 max-w-4xl\">\n {/* Summary / Description */}\n {(endpoint.summary || endpoint.description) && (\n <div>\n {endpoint.summary && (\n <Typography variant=\"h6\" className=\"font-semibold mb-1\">\n {endpoint.summary}\n </Typography>\n )}\n {endpoint.description && (\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {endpoint.description}\n </Typography>\n )}\n </div>\n )}\n\n {/* Parameters */}\n {endpoint.parameters.length > 0 && (\n <section>\n <SectionHeading icon={<SlidersHorizontalIcon size={iconSize.small} className=\"text-text-secondary dark:text-text-secondary-dark\" />} title=\"Parameters\"/>\n <div className={cls(\"rounded-lg border overflow-hidden\", defaultBorderMixin)}>\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"bg-surface-raised text-left\">\n <th className=\"px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark\">\n Name\n </th>\n <th className=\"px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark\">\n In\n </th>\n <th className=\"px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark\">\n Type\n </th>\n <th className=\"px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark\">\n Description\n </th>\n </tr>\n </thead>\n <tbody>\n {endpoint.parameters.map((p, i) => (\n <tr\n key={p.name + i}\n className={cls(\"border-t\", defaultBorderMixin)}\n >\n <td className=\"px-4 py-2.5\">\n <code className=\"text-xs font-mono font-semibold\">{p.name}</code>\n {p.required && <span className=\"text-red-500 ml-1 text-xs\">*</span>}\n </td>\n <td className=\"px-4 py-2.5\">\n <Chip\n size=\"smallest\"\n colorScheme={p.in === \"path\" ? \"orangeDarker\" : \"cyanDarker\"}\n >\n {p.in}\n </Chip>\n </td>\n <td className=\"px-4 py-2.5 text-xs font-mono text-text-secondary dark:text-text-secondary-dark\">\n {schemaTypeLabel(p.schema)}\n </td>\n <td className=\"px-4 py-2.5 text-xs text-text-secondary dark:text-text-secondary-dark\">\n {p.description ?? \"—\"}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </section>\n )}\n\n {/* Request Body */}\n {endpoint.requestBody && (\n <section>\n <SectionHeading icon={<UploadIcon size={iconSize.small} className=\"text-text-secondary dark:text-text-secondary-dark\" />} title=\"Request Body\"/>\n {Object.entries(endpoint.requestBody.content ?? {}).map(([contentType, media]) => (\n <div key={contentType}>\n <Chip size=\"smallest\" colorScheme=\"blueDarker\" className=\"mb-3\">\n {contentType}\n </Chip>\n {media.schema && <SchemaBlock schema={media.schema} spec={spec} depth={0}/>}\n </div>\n ))}\n </section>\n )}\n\n {/* Responses */}\n <section>\n <SectionHeading icon={<ArrowRightFromLineIcon size={iconSize.small} className=\"text-text-secondary dark:text-text-secondary-dark\" />} title=\"Responses\"/>\n <div className=\"space-y-3\">\n {Object.entries(endpoint.responses).map(([code, res]) => (\n <div\n key={code}\n className={cls(\"rounded-lg border overflow-hidden\", defaultBorderMixin)}\n >\n <div\n className={cls(\n \"flex items-center gap-3 px-4 py-2.5\",\n \"bg-surface-sheet\"\n )}\n >\n <StatusBadge code={code}/>\n <Typography\n variant=\"body2\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs\"\n >\n {res.description}\n </Typography>\n </div>\n {res.content &&\n Object.entries(res.content).map(\n ([ct, media]) =>\n media.schema && (\n <div\n key={ct}\n className={cls(\"px-4 py-3 border-t\", defaultBorderMixin)}\n >\n <SchemaBlock schema={media.schema} spec={spec} depth={0}/>\n </div>\n )\n )}\n </div>\n ))}\n </div>\n </section>\n </div>\n );\n}\n\n/* ── Schema Block ─────────────────────────────────────────────────── */\n\nfunction SchemaBlock({ schema, spec, depth }: { schema: OpenApiSchema; spec: OpenApiSpec; depth: number }) {\n // Resolve $ref\n if (schema.$ref) {\n const name = resolveRefName(schema.$ref);\n const resolved = resolveRef(spec, schema.$ref) as OpenApiSchema;\n return (\n <div>\n <Typography\n variant=\"caption\"\n className=\"text-primary dark:text-primary-dark font-mono text-xs mb-2 block\"\n >\n {name}\n </Typography>\n <SchemaBlock schema={resolved} spec={spec} depth={depth}/>\n </div>\n );\n }\n\n // Object with properties\n if (schema.properties) {\n const required = new Set(schema.required ?? []);\n return (\n <div\n className={cls(\n \"rounded-lg overflow-hidden\",\n depth > 0 && `border ml-4 mt-1 ${defaultBorderMixin}`\n )}\n >\n <table className=\"w-full text-xs\">\n <tbody>\n {Object.entries(schema.properties).map(([key, prop]) => (\n <tr\n key={key}\n className={cls(\"border-t first:border-t-0\", defaultBorderMixin)}\n >\n <td className=\"px-3 py-2 align-top w-36\">\n <code className=\"font-mono font-semibold text-text-primary dark:text-text-primary-dark\">\n {key}\n </code>\n {required.has(key) && <span className=\"text-red-500 ml-0.5\">*</span>}\n {prop.readOnly && (\n <span className=\"ml-1.5 text-[9px] text-text-secondary dark:text-text-secondary-dark italic\">\n read-only\n </span>\n )}\n </td>\n <td className=\"px-3 py-2 align-top w-28\">\n <span className=\"font-mono text-text-secondary dark:text-text-secondary-dark\">\n {schemaTypeLabel(prop)}\n </span>\n </td>\n <td className=\"px-3 py-2 align-top text-text-secondary dark:text-text-secondary-dark\">\n {prop.description ?? \"\"}\n {prop.enum && (\n <div className=\"flex flex-wrap gap-1 mt-1\">\n {prop.enum.map((v) => (\n <span\n key={String(v)}\n className=\"px-1.5 py-0.5 rounded bg-surface-raised text-xs font-mono\"\n >\n {String(v)}\n </span>\n ))}\n </div>\n )}\n {prop.properties && <SchemaBlock schema={prop} spec={spec} depth={depth + 1}/>}\n {prop.$ref && <SchemaBlock schema={prop} spec={spec} depth={depth + 1}/>}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n }\n\n // Array\n if (schema.type === \"array\" && schema.items) {\n return (\n <div>\n <span className=\"font-mono text-xs text-text-secondary dark:text-text-secondary-dark\">Array of:</span>\n <SchemaBlock schema={schema.items} spec={spec} depth={depth + 1}/>\n </div>\n );\n }\n\n // Primitive\n return (\n <span className=\"font-mono text-xs text-text-secondary dark:text-text-secondary-dark\">\n {schemaTypeLabel(schema)}\n </span>\n );\n}\n\n/* ── Helpers ──────────────────────────────────────────────────────── */\n\nfunction schemaTypeLabel(schema?: OpenApiSchema): string {\n if (!schema) return \"any\";\n if (schema.$ref) return resolveRefName(schema.$ref);\n if (schema.type === \"array\") return `${schemaTypeLabel(schema.items)}[]`;\n if (schema.format) return `${schema.type} (${schema.format})`;\n return schema.type ?? \"object\";\n}\n\nfunction SectionHeading({ icon, title }: { icon: React.ReactNode; title: string }) {\n return (\n <div className=\"flex items-center gap-2 mb-3\">\n {icon}\n <Typography variant=\"subtitle2\" className=\"font-semibold text-sm\">\n {title}\n </Typography>\n </div>\n );\n}\n\nfunction StatusBadge({ code }: { code: string }) {\n const n = parseInt(code, 10);\n const color =\n n < 300\n ? \"text-emerald-600 dark:text-emerald-400\"\n : n < 400\n ? \"text-blue-600 dark:text-blue-400\"\n : n < 500\n ? \"text-amber-600 dark:text-amber-400\"\n : \"text-red-600 dark:text-red-400\";\n\n return <span className={cls(\"text-xs font-semibold font-mono\", color)}>{code}</span>;\n}\n","import { toPublicApiUrl, useStudioCapabilities, useTranslation } from \"@rebasepro/app\";\nimport React, { useState, useCallback, useMemo, useEffect } from \"react\";\nimport {\n Button,\n cls,\n defaultBorderMixin,\n IconButton,\n iconSize,\n LoaderIcon,\n PlusIcon,\n SendIcon,\n TextField,\n Typography,\n XIcon\n} from \"@rebasepro/ui\";\nimport type { SelectableUser } from \"@rebasepro/app\";\nimport { AuthSimulationSelector } from \"../AuthSimulationSelector\";\nimport { useRunAsUsers } from \"../useRunAsUsers\";\nimport type { ParsedEndpoint } from \"./types\";\nimport { IMPERSONATE_HEADER, type User } from \"@rebasepro/types\";\n\ninterface TryItPanelProps {\n endpoint: ParsedEndpoint;\n apiUrl: string;\n getAuthToken: () => Promise<string | null | undefined>;\n user: User | null;\n basePath?: string;\n}\n\n/**\n * Interactive \"Try It\" panel that lets the user execute API requests\n * using their current JWT token directly from the Studio.\n *\n * An administrator can run a request as another user: it is sent with their\n * own token and the {@link IMPERSONATE_HEADER} header, and the server runs it\n * as that user — their uid and roles, under row-level security — or refuses\n * it. It never runs as the administrator instead.\n *\n * Under a host whose requests all run as a service key\n * ({@link StudioCapabilities.requestIdentity}, the hosted console), neither\n * choice exists: a request without a credential is refused by the proxy, and\n * the server refuses impersonation from a service key. The panel says what the\n * request runs as instead, and shows the project's public URL.\n */\nexport function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = \"\" }: TryItPanelProps) {\n const { t } = useTranslation();\n const capabilities = useStudioCapabilities();\n const serviceIdentity = capabilities.requestIdentity !== undefined;\n const storageKey = `rebase_apiexplorer_${endpoint.method}_${endpoint.path}`;\n\n const [pathParams, setPathParams] = useState<Record<string, string>>(() => {\n try { const v = localStorage.getItem(`${storageKey}_path`); if (v) return JSON.parse(v); } catch { /* ignore */ }\n return {};\n });\n const [queryParams, setQueryParams] = useState<Record<string, string>>(() => {\n try { const v = localStorage.getItem(`${storageKey}_query`); if (v) return JSON.parse(v); } catch { /* ignore */ }\n return {};\n });\n const [customHeaders, setCustomHeaders] = useState<Array<{ key: string; value: string }>>(() => {\n try { const v = localStorage.getItem(`${storageKey}_headers`); if (v) return JSON.parse(v); } catch { /* ignore */ }\n // None until the caller adds one: every header here is sent.\n return [];\n });\n const [body, setBody] = useState(() => {\n try { const v = localStorage.getItem(`${storageKey}_body`); if (v) return JSON.parse(v); } catch { /* ignore */ }\n return buildBodyTemplate(endpoint);\n });\n const [response, setResponse] = useState<{ status: number; statusText: string; body: string; time: number } | null>(\n null\n );\n const [loading, setLoading] = useState(false);\n const [chosenAuthMode, setAuthMode] = useState<\"jwt\" | \"none\">(\"jwt\");\n const authMode = serviceIdentity ? \"jwt\" : chosenAuthMode;\n const [validationError, setValidationError] = useState<string | null>(null);\n\n // An administrator is offered the project's users; anyone else, only\n // themselves — the server lets nobody else run a request as someone.\n const { users, currentUser, loading: usersLoading, onSearchTextChange, totalCount: userTotalCount } = useRunAsUsers();\n\n const [chosenUser, setSelectedUser] = useState<SelectableUser | null>(null);\n const selectedUser = serviceIdentity ? null : chosenUser;\n\n useEffect(() => {\n localStorage.setItem(`${storageKey}_path`, JSON.stringify(pathParams));\n localStorage.setItem(`${storageKey}_query`, JSON.stringify(queryParams));\n localStorage.setItem(`${storageKey}_headers`, JSON.stringify(customHeaders));\n localStorage.setItem(`${storageKey}_body`, JSON.stringify(body));\n }, [storageKey, pathParams, queryParams, customHeaders, body]);\n\n // Build the final URL\n const resolvedUrl = useMemo(() => {\n const base = basePath.startsWith(\"/\") ? basePath : `/${basePath}`;\n const cleanBase = base === \"/\" ? \"\" : base;\n let url = `${apiUrl.replace(/\\/+$/, \"\")}${cleanBase}${endpoint.path}`;\n // Replace path params\n for (const [key, val] of Object.entries(pathParams)) {\n url = url.replace(`{${key}}`, encodeURIComponent(val));\n }\n // Append query params\n const qp = Object.entries(queryParams).filter(([, v]) => v.trim() !== \"\");\n if (qp.length > 0) {\n url += \"?\" + qp.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join(\"&\");\n }\n return url;\n }, [apiUrl, basePath, endpoint.path, pathParams, queryParams]);\n\n // What the URL preview shows: the project's own address when the request\n // goes through a host's proxy, so a copied URL works outside it.\n const displayedUrl = toPublicApiUrl(resolvedUrl, apiUrl, capabilities);\n\n const pathParamDefs = endpoint.parameters.filter((p) => p.in === \"path\");\n const queryParamDefs = endpoint.parameters.filter((p) => p.in === \"query\");\n const hasBody = [\"post\", \"put\", \"patch\"].includes(endpoint.method);\n\n const execute = useCallback(async () => {\n setValidationError(null);\n if (hasBody && body.trim()) {\n try {\n JSON.parse(body);\n } catch (err: unknown) {\n setValidationError(`Invalid JSON: ${err instanceof Error ? err.message : String(err)}`);\n return;\n }\n }\n\n setLoading(true);\n setResponse(null);\n const start = performance.now();\n\n try {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n\n for (const h of customHeaders) {\n if (h.key.trim()) headers[h.key.trim()] = h.value;\n }\n\n if (authMode === \"jwt\") {\n const token = await getAuthToken();\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n if (selectedUser && selectedUser.uid !== currentUser?.uid) {\n headers[IMPERSONATE_HEADER] = selectedUser.uid;\n }\n }\n\n const res = await fetch(resolvedUrl, {\n method: endpoint.method.toUpperCase(),\n headers,\n body: hasBody && body.trim() ? body : undefined\n });\n\n const elapsed = Math.round(performance.now() - start);\n let text: string;\n\n const rawText = await res.text();\n try {\n const json = JSON.parse(rawText);\n text = JSON.stringify(json, null, 2);\n } catch {\n text = rawText;\n }\n\n setResponse({ status: res.status,\nstatusText: res.statusText,\nbody: text,\ntime: elapsed });\n } catch (err: unknown) {\n setResponse({\n status: 0,\n statusText: \"Network Error\",\n body: err instanceof Error ? err.message : \"Request failed\",\n time: Math.round(performance.now() - start)\n });\n } finally {\n setLoading(false);\n }\n }, [resolvedUrl, endpoint.method, hasBody, body, authMode, getAuthToken, customHeaders, selectedUser, currentUser?.uid]);\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"p-5 space-y-5 overflow-y-auto flex-1\">\n {/* Auth Mode */}\n <AuthSimulationSelector\n authMode={authMode}\n setAuthMode={setAuthMode}\n selectedUser={selectedUser}\n setSelectedUser={setSelectedUser}\n users={users}\n loading={usersLoading}\n onUserSearchTextChange={onSearchTextChange}\n userTotalCount={userTotalCount}\n currentUser={currentUser}\n fixedIdentityLabel={serviceIdentity ? t(\"studio_auth_service_key\") : undefined}\n fixedIdentityHint={serviceIdentity ? t(\"studio_auth_service_key_hint\") : undefined}\n />\n\n {/* Path Params */}\n {pathParamDefs.length > 0 && (\n <ParamSection\n title=\"Path Parameters\"\n params={pathParamDefs}\n values={pathParams}\n onChange={(k, v) => setPathParams((prev) => ({ ...prev,\n[k]: v }))}\n />\n )}\n\n {/* Query Params */}\n {queryParamDefs.length > 0 && (\n <ParamSection\n title=\"Query Parameters\"\n params={queryParamDefs}\n values={queryParams}\n onChange={(k, v) => setQueryParams((prev) => ({ ...prev,\n[k]: v }))}\n />\n )}\n\n {/* Custom Headers */}\n <CustomKeyValueSection\n title=\"Custom Headers\"\n values={customHeaders}\n onChange={(i, k, v) => {\n const next = [...customHeaders];\n next[i] = { key: k,\nvalue: v };\n setCustomHeaders(next);\n }}\n onAdd={() => setCustomHeaders((prev) => [...prev, { key: \"\",\nvalue: \"\" }])}\n onRemove={(i) => {\n const next = [...customHeaders];\n next.splice(i, 1);\n setCustomHeaders(next);\n }}\n />\n\n {/* Request Body */}\n {hasBody && (\n <div>\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block\"\n >\n Request Body\n </Typography>\n <TextField\n multiline\n minRows={10}\n aria-label=\"Request Body\"\n value={body}\n onChange={(e) => { setBody(e.target.value); setValidationError(null); }}\n spellCheck={false}\n error={!!validationError}\n className=\"w-full\"\n inputClassName=\"font-mono text-xs p-3 resize-y\"\n />\n {validationError && (\n <Typography variant=\"caption\" className=\"text-red-500 mt-1 block text-xs\">\n {validationError}\n </Typography>\n )}\n </div>\n )}\n\n {/* URL Preview */}\n <div className=\"rounded-lg bg-surface-raised p-3\">\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-[10px] uppercase tracking-wider block mb-1\"\n >\n Request URL\n </Typography>\n <code className=\"text-xs font-mono text-text-primary dark:text-text-primary-dark break-all\">\n {displayedUrl}\n </code>\n </div>\n\n {/* Execute Button */}\n <Button variant=\"filled\" onClick={execute} disabled={loading} className=\"w-full\">\n {loading ? (\n <span className=\"flex items-center gap-2\">\n <LoaderIcon size={iconSize.small} className=\"animate-spin\" />\n Sending…\n </span>\n ) : (\n <span className=\"flex items-center gap-2\">\n <SendIcon size={iconSize.small} />\n Send Request\n </span>\n )}\n </Button>\n\n {/* Response */}\n {response && (\n <div className={cls(\"rounded-lg border overflow-hidden\", defaultBorderMixin)}>\n <div\n className={cls(\n \"flex items-center justify-between px-4 py-2.5\",\n \"bg-surface-sheet\"\n )}\n >\n <div className=\"flex items-center gap-3\">\n <ResponseBadge status={response.status}/>\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs\"\n >\n {response.statusText}\n </Typography>\n </div>\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-mono\"\n >\n {response.time}ms\n </Typography>\n </div>\n <pre\n className={cls(\n \"p-4 text-xs font-mono overflow-auto max-h-96\",\n \"bg-surface-well text-emerald-700 dark:text-emerald-400\"\n )}\n >\n {response.body}\n </pre>\n </div>\n )}\n </div>\n </div>\n );\n}\n\n/* ── Param Section ────────────────────────────────────────────────── */\n\nfunction ParamSection({\n title,\n params,\n values,\n onChange\n}: {\n title: string;\n params: ParsedEndpoint[\"parameters\"];\n values: Record<string, string>;\n onChange: (_key: string, _value: string) => void;\n}) {\n const paramIdBase = React.useId();\n return (\n <div>\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block\"\n >\n {title}\n </Typography>\n <div className=\"space-y-2\">\n {params.map((p, index) => (\n <div key={p.name} className=\"flex items-center gap-3\">\n <label className=\"w-32 shrink-0\" htmlFor={`${paramIdBase}-${index}-param`}>\n <code className=\"text-xs font-mono font-semibold\">{p.name}</code>\n {p.required && <span className=\"text-red-500 ml-0.5 text-xs\">*</span>}\n </label>\n <TextField\n id={`${paramIdBase}-${index}-param`}\n size=\"small\"\n placeholder={p.description ?? p.name}\n value={values[p.name] ?? \"\"}\n onChange={(e) => onChange(p.name, e.target.value)}\n className=\"flex-1\"\n inputClassName=\"font-mono text-xs\"\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nfunction CustomKeyValueSection({\n title,\n values,\n onChange,\n onAdd,\n onRemove\n}: {\n title: string;\n values: Array<{ key: string; value: string }>;\n onChange: (index: number, key: string, value: string) => void;\n onAdd: () => void;\n onRemove: (index: number) => void;\n}) {\n const { t } = useTranslation();\n return (\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider block\"\n >\n {title}\n </Typography>\n <Button\n variant=\"text\"\n size=\"small\"\n color=\"primary\"\n onClick={onAdd}\n className=\"text-xs p-0 min-h-0\"\n >\n <PlusIcon size={iconSize.small} className=\"mr-1\" /> Add Header\n </Button>\n </div>\n <div className=\"space-y-2\">\n {values.map((v, i) => (\n <div key={i} className=\"flex items-center gap-2\">\n <TextField\n size=\"small\"\n aria-label={`Header ${i + 1} name`}\n placeholder=\"Header name\"\n value={v.key}\n onChange={(e) => onChange(i, e.target.value, v.value)}\n className=\"w-1/3\"\n inputClassName=\"font-mono text-xs\"\n />\n <TextField\n size=\"small\"\n aria-label={`Header ${i + 1} value`}\n placeholder=\"Value\"\n value={v.value}\n onChange={(e) => onChange(i, v.key, e.target.value)}\n className=\"flex-1\"\n inputClassName=\"font-mono text-xs\"\n />\n <IconButton aria-label={t(\"remove\")}\n size=\"small\"\n onClick={() => onRemove(i)}\n className=\"text-text-secondary hover:text-red-500 shrink-0\"\n title={t(\"remove\")}\n >\n <XIcon size={iconSize.small} />\n </IconButton>\n </div>\n ))}\n {values.length === 0 && (\n <Typography variant=\"caption\" className=\"text-text-secondary/50 italic text-xs\">\n No custom headers added.\n </Typography>\n )}\n </div>\n </div>\n );\n}\n\n/* ── Helpers ──────────────────────────────────────────────────────── */\n\nfunction ResponseBadge({ status }: { status: number }) {\n let colorClass = \"text-red-500\";\n if (status >= 200 && status < 300) colorClass = \"text-emerald-500\";\n else if (status >= 300 && status < 400) colorClass = \"text-blue-500\";\n else if (status >= 400 && status < 500) colorClass = \"text-amber-500\";\n\n return (\n <span className={cls(\"text-xs font-semibold font-mono\", colorClass)}>\n {status || \"ERR\"}\n </span>\n );\n}\n\nfunction buildBodyTemplate(endpoint: ParsedEndpoint): string {\n if (!endpoint.requestBody?.content) return \"{\\n \\n}\";\n const json = endpoint.requestBody.content[\"application/json\"];\n if (!json?.schema?.properties) return \"{\\n \\n}\";\n\n const props = json.schema.properties;\n const lines: string[] = [\"{\"];\n const keys = Object.keys(props);\n keys.forEach((key, i) => {\n const prop = props[key];\n if (prop.readOnly) return;\n const comma = i < keys.length - 1 ? \",\" : \"\";\n const val = defaultValue(prop);\n lines.push(` \"${key}\": ${val}${comma}`);\n });\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\nfunction defaultValue(schema: { type?: string; format?: string; enum?: (string | number)[] }): string {\n if (schema.enum) return JSON.stringify(schema.enum[0]);\n switch (schema.type) {\n case \"string\":\n return schema.format === \"date-time\" ? `\"${new Date().toISOString()}\"` : '\"\"';\n case \"number\":\n case \"integer\":\n return \"0\";\n case \"boolean\":\n return \"false\";\n case \"array\":\n return \"[]\";\n default:\n return \"null\";\n }\n}\n","import React, { useState, useEffect, useMemo } from \"react\";\nimport { useApiBase, useApiConfig, useAuthController, useTranslation } from \"@rebasepro/app\";\nimport {\n CircularProgress,\n Typography,\n Alert,\n cls,\n Button,\n Chip,\n defaultBorderMixin,\n SearchBar,\n iconSize\n} from \"@rebasepro/ui\";\nimport { BookOpenIcon, PlayIcon } from \"@rebasepro/ui\";\nimport { EndpointDetail } from \"./EndpointDetail\";\nimport { TryItPanel } from \"./TryItPanel\";\nimport type { OpenApiSpec, ParsedEndpoint } from \"./types\";\nimport { parseOpenApiSpec } from \"./parseSpec\";\n\n/**\n * Custom-built API Explorer for Rebase Studio.\n * No external dependencies — renders the OpenAPI spec natively\n * with deep integration into the Rebase auth system.\n */\nexport function ApiExplorer() {\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n const authController = useAuthController();\n const { t } = useTranslation();\n const apiUrl = apiConfig?.apiUrl;\n\n const [spec, setSpec] = useState<OpenApiSpec | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n\n const [selectedEndpoint, setSelectedEndpoint] = useState<ParsedEndpoint | null>(null);\n const [sidebarFilter, setSidebarFilter] = useState(\"\");\n const [tryItOpen, setTryItOpen] = useState(false);\n\n // Fetch OpenAPI spec\n useEffect(() => {\n if (!apiUrl) return;\n let cancelled = false;\n const specUrl = `${apiBase}/docs`;\n\n (async () => {\n try {\n // The spec endpoint itself is public on a stock backend, but\n // `apiUrl` may route through an authenticated proxy (the\n // console's Studio embed) — carry the token like every other\n // request in this view, and like LogsExplorer does.\n const getAuthToken = apiConfig?.getAuthToken ?? authController.getAuthToken;\n const token = getAuthToken ? await getAuthToken() : null;\n const res = await fetch(specUrl, token ? { headers: { Authorization: `Bearer ${token}` } } : undefined);\n if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);\n const data = await res.json();\n if (!cancelled) {\n setSpec(data);\n setLoading(false);\n }\n } catch (err: unknown) {\n if (!cancelled) {\n setError(err instanceof Error ? err.message : \"Failed to load API spec\");\n setLoading(false);\n }\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [apiUrl, apiBase, apiConfig, authController]);\n\n // Parse spec into grouped endpoints\n const { groups, allEndpoints } = useMemo(() => {\n if (!spec) return { groups: [],\nallEndpoints: [] };\n return parseOpenApiSpec(spec);\n }, [spec]);\n\n // Filter\n const filteredGroups = useMemo(() => {\n if (!sidebarFilter.trim()) return groups;\n const q = sidebarFilter.toLowerCase();\n return groups\n .map((g) => ({\n ...g,\n endpoints: g.endpoints.filter(\n (e) =>\n e.path.toLowerCase().includes(q) ||\n e.summary.toLowerCase().includes(q) ||\n e.method.toLowerCase().includes(q)\n )\n }))\n .filter((g) => g.endpoints.length > 0);\n }, [groups, sidebarFilter]);\n\n // Auto-select first endpoint\n useEffect(() => {\n if (!selectedEndpoint && allEndpoints.length > 0) {\n setSelectedEndpoint(allEndpoints[0]);\n }\n }, [allEndpoints, selectedEndpoint]);\n\n // ── States ───────────────────────────────────────────────────────\n if (!apiUrl) {\n return (\n <div className=\"flex items-center justify-center h-full w-full p-8\">\n <Alert color=\"warning\">\n <Typography variant=\"body2\">\n No API URL configured. Ensure your app provides an{\" \"}\n <code className=\"font-mono text-xs\">apiUrl</code>.\n </Typography>\n </Alert>\n </div>\n );\n }\n\n if (loading) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full w-full gap-4\">\n <CircularProgress size=\"medium\"/>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark animate-pulse\">\n Loading API specification…\n </Typography>\n </div>\n );\n }\n\n if (error || !spec) {\n // The API spec fetch rejects with whatever the transport says, and for\n // an expired console session that is the string \"401\". Rendering it\n // verbatim produced the worst screen in the console: a red box\n // containing three digits, no title, no cause, no way out — on the same\n // product whose storage browser writes four sentences explaining which\n // authorization hook refused a listing.\n //\n // The raw text is kept, below the sentence, because it is what someone\n // pastes into a bug report. It is just no longer the whole message.\n const status = (error ?? \"\").trim();\n const isAuth = /^(401|403)\\b/.test(status) || /unauthori[sz]ed|forbidden/i.test(status);\n return (\n <div className=\"flex items-center justify-center h-full w-full p-8\">\n <div className=\"max-w-md text-center\">\n <Typography variant=\"subtitle2\" className=\"block text-text-primary dark:text-text-primary-dark\">\n {isAuth ? t(\"studio_api_explorer_spec_refused_title\") : t(\"studio_api_explorer_spec_failed_title\")}\n </Typography>\n <Typography variant=\"body2\" className=\"block mt-2 text-text-secondary dark:text-text-secondary-dark\">\n {isAuth\n ? t(\"studio_api_explorer_spec_refused_body\")\n : t(\"studio_api_explorer_spec_failed_body\")}\n </Typography>\n <Button\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\"\n className=\"mt-4\"\n onClick={() => window.location.reload()}\n >\n {t(\"retry\")}\n </Button>\n {status && (\n <Typography variant=\"caption\" className=\"block mt-4 font-mono text-text-disabled dark:text-text-disabled-dark\">\n {status}\n </Typography>\n )}\n </div>\n </div>\n );\n }\n\n const METHOD_COLORS: Record<string, string> = {\n get: \"text-blue-600 dark:text-blue-400\",\n post: \"text-emerald-600 dark:text-emerald-400\",\n put: \"text-amber-600 dark:text-amber-400\",\n patch: \"text-orange-600 dark:text-orange-400\",\n delete: \"text-red-600 dark:text-red-400\"\n };\n\n return (\n <div className=\"flex h-full w-full overflow-hidden\">\n {/* ── Sidebar ──────────────────────────────────────── */}\n <div\n className={cls(\n \"w-72 min-w-[272px] flex flex-col h-full overflow-hidden border-r\",\n defaultBorderMixin,\n \"bg-surface-sheet\"\n )}\n >\n {/* Header */}\n <div className={cls(\"h-12 px-4 border-b bg-surface-sheet flex items-center justify-between gap-2 shrink-0\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-2 min-w-0\">\n <BookOpenIcon size={iconSize.medium} className=\"text-primary dark:text-primary-dark shrink-0\" />\n <Typography variant=\"subtitle2\" className=\"font-semibold truncate\">\n {spec.info?.title ?? \"API Reference\"}\n </Typography>\n </div>\n {spec.info?.version && (\n <Chip size=\"smallest\" colorScheme=\"cyanDarker\" className=\"shrink-0\">\n v{spec.info.version}\n </Chip>\n )}\n </div>\n\n {/* Search */}\n <div className={cls(\"p-2 border-b shrink-0\", defaultBorderMixin)}>\n <SearchBar\n placeholder=\"Filter endpoints…\"\n size=\"small\"\n onTextSearch={(val) => setSidebarFilter(val ?? \"\")}\n />\n </div>\n\n {/* Endpoint list */}\n <div className=\"flex-1 overflow-y-auto px-2 pb-4\">\n {filteredGroups.map((group) => (\n <div key={group.tag} className=\"mb-3\">\n <Typography\n variant=\"caption\"\n className=\"px-2 py-1.5 text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider font-semibold text-[10px]\"\n >\n {group.tag}\n </Typography>\n {group.endpoints.map((ep) => {\n const isSelected = selectedEndpoint?.id === ep.id;\n return (\n <Button\n key={ep.id}\n variant=\"text\"\n color=\"neutral\"\n fullWidth\n onClick={() => {\n setSelectedEndpoint(ep);\n setTryItOpen(false);\n }}\n className={cls(\n \"!justify-between !px-2.5 !py-1.5 !text-left !text-sm\",\n isSelected\n ? \"bg-surface-raised font-medium\"\n : \"text-text-primary dark:text-text-primary-dark\"\n )}\n >\n <span className=\"truncate text-[13px] opacity-90\">{ep.summary || ep.shortPath}</span>\n <span\n className={cls(\n \"text-[10px] font-semibold uppercase shrink-0\",\n METHOD_COLORS[ep.method] ?? \"text-text-secondary\"\n )}\n >\n {ep.method}\n </span>\n </Button>\n );\n })}\n </div>\n ))}\n {filteredGroups.length === 0 && (\n <Typography\n variant=\"body2\"\n className=\"text-center text-text-secondary dark:text-text-secondary-dark py-8\"\n >\n No endpoints match\n </Typography>\n )}\n </div>\n </div>\n\n {/* ── Main content ─────────────────────────────────── */}\n <div className=\"flex-1 flex flex-col h-full overflow-hidden\">\n {selectedEndpoint ? (\n <>\n {/* Top bar */}\n <div\n className={cls(\n \"flex items-center justify-between px-5 h-12 gap-4 shrink-0 border-b z-10\",\n defaultBorderMixin,\n \"bg-surface-sheet/90 backdrop-blur-md sticky top-0\"\n )}\n >\n <div className=\"flex items-center gap-3 min-w-0\">\n <span\n className={cls(\n \"text-xs font-semibold uppercase\",\n METHOD_COLORS[selectedEndpoint.method] ?? \"\"\n )}\n >\n {selectedEndpoint.method}\n </span>\n <code className=\"text-sm font-mono text-text-primary dark:text-text-primary-dark truncate\">\n {selectedEndpoint.path}\n </code>\n </div>\n <Button\n variant={tryItOpen ? \"filled\" : \"outlined\"}\n size=\"small\"\n onClick={() => setTryItOpen((v) => !v)}\n >\n <PlayIcon size={iconSize.small} className=\"mr-1\" />\n Try It\n </Button>\n </div>\n\n {/* Body */}\n <div className=\"flex-1 overflow-y-auto\">\n {tryItOpen ? (\n <TryItPanel\n key={selectedEndpoint.operationId || selectedEndpoint.path}\n endpoint={selectedEndpoint}\n apiUrl={apiUrl}\n getAuthToken={apiConfig?.getAuthToken ?? authController.getAuthToken}\n user={authController.user}\n basePath={spec?.servers?.[0]?.url || \"\"}\n />\n ) : (\n <EndpointDetail endpoint={selectedEndpoint} spec={spec}/>\n )}\n </div>\n </>\n ) : (\n <div className=\"flex items-center justify-center h-full\">\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n Select an endpoint from the sidebar\n </Typography>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nApiExplorer.displayName = \"ApiExplorer\";\n\n"],"mappings":";;;;;;;AAIA,IAAM,iCAAiB,IAAI,IAAY;CAAC;CAAO;CAAQ;CAAO;CAAS;AAAQ,CAAC;AAEhF,SAAS,eAAe,KAAkC;CACtD,OAAO,eAAe,IAAI,GAAG;AACjC;;;;AAKA,SAAgB,iBAAiB,MAG/B;CACE,MAAM,eAAiC,CAAC;CACxC,MAAM,yBAAS,IAAI,IAA8B;CAGjD,MAAM,kCAAkB,IAAI,IAAoB;CAChD,KAAK,MAAM,KAAK,KAAK,QAAQ,CAAC,GAC1B,gBAAgB,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;CAGnD,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,GACtD,KAAK,MAAM,UAAU,OAAO,KAAK,IAAI,GAAG;EACpC,IAAI,CAAC,eAAe,MAAM,GAAG;EAC7B,MAAM,KAAK,KAAK;EAChB,IA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,IAED,oBAAC,gBAAD;KAAgB,UAAU;KAAwB;IAAM,CAAA;GAE3D,CAAA,CACP,EAAA,CAAA,IAEF,oBAAC,OAAD;IAAK,WAAU;cACX,oBAAC,YAAD;KAAY,SAAQ;KAAQ,WAAU;eAAoD;IAE9E,CAAA;GACX,CAAA;EAER,CAAA,CACJ;;AAEb;AAEA,YAAY,cAAc"}
@@ -1,6 +1,6 @@
1
1
  import { t as classifyLoadFailure } from "./load-failure-Bd8lFIO7.js";
2
2
  import { t as LoadFailureView } from "./load-failure-view-CBTB_h-h.js";
3
- import { useApiBase, useApiConfig, useRebaseClient, useSnackbarController, useStorageSources, useTableDescriptors, useTranslation } from "@rebasepro/app";
3
+ import { useApiBase, useApiConfig, useRebaseClient, useSnackbarController, useStorageSources, useStudioCapabilities, useTableDescriptors, useTranslation } from "@rebasepro/app";
4
4
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { Alert, AlertCircleIcon, Button, CheckCircleIcon, Checkbox, Chip, CircularProgress, CopyIcon, DatabaseIcon, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, KeyRoundIcon, Label, MultiSelect, MultiSelectItem, PlusIcon, RefreshCwIcon, Select, SelectItem, ShieldIcon, Tab, Tabs, TagIcon, TextField, Tooltip, Trash2Icon, Typography, WrenchIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -289,7 +289,7 @@ function planeHint(t, plane) {
289
289
  case "app": return t("studio_api_keys_plane_app_hint");
290
290
  }
291
291
  }
292
- /** "Every collection", "Every storage source", "Every function", "Any project". */
292
+ /** "Every table", "Every storage source", "Every function", "Any project". */
293
293
  function everyTargetLabel(t, targetKind) {
294
294
  switch (targetKind) {
295
295
  case "collection": return t("studio_api_keys_target_all_collection");
@@ -1019,15 +1019,17 @@ function useScopeListing(client) {
1019
1019
  function ApiKeysView() {
1020
1020
  const client = useRebaseClient();
1021
1021
  const { t } = useTranslation();
1022
- const [kind, setKind] = useState("service");
1022
+ const serviceIdentity = useStudioCapabilities().requestIdentity !== void 0;
1023
+ const [chosenKind, setKind] = useState("service");
1024
+ const kind = serviceIdentity ? "service" : chosenKind;
1023
1025
  const [scopeListing, retryScopes] = useScopeListing(client);
1024
1026
  return /* @__PURE__ */ jsx(KeysPane, {
1025
1027
  kind,
1026
- tabs: /* @__PURE__ */ jsxs(Tabs, {
1028
+ tabs: serviceIdentity ? null : /* @__PURE__ */ jsxs(Tabs, {
1027
1029
  value: kind,
1028
1030
  onValueChange: (value) => setKind(value === "personal" ? "personal" : "service"),
1029
1031
  variant: "boxy",
1030
- className: "border-b border-hairline",
1032
+ className: "border-b border-hairline px-4 bg-surface-sheet shrink-0",
1031
1033
  children: [/* @__PURE__ */ jsx(Tab, {
1032
1034
  value: "service",
1033
1035
  children: t("studio_api_keys_tab_service")
@@ -1118,13 +1120,13 @@ function KeysPane({ kind, tabs, scopeListing, onRetryScopes }) {
1118
1120
  const inactiveKeys = keys.filter((k) => k.revoked_at || isExpired(k));
1119
1121
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1120
1122
  /* @__PURE__ */ jsxs("div", {
1121
- className: "flex h-full w-full overflow-hidden bg-surface-card",
1122
- children: [/* @__PURE__ */ jsxs("div", {
1123
- className: cls("flex flex-col w-[340px] min-w-[280px] border-r h-full", defaultBorderMixin),
1124
- children: [
1125
- tabs,
1126
- /* @__PURE__ */ jsxs("div", {
1127
- className: cls("flex items-center justify-between px-4 py-2.5 border-b bg-surface-sheet min-h-[48px]", defaultBorderMixin),
1123
+ className: "flex flex-col h-full w-full overflow-hidden bg-surface-card",
1124
+ children: [tabs, /* @__PURE__ */ jsxs("div", {
1125
+ className: "flex flex-1 min-h-0 w-full overflow-hidden",
1126
+ children: [/* @__PURE__ */ jsxs("div", {
1127
+ className: cls("flex flex-col w-[340px] min-w-[280px] border-r h-full", defaultBorderMixin),
1128
+ children: [/* @__PURE__ */ jsxs("div", {
1129
+ className: cls("flex items-center justify-between px-4 h-14 shrink-0 border-b bg-surface-sheet", defaultBorderMixin),
1128
1130
  children: [/* @__PURE__ */ jsxs("div", {
1129
1131
  className: "flex items-center gap-2",
1130
1132
  children: [
@@ -1160,8 +1162,7 @@ function KeysPane({ kind, tabs, scopeListing, onRetryScopes }) {
1160
1162
  children: t("studio_api_keys_new")
1161
1163
  })]
1162
1164
  })]
1163
- }),
1164
- /* @__PURE__ */ jsxs("div", {
1165
+ }), /* @__PURE__ */ jsxs("div", {
1165
1166
  className: "flex-1 overflow-y-auto p-2 space-y-1",
1166
1167
  children: [
1167
1168
  loading && /* @__PURE__ */ jsx("div", {
@@ -1216,23 +1217,23 @@ function KeysPane({ kind, tabs, scopeListing, onRetryScopes }) {
1216
1217
  onClick: () => setSelectedId(key.id)
1217
1218
  }, key.id))] })
1218
1219
  ]
1220
+ })]
1221
+ }), /* @__PURE__ */ jsx("div", {
1222
+ className: "flex-1 flex flex-col min-w-0 h-full overflow-hidden",
1223
+ children: !selectedKey ? /* @__PURE__ */ jsx("div", {
1224
+ className: "flex items-center justify-center h-full",
1225
+ children: !personalOff && /* @__PURE__ */ jsx(Typography, {
1226
+ variant: "body2",
1227
+ color: "disabled",
1228
+ children: t("studio_api_keys_select_hint")
1229
+ })
1230
+ }) : /* @__PURE__ */ jsx(KeyDetail, {
1231
+ apiKey: selectedKey,
1232
+ catalogue,
1233
+ revoking: revoking === selectedKey.id,
1234
+ onRevoke: () => setConfirmRevoke(selectedKey)
1219
1235
  })
1220
- ]
1221
- }), /* @__PURE__ */ jsx("div", {
1222
- className: "flex-1 flex flex-col min-w-0 h-full overflow-hidden",
1223
- children: !selectedKey ? /* @__PURE__ */ jsx("div", {
1224
- className: "flex items-center justify-center h-full",
1225
- children: !personalOff && /* @__PURE__ */ jsx(Typography, {
1226
- variant: "body2",
1227
- color: "disabled",
1228
- children: t("studio_api_keys_select_hint")
1229
- })
1230
- }) : /* @__PURE__ */ jsx(KeyDetail, {
1231
- apiKey: selectedKey,
1232
- catalogue,
1233
- revoking: revoking === selectedKey.id,
1234
- onRevoke: () => setConfirmRevoke(selectedKey)
1235
- })
1236
+ })]
1236
1237
  })]
1237
1238
  }),
1238
1239
  /* @__PURE__ */ jsxs(Dialog, {
@@ -1383,7 +1384,7 @@ function KeyDetail({ apiKey, catalogue, revoking, onRevoke }) {
1383
1384
  const service = apiKey.kind === "service";
1384
1385
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1385
1386
  /* @__PURE__ */ jsxs("div", {
1386
- className: cls("flex items-center justify-between px-5 py-3 border-b bg-surface-card min-h-[56px]", defaultBorderMixin),
1387
+ className: cls("flex items-center justify-between px-5 h-14 shrink-0 border-b bg-surface-sheet", defaultBorderMixin),
1387
1388
  children: [/* @__PURE__ */ jsxs("div", {
1388
1389
  className: "flex items-center gap-3 min-w-0",
1389
1390
  children: [/* @__PURE__ */ jsx(KeyRoundIcon, {
@@ -1746,4 +1747,4 @@ function SecretDisplayDialog({ keyWithSecret, catalogue, onClose }) {
1746
1747
  //#endregion
1747
1748
  export { ApiKeysView };
1748
1749
 
1749
- //# sourceMappingURL=ApiKeysView-CLBXUCgu.js.map
1750
+ //# sourceMappingURL=ApiKeysView-BdqASL_2.js.map