reactiveadmin 0.2.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +88 -0
- data/LICENSE +21 -0
- data/README.md +81 -0
- data/app/assets/reactive_admin/bridge.js +89 -0
- data/app/controllers/reactive_admin/api_controller.rb +30 -0
- data/app/controllers/reactive_admin/client_errors_controller.rb +38 -0
- data/app/controllers/reactive_admin/manifest_controller.rb +10 -0
- data/app/controllers/reactive_admin/mcp_controller.rb +48 -0
- data/app/controllers/reactive_admin/openapi_controller.rb +13 -0
- data/app/controllers/reactive_admin/session_controller.rb +11 -0
- data/app/views/layouts/reactive_admin/embed.html.erb +30 -0
- data/lib/generators/reactiveadmin/install/install_generator.rb +341 -0
- data/lib/generators/reactiveadmin/install/templates/menu.rb.tt +25 -0
- data/lib/generators/reactiveadmin/install/templates/reactive_admin.rb.tt +53 -0
- data/lib/generators/reactiveadmin/install/templates/reactive_admin_annotated.rb.tt +110 -0
- data/lib/reactive_admin/aa/v3/controller.rb +76 -0
- data/lib/reactive_admin/aa/v3/forms.rb +29 -0
- data/lib/reactive_admin/aa/v3/inputs/filters/typeahead_input.rb +51 -0
- data/lib/reactive_admin/aa/v3/inputs/typeahead_input.rb +8 -0
- data/lib/reactive_admin/aa/v3/install.rb +36 -0
- data/lib/reactive_admin/aa/v3/menu.rb +67 -0
- data/lib/reactive_admin/aa/v3/presenters.rb +102 -0
- data/lib/reactive_admin/aa/v3/registry.rb +78 -0
- data/lib/reactive_admin/aa/v3/views.rb +63 -0
- data/lib/reactive_admin/aa/v3.rb +23 -0
- data/lib/reactive_admin/aa/v4.rb +59 -0
- data/lib/reactive_admin/aa.rb +46 -0
- data/lib/reactive_admin/action_items.rb +39 -0
- data/lib/reactive_admin/action_links.rb +197 -0
- data/lib/reactive_admin/action_safety.rb +19 -0
- data/lib/reactive_admin/actions.rb +95 -0
- data/lib/reactive_admin/api_errors.rb +116 -0
- data/lib/reactive_admin/api_fallback.rb +15 -0
- data/lib/reactive_admin/api_guards.rb +445 -0
- data/lib/reactive_admin/audit.rb +72 -0
- data/lib/reactive_admin/auth/guard.rb +68 -0
- data/lib/reactive_admin/auth/token_requests.rb +15 -0
- data/lib/reactive_admin/auth.rb +135 -0
- data/lib/reactive_admin/authorizer.rb +47 -0
- data/lib/reactive_admin/background_requests.rb +33 -0
- data/lib/reactive_admin/batch_actions.rb +57 -0
- data/lib/reactive_admin/choices.rb +289 -0
- data/lib/reactive_admin/client_error.rb +70 -0
- data/lib/reactive_admin/composite_keys.rb +12 -0
- data/lib/reactive_admin/configuration.rb +221 -0
- data/lib/reactive_admin/controller_extension.rb +229 -0
- data/lib/reactive_admin/csv_injection.rb +26 -0
- data/lib/reactive_admin/date_bound.rb +31 -0
- data/lib/reactive_admin/degradation.rb +72 -0
- data/lib/reactive_admin/diagnostics.rb +16 -0
- data/lib/reactive_admin/doctor.rb +466 -0
- data/lib/reactive_admin/dry_run.rb +147 -0
- data/lib/reactive_admin/dry_run_flag.rb +18 -0
- data/lib/reactive_admin/embed.rb +73 -0
- data/lib/reactive_admin/engine.rb +47 -0
- data/lib/reactive_admin/error_keys.rb +23 -0
- data/lib/reactive_admin/exposure.rb +86 -0
- data/lib/reactive_admin/filters.rb +165 -0
- data/lib/reactive_admin/fixtures/scrubber.rb +1075 -0
- data/lib/reactive_admin/fixtures.rb +161 -0
- data/lib/reactive_admin/form_content.rb +78 -0
- data/lib/reactive_admin/form_field.rb +279 -0
- data/lib/reactive_admin/form_has_many.rb +116 -0
- data/lib/reactive_admin/form_lock.rb +71 -0
- data/lib/reactive_admin/form_payload.rb +57 -0
- data/lib/reactive_admin/form_recorder.rb +192 -0
- data/lib/reactive_admin/form_schema.rb +160 -0
- data/lib/reactive_admin/frame.rb +97 -0
- data/lib/reactive_admin/html_nodes.rb +390 -0
- data/lib/reactive_admin/html_policy.rb +338 -0
- data/lib/reactive_admin/html_rich.rb +186 -0
- data/lib/reactive_admin/implicit_defaults.rb +102 -0
- data/lib/reactive_admin/index_options.rb +41 -0
- data/lib/reactive_admin/index_payload.rb +259 -0
- data/lib/reactive_admin/index_recorder.rb +115 -0
- data/lib/reactive_admin/index_views.rb +85 -0
- data/lib/reactive_admin/inline_style.rb +125 -0
- data/lib/reactive_admin/labels_payload.rb +34 -0
- data/lib/reactive_admin/ladder.rb +268 -0
- data/lib/reactive_admin/layout_classes.rb +167 -0
- data/lib/reactive_admin/legacy_inventory.rb +547 -0
- data/lib/reactive_admin/location.rb +22 -0
- data/lib/reactive_admin/lookup_audit.rb +30 -0
- data/lib/reactive_admin/lookup_payload.rb +41 -0
- data/lib/reactive_admin/manifest.rb +36 -0
- data/lib/reactive_admin/masked_json.rb +62 -0
- data/lib/reactive_admin/masking.rb +100 -0
- data/lib/reactive_admin/mcp/access.rb +111 -0
- data/lib/reactive_admin/mcp/api.rb +123 -0
- data/lib/reactive_admin/mcp/count_tool.rb +22 -0
- data/lib/reactive_admin/mcp/layout.rb +175 -0
- data/lib/reactive_admin/mcp/output.rb +46 -0
- data/lib/reactive_admin/mcp/prompts.rb +111 -0
- data/lib/reactive_admin/mcp/server.rb +134 -0
- data/lib/reactive_admin/mcp/shapes.rb +164 -0
- data/lib/reactive_admin/mcp/tools.rb +386 -0
- data/lib/reactive_admin/mcp.rb +53 -0
- data/lib/reactive_admin/media_nodes.rb +34 -0
- data/lib/reactive_admin/menu.rb +90 -0
- data/lib/reactive_admin/menu_overlay.rb +291 -0
- data/lib/reactive_admin/node_registry.rb +47 -0
- data/lib/reactive_admin/open_api/builder.rb +156 -0
- data/lib/reactive_admin/open_api/context.rb +46 -0
- data/lib/reactive_admin/open_api/core.rb +51 -0
- data/lib/reactive_admin/open_api/operation_ids.rb +18 -0
- data/lib/reactive_admin/open_api/page_doc.rb +75 -0
- data/lib/reactive_admin/open_api/parts.rb +86 -0
- data/lib/reactive_admin/open_api/resource_doc.rb +423 -0
- data/lib/reactive_admin/open_api/security.rb +55 -0
- data/lib/reactive_admin/open_api/write_schema.rb +104 -0
- data/lib/reactive_admin/open_api.rb +41 -0
- data/lib/reactive_admin/option_source.rb +36 -0
- data/lib/reactive_admin/option_sources.rb +14 -0
- data/lib/reactive_admin/options_payload.rb +61 -0
- data/lib/reactive_admin/page_controller_extension.rb +112 -0
- data/lib/reactive_admin/page_forms.rb +181 -0
- data/lib/reactive_admin/page_payload.rb +120 -0
- data/lib/reactive_admin/param_normalizer.rb +89 -0
- data/lib/reactive_admin/paths.rb +63 -0
- data/lib/reactive_admin/permissions.rb +31 -0
- data/lib/reactive_admin/provenance.rb +57 -0
- data/lib/reactive_admin/query_guard.rb +108 -0
- data/lib/reactive_admin/ransack_guard.rb +107 -0
- data/lib/reactive_admin/rate_limit.rb +59 -0
- data/lib/reactive_admin/reactive_dsl.rb +99 -0
- data/lib/reactive_admin/readiness.rb +189 -0
- data/lib/reactive_admin/registry.rb +69 -0
- data/lib/reactive_admin/resource_meta.rb +120 -0
- data/lib/reactive_admin/resource_summary.rb +41 -0
- data/lib/reactive_admin/routes.rb +60 -0
- data/lib/reactive_admin/row_errors.rb +29 -0
- data/lib/reactive_admin/rspec.rb +116 -0
- data/lib/reactive_admin/scrubbed_error.rb +22 -0
- data/lib/reactive_admin/search.rb +79 -0
- data/lib/reactive_admin/server_timing.rb +31 -0
- data/lib/reactive_admin/show_payload.rb +88 -0
- data/lib/reactive_admin/sidebars.rb +34 -0
- data/lib/reactive_admin/site.rb +55 -0
- data/lib/reactive_admin/style_report.rb +129 -0
- data/lib/reactive_admin/style_sources.rb +83 -0
- data/lib/reactive_admin/template_actions.rb +126 -0
- data/lib/reactive_admin/template_content.rb +49 -0
- data/lib/reactive_admin/template_form.rb +442 -0
- data/lib/reactive_admin/test_support.rb +31 -0
- data/lib/reactive_admin/typeahead.rb +33 -0
- data/lib/reactive_admin/ui/assets.rb +91 -0
- data/lib/reactive_admin/ui/client_build.rb +47 -0
- data/lib/reactive_admin/ui/helper.rb +24 -0
- data/lib/reactive_admin/ui/packaged_client.rb +67 -0
- data/lib/reactive_admin/ui/shell.rb +81 -0
- data/lib/reactive_admin/ui/switch.rb +38 -0
- data/lib/reactive_admin/ui.rb +43 -0
- data/lib/reactive_admin/value_payload.rb +147 -0
- data/lib/reactive_admin/value_token.rb +36 -0
- data/lib/reactive_admin/values.rb +43 -0
- data/lib/reactive_admin/version.rb +3 -0
- data/lib/reactive_admin/write_audit.rb +60 -0
- data/lib/reactive_admin/write_guards.rb +142 -0
- data/lib/reactive_admin.rb +153 -0
- data/lib/reactiveadmin.rb +1 -0
- data/lib/tasks/reactiveadmin.rake +36 -0
- data/lib/tasks/reactiveadmin_client.rake +11 -0
- data/lib/tasks/reactiveadmin_legacy.rake +7 -0
- data/lib/tasks/reactiveadmin_styles.rake +6 -0
- data/openapi/core.yaml +1643 -0
- data/vendor/client/assets/ActionPage-XUYorI8E.js +1 -0
- data/vendor/client/assets/ActionView-BsZFcsgp.js +1 -0
- data/vendor/client/assets/CommandPalette-C59HT1ip.js +1 -0
- data/vendor/client/assets/DatePicker-DuaK0iMg.js +1 -0
- data/vendor/client/assets/DateRangeCalendar-B2BDsG-X.js +1 -0
- data/vendor/client/assets/DegradedNotice-DiH5n2DO.js +1 -0
- data/vendor/client/assets/FormDialog-pmYl8Eov.js +1 -0
- data/vendor/client/assets/FormSkeleton-DuSBZO3C.js +1 -0
- data/vendor/client/assets/FrameView-2X8cFvUt.css +1 -0
- data/vendor/client/assets/FrameView-zmUeDO8d.js +1 -0
- data/vendor/client/assets/GroupOverview-DI5T3k5K.js +1 -0
- data/vendor/client/assets/InlineForm-CMEIMgeh.js +1 -0
- data/vendor/client/assets/JsonDiff-o7JWr7CH.js +3 -0
- data/vendor/client/assets/JsonEditor-D4VXdlEx.js +1 -0
- data/vendor/client/assets/JsonView-BrJLDmSN.js +1 -0
- data/vendor/client/assets/MobileMenu-GAeFOeEb.js +1 -0
- data/vendor/client/assets/Node-SQl61V4K.js +2 -0
- data/vendor/client/assets/PageView-C-laNEPZ.js +1 -0
- data/vendor/client/assets/ResourceForm-BPjsoCY6.js +1 -0
- data/vendor/client/assets/ResourceIndex-COezAw5t.js +3 -0
- data/vendor/client/assets/ResourceOrPage-CRZGCY84.js +1 -0
- data/vendor/client/assets/ResourceShow-DweRXn18.js +1 -0
- data/vendor/client/assets/Segmented-BE9TCbph.js +1 -0
- data/vendor/client/assets/Sidebars-CsB9rFqX.js +1 -0
- data/vendor/client/assets/breadcrumb-DSA3Tlyd.js +1 -0
- data/vendor/client/assets/button-CvZ4_DFC.js +1 -0
- data/vendor/client/assets/calendar-BoyMpJIf.js +1 -0
- data/vendor/client/assets/check-C5A3J16N.js +1 -0
- data/vendor/client/assets/command-CMuk0oAt.js +1 -0
- data/vendor/client/assets/dist-CqEI82S_.js +1 -0
- data/vendor/client/assets/dist-IW4yX942.js +1 -0
- data/vendor/client/assets/editor-yqRLzgsJ.js +2 -0
- data/vendor/client/assets/external-link-C2aR4slL.js +1 -0
- data/vendor/client/assets/frames-C9gPCc3N.js +1 -0
- data/vendor/client/assets/humanize-DtU_Kpr4.js +1 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- data/vendor/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- data/vendor/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- data/vendor/client/assets/index-B51aUaAY.js +43 -0
- data/vendor/client/assets/index-Cs9rCoWM.css +2 -0
- data/vendor/client/assets/input-DByFmQPa.js +1 -0
- data/vendor/client/assets/json-De3PN-R6.css +1 -0
- data/vendor/client/assets/json-oTp7Q-d-.js +5 -0
- data/vendor/client/assets/media-D4a_En8R.js +1 -0
- data/vendor/client/assets/plus-CfJ9vo8X.js +1 -0
- data/vendor/client/assets/popover-CDtI9R8Q.js +1 -0
- data/vendor/client/assets/purify-G7QKJyJq.js +1 -0
- data/vendor/client/assets/query-CCsZN2fa.js +1 -0
- data/vendor/client/assets/recent-BrzLwL0D.js +1 -0
- data/vendor/client/assets/rich-BQc_q5T7.js +1 -0
- data/vendor/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- data/vendor/client/assets/select-C43qDA3k.js +1 -0
- data/vendor/client/assets/sheet-BPl2n-4n.js +1 -0
- data/vendor/client/assets/textarea-BnOphXry.js +1 -0
- data/vendor/client/assets/uiMode-z0ZbRV49.js +1 -0
- data/vendor/client/assets/uiToggle-DwnRQTH1.js +1 -0
- data/vendor/client/assets/useRecordForm-X_DExEP2.js +1 -0
- data/vendor/client/assets/useRecordVisit-BRtfMi-q.js +1 -0
- data/vendor/client/assets/utils-DwBGbDkG.js +1 -0
- data/vendor/client/assets/vendor-calendar-nTZiq9oY.js +1 -0
- data/vendor/client/assets/vendor-datefns-BoC6MCnl.js +1 -0
- data/vendor/client/assets/vendor-forms-D0h8hG_S.js +55 -0
- data/vendor/client/assets/vendor-purify-BXoPR7WT.js +3 -0
- data/vendor/client/assets/vendor-query-DZ6APRNI.js +1 -0
- data/vendor/client/assets/vendor-react-C1iE8mnY.js +9 -0
- data/vendor/client/assets/vendor-router-CI6Vh4k_.js +1 -0
- data/vendor/client/assets/vendor-table-DuQ835by.js +4 -0
- data/vendor/client/index.html +24 -0
- data/vendor/client/manifest.json +867 -0
- data/vendor/client/reactiveadmin-client.json +4 -0
- metadata +350 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 44c03bc2825ae658fec598e140daf653a6637af6d303d77f7555dfa68c04e1f2
|
|
4
|
+
data.tar.gz: 2a62fbf39cc4c83981f20b419f75ae6fd7b2e941cd2ae558197b86a424a95b4f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 70334041b5c581100636a4db3857fec9f8233753abc3ec68ce38d91a66ce2006e31caebe8a6d02bfa22e7c4d7751f5ea022fd5509a51fd19e36ebe176a3c88ed
|
|
7
|
+
data.tar.gz: 2524a3d6e0675add16df9c513c4766d1f2f397596b4bde51939d67f5c275c871ac92b79e7f61bce71d1ee5ff559de5d5834c4b7b4df9107c5c4a48fb6e98b95b
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project aims to follow [Semantic Versioning](https://semver.org/) from 1.0.
|
|
4
|
+
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **MCP agent workflow tools.** `count_records` returns the total and per-scope counts for filters and a scope, through the index's own guards, with no rows. `update_record` takes `dry_run: true` and returns each field's `from` and `to` without saving; it is the API's `PATCH ... dry_run`, validated inside a rolled-back transaction, with masked values hidden and no `write` audit event. It previews only plain attributes the form offers a control for, and in-memory nested rows, and `dry_run` is refused anywhere but update. `prompts/list` and `prompts/get` serve three runbooks (`find_record`, `review_recent_changes`, `bulk_update`), offered only when the token can use the tools they name, and `initialize` advertises the `prompts` capability.
|
|
10
|
+
- A project website on GitHub Pages (`apps/site`, VitePress): a landing page, the guides and the changelog, plus a demo of the React admin that runs on mock data (`pnpm --filter standalone build:demo`).
|
|
11
|
+
- The crawl runs against a host app: `--base-url` takes a host's admin URL, `--auth` names a login hook, and the `reactiveadmin-crawl` bin runs it from a checkout. Docs warn that crawling real data creates audit reads and recommend a dedicated user.
|
|
12
|
+
- Performance budgets for the crawl (`--budget=p95=1500`, `--budget=index.max=4000`, `--budget-file`): the run exits non-zero and the report lists the screens over the limit.
|
|
13
|
+
- `--parity` compares each index's first page (row count and record ids, never values) with classic ActiveAdmin. Table rows, cards and grid items carry `data-row-id`.
|
|
14
|
+
- Keyboard navigation on index pages: `j`/`k` or the arrow keys move a visible row cursor in the table, card and grid views, `Enter` opens the row, `x` selects it when the resource has batch actions, and `/` focuses the filters. Press `?` for a dialog listing the shortcuts on the current screen.
|
|
15
|
+
- The gem ships a prebuilt React client (`gem/vendor/client`, built by `rake package`), so installing it from RubyGems needs no repository checkout and no Node.js. It is stamped with the gem version and manifest `schema_version`, and served only while they match. Builds refer to their own files relatively, so the packaged client works under any `ui.asset_prefix` or CDN, and `RA_ASSET_PREFIX` is gone. `config.ui.client_assets` and a host's own build (`rake reactiveadmin:client:build`) both win over it.
|
|
16
|
+
- A `packaged gem` CI job that builds the gem, installs it from a local index and smoke-tests the manifest and the client page.
|
|
17
|
+
- A `release` workflow: pushing a `v<version>` tag builds the gem with the client, smoke-tests it, publishes it to RubyGems with trusted publishing after maintainer approval, and creates a GitHub release from the CHANGELOG. The gem now includes the README, LICENSE and CHANGELOG, and lists Form Health as its author.
|
|
18
|
+
- `rails generate reactiveadmin:install`, which asks how to start (guided by default: `config.expose = :listed` with a generated `app/admin/menu.rb` listing every registration to prune, and an initializer annotated with `TODO(setup)` notes; quick: `expose :all`; strict: only what's listed, plus the dashboard and anything marked `reactive { expose true }`), which attributes to mask (proposed from `db/schema.rb`), whether to turn on MCP, and who may switch to the new admin, adding the switch to the dashboard. Every answer is also a flag (`--preset`, `--mask`, `--mcp`, `--ui`, `--yes`). It mounts the routes, serves ActiveAdmin's namespace, boots the app to check the setup, and changes nothing when run again.
|
|
19
|
+
- Typed react-query hooks per resource (`useListAuthors`) generated from a host's own `rake reactiveadmin:openapi` document with `reactiveadmin-gen`, through the client's `apiFetch`, optionally split by tag. CI generates and typechecks them against the dummy app.
|
|
20
|
+
- Rollout telemetry: the client reports caught crashes, names only, to `POST {mount}/admin/_client_errors` (a `client_error.reactiveadmin` event and `config.error_reporter`, in the `client_error` rate-limit bucket), which `config.ui.client_errors = false` turns off, and `rake reactiveadmin:readiness` combines each resource's doctor mode with recent `degraded` and client error counts (`config.event_counts`) as a checklist for leaving classic.
|
|
21
|
+
- `rake reactiveadmin:fixtures` records scrubbed JSON fixtures of the manifest, meta, index, show and form payloads from a running app, and `fixtureHandlers` turns them into MSW handlers for Storybook.
|
|
22
|
+
- A statement that the client needs React 19.2 or later. A React 18 install fails because React Router 8 and the client use React 19 APIs.
|
|
23
|
+
- A unified audit envelope: every audit event is also published as `audit.reactiveadmin` with one schema (kind, user, resource, action, record ids, channel, client id, request id, correlation id, outcome, time, details), and `ReactiveAdmin.on_audit { |event| ... }` subscribes to it. The existing events are unchanged.
|
|
24
|
+
- MCP writes carry the tool call's `correlation_id`, `channel: "mcp"` and the token's `client_id` in the envelope.
|
|
25
|
+
- Batch-action write events carry the selected ids as `record_ids`.
|
|
26
|
+
- `config.audit_views` (default `false`) publishes a `view` envelope for API show and edit reads.
|
|
27
|
+
- Switching between the classic and new admin publishes a `ui_switch` envelope.
|
|
28
|
+
- Panels' `header_action` (the method form) records as typed `header_actions`, kept through form content and MCP.
|
|
29
|
+
- Grid, blog and block index views show a selection checkbox per record when the resource has batch actions.
|
|
30
|
+
- `ReactiveAdmin::RSpec.contract_examples` (`require "reactive_admin/rspec"`) runs each registration's meta, index and show against the contract in a host's own suite.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- The minimum Rails version is now 8.1.
|
|
35
|
+
- The middleware serves the client's page only once `config.ui.available` names who may use it. Until then, upgrading changes nothing, even though a client is now installed.
|
|
36
|
+
|
|
37
|
+
### Security
|
|
38
|
+
|
|
39
|
+
These close gaps in the API and change what some clients get. Review them before you upgrade.
|
|
40
|
+
|
|
41
|
+
- **Disabled nested fields.** A write drops the params of a has_many row's disabled fields, as it already did for top-level fields. A row is held to the saved row its `id` names, or to a new row's fields, whatever index the client sent it at.
|
|
42
|
+
- **Mutating GET actions.** GET and HEAD actions stay reads. Declare a GET action that changes data with `reactive { unsafe_gets :name }`: it then needs the write scope, is write-audited, is refused by `api :read_only`, and needs MCP confirmation in `run_action`.
|
|
43
|
+
- **MCP is read-only by default (behavior change).** Each resource and page has an MCP mode: `config.mcp.default` (new, `:read_only`) or `reactive { mcp :full | :read_only | :none }`, with `mcp actions: [...]` to let agents run named custom or batch actions on a read-only resource. Agents lose `create_record`, `update_record`, `delete_record`, `get_form` and every `run_action` but GET and HEAD actions not listed in `unsafe_gets` on any resource that doesn't opt in, whatever the token's scopes; add `mcp :full` where agents must write, or set `config.mcp.default = :full` for the old behavior. `:none` leaves a resource out of MCP. `tools/list` hides tools no resource offers, a tool called on a resource whose mode excludes it fails as an unknown resource, and the API refuses MCP-dispatched requests the mode excludes. A mode never widens an `api` guard. `rake reactiveadmin:doctor` adds an "MCP surface" section and warns (`mcp_full_sensitive`) about `:full` on sensitive or masked resources.
|
|
44
|
+
- **MCP.** `tools/call` answers a tool the token's scopes hide as an unknown tool. `run_action` runs only the member, collection and batch actions the resource declares, and uses a method the action declares rather than the one the caller asks for.
|
|
45
|
+
- **Frames.** A frame form or `data-method` link that isn't a GET is sent, with the session's CSRF token, only to an admin page; anything else is refused, including paths with encoded separators (also inherited from the page URL) or control characters.
|
|
46
|
+
- **CSV exports without a `csv` block.** An API export of such a resource takes the attribute columns of its `index` block, or the secure default columns when it has no table index, instead of ActiveAdmin's id and every content column. Columns that an index block computes are no longer exported. The secure default columns leave out encrypted, filtered, masked and binary columns; columns an index block names are the host's choice and aren't filtered, and masked values are exported raw when `mask_csv` is off. Under `strict_defaults` such an export answers `422` unless a table index block supplies the columns. The table index decides the columns whatever `as` view is requested. Classic exports keep their columns. Declare a `csv` block to choose the columns.
|
|
47
|
+
- With `mask_csv` on, a masked key nested inside a json column is masked in any export, classic included.
|
|
48
|
+
- The CSV formula escaping flag is per request, so concurrent classic and API exports no longer share it.
|
|
49
|
+
- **Filter options and conditions.** The options of a filter on a plain column list only values from rows the user may read. A filter hidden by `if:` or `unless:` answers `404` for its options, and the API refuses its `q` keys with `400`. Option cache keys include the user id. A bounded `distinct` scope that doesn't project the column or its primary key offers no options.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- Filter and form option lists that read request params (such as other filters' values) are no longer served from the option cache across different params.
|
|
54
|
+
- A native view whose API answers 501 reopens in the frame or iframe the action allows, keeping its dialog or sheet and its query, instead of failing.
|
|
55
|
+
- A sort picked in the table view is checked against the table's columns when another index view is shown.
|
|
56
|
+
- `openapi/core.yaml` ships in the gem; the OpenAPI document failed to build from an installed gem without it.
|
|
57
|
+
- `config.mount_path` is normalized: a trailing slash (`"/api/"`) or a root mount (`""`) no longer breaks prefix checks such as contract lookup and CSV export detection.
|
|
58
|
+
- Switching resources no longer shows the previous resource's rows while the next index loads.
|
|
59
|
+
- A scope group's label isn't announced twice by screen readers.
|
|
60
|
+
|
|
61
|
+
## 0.1.0
|
|
62
|
+
|
|
63
|
+
First public release. The gem and the client are early: interfaces may change before 1.0.
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- A JSON API (`application/vnd.reactiveadmin+json`) served through your ActiveAdmin controllers, so filtering, scoping, sorting, pagination, authentication, authorization and the write path match the classic pages.
|
|
68
|
+
- Typed manifests, index, show and form payloads: Arbre component trees become typed nodes, Formtastic forms become typed form schemas (including `has_many` nested rows), and views that can't be represented natively fall back to sanitized HTML or an embedded classic page.
|
|
69
|
+
- A generated OpenAPI 3.1 document, filtered to what the requesting admin may access.
|
|
70
|
+
- An MCP server (`{mount}/_mcp`) whose tools call the same API, with bearer-token authentication and read and write scopes.
|
|
71
|
+
- A registration DSL (`reactive do ... end`) for option sources, masking, query params and API guards, and a menu overlay DSL.
|
|
72
|
+
- Security controls: explicit exposure (`config.expose = :listed`), API guards (`api false`, `:deny`, `:read_only`, `:session_only`, custom guards), attribute masking, summarized and tokenized JSON values, rate limits, optimistic locking for edits, and audit notifications that carry ids and no record data.
|
|
73
|
+
- Marking a resource as sensitive (`config.sensitive_resources`, `reactive { sensitive true }`) so that typeahead, option and label lookups that return its records publish a `lookup.reactiveadmin` event.
|
|
74
|
+
- `rake reactiveadmin:doctor`, `reactiveadmin:legacy` and `reactiveadmin:styles` to measure how much of an admin renders natively and what still depends on classic ActiveAdmin.
|
|
75
|
+
- A React client (Vite, TypeScript, Tailwind CSS, shadcn/ui, TanStack Table, React Query, orval) with filter bars, scope tabs, batch and member actions, typeahead and date controls, a JSON editor, a command menu, light and dark themes, and Storybook stories checked with axe.
|
|
76
|
+
- Serving the client at the classic admin's URLs, chosen per person by a cookie (`config.ui`, `reactiveadmin_ui_toggle`, `rake reactiveadmin:client:build`).
|
|
77
|
+
- An end-to-end crawl (`pnpm crawl`, `pnpm crawl:dummy`) that visits every screen the manifest describes.
|
|
78
|
+
- CI for the gem (Standard Ruby, an RSpec matrix over the default, custom and Pundit authorization adapters on SQLite and PostgreSQL) and for the client (contract drift, types, lint, tests, builds, Storybook, accessibility, crawl).
|
|
79
|
+
|
|
80
|
+
### Naming
|
|
81
|
+
|
|
82
|
+
The sensitive-data feature was named after one kind of sensitive data during development. It is now generic, and there is no alias for the old names:
|
|
83
|
+
|
|
84
|
+
- `config.phi_resources` is now `config.sensitive_resources`.
|
|
85
|
+
- `reactive { phi true }` and `reactive { phi false }` are now `reactive { sensitive true }` and `reactive { sensitive false }`.
|
|
86
|
+
- The `phi` option stored in a registration's `reactive_options` is now `sensitive`.
|
|
87
|
+
- The internal `ReactiveAdmin::LookupAudit.phi?` is now `sensitive?`.
|
|
88
|
+
- The OpenAPI descriptions of the JSON value endpoint now say that it is audited as a sensitive-data view. The `lookup.reactiveadmin` notification and its payload are unchanged.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Form Health, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ReactiveAdmin
|
|
2
|
+
|
|
3
|
+
ReactiveAdmin serves your existing [ActiveAdmin](https://activeadmin.info) registrations as a JSON API with an OpenAPI description and an MCP server, and it ships a React admin client that renders them. Your ActiveAdmin resources stay the source of truth: ReactiveAdmin reuses their controllers, filters, scopes, forms, actions and authorization, and adds the API and the UI on top.
|
|
4
|
+
|
|
5
|
+
Website and docs: <https://formhealth.github.io/reactiveadmin/>, with a [demo](https://formhealth.github.io/reactiveadmin/demo/) that runs on sample data and a [Storybook](https://formhealth.github.io/reactiveadmin/storybook/) of the client's components.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
Version 0.2.0. This is early software: interfaces may change before 1.0. See the [changelog](CHANGELOG.md).
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
| Tool | Version |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| Ruby | 3.4 or later |
|
|
16
|
+
| Rails | 8.1 or later |
|
|
17
|
+
| ActiveAdmin | 3.5 or later in the 3.x line (ActiveAdmin 4 isn't supported yet) |
|
|
18
|
+
| Node.js | 24, only to build the client from a source checkout (`.nvmrc`) |
|
|
19
|
+
| pnpm | 8.14.1, likewise (`corepack enable`) |
|
|
20
|
+
|
|
21
|
+
The released gem ships the client prebuilt, so a host installed from RubyGems needs no Node.js. Only a source checkout builds it.
|
|
22
|
+
|
|
23
|
+
The client bundles its own React 19.2 or later, so a host that runs React 18 elsewhere is unaffected. React 18 isn't supported: see [Custom components](docs/guide/custom-views.md#register-a-custom-component).
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
bundle add reactiveadmin
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The gem ships a prebuilt client, so the host needs no Node.js.
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
bin/rails generate reactiveadmin:install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The generator writes `config/initializers/reactive_admin.rb` with secure defaults (`config.expose = :listed`, `implicit_defaults = :secure`), adds `ReactiveAdmin.routes(self)` after `ActiveAdmin.routes(self)` in `config/routes.rb`, and prints the next steps. Running it again changes nothing. With `expose = :listed`, the API serves only the resources you place in `ReactiveAdmin.menu` or list in `config.exposed_resources`; see [Security](docs/guide/security.md#exposure).
|
|
40
|
+
|
|
41
|
+
With your app on port 3003 and a signed-in classic admin session, `http://localhost:3003/api/admin/_manifest` lists every resource the API serves. Add `reactive do ... end` blocks to resources that need hints; see the [DSL reference](docs/guide/dsl.md).
|
|
42
|
+
|
|
43
|
+
## Build and serve the client
|
|
44
|
+
|
|
45
|
+
For development, run the client against your app:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pnpm install
|
|
49
|
+
pnpm dev # http://localhost:5174, proxying to localhost:3003
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
In production the gem serves the prebuilt client at your classic admin's URLs, switched per person by a cookie, once you set `config.ui.available`. [Roll out the new admin](docs/guide/rollout.md) covers the configuration and ramp-up. From a source checkout, build the client first:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
bin/rails reactiveadmin:client:build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
- [Overview](docs/guide/overview.md): why the project exists, what it reuses from ActiveAdmin, and where it stops
|
|
61
|
+
- [Getting started](docs/guide/getting-started.md)
|
|
62
|
+
- [Configuration](docs/guide/configuration.md)
|
|
63
|
+
- [DSL reference](docs/guide/dsl.md)
|
|
64
|
+
- [ActiveAdmin support](docs/guide/activeadmin-support.md)
|
|
65
|
+
- [Custom views](docs/guide/custom-views.md)
|
|
66
|
+
- [Doctor](docs/guide/doctor.md): measure how much of your admin renders natively
|
|
67
|
+
- [OpenAPI](docs/guide/openapi.md)
|
|
68
|
+
- [MCP server](docs/guide/mcp.md)
|
|
69
|
+
- [Security](docs/guide/security.md)
|
|
70
|
+
- [Rolling out the new admin](docs/guide/rollout.md)
|
|
71
|
+
- [Testing](docs/guide/testing.md): the end-to-end crawl, contract examples for your request specs, and fixtures for Storybook
|
|
72
|
+
- [Roadmap](ROADMAP.md)
|
|
73
|
+
- [Contributing](CONTRIBUTING.md)
|
|
74
|
+
|
|
75
|
+
## Security notes
|
|
76
|
+
|
|
77
|
+
ReactiveAdmin keeps ActiveAdmin's authentication and authorization and adds guards of its own, but it exposes your data through a new API surface. Before you serve a resource that holds sensitive data, read the [security guide](docs/guide/security.md): set `config.expose = :listed`, declare explicit `index` and `show` blocks, mask credentials, and subscribe to the audit events. Report vulnerabilities privately; see [SECURITY.md](SECURITY.md).
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Runs inside a classic page rendered with ?embed=1 and reports to the embedding window.
|
|
2
|
+
(function () {
|
|
3
|
+
if (window.parent === window || window.__reactiveadminBridge) return;
|
|
4
|
+
window.__reactiveadminBridge = true;
|
|
5
|
+
|
|
6
|
+
var origin = window.location.origin;
|
|
7
|
+
var root = "/" + (window.location.pathname.split("/")[1] || "");
|
|
8
|
+
|
|
9
|
+
function post(message) {
|
|
10
|
+
window.parent.postMessage(message, origin);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function clean(url) {
|
|
14
|
+
url.searchParams.delete("embed");
|
|
15
|
+
return url.pathname + url.search + url.hash;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function sendHeight() {
|
|
19
|
+
post({ type: "reactiveadmin:resize", height: Math.ceil(document.body.getBoundingClientRect().height) });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function flashes() {
|
|
23
|
+
return Array.prototype.map
|
|
24
|
+
.call(document.querySelectorAll(".flashes .flash"), function (el) {
|
|
25
|
+
var kind = /flash_(\w+)/.exec(el.className);
|
|
26
|
+
return { type: kind ? kind[1] : "notice", message: el.textContent.trim() };
|
|
27
|
+
})
|
|
28
|
+
.filter(function (flash) {
|
|
29
|
+
return flash.message;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Links to other admin pages are the embedding app's to route; links that act stay with rails-ujs.
|
|
34
|
+
document.addEventListener("click", function (event) {
|
|
35
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
36
|
+
var link = event.target.closest && event.target.closest("a[href]");
|
|
37
|
+
if (!link || link.target === "_blank" || link.hasAttribute("download")) return;
|
|
38
|
+
if (link.dataset.method || link.dataset.remote || link.dataset.confirm) return;
|
|
39
|
+
|
|
40
|
+
var url = new URL(link.href, window.location.href);
|
|
41
|
+
var samePage = url.pathname === window.location.pathname && url.search === window.location.search;
|
|
42
|
+
if (url.origin !== origin || samePage || url.pathname.indexOf(root) !== 0) return;
|
|
43
|
+
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
post({ type: "reactiveadmin:navigate", url: clean(url) });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Submits stay in the embed, so the redirect that follows does too.
|
|
49
|
+
document.addEventListener(
|
|
50
|
+
"submit",
|
|
51
|
+
function (event) {
|
|
52
|
+
var form = event.target;
|
|
53
|
+
if (!form || form.tagName !== "FORM") return;
|
|
54
|
+
var action = form.getAttribute("action") || window.location.href;
|
|
55
|
+
var url = new URL(action, window.location.href);
|
|
56
|
+
if (url.origin !== origin) return;
|
|
57
|
+
if ((form.getAttribute("method") || "get").toLowerCase() === "get") {
|
|
58
|
+
if (!form.querySelector("input[name=embed]")) {
|
|
59
|
+
var input = document.createElement("input");
|
|
60
|
+
input.type = "hidden";
|
|
61
|
+
input.name = "embed";
|
|
62
|
+
input.value = "1";
|
|
63
|
+
form.appendChild(input);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
url.searchParams.set("embed", "1");
|
|
67
|
+
form.setAttribute("action", url.pathname + url.search + url.hash);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
true
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
function ready() {
|
|
74
|
+
var found = flashes();
|
|
75
|
+
if (found.length) post({ type: "reactiveadmin:flash", flashes: found });
|
|
76
|
+
|
|
77
|
+
var navigation = window.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
78
|
+
if (navigation && navigation.redirectCount > 0) {
|
|
79
|
+
post({ type: "reactiveadmin:navigate", url: clean(new URL(window.location.href)), redirected: true });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
sendHeight();
|
|
83
|
+
if (window.ResizeObserver) new ResizeObserver(sendHeight).observe(document.body);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", ready);
|
|
87
|
+
else ready();
|
|
88
|
+
window.addEventListener("load", sendHeight);
|
|
89
|
+
})();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module ReactiveAdmin
|
|
2
|
+
# Base of the shell endpoints. Subclasses ActiveAdmin's controller base, so authentication,
|
|
3
|
+
# the authorization adapter and the host's callbacks for AA controllers apply as for any AA page.
|
|
4
|
+
class ApiController < AA.base_controller
|
|
5
|
+
include Auth::Authentication
|
|
6
|
+
include ApiErrors
|
|
7
|
+
include BackgroundRequests
|
|
8
|
+
include Auth::Request
|
|
9
|
+
include Ui::Switch
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
# The namespace's root page stands in for AA's per-controller config: its authorization
|
|
14
|
+
# decides who may open the admin at all.
|
|
15
|
+
def active_admin_config = @active_admin_config ||= root_page
|
|
16
|
+
|
|
17
|
+
def active_admin_namespace = Registry.namespace
|
|
18
|
+
|
|
19
|
+
def root_page
|
|
20
|
+
pages = Registry.pages
|
|
21
|
+
root = AA.root_page_key(active_admin_namespace)
|
|
22
|
+
pages.find { it.controller.controller_path.split("/").last == root } || pages.first
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def authorize_root!
|
|
26
|
+
authorize!(AA::Auth::READ, active_admin_config) if active_admin_config
|
|
27
|
+
ReactiveAdmin.config.after_authorize&.call(self)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module ReactiveAdmin
|
|
2
|
+
# `{mount}/_client_errors`: the React client reports a crash its error boundary caught (see ClientError).
|
|
3
|
+
# Sessions only: the reports come from a browser, and a token has no reason to send them.
|
|
4
|
+
class ClientErrorsController < ApiController
|
|
5
|
+
wrap_parameters false
|
|
6
|
+
before_action :require_enabled
|
|
7
|
+
# Throttled first, so a flood never reaches the host's authorization checks.
|
|
8
|
+
before_action :throttle
|
|
9
|
+
before_action :authorize_root!
|
|
10
|
+
before_action :require_session
|
|
11
|
+
|
|
12
|
+
def create
|
|
13
|
+
error = ClientError.from_params(params, authorizer: Authorizer.for(self)) or return render_api_error(:invalid, "error_name is required", 400)
|
|
14
|
+
|
|
15
|
+
ClientError.report(error, request_id: request.request_id, user_id: ReactiveAdmin.current_user(self).id)
|
|
16
|
+
head :no_content
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def audit_writes? = false
|
|
22
|
+
|
|
23
|
+
def require_enabled
|
|
24
|
+
render_api_error(:not_found, "Not found", 404) unless Ui.settings.client_errors
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def require_session
|
|
28
|
+
render_api_error(:forbidden, "Client errors are reported from a session", 403) if token_request?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def throttle
|
|
32
|
+
seconds = RateLimit.retry_after(:client_error, ReactiveAdmin.current_user(self)&.id) or return
|
|
33
|
+
|
|
34
|
+
response.headers["Retry-After"] = seconds.to_s
|
|
35
|
+
render_api_error(:rate_limited, "Too many requests; try again in #{seconds} seconds", 429)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module ReactiveAdmin
|
|
2
|
+
# `{mount}/_mcp`: the MCP endpoint (see Mcp). Bearer tokens only; a session cookie is never accepted
|
|
3
|
+
# here, so a page the operator has open can't be made to drive it.
|
|
4
|
+
class McpController < ApiController
|
|
5
|
+
wrap_parameters false
|
|
6
|
+
rescue_from ActionDispatch::Http::Parameters::ParseError, with: :parse_error
|
|
7
|
+
before_action :authorize_root!
|
|
8
|
+
before_action :ensure_enabled
|
|
9
|
+
|
|
10
|
+
def create
|
|
11
|
+
status, body = Mcp::Server.new(self).handle(request.raw_post)
|
|
12
|
+
response.cache_control[:no_store] = true
|
|
13
|
+
body ? render(json: body, status:, content_type: "application/json") : head(status)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# No server-initiated stream (GET) and no sessions to end (DELETE).
|
|
17
|
+
def unsupported
|
|
18
|
+
response.headers["Allow"] = "POST"
|
|
19
|
+
head :method_not_allowed
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def token_only? = true
|
|
25
|
+
|
|
26
|
+
def audit_writes? = false
|
|
27
|
+
|
|
28
|
+
# Every message is a POST, but the tool behind it is what reads or writes, and its request is held to its own scope.
|
|
29
|
+
def required_scope = ReactiveAdmin.config.mcp.read_scope
|
|
30
|
+
|
|
31
|
+
# Before authentication: a disabled or foreign-origin request learns nothing about the app.
|
|
32
|
+
def process_action(*)
|
|
33
|
+
return reject(:not_found, "Not found", 404) unless ReactiveAdmin.config.mcp.possibly_enabled?
|
|
34
|
+
return reject(:forbidden, "Origin not allowed", 403) unless Mcp.origin_allowed?(request)
|
|
35
|
+
return reject(:invalid, "Unsupported MCP-Protocol-Version", 400) unless Mcp.protocol_version_supported?(request)
|
|
36
|
+
|
|
37
|
+
super
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def ensure_enabled
|
|
41
|
+
reject(:not_found, "Not found", 404) unless ReactiveAdmin.config.mcp.enabled_for?(ReactiveAdmin.current_user(self))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def reject(code, message, status) = render(json: {code:, message:}, status:, content_type: "application/json")
|
|
45
|
+
|
|
46
|
+
def parse_error = render(json: {jsonrpc: "2.0", id: nil, error: {code: -32700, message: "Parse error"}}, status: :bad_request, content_type: "application/json")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module ReactiveAdmin
|
|
2
|
+
# The OpenAPI document of what the signed-in user may do. Plain JSON, so any docs viewer can fetch it.
|
|
3
|
+
class OpenapiController < ApiController
|
|
4
|
+
include RateLimit::Guard
|
|
5
|
+
|
|
6
|
+
before_action :authorize_root!
|
|
7
|
+
|
|
8
|
+
def show
|
|
9
|
+
lookup_context.formats = [:html]
|
|
10
|
+
render json: OpenApi.fetch(self), content_type: "application/json"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module ReactiveAdmin
|
|
2
|
+
# Current user and the CSRF token clients must send as X-CSRF-Token on writes.
|
|
3
|
+
class SessionController < ApiController
|
|
4
|
+
def show
|
|
5
|
+
lookup_context.formats = [:html]
|
|
6
|
+
user = ReactiveAdmin.current_user(self)
|
|
7
|
+
render json: {user: {id: user.id.to_s, display_name: AA.display_name(view_context, user)}, csrf_token: form_authenticity_token, ui: Ui.payload(user)},
|
|
8
|
+
content_type: "application/json"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="<%= I18n.locale %>">
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
5
|
+
|
|
6
|
+
<title><%= [@page_title, ReactiveAdmin::AA.site_title(self)].compact.join(" | ") %></title>
|
|
7
|
+
|
|
8
|
+
<%= ReactiveAdmin::AA.embed_head(self) %>
|
|
9
|
+
|
|
10
|
+
<%= csrf_meta_tags %>
|
|
11
|
+
<%= csp_meta_tag %>
|
|
12
|
+
</head>
|
|
13
|
+
<body class="active_admin logged_in <%= controller.controller_path.tr("/", "_") %> <%= controller.action_name %>" data-reactiveadmin-embed>
|
|
14
|
+
<div id="wrapper">
|
|
15
|
+
<div class="flashes">
|
|
16
|
+
<% flash_messages.each do |type, message| %>
|
|
17
|
+
<%= content_tag :div, message, class: "flash flash_#{type}" %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
20
|
+
<div id="active_admin_content" class="without_sidebar">
|
|
21
|
+
<div id="main_content_wrapper">
|
|
22
|
+
<div id="main_content">
|
|
23
|
+
<%= yield %>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<%= javascript_tag ReactiveAdmin::Embed.bridge_js, nonce: true %>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|