Skip to content

EPILIBS-186: wrap several endpoints with new adapters#162

Open
kailerg wants to merge 1 commit into
masterfrom
rock-ai
Open

EPILIBS-186: wrap several endpoints with new adapters#162
kailerg wants to merge 1 commit into
masterfrom
rock-ai

Conversation

@kailerg

@kailerg kailerg commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Created with the help of AI

Not entirely sure what some endpoints do so i may have made some wrong assumptions or added inaccurate descriptions

  • automaton
  • context
  • dashboard
  • encyclopedia
  • fido2
  • forge
  • information
  • notification

@kailerg kailerg changed the title feat: wrap several endpoints with new adapters EPILIBS-186: wrap several endpoints with new adapters Apr 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several new adapters to the epicenter-libs package, including automaton, context, dashboard, encyclopedia, fido2, forge, information, and notification. Each new adapter comes with comprehensive unit tests and updated type definitions. Additionally, common constants like MODEL_LANGUAGE and MORPHOLOGY have been centralized. Feedback highlights a necessary correction to the return type of the dashboard getAll method, the removal of redundant await keywords when chaining promises, and improvements for consistency in imports and test data access.

Comment thread src/adapters/dashboard.ts
optionals: {
version?: DashboardVersion;
} & RoutingOptions = {},
): Promise<DashboardPreferenceReadOutView> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function getAll is expected to return a list of all dashboard preferences, but the current return type Promise<DashboardPreferenceReadOutView> suggests a single object. Based on the function name and the likely API behavior for a "get all" endpoint, this should probably return an array of preferences.

Suggested change
): Promise<DashboardPreferenceReadOutView> {
): Promise<DashboardPreferenceReadOutView[]> {

Comment thread src/adapters/automaton.ts
Comment on lines +51 to +56
return await new Router()
.withSearchParams({ addNonce })
.post(`/automaton/${automata}`, {
body: { parameters },
...routingOptions,
}).then(({ body }) => body);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using await with .then() is redundant. An async function will automatically wrap the returned value in a Promise, so you can directly return the promise chain. This will make the code cleaner and slightly more performant.

This comment applies to getStatus in this file, and all similar async functions in the other new adapter files (context.ts, dashboard.ts, etc.).

Suggested change
return await new Router()
.withSearchParams({ addNonce })
.post(`/automaton/${automata}`, {
body: { parameters },
...routingOptions,
}).then(({ body }) => body);
return new Router()
.withSearchParams({ addNonce })
.post(`/automaton/${automata}`, {
body: { parameters },
...routingOptions,
}).then(({ body }) => body);

@@ -0,0 +1,112 @@
import type { RoutingOptions } from '../utils/router';

import Router from '../utils/router';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other adapter files in this PR (e.g., automaton.ts), please use a named import for Router. This also applies to src/adapters/fido2.ts.

Suggested change
import Router from '../utils/router';
import { Router } from '../utils/router';

Comment thread tests/fido2.spec.js
it('Should send the credential in the body', async () => {
await fido2Adapter.register(credential);
const req = capturedRequests[capturedRequests.length - 1];
const body = JSON.parse(req.requestBody);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's an inconsistency in how the request body is accessed in the new test files. Some use req.requestBody while others use req.options.body. To maintain consistency across the test suite, please prefer using req.options.body.

This comment also applies to line 165 in this file and similar instances in tests/forge.spec.js.

Suggested change
const body = JSON.parse(req.requestBody);
const body = JSON.parse(req.options.body);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant