Conversation
There was a problem hiding this comment.
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.
| optionals: { | ||
| version?: DashboardVersion; | ||
| } & RoutingOptions = {}, | ||
| ): Promise<DashboardPreferenceReadOutView> { |
There was a problem hiding this comment.
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.
| ): Promise<DashboardPreferenceReadOutView> { | |
| ): Promise<DashboardPreferenceReadOutView[]> { |
| return await new Router() | ||
| .withSearchParams({ addNonce }) | ||
| .post(`/automaton/${automata}`, { | ||
| body: { parameters }, | ||
| ...routingOptions, | ||
| }).then(({ body }) => body); |
There was a problem hiding this comment.
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.).
| 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'; | |||
| 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); |
There was a problem hiding this comment.
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.
| const body = JSON.parse(req.requestBody); | |
| const body = JSON.parse(req.options.body); |
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