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.
Solves #102 as part of #99.
Adds the new API endpoint
POST /api/assets/search
which can be used as a replacement forPOST /api/search-asset
andGET /api/asset
. The endpoint can be tested via theasset-search.http
file.The endpoint's request format is described via
AssetSearchQuery
, its response inAssetSearchResult
. To parse the response, use:Due to
fp-ts
not being compatible withclass-transformer
, the returned assets will need to be parsed individually: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 typeAssetSearchStats
.Other Changes
class-transformer
andclass-validator
dependencies to (de)serialize and validate API boundaries.NODE_ENV
is set todevelopment
. This allows testing of API routes without going through eIAM.