-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: add component atlas source dataset apis (#275) * test: add tests for component atlas source dataset apis (#275) * style: fix variable name (#275) * chore: remove commented-out code (#275) * feat: add component atlas source datasets get api (#275) * test: add tests for component atlas source datasets get api (#275) * feat: add component atlas individual source dataset api (#275) * fix: remove inconsistent and unnecessary client parameter (#275)
- Loading branch information
Showing
12 changed files
with
1,281 additions
and
8 deletions.
There are no files selected for viewing
442 changes: 442 additions & 0 deletions
442
__tests__/api-atlases-id-component-atlases-id-source-datasets-id.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
480 changes: 480 additions & 0 deletions
480
__tests__/api-atlases-id-component-atlases-id-source-datasets.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
pages/api/atlases/[atlasId]/component-atlases/[componentAtlasId]/source-datasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ROLE_GROUP } from "app/apis/catalog/hca-atlas-tracker/common/constants"; | ||
import { ROLE } from "../../../../../../app/apis/catalog/hca-atlas-tracker/common/entities"; | ||
import { componentAtlasAddSourceDatasetsSchema } from "../../../../../../app/apis/catalog/hca-atlas-tracker/common/schema"; | ||
import { dbSourceDatasetToApiSourceDataset } from "../../../../../../app/apis/catalog/hca-atlas-tracker/common/utils"; | ||
import { METHOD } from "../../../../../../app/common/entities"; | ||
import { | ||
addSourceDatasetsToComponentAtlas, | ||
deleteSourceDatasetsFromComponentAtlas, | ||
} from "../../../../../../app/services/component-atlases"; | ||
import { getComponentAtlasDatasets } from "../../../../../../app/services/source-datasets"; | ||
import { | ||
handleByMethod, | ||
handler, | ||
role, | ||
} from "../../../../../../app/utils/api-handler"; | ||
|
||
const getHandler = handler(role(ROLE_GROUP.READ), async (req, res) => { | ||
const atlasId = req.query.atlasId as string; | ||
const componentAtlasId = req.query.componentAtlasId as string; | ||
res | ||
.status(200) | ||
.json( | ||
(await getComponentAtlasDatasets(atlasId, componentAtlasId)).map( | ||
dbSourceDatasetToApiSourceDataset | ||
) | ||
); | ||
}); | ||
|
||
const postHandler = handler(role(ROLE.CONTENT_ADMIN), async (req, res) => { | ||
const atlasId = req.query.atlasId as string; | ||
const componentAtlasId = req.query.componentAtlasId as string; | ||
const { sourceDatasetIds } = | ||
await componentAtlasAddSourceDatasetsSchema.validate(req.body); | ||
await addSourceDatasetsToComponentAtlas( | ||
atlasId, | ||
componentAtlasId, | ||
sourceDatasetIds | ||
); | ||
res.status(201).end(); | ||
}); | ||
|
||
const deleteHandler = handler(role(ROLE.CONTENT_ADMIN), async (req, res) => { | ||
const atlasId = req.query.atlasId as string; | ||
const componentAtlasId = req.query.componentAtlasId as string; | ||
const { sourceDatasetIds } = | ||
await componentAtlasAddSourceDatasetsSchema.validate(req.body); | ||
await deleteSourceDatasetsFromComponentAtlas( | ||
atlasId, | ||
componentAtlasId, | ||
sourceDatasetIds | ||
); | ||
res.status(200).end(); | ||
}); | ||
|
||
/** | ||
* API route for adding or deleting multiple source datasets on a component atlas. | ||
*/ | ||
export default handleByMethod({ | ||
[METHOD.GET]: getHandler, | ||
[METHOD.POST]: postHandler, | ||
[METHOD.DELETE]: deleteHandler, | ||
}); |
Oops, something went wrong.