Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 99: Refactor Suche - Backend #125

Merged
merged 2 commits into from
May 22, 2024

Conversation

daniel-va
Copy link
Contributor

@daniel-va daniel-va commented May 22, 2024

Solves #102 as part of #99.

Adds the new API endpoint POST /api/assets/search which can be used as a replacement for POST /api/search-asset and GET /api/asset. The endpoint can be tested via the asset-search.http file.

The endpoint's request format is described via AssetSearchQuery, its response in AssetSearchResult.
To parse the response, use:

import { plainToInstance } from 'class-transformer';
import { AssetSearchResultDTO } from '@asset-sg/shared';

const serializedResult = /* ...fetch data... */;
const result = plainToInstance(AssetSearchResultDTO, serializedResult);

Due to fp-ts not being compatible with class-transformer, the returned assets will need to be parsed individually:

import { AssetEditDetail} from '@asset-sg/shared';

result.data = result.data.map(AssetEditDetail.decode)

To complement the search, the endpoint POST /api/assets/search/stats has been added, which allows retrieval of aggregations related to a specific search. It can be used with the same query as the search endpoint itself, and returns values of type AssetSearchStats.

Other Changes

  • Added class-transformer and class-validator dependencies to (de)serialize and validate API boundaries.
  • Added a way to impersonate users while NODE_ENV is set to development. This allows testing of API routes without going through eIAM.
  • Updated the elastic sync process to use a separate sync index.
  • Updated the elastic sync process to also update the index to the currently configured mapping.

@daniel-va daniel-va requested a review from TIL-EBP May 22, 2024 09:15
@daniel-va daniel-va changed the title Feature/asset 99 refactor suche Feature 99: Refactor Suche - Backend May 22, 2024
TIL-EBP and others added 2 commits May 22, 2024 11:25
Rename `Polygon` to `StudyPolygon`

Install NestJS class transform/validation packages

Extend asset search types
Add API auth impersonation for development

Remove fixed email from `http-client.env.json`

Add `http-client.env.json` to gitignore

Encode output of `POST /api/assets/search` with `AssetSearchResultDTO`

Test `AssetSearchService.search`

Extend tests of `AssetSearchService.search`

Add `geometryCodes` to elastic assets

Add `POST /api/assets/search/stats`  api path

Fix lint

Allow lucene syntax in search text

Replace workflow prisma commands with npm shorthand
@daniel-va daniel-va force-pushed the feature/asset-99-refactor-suche branch from f49cd99 to b136de5 Compare May 22, 2024 09:26
@daniel-va daniel-va merged commit 170e179 into develop May 22, 2024
9 checks passed
@daniel-va daniel-va deleted the feature/asset-99-refactor-suche branch May 22, 2024 09:31
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.

2 participants