Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
5889df2
feat: prepare external API persistence foundation
bballdavis Jul 31, 2026
fb1cf01
fix: restore external API foundation CI
bballdavis Jul 31, 2026
8731466
fix: reissue external API migrations after schema normalization
bballdavis Sep 8, 2026
67c4c9a
fix: close external API compatibility migration markers
bballdavis Sep 8, 2026
3da0a68
fix: clear dependency audit findings
bballdavis Sep 8, 2026
52f5ab4
feat: add external API control plane
bballdavis Sep 8, 2026
23a3680
fix: make external API opt-in and verify MariaDB migrations
bballdavis Sep 8, 2026
0b43baa
fix: close config watcher after fixture validation
bballdavis Sep 8, 2026
074f14c
fix: keep contract pagination tests watcher-free
bballdavis Sep 9, 2026
f186253
fix: keep external request tests watcher-free
bballdavis Sep 9, 2026
c36ce89
test: keep auto-removal route mocks isolated
bballdavis Sep 9, 2026
bf14e3f
feat: add external API persistence foundation
bballdavis Sep 15, 2026
122fd47
test: keep channel model mocks association-compatible
bballdavis Sep 15, 2026
d10af4a
fix: use portable JSON literal in API key migration
bballdavis Sep 20, 2026
699a621
feat: add external API control plane
bballdavis Sep 8, 2026
bddf26a
fix: make external API opt-in and verify MariaDB migrations
bballdavis Sep 8, 2026
11e6149
fix: close config watcher after fixture validation
bballdavis Sep 8, 2026
45b7dd4
fix: keep contract pagination tests watcher-free
bballdavis Sep 9, 2026
8cc2b8e
feat: add external API administrator UI
bballdavis Sep 8, 2026
3d689ca
test: cover external request review states
bballdavis Sep 8, 2026
ebc698b
fix: keep external request tests watcher-free
bballdavis Sep 9, 2026
90c578c
test: keep auto-removal route mocks isolated
bballdavis Sep 9, 2026
927396a
feat: expose external API runtime capability
bballdavis Sep 18, 2026
74f5c04
docs: describe external API config capability
bballdavis Sep 18, 2026
1d5cab5
feat: type external API runtime capability
bballdavis Sep 18, 2026
c11f1b8
feat: default external API capability off
bballdavis Sep 18, 2026
fb4c93f
feat: gate external requests by runtime capability
bballdavis Sep 18, 2026
e3652d2
feat: pass external API capability to key settings
bballdavis Sep 18, 2026
c0b3fbe
feat: hide external key controls when API is disabled
bballdavis Sep 18, 2026
78a9a81
fix: keep select content in its portal
bballdavis Sep 18, 2026
8e953c6
docs: document external API request navigation
bballdavis Sep 18, 2026
6693dfe
docs: describe ExternalRequests architecture
bballdavis Sep 18, 2026
74e8837
fix: preserve API key section test defaults
bballdavis Sep 18, 2026
8157650
fix: normalize gated key section formatting
bballdavis Sep 18, 2026
87971a7
test: cover external API runtime capability
bballdavis Sep 18, 2026
f15e49a
test: cover enabled Requests navigation
bballdavis Sep 18, 2026
feac0a0
test: preserve trusted select pointer guard
bballdavis Sep 18, 2026
26fe94c
test: preserve trusted select pointer guard
bballdavis Sep 18, 2026
c425e7e
test: cover disabled direct Requests route
bballdavis Sep 18, 2026
8961bd6
refactor: add API key helper component
bballdavis Sep 18, 2026
6be3136
refactor: add API key helper component
bballdavis Sep 18, 2026
f60b574
refactor: add API key helper component
bballdavis Sep 18, 2026
2b3a2ed
refactor: export channel list response type
bballdavis Sep 18, 2026
5840ec6
fix: include channel database ids in list responses
bballdavis Sep 18, 2026
4615528
refactor external requests review flow
bballdavis Sep 18, 2026
b5f7b3e
refactor: extract api key channel grant helpers
bballdavis Sep 18, 2026
8c1e58d
wire API key policy and channel picker components
bballdavis Sep 18, 2026
b9acaad
Wire API key operations through typed hook
bballdavis Sep 18, 2026
81a9db9
Use app dialog for external access confirmation
bballdavis Sep 18, 2026
0df067b
Fix mapper regression test scope
bballdavis Sep 18, 2026
bc9ae6c
Update API key tests for typed hook
bballdavis Sep 18, 2026
df8ba11
test: close external API review gaps
bballdavis Sep 19, 2026
97bcf3b
style: clean extracted API key helpers
bballdavis Sep 19, 2026
52b0844
fix: align external API capability gate
bballdavis Sep 19, 2026
b27a25e
test: align logger expectations with current dev
bballdavis Sep 19, 2026
fa22465
test: align PR validation with current dev
bballdavis Sep 22, 2026
2dff745
fix: keep API key policy edits retryable
bballdavis Sep 22, 2026
7b4be9c
Merge PR #750 foundation and upstream dev into external API GUI
bballdavis Sep 29, 2026
e825d1f
Merge current external API runtime into GUI branch
bballdavis Sep 29, 2026
9d9cec4
fix: reconcile runtime dependency lockfile
bballdavis Sep 29, 2026
4aaaaa2
merge: align external API UI with reviewed runtime
bballdavis Oct 7, 2026
f49effb
fix: make external request review retries reliable
bballdavis Oct 7, 2026
4d811e3
fix: isolate external API key dialogs and preserve grants
bballdavis Oct 7, 2026
ac89554
fix: keep external request actions visible on mobile
bballdavis Oct 7, 2026
8ca3178
merge: include verified channel grant validation fix
bballdavis Oct 7, 2026
0468713
Merge external API runtime and current dev into GUI branch
bballdavis Oct 22, 2026
9ee25db
fix: limit the select change to the trusted-event guard
bballdavis Oct 22, 2026
927640a
refactor: name the external key workload limits once
bballdavis Oct 22, 2026
144251b
refactor: tidy the external request queue components
bballdavis Oct 22, 2026
1231cca
docs: describe the API keys page and Requests queue as built
bballdavis Oct 22, 2026
c95f8fa
Merge external API runtime review fixes into GUI branch
bballdavis Oct 22, 2026
0f9d9ec
feat: follow background request execution in the Requests queue
bballdavis Oct 22, 2026
62c1ae7
Merge remaining external API runtime fixes into GUI branch
bballdavis Oct 22, 2026
ab709a9
test: point capability check at the moved external API config module
bballdavis Oct 22, 2026
446058c
Merge external API runtime CI fixes into GUI branch
bballdavis Oct 22, 2026
eeba599
Merge upstream dev into external API administrator UI
bballdavis Nov 6, 2026
2c6c3ea
Merge upstream dev into external API administrator UI
bballdavis Nov 24, 2026
55edba8
fix: keep grants on disabled channels when saving a key
bballdavis Nov 24, 2026
bfcef58
fix: break channel list sort ties by id
bballdavis Nov 24, 2026
834964a
fix: wait for the config before redirecting away from Requests
bballdavis Nov 24, 2026
806ea2c
fix: only treat the polled query as a silent reload
bballdavis Nov 24, 2026
b4bc43b
fix: close dialogs on a backdrop click again
bballdavis Nov 24, 2026
207635b
fix: make Select all act on the channels shown
bballdavis Nov 24, 2026
e6609e2
refactor: import new icons from lib/icons
bballdavis Nov 24, 2026
30583cd
fix: tidy the API key lists and add read-only status keys
bballdavis Nov 24, 2026
1416e92
fix: return to the list after deciding a request from it
bballdavis Nov 24, 2026
b50ed54
refactor: import the Requests nav icon from lib/icons
bballdavis Nov 24, 2026
74e84cf
docs: describe the API keys page as it works with the External API
bballdavis Nov 24, 2026
c836856
test: drop the select-in-dialog test that cannot reach the touch guard
bballdavis Nov 24, 2026
879ba0e
refactor: trim the API keys section's dialog state
bballdavis Nov 24, 2026
4c221e8
test: cover the API key hook calls, policy checks and access editor
bballdavis Nov 24, 2026
161bdcc
fix: tolerate a dormant grant when saving channel grants
bballdavis Nov 24, 2026
551ac51
fix: polish the channel picker and key editor
bballdavis Nov 24, 2026
74fd4a9
Merge branch 'dev' into feature/external-api-gui
dialmaster Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .claude/rules/external-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ paths:
- "server/routes/externalApi.js"
- "server/routes/externalRequests.js"
- "server/middleware/externalApiAuth.js"
- "client/src/components/ExternalRequests/**/*"
- "client/src/components/Configuration/sections/ApiKeysSection.tsx"
- "client/src/components/Configuration/sections/ApiKeysSection/**/*"
- "client/src/types/externalRequest.ts"
- "client/src/utils/externalRatingPolicy.ts"
- "client/src/utils/__tests__/externalRatingPolicy.test.ts"
---

# External API
Expand All @@ -20,5 +26,6 @@ The opt-in `/external-api/v1` surface for external tools: catalog reads and down
- The executor rechecks authority, claims `approved` -> `processing`, queues downloads through `downloadModule.doSpecificDownloads` with the request id as the job id, provisions, enables and grants channels, and deletes videos through `videoDeletionModule`.
- It holds requests with a message while downloads are paused or the video is busy, and recovers interrupted rows at startup.
- `externalRequestTargets.js` validates grant, channel, video and policy targets; `externalRequestReconciliation.js` closes processing video requests whose job ended; `externalRequestPrimitives.js` shares validation and DTOs.
- Key-before-request locks serialize decisions; `externalWorkLimiter.js` bounds expensive work. `routes/externalRequests.js` exposes admin management endpoints that reject every API key; their UI is a separate follow-up.
- Key-before-request locks serialize decisions; `externalWorkLimiter.js` bounds expensive work. `routes/externalRequests.js` exposes admin management endpoints that reject every API key; their UI lives in `client/src/components/ExternalRequests/`.
- Grant replacement (`replaceChannelGrants`) touches only grants on enabled, non-terminated channels, the set the editor sees; a grant on a disabled channel stays dormant so re-enabling the channel restores it.
- External API jobs never use the cookies' membership: `doSpecificDownloads` keeps the members-only filter for the `(external request)` label or an `externalRequest: true` job flag, which `enqueueAutoRetryJob` copies onto its retries because their `Auto-retry:` label drops the source.
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ For multi-part requests (e.g., "review this PR AND explain WebSocket handling"),
### Frontend (`client/src/`)

- `App.tsx`: routing plus the global `fetch()` override and axios response interceptor that turn a 503 `requiresDbFix` response into the database error overlay.
- `components/`: one directory per feature (`Subscriptions/`, `ChannelPage/`, `PlaylistPage/`, `VideosPage/`, `FindVideos/`, `FindChannels/`, `DownloadManager/`, `SubscriptionImport/`, `Settings/` + `Configuration/`); `components/shared/` for cross-feature pieces (`VideoModal/`, `DeleteVideosDialog`, `AddChannelDialog`); `components/ui/` for theme-neutral primitives; `components/layout/` for the app shell and nav.
- `components/`: one directory per feature (`Subscriptions/`, `ChannelPage/`, `PlaylistPage/`, `VideosPage/`, `FindVideos/`, `FindChannels/`, `DownloadManager/`, `SubscriptionImport/`, `Settings/` + `Configuration/`, `ExternalRequests/`); `components/shared/` for cross-feature pieces (`VideoModal/`, `DeleteVideosDialog`, `AddChannelDialog`); `components/ui/` for theme-neutral primitives; `components/layout/` for the app shell and nav.
- `hooks/`, `contexts/`, `providers/` (auth token, WebSocket, theme, video activity), `themes/` (the `ALL_THEMES` registry), `config/` (the `CONFIG_FIELDS` registry), `types/`, `utils/`.

### Database
Expand Down
73 changes: 73 additions & 0 deletions client/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ jest.mock('./components/ChannelPage', () => {
};
});

jest.mock('./components/Settings/Settings', () => ({
Settings: () => <div data-testid="settings-page">Settings Component</div>,
}));

jest.mock('./components/ExternalRequests/RequestsPage', () => ({
__esModule: true,
default: () => <div data-testid="requests-page">Requests Component</div>,
}));

jest.mock('./components/ChangelogPage', () => {
return function ChangelogPage() {
return <div data-testid="changelog-page">Changelog Page Component</div>;
Expand Down Expand Up @@ -171,6 +180,7 @@ Object.defineProperty(window, 'matchMedia', {
beforeEach(() => {
jest.clearAllMocks();
setMockLocation('http://localhost/');
window.history.replaceState({}, '', '/');
// Re-apply matchMedia mock - resetMocks:true in jest.config.cjs clears implementations
Object.defineProperty(window, 'matchMedia', {
writable: true,
Expand Down Expand Up @@ -533,6 +543,69 @@ describe('App Component', () => {
// ElfHosted platform sets token via platform-managed auth
});

test('redirects direct Requests navigation when external API is disabled', async () => {
localStorageMock.getItem.mockReturnValue('test-token');
window.history.replaceState({}, '', '/requests');
(global.fetch as jest.Mock).mockImplementation((url) => {
if (url === '/getconfig') {
return Promise.resolve({
ok: true,
json: async () => ({ isPlatformManaged: { externalApiEnabled: false } }),
});
}
if (url === '/api/db-status') {
return Promise.resolve({ ok: true, json: async () => ({ status: 'healthy' }) });
}
if (url === '/setup/status') {
return Promise.resolve({ ok: true, json: async () => ({ requiresSetup: false }) });
}
if (url === '/auth/validate') {
return Promise.resolve({ ok: true, json: async () => ({}) });
}
return Promise.resolve({ ok: true, json: async () => ({}) });
});

render(<App />);

await waitFor(() => {
expect(screen.getByTestId('settings-page')).toBeInTheDocument();
});
expect(screen.queryByTestId('requests-page')).not.toBeInTheDocument();
});

test('waits for the config before deciding whether to open Requests', async () => {
localStorageMock.getItem.mockReturnValue('test-token');
window.history.replaceState({}, '', '/requests');
let resolveConfig: (value: unknown) => void = () => undefined;
(global.fetch as jest.Mock).mockImplementation((url) => {
if (url === '/getconfig') {
return new Promise((resolve) => { resolveConfig = resolve; });
}
if (url === '/api/db-status') {
return Promise.resolve({ ok: true, json: async () => ({ status: 'healthy' }) });
}
if (url === '/setup/status') {
return Promise.resolve({ ok: true, json: async () => ({ requiresSetup: false }) });
}
return Promise.resolve({ ok: true, json: async () => ({}) });
});

render(<App />);

await waitFor(() => {
expect(global.fetch).toHaveBeenCalledWith('/getconfig', expect.anything());
});
expect(screen.queryByTestId('settings-page')).not.toBeInTheDocument();

resolveConfig({
ok: true,
json: async () => ({ isPlatformManaged: { externalApiEnabled: true } }),
});

expect(await screen.findByTestId('requests-page')).toBeInTheDocument();
expect(screen.queryByTestId('settings-page')).not.toBeInTheDocument();
});

test('renders authenticated pages when user has token', async () => {
localStorageMock.getItem.mockReturnValue('test-token');

Expand Down
25 changes: 23 additions & 2 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import InitialSetup from './components/InitialSetup';
import ChannelPage from './components/ChannelPage';
import PlaylistPage from './components/PlaylistPage';
import ImportSubscriptionsPage from './components/SubscriptionImport';
import RequestsPage from './components/ExternalRequests/RequestsPage';
import ChangelogPage from './components/ChangelogPage';
import { AuthSplash } from './components/AuthSplash';
import { useConfig } from './hooks/useConfig';
Expand Down Expand Up @@ -83,10 +84,20 @@ function AppContent() {
const [dbErrors, setDbErrors] = useState<string[]>([]);
const [dbRecovered, setDbRecovered] = useState(false);
const [countdown, setCountdown] = useState(15);
const [requestsNavLinkPreview, setRequestsNavLinkPreview] = useState<boolean | null>(null);
const location = useLocation();

// Use config hook for global configuration access
const { config: appConfig, deploymentEnvironment } = useConfig(token);
const {
config: appConfig,
initialConfig: loadedConfig,
error: configError,
isPlatformManaged: platformManagedConfig,
deploymentEnvironment,
} = useConfig(token);
// externalApiEnabled reads false until /getconfig answers, so routes gated on
// it wait for the config instead of redirecting a reload or bookmark.
const configResolved = loadedConfig !== null || configError !== null;
const { version } = packageJson;
const clientVersion = `v${version}`; // Create a version with 'v' prefix for comparison
const tmpDirectory = '/tmp';
Expand Down Expand Up @@ -541,6 +552,7 @@ function AppContent() {
serverVersion={serverVersion}
ytDlpUpdateAvailable={ytDlpUpdateAvailable}
ytDlpUpdateTooltip={ytDlpUpdateTooltip}
showRequestsNavLink={platformManagedConfig.externalApiEnabled && (requestsNavLinkPreview ?? appConfig.showRequestsNavLink)}
onLogout={handleLogout}
>
<Container
Expand All @@ -554,7 +566,15 @@ function AppContent() {
path="/changelog"
element={<ChangelogPage updateAvailable={updateAvailable} serverVersion={serverVersion} />}
/>
<Route path="/settings/*" element={<Settings token={token} />} />
<Route
path="/settings/*"
element={
<Settings
token={token}
onRequestsNavLinkPreview={setRequestsNavLinkPreview}
/>
}
/>
<Route path="/configuration" element={<Navigate to="/settings" replace />} />
<Route path="/subscriptions" element={<Subscriptions token={token} />} />
<Route path="/subscriptions/imports" element={<ImportSubscriptionsPage token={token} />} />
Expand All @@ -564,6 +584,7 @@ function AppContent() {
<Route path="/downloads/*" element={<DownloadManager token={token} />} />
<Route path="/videos" element={<VideosPage token={token} />} />
<Route path="/videos/find" element={<FindVideos token={token} />} />
<Route path="/requests" element={!configResolved ? null : platformManagedConfig.externalApiEnabled ? <RequestsPage token={token} /> : <Navigate to="/settings/api-keys" replace />} />
<Route path="/channel/:channel_id" element={<ChannelPage token={token} />} />
<Route path="/playlist/:id" element={<PlaylistPage token={token} />} />
<Route path="/" element={<Navigate to="/subscriptions" replace />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ describe('ChannelSettingsDialog', () => {
plexUrl: false,
authEnabled: true,
useTmpForDownloads: false,
ytdlpUpdates: false
ytdlpUpdates: false,
externalApiEnabled: false
},
deploymentEnvironment: {
platform: null,
Expand Down Expand Up @@ -362,7 +363,8 @@ describe('ChannelSettingsDialog', () => {
plexUrl: false,
authEnabled: true,
useTmpForDownloads: false,
ytdlpUpdates: false
ytdlpUpdates: false,
externalApiEnabled: false
},
deploymentEnvironment: {
platform: null,
Expand Down
Loading
Loading