feat(works-v2): optimized and documented works v2 service
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-07-19 15:17:57 +02:00
parent d1490dceb0
commit 0a97b3797e
47 changed files with 1515 additions and 799 deletions
@@ -0,0 +1,8 @@
from inse.model import Page
from inse.models.openalex.author import Author
class AuthorPage(Page[Author]):
"""A paginated response containing a list of authors."""
pass
@@ -0,0 +1,47 @@
import logging
from typing import Annotated
from fastapi import APIRouter, Query
from inse.tags import Tags
from inse.authors.v2.model import AuthorPage
import inse.authors.v2.service as authors_service
AUTHORS_V2_PREFIX = "/api/v2/authors"
logger = logging.getLogger(__name__)
router = APIRouter(prefix=AUTHORS_V2_PREFIX, tags=[Tags.AUTHORS_V2])
@router.get(
"/authors/id",
operation_id="getAuthorsByIds",
summary="Returns a paginated list of authors for a given list of author IDs.",
)
async def get_authors_by_ids(
author_ids: Annotated[
list[str],
Query(description="A list of author IDs to retrieve."),
] = [],
) -> AuthorPage:
return await authors_service.get_authors_by_ids(author_ids=author_ids or [])
@router.get(
"/autocomplete/selector",
operation_id="autocompleteAuthorsForSelector",
summary="Returns a paginated list of authors for a given search term based on their display name.",
)
async def autocomplete_authors_for_selector(
query: Annotated[
str,
Query(
description="A search term to filter authors by (partial matches allowed)."
),
] = "",
) -> AuthorPage:
return await authors_service.autocomplete_authors_for_selector(query=query)
@@ -0,0 +1,97 @@
from typing import Dict, List, Optional
from inse.authors.v2.model import AuthorPage
from inse.integrations import elasticsearch
from inse.model import ESIndex
from inse.models.openalex.author import Author
async def search_authors(
page: int = 0,
size: int = 10,
query: Optional[Dict] = None,
source: Optional[List[str]] = None,
sort: Optional[List[dict]] = None,
body: Optional[dict] = None,
) -> AuthorPage:
"""Searches for authors in the OpenAlex Elasticsearch index based on the provided parameters.
Args:
page (int, optional): The page number for pagination (0-indexed). Defaults to 0.
size (int, optional): The number of results to return per page. Defaults to 10.
query (Optional[Dict], optional): The search query. Defaults to None.
source (Optional[List[str]], optional): The fields to include in the response. Defaults to None.
sort (Optional[List[dict]], optional): The sorting criteria. Defaults to None.
body (Optional[dict], optional): The request body for the search query. Defaults to None.
Returns:
AuthorPage: A page of authors matching the search criteria.
"""
response = await elasticsearch.search(
ESIndex.OPENALEX_AUTHORS,
query=query,
source=source,
size=size,
offset=size * page,
sort=sort,
body=body,
)
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
authors: List[Author] = []
for hit in hits:
_source = hit.get("_source", {})
authors.append(Author.from_dict(_source)) # type: ignore
return AuthorPage(elements=authors, total=len(authors), page=page, size=size)
async def autocomplete_authors_for_selector(query: str) -> AuthorPage:
"""Autocompletes authors based on a search term for use in a selector component.
Args:
query (str): The search term to filter authors by (partial matches allowed).
Returns:
AuthorPage: A page of authors matching the search criteria.
"""
return await search_authors(
page=0,
size=10,
query={"match_phrase_prefix": {"display_name": query}},
source=[
"id",
"display_name",
"orcid",
"last_known_institutions",
"works_count",
],
)
async def get_authors_by_ids(author_ids: List[str]) -> AuthorPage:
"""Retrieves authors based on a list of author IDs.
Args:
author_ids (List[str]): A list of author IDs to retrieve.
Returns:
AuthorPage: A page of authors matching the provided IDs.
"""
if not author_ids:
return AuthorPage(elements=[], total=0, page=0, size=0)
return await search_authors(
page=0,
size=len(author_ids),
query={"terms": {"id": author_ids}},
source=[
"id",
"display_name",
"orcid",
"last_known_institutions",
"works_count",
],
)
@@ -0,0 +1,8 @@
from inse.model import Page
from inse.models.openalex.institution import Institution
class InstitutionPageV2(Page[Institution]):
"""A paginated response containing a list of institutions."""
pass
@@ -0,0 +1,49 @@
import logging
from typing import Annotated
from fastapi import APIRouter, Query
from inse.institutions.v2.model import InstitutionPageV2
from inse.tags import Tags
logger = logging.getLogger(__name__)
INSTITUTIONS_v2_PREFIX = "/api/v2/institutions"
router = APIRouter(prefix=INSTITUTIONS_v2_PREFIX, tags=[Tags.INSTITUTIONS_V2])
@router.get(
"/ids",
operation_id="getInstitutionsByIds",
summary="Returns a list of institutions based on their IDs.",
)
async def get_institutions_by_ids(
institution_ids: Annotated[
list[str],
Query(description="A list of institution IDs to retrieve."),
] = [],
) -> InstitutionPageV2:
from inse.institutions.v2.service import get_institutions_by_ids
return await get_institutions_by_ids(institution_ids=institution_ids or [])
@router.get(
"/autocomplete/selector",
operation_id="getInstitutionAutocompleteForSelector",
summary="Returns a list of institutions based on a search term for autocomplete functionality.",
)
async def get_institution_autocomplete(
query: Annotated[
str,
Query(
description="A search term to filter institutions by (partial matches allowed)."
),
] = "",
) -> InstitutionPageV2:
from inse.institutions.v2.service import autocomplete_institutions_for_selector
return await autocomplete_institutions_for_selector(query=query)
@@ -0,0 +1,141 @@
import logging
from typing import Dict, List, Optional
from inse.integrations import elasticsearch
from inse.model import ESIndex
from inse.models.openalex.institution import Institution
from inse.institutions.v2.model import InstitutionPageV2
logger = logging.getLogger(__name__)
async def search_institutions(
page: int = 0,
size: int = 10,
query: Optional[Dict] = None,
source: Optional[List[str]] = None,
sort: Optional[List[Dict]] = None,
body: Optional[Dict] = None,
) -> InstitutionPageV2:
"""Searches for institutions in the OpenAlex Elasticsearch index based on the provided parameters.
Args:
page (int, optional): The page number to retrieve. Defaults to 0.
size (int, optional): The number of institutions to retrieve per page. Defaults to 10.
query (Optional[Dict], optional): The search query to filter institutions by. Defaults to None.
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
sort (Optional[List[Dict]], optional): A list of sorting criteria. Defaults to None.
body (Optional[Dict], optional): The request body for the Elasticsearch search query. Defaults to None.
Returns:
InstitutionPageV2: A page of institutions matching the search criteria.
"""
response = await elasticsearch.search(
ESIndex.OPENALEX_INSTITUTIONS,
query=query,
source=source,
size=size,
offset=size * page,
sort=sort,
body=body,
)
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
institutions: List[Institution] = []
for hit in hits:
_source = hit.get("_source", {})
institutions.append(Institution.from_dict(_source)) # type: ignore
return InstitutionPageV2(
elements=institutions, total=len(institutions), page=page, size=size
)
async def get_institutions_by_ids(institution_ids: List[str]) -> InstitutionPageV2:
"""Retrieves institutions based on a list of institution IDs.
Args:
institution_ids (List[str]): A list of institution IDs to retrieve.
Returns:
InstitutionPageV2: A page of institutions matching the provided IDs.
"""
logger.debug(f"Fetching institutions for IDs: {institution_ids}")
if not institution_ids:
return InstitutionPageV2(elements=[], total=0, page=0, size=0)
return await search_institutions(
page=0,
size=len(institution_ids),
query={"terms": {"id": institution_ids}},
source=[
"id",
"display_name",
"display_name_alternatives",
"country_code",
"type",
"ror",
],
)
async def autocomplete_institutions(
query: str, page: int = 0, size: int = 10, source: Optional[List[str]] = None
) -> InstitutionPageV2:
"""Autocompletes institutions based on a search term.
Args:
query (str): The search term to autocomplete institutions with.
page (int, optional): The page number to retrieve. Defaults to 0.
size (int, optional): The number of institutions to retrieve per page. Defaults to 10.
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
Returns:
InstitutionPageV2: A page of institutions matching the autocomplete criteria.
"""
logger.debug(f"Autocomplete institutions for query: {query}")
if not query:
return InstitutionPageV2(elements=[], total=0, page=0, size=0)
return await search_institutions(
page=page,
size=size,
query={
"bool": {
"should": [
{"match_phrase_prefix": {"display_name": query}},
{"match_phrase_prefix": {"display_name_alternatives": query}},
]
}
},
source=source,
)
async def autocomplete_institutions_for_selector(
query: str, page: int = 0, size: int = 10
) -> InstitutionPageV2:
"""Autocompletes institutions based on a search term for use in a selector component.
Args:
query (str): The search term to filter institutions by (partial matches allowed).
page (int, optional): The page number to retrieve. Defaults to 0.
size (int, optional): The number of institutions to retrieve per page. Defaults to 10.
Returns:
InstitutionPageV2: A page of institutions matching the autocomplete criteria.
"""
return await autocomplete_institutions(
query=query,
page=page,
size=size,
source=[
"id",
"display_name",
"display_name_alternatives",
"country_code",
"type",
"ror",
],
)
+7
View File
@@ -54,6 +54,9 @@ from inse.patents.service import (
)
from inse.works.v2.router import router as works_v2_router
from inse.authors.v2.router import router as authors_v2_router
from inse.institutions.v2.router import router as institutions_v2_router
from inse.topics.v2.router import router as topics_v2_router
logger = logging.getLogger(__name__)
@@ -102,7 +105,11 @@ app.include_router(service_router)
app.include_router(auth_router)
app.include_router(account_management_router)
app.include_router(organization_management_router)
app.include_router(works_v2_router)
app.include_router(authors_v2_router)
app.include_router(institutions_v2_router)
app.include_router(topics_v2_router)
app.include_router(dashboard_router)
app.include_router(bookmarks_router)
+2 -1
View File
@@ -28,6 +28,8 @@ T = TypeVar("T", bound=BaseModel)
class Page(BaseModel, Generic[T]):
"""A generic page model that represents a paginated response containing elements of type T."""
elements: List[T] = Field(default=[], description="The elements of the page.")
page: int = Field(default=0, description="The page number. (0-based)")
size: int = Field(default=20, description="The page size in elements.")
@@ -114,4 +116,3 @@ class ESIndex(StrEnum):
PROJECTS_CORDIS_EU_H2020_TOPICS = "projects_cordiseu_h2020_openalex_topics"
PROJECTS_CORDIS_EU_HEUROPE_TOPICS = "projects_cordiseu_heurope_openalex_topics"
PATENTS_OPENALEX_KEYWORDS = "patents_openalex_keywords"
+5 -1
View File
@@ -7,7 +7,6 @@ class Tags(StrEnum):
INSTITUTIONS = "Institutions"
TOPICS = "Topics"
WORKS = "Works"
WORKS_V2 = "Works V2"
NEWS = "News"
PROJECTS = "Projects"
AUTH = "Auth"
@@ -15,3 +14,8 @@ class Tags(StrEnum):
ORGANIZATION = "Organization"
UNIVERSITY_RANKINGS = "University Rankings"
DASHBOARD = "Dashboard"
AUTHORS_V2 = "Authors V2"
INSTITUTIONS_V2 = "Institutions V2"
TOPICS_V2 = "Topics V2"
WORKS_V2 = "Works V2"
+6
View File
@@ -0,0 +1,6 @@
from inse.model import Page
from inse.models.openalex.topic import Topic
class TopicPageV2(Page[Topic]):
pass
+47
View File
@@ -0,0 +1,47 @@
import logging
from typing import Annotated
from fastapi import APIRouter, Query
from inse.tags import Tags
import inse.topics.v2.service as topics_service
from inse.topics.v2.model import TopicPageV2
TOPICS_V2_PREFIX = "/api/v2/topics"
logger = logging.getLogger(__name__)
router = APIRouter(prefix=TOPICS_V2_PREFIX, tags=[Tags.TOPICS_V2])
@router.get(
"/topics/id",
operation_id="getTopicsByIds",
summary="Returns a paginated list of topics for a given list of topic IDs.",
)
async def get_topics_by_ids(
topic_ids: Annotated[
list[str],
Query(description="A list of topic IDs to retrieve."),
] = [],
) -> TopicPageV2:
return await topics_service.get_topics_by_ids(topic_ids=topic_ids or [])
@router.get(
"/autocomplete/selector",
operation_id="autocompleteTopicsForSelector",
summary="Returns a paginated list of topics for a given search term based on their display name.",
)
async def autocomplete_topics_for_selector(
query: Annotated[
str,
Query(
description="A search term to filter topics by (partial matches allowed)."
),
] = "",
) -> TopicPageV2:
return await topics_service.autocomplete_topics_for_selector(query=query)
@@ -0,0 +1,95 @@
from typing import Dict, List, Optional
from inse.integrations import elasticsearch
from inse.model import ESIndex
from inse.models.openalex.topic import Topic
from inse.topics.v2.model import TopicPageV2
async def search_topics(
page: int = 0,
size: int = 10,
query: Optional[Dict] = None,
source: Optional[List[str]] = None,
sort: Optional[List[Dict]] = None,
body: Optional[Dict] = None,
) -> TopicPageV2:
"""Searches for topics based on the provided criteria.
Args:
page (int, optional): The page number to retrieve. Defaults to 0.
size (int, optional): The number of topics to retrieve per page. Defaults to 10.
query (Optional[Dict], optional): The search query. Defaults to None.
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
sort (Optional[List[Dict]], optional): A list of sort criteria. Defaults to None.
body (Optional[Dict], optional): The request body for the search query. Defaults to None.
Returns:
TopicPageV2: A page of topics matching the search criteria.
"""
response = await elasticsearch.search(
ESIndex.OPENALEX_TOPICS,
query=query,
source=source,
size=size,
offset=size * page,
sort=sort,
body=body,
)
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
topics: List[Topic] = []
for hit in hits:
_source = hit.get("_source", {})
topics.append(Topic.from_dict(_source)) # type: ignore
return TopicPageV2(elements=topics, total=len(topics), page=page, size=size)
async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
"""Autocompletes topics based on a search term for use in a selector component.
Args:
query (str): The search term to filter topics by (partial matches allowed).
Returns:
TopicPageV2: A page of topics matching the autocomplete criteria.
"""
return await search_topics(
page=0,
size=10,
query={"match_phrase_prefix": {"display_name": query}},
source=[
"id",
"display_name",
"subfield",
"field",
"domain",
],
)
async def get_topics_by_ids(topic_ids: List[str]) -> TopicPageV2:
"""Retrieves topics based on a list of topic IDs.
Args:
topic_ids (List[str]): A list of topic IDs to retrieve.
Returns:
TopicPageV2: A page of topics matching the provided IDs.
"""
if not topic_ids:
return TopicPageV2(elements=[], total=0, page=0, size=0)
return await search_topics(
page=0,
size=len(topic_ids),
query={"terms": {"id": topic_ids}},
source=[
"id",
"display_name",
"subfield",
"field",
"domain",
],
)
+1 -1
View File
@@ -17,7 +17,7 @@ class WorkSortBy(StrEnum):
CITED_BY_COUNT = "cited_by_count"
class WorkPage(Page[Work]):
class WorkPageV2(Page[Work]):
pass
+4 -110
View File
@@ -1,5 +1,5 @@
import logging
from typing import Annotated, List
from typing import Annotated
from fastapi import APIRouter, Path, Query
@@ -9,13 +9,9 @@ from inse.works.v2.model import (
WorkClassification,
WorkClassificationMergePage,
WorkClassificationPage,
WorkPage,
WorkPageV2,
WorkSortBy,
)
from inse.models.openalex.work_topic import WorkTopic
from inse.models.openalex.institution import Institution
from inse.models.openalex.author import Author
from inse.models.openalex.topic import Topic
from inse.auth.model import AccessTokenMetadata
from inse.auth.service import CurrentUserAccessTokenPayloadDep
@@ -70,7 +66,7 @@ async def get_author_works(
sort_order: Annotated[
SortDirection, Query(description="The order to sort by.")
] = SortDirection.DESCENDING,
) -> WorkPage:
) -> WorkPageV2:
from inse.works.v2.service import get_author_works
return await get_author_works(
@@ -133,7 +129,7 @@ async def get_institution_works(
sort_order: Annotated[
SortDirection, Query(description="The order to sort by.")
] = SortDirection.DESCENDING,
) -> WorkPage:
) -> WorkPageV2:
from inse.works.v2.service import get_institution_works
return await get_institution_works(
@@ -151,108 +147,6 @@ async def get_institution_works(
)
@router.get(
"/topics/search",
operation_id="getWorkTopicsByIds",
summary="Returns a list of work topics based on their IDs.",
)
async def get_work_topics_by_ids(
topic_ids: Annotated[
list[str],
Query(description="A list of topic IDs to retrieve."),
] = [],
) -> List[WorkTopic]:
from inse.works.v2.service import get_work_topics_by_ids
return await get_work_topics_by_ids(topic_ids=topic_ids or [])
@router.get(
"/institutions/search",
operation_id="getInstitutionsByIds",
summary="Returns a list of institutions based on their IDs.",
)
async def get_institutions_by_ids(
institution_ids: Annotated[
list[str],
Query(description="A list of institution IDs to retrieve."),
] = [],
) -> List[Institution]:
from inse.works.v2.service import get_work_institutions_by_ids
return await get_work_institutions_by_ids(institution_ids=institution_ids or [])
@router.get(
"/authors/search",
operation_id="getAuthorsByIds",
summary="Returns a list of authors based on their IDs.",
)
async def get_authors_by_ids(
author_ids: Annotated[
list[str],
Query(description="A list of author IDs to retrieve."),
] = [],
) -> List[Author]:
from inse.works.v2.service import get_work_authors_by_ids
return await get_work_authors_by_ids(author_ids=author_ids or [])
@router.get(
"/topics/autocomplete",
operation_id="getTopicAutocomplete",
summary="Returns a list of work topics based on a search term for autocomplete functionality.",
)
async def get_topic_autocomplete(
query: Annotated[
str,
Query(
description="A search term to filter topics by (partial matches allowed)."
),
] = "",
) -> List[Topic]:
from inse.works.v2.service import search_topics
return await search_topics(query=query)
@router.get(
"/institutions/autocomplete",
operation_id="getInstitutionAutocomplete",
summary="Returns a list of institutions based on a search term for autocomplete functionality.",
)
async def get_institution_autocomplete(
query: Annotated[
str,
Query(
description="A search term to filter institutions by (partial matches allowed)."
),
] = "",
) -> List[Institution]:
from inse.works.v2.service import search_institutions
return await search_institutions(query=query)
@router.get(
"/authors/autocomplete",
operation_id="getAuthorAutocomplete",
summary="Returns a list of authors based on a search term for autocomplete functionality.",
)
async def get_author_autocomplete(
query: Annotated[
str,
Query(
description="A search term to filter authors by (partial matches allowed)."
),
] = "",
) -> List[Author]:
from inse.works.v2.service import search_authors
return await search_authors(query=query)
@router.get(
"/classification/author/{raw_oa_author_id}",
operation_id="getWorkClassificationsByAuthorId",
+266 -223
View File
@@ -8,21 +8,25 @@ from inse.works.v2.model import (
WorkClassificationPage,
WorkClassificationMerge,
WorkClassificationMergePage,
WorkPage,
WorkPageV2,
WorkSortBy,
)
from inse.models.openalex.work_topic import WorkTopic
from inse.models.openalex.institution import Institution
from inse.models.openalex.work import Work
from inse.models.openalex.author import Author
from inse.models.openalex.topic import Topic
from inse.auth.model import AccessTokenMetadata
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
def _authors_nested_query(author_ids: List[str]) -> dict:
def _authors_nested_query(author_ids: List[str]) -> Dict:
"""Returns a nested query for filtering works by a list of author IDs.
Args:
author_ids (List[str]): A list of author IDs to filter by.
Returns:
Dict: A nested query for filtering works by the specified author IDs.
"""
prefixed = [_prefix_id(aid) for aid in author_ids]
return {
"nested": {
@@ -32,7 +36,15 @@ def _authors_nested_query(author_ids: List[str]) -> dict:
}
def _institutions_nested_query(institution_ids: List[str]) -> dict:
def _institutions_nested_query(institution_ids: List[str]) -> Dict:
"""Returns a nested query for filtering works by a list of institution IDs.
Args:
institution_ids (List[str]): A list of institution IDs to filter by.
Returns:
Dict: A nested query for filtering works by the specified institution IDs.
"""
prefixed = [_prefix_id(iid) for iid in institution_ids]
return {
"nested": {
@@ -47,7 +59,15 @@ def _institutions_nested_query(institution_ids: List[str]) -> dict:
}
def _title_query(title: str) -> dict:
def _title_query(title: str) -> Dict:
"""Returns a query for filtering works by title using a multi-match query.
Args:
title (str): The title to filter works by.
Returns:
Dict: A multi-match query for filtering works by the specified title.
"""
return {
"multi_match": {
"query": title,
@@ -62,13 +82,23 @@ def _title_query(title: str) -> dict:
def _apply_common_filters(
must: list,
must: List,
publication_years: Optional[List[int]],
publication_types: Optional[List[str]],
language_codes: Optional[List[str]],
topic_ids: Optional[List[str]],
title: Optional[str] = None,
) -> None:
"""Applies common filters to the provided list of must conditions for filtering works.
Args:
must (list): A list of must conditions to which the common filters will be appended.
publication_years (Optional[List[int]]): A list of publication years to filter by.
publication_types (Optional[List[str]]): A list of publication types to filter by.
language_codes (Optional[List[str]]): A list of language codes to filter by.
topic_ids (Optional[List[str]]): A list of topic IDs to filter by.
title (Optional[str], optional): The title to filter works by. Defaults to None.
"""
if publication_years:
must.append({"terms": {"publication_year": publication_years}})
if publication_types:
@@ -83,17 +113,41 @@ def _apply_common_filters(
must.append(_title_query(title))
def _build_sort(sort_by: WorkSortBy, sort_order: SortDirection) -> list:
def _build_sort(sort_by: WorkSortBy, sort_order: SortDirection) -> List[Dict]:
"""Builds a sort criteria list for sorting works based on the specified sort_by and sort_order.
Args:
sort_by (WorkSortBy): The field to sort by.
sort_order (SortDirection): The direction to sort in.
Returns:
List[Dict]: A list of sort criteria.
"""
if sort_by == WorkSortBy.TITLE:
return [{"title.keyword": sort_order.value}]
return [{sort_by.value: sort_order.value}]
async def _execute_works_search(
must: list, page: int, size: int, sort_by: WorkSortBy, sort_order: SortDirection
) -> WorkPage:
response = await elasticsearch.search(
ESIndex.OPENALEX_WORKS_WILDCARD,
must: List[Dict],
page: int,
size: int,
sort_by: WorkSortBy,
sort_order: SortDirection,
) -> WorkPageV2:
"""Executes a search for works based on the provided must conditions, pagination, and sorting criteria.
Args:
must (List[Dict]): A list of must conditions for filtering works.
page (int): The page number for pagination.
size (int): The number of results per page.
sort_by (WorkSortBy): The field to sort by.
sort_order (SortDirection): The direction to sort in.
Returns:
WorkPageV2: The page of works matching the search criteria.
"""
return await search_works(
source=[
"id",
"title",
@@ -108,21 +162,11 @@ async def _execute_works_search(
"topics",
],
query={"bool": {"must": must}},
page=page,
size=size,
offset=page * size,
sort=_build_sort(sort_by, sort_order),
)
hits_block = response.get("hits", {})
total = hits_block.get("total", {}).get("value", 0)
elements: List[Work] = []
for hit in hits_block.get("hits", []):
work = Work.from_dict(hit.get("_source", {})) # type: ignore
if work is not None:
elements.append(work)
return WorkPage(elements=elements, total=total, page=page, size=size)
async def get_works(
page: int,
@@ -138,7 +182,30 @@ async def get_works(
language_codes: Optional[List[str]] = None,
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
sort_order: SortDirection = SortDirection.DESCENDING,
) -> WorkPage:
) -> WorkPageV2:
"""Searches for works based on the provided criteria.
Args:
page (int): The page number for pagination.
size (int): The number of results per page.
raw_oa_author_id (Optional[str], optional): The ID of the author to filter by. Defaults to None.
raw_oa_institution_id (Optional[str], optional): The ID of the institution to filter by. Defaults to None.
title (Optional[str], optional): The title of the works to filter by. Defaults to None.
author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None.
institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None.
publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None.
publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None.
topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None.
language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None.
sort_by (WorkSortBy, optional): The field to sort by. Defaults to WorkSortBy.PUBLICATION_YEAR.
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
Raises:
ValueError: If neither raw_oa_author_id nor raw_oa_institution_id is provided.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
if not raw_oa_author_id and not raw_oa_institution_id:
raise ValueError(
"get_works requires at least one of raw_oa_author_id or raw_oa_institution_id"
@@ -175,7 +242,26 @@ async def get_author_works(
language_codes: Optional[List[str]] = None,
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
sort_order: SortDirection = SortDirection.DESCENDING,
) -> WorkPage:
) -> WorkPageV2:
"""Retrieves works for a specific author based on the provided criteria.
Args:
raw_oa_author_id (str): The ID of the author for whom to retrieve works.
page (int): The page number of the results to retrieve.
size (int): The number of results per page.
title (str, optional): The title of the works to filter by. Defaults to "".
publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None.
publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None.
institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None.
topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None.
language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None.
sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR.
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
return await get_works(
page=page,
size=size,
@@ -203,7 +289,26 @@ async def get_institution_works(
language_codes: Optional[List[str]] = None,
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
sort_order: SortDirection = SortDirection.DESCENDING,
) -> WorkPage:
) -> WorkPageV2:
"""Retrieves works for a specific institution based on the provided criteria.
Args:
raw_oa_institution_id (str): The ID of the institution for whom to retrieve works.
page (int): The page number of the results to retrieve.
size (int): The number of results per page.
title (str, optional): The title of the works to filter by. Defaults to "".
publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None.
publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None.
author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None.
topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None.
language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None.
sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR.
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
return await get_works(
page=page,
size=size,
@@ -219,189 +324,18 @@ async def get_institution_works(
)
async def get_work_topics_by_ids(topic_ids: List[str]) -> List[WorkTopic]:
logger.debug(f"Fetching work topics for IDs: {topic_ids}")
if not topic_ids:
return []
must = [{"terms": {"id": topic_ids}}]
response = await elasticsearch.search(
ESIndex.OPENALEX_TOPICS,
source=["id", "display_name", "field", "domain"],
query={"bool": {"must": must}},
size=len(topic_ids),
)
logger.debug(f"Elasticsearch response for work topics {topic_ids}: {response}")
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
topics: List[WorkTopic] = []
for hit in hits:
source = hit.get("_source", {})
logger.debug(f"Hit source for work topic {source.get('id', '')}: {source}")
topics.append(WorkTopic.from_dict(source)) # type: ignore
return topics
async def get_work_institutions_by_ids(institution_ids: List[str]) -> List[Institution]:
logger.debug(f"Fetching institutions for IDs: {institution_ids}")
if not institution_ids:
return []
must = [{"terms": {"id": institution_ids}}]
response = await elasticsearch.search(
ESIndex.OPENALEX_INSTITUTIONS,
source=[
"id",
"display_name",
"display_name_alternatives",
"country_code",
"type",
"ror",
],
query={"bool": {"must": must}},
size=len(institution_ids),
)
logger.debug(
f"Elasticsearch response for institutions {institution_ids}: {response}"
)
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
institutions: List[Institution] = []
for hit in hits:
source = hit.get("_source", {})
logger.debug(f"Hit source for institution {source.get('id', '')}: {source}")
institutions.append(Institution.from_dict(source)) # type: ignore
return institutions
async def get_work_authors_by_ids(author_ids: List[str]) -> List[Author]:
logger.debug(f"Fetching authors for IDs: {author_ids}")
if not author_ids:
return []
must = [{"terms": {"id": author_ids}}]
response = await elasticsearch.search(
ESIndex.OPENALEX_AUTHORS,
source=[
"id",
"display_name",
"orcid",
"last_known_institutions",
"works_count",
],
query={"bool": {"must": must}},
size=len(author_ids),
)
logger.debug(f"Elasticsearch response for authors {author_ids}: {response}")
hits_block = response.get("hits", {})
hits = hits_block.get("hits", [])
authors: List[Author] = []
for hit in hits:
source = hit.get("_source", {})
logger.debug(f"Hit source for author {source.get('id', '')}: {source}")
authors.append(Author.from_dict(source)) # type: ignore
return authors
async def search_topics(
query: str,
size: int = 10,
) -> List[Topic]:
response = await elasticsearch.search(
ESIndex.OPENALEX_TOPICS,
source=[
"id",
"display_name",
"subfield",
"field",
"domain",
],
query={"match_bool_prefix": {"display_name": query}},
size=min(size, 10),
)
hits_block = response.get("hits", {})
elements: List[Topic] = []
for hit in hits_block.get("hits", []):
topic = Topic.from_dict(hit.get("_source", {})) # type: ignore
if topic is not None:
elements.append(topic)
return elements
async def search_institutions(
query: str,
size: int = 10,
) -> List[Institution]:
response = await elasticsearch.search(
ESIndex.OPENALEX_INSTITUTIONS,
source=[
"id",
"display_name",
"display_name_alternatives",
"country_code",
"type",
"ror",
],
query={
"bool": {
"should": [
{"match_bool_prefix": {"display_name": query}},
{"match_bool_prefix": {"display_name_alternatives": query}},
],
"minimum_should_match": 1,
}
},
size=min(size, 10),
)
hits_block = response.get("hits", {})
elements: List[Institution] = []
for hit in hits_block.get("hits", []):
institution = Institution.from_dict(hit.get("_source", {})) # type: ignore
if institution is not None:
elements.append(institution)
return elements
async def search_authors(
query: str,
size: int = 10,
) -> List[Author]:
response = await elasticsearch.search(
ESIndex.OPENALEX_AUTHORS,
source=[
"id",
"display_name",
"orcid",
"last_known_institutions",
"works_count",
],
query={"match_phrase_prefix": {"display_name": query}},
size=min(size, 10),
)
hits_block = response.get("hits", {})
elements: List[Author] = []
for hit in hits_block.get("hits", []):
author = Author.from_dict(hit.get("_source", {})) # type: ignore
if author is not None:
elements.append(author)
return elements
async def get_work_classifications_by_author_id(
access_token_metadata: AccessTokenMetadata, raw_oa_author_id: str
) -> WorkClassificationMergePage:
"""Retrieves work classifications for a specific author, filtered by the effective institution ID from the access token metadata.
Args:
access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID.
raw_oa_author_id (str): The ID of the author for whom to retrieve work classifications.
Returns:
WorkClassificationMergePage: The page of work classifications matching the criteria.
"""
raw_account_institution_id = access_token_metadata.effective_institution_id
work_page = await _get_work_ids_with_publication_year_for_author_id(
@@ -467,19 +401,26 @@ async def get_work_classifications_by_author_id(
async def get_work(
raw_oa_work_id: str, source: Optional[List[str]] = None
) -> Work | None:
response = await elasticsearch.search(
ESIndex.OPENALEX_WORKS_WILDCARD,
"""Retrieves a work based on its OpenAlex ID.
Args:
raw_oa_work_id (str): The ID of the work to retrieve.
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
Returns:
Work | None: The retrieved work, or None if not found.
"""
work_page = await search_works(
query={"term": {"id": _prefix_id(raw_oa_work_id)}},
source=source,
page=0,
size=1,
)
if work_page.elements:
return work_page.elements[0]
hits = response.get("hits", {}).get("hits", [])
if not hits:
return None
work = Work.from_dict(hits[0].get("_source", {})) # type: ignore
logger.debug(f"Quux {work}")
return work
return None
async def search_works(
@@ -487,13 +428,27 @@ async def search_works(
source: Optional[List[str]] = None,
page: int = 0,
size: int = 10,
) -> WorkPage:
sort: Optional[List[Dict]] = None,
) -> WorkPageV2:
"""Searches for works based on the provided criteria.
Args:
query (Optional[Dict], optional): The search query. Defaults to None.
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
page (int, optional): The page number. Defaults to 0.
size (int, optional): The number of results per page. Defaults to 10.
sort (Optional[List[Dict]], optional): The sorting criteria. Defaults to None.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
response = await elasticsearch.search(
ESIndex.OPENALEX_WORKS_WILDCARD,
source=source,
query=query,
size=size,
offset=page * size,
sort=sort,
)
hits_block = response.get("hits", {})
@@ -504,12 +459,21 @@ async def search_works(
if work is not None:
works.append(work)
return WorkPage(elements=works, total=total, page=page, size=size)
return WorkPageV2(elements=works, total=total, page=page, size=size)
async def _get_work_ids_with_publication_year_for_author_id(
raw_oa_author_id: str,
) -> WorkPage:
) -> WorkPageV2:
"""Retrieves works for a specific author, including only those works that have a publication year and are associated with the specified author ID.
Args:
raw_oa_author_id (str): The ID of the author for which to retrieve works.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
return await search_works(
query={
"nested": {
@@ -526,9 +490,19 @@ async def _get_work_ids_with_publication_year_for_author_id(
async def _get_works_by_work_ids_and_institution_id(
work_ids: List[str], raw_oa_institution_id: str | None
) -> WorkPage:
) -> WorkPageV2:
"""Retrieves works based on a list of work IDs and filters them by the specified institution ID.
Args:
work_ids (List[str]): The list of work IDs to retrieve.
raw_oa_institution_id (str | None): The ID of the institution by which to filter the works.
Returns:
WorkPageV2: The page of works matching the criteria.
"""
if not work_ids or not raw_oa_institution_id:
return WorkPage(elements=[], total=0, page=0, size=0)
return WorkPageV2(elements=[], total=0, page=0, size=0)
prefixed_work_ids = [_prefix_id(wid) for wid in work_ids]
prefixed_institution_id = _prefix_id(raw_oa_institution_id)
@@ -566,6 +540,16 @@ async def _get_works_by_work_ids_and_institution_id(
def _work_has_authorship_with_institution_id(
work: Work, institution_id: str | None
) -> bool:
"""Checks if a work has at least one authorship associated with the specified institution ID.
Args:
work (Work): The work to check for authorships.
institution_id (str | None): The ID of the institution to check for.
Returns:
bool: True if the work has at least one authorship associated with the specified institution ID, False otherwise.
"""
if not institution_id:
return False
@@ -583,6 +567,17 @@ async def search_work_classifications(
page: int = 0,
size: int = 10,
) -> WorkClassificationPage:
"""Searches for work classifications based on the provided criteria.
Args:
query (Optional[Dict], optional): The search query. Defaults to None.
source (Optional[List[str]], optional): The fields to include in the response. Defaults to None.
page (int, optional): The page number. Defaults to 0.
size (int, optional): The number of results per page. Defaults to 10.
Returns:
WorkClassificationPage: The page of work classifications matching the criteria.
"""
response = await elasticsearch.search(
ESIndex.WORK_CLASSIFICATIONS,
source=source,
@@ -609,6 +604,17 @@ async def _get_work_classifications_by_work_ids(
page: int = 0,
size: int = 10000,
) -> WorkClassificationPage:
"""Retrieves work classifications based on a list of work IDs.
Args:
work_ids (List[str]): The list of work IDs to retrieve classifications for.
page (int, optional): The page number. Defaults to 0.
size (int, optional): The number of results per page. Defaults to 10000.
Returns:
WorkClassificationPage: The page of work classifications matching the criteria.
"""
work_ids = [_prefix_id(wid) for wid in work_ids]
return await search_work_classifications(
@@ -636,6 +642,17 @@ async def get_work_classifications_by_work_ids(
page: int = 0,
size: int = 10000,
) -> WorkClassificationPage:
"""Retrieves work classifications for a list of work IDs, filtered by the effective institution ID from the access token metadata.
Args:
access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID.
work_ids (List[str]): The list of work IDs to retrieve classifications for.
page (int, optional): The page number. Defaults to 0.
size (int, optional): The number of results per page. Defaults to 10000.
Returns:
WorkClassificationPage: The page of work classifications matching the criteria.
"""
raw_account_institution_id = access_token_metadata.effective_institution_id
work_page = await _get_works_by_work_ids_and_institution_id(
@@ -654,14 +671,22 @@ async def get_work_classifications_by_work_ids(
async def _get_work_classification_by_work_id(
raw_oa_work_id: str, source: Optional[List[str]] = None
) -> Optional[WorkClassification]:
"""Retrieves a work classification for a specific work ID.
Args:
raw_oa_work_id (str): The work ID for which to retrieve classification.
source (Optional[List[str]], optional): The fields to include in the response. Defaults to None.
Returns:
Optional[WorkClassification]: The work classification if found, otherwise None.
"""
response = await elasticsearch.get(
ESIndex.WORK_CLASSIFICATIONS,
doc_id=raw_oa_work_id,
source=source,
)
logger.debug(f"Baz {response}")
_source = response.get("_source")
if _source:
return WorkClassification.from_dict(_source)
@@ -673,6 +698,16 @@ async def get_work_classification_by_work_id(
access_token_metadata: AccessTokenMetadata,
raw_oa_work_id: str,
) -> Optional[WorkClassification]:
"""Retrieves a work classification for a specific work ID, filtered by the effective institution ID from the access token metadata.
Args:
access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID.
raw_oa_work_id (str): The work ID for which to retrieve classification.
Returns:
Optional[WorkClassification]: The work classification if found, otherwise None.
"""
raw_account_institution_id = access_token_metadata.effective_institution_id
if not raw_account_institution_id:
return None
@@ -698,6 +733,14 @@ async def get_work_classification_by_work_id(
def _prefix_id(raw_id: str) -> str:
"""Adds the OpenAlex prefix to an ID if it does not already have it.
Args:
raw_id (str): The ID to prefix.
Returns:
str: The ID with the OpenAlex prefix added if it was missing.
"""
if not raw_id.startswith("https://openalex.org/"):
return f"https://openalex.org/{raw_id}"
return raw_id
+8 -2
View File
@@ -5,12 +5,14 @@ api.base.service.ts
api.module.ts
api/api.ts
api/auth.service.ts
api/authorsV2.service.ts
api/bookmarks.service.ts
api/companyConnections.service.ts
api/dashboard.service.ts
api/funding.service.ts
api/iNSEService.service.ts
api/institutions.service.ts
api/institutionsV2.service.ts
api/keywords.service.ts
api/news.service.ts
api/organization.service.ts
@@ -19,6 +21,7 @@ api/personNetwork.service.ts
api/persons.service.ts
api/projects.service.ts
api/topics.service.ts
api/topicsV2.service.ts
api/universityRankings.service.ts
api/works.service.ts
api/worksV2.service.ts
@@ -36,6 +39,7 @@ model/authorAffiliationsInner.ts
model/authorCountsByYearInner.ts
model/authorIds.ts
model/authorNetworkNode.ts
model/authorPage.ts
model/authorParsedLongestName.ts
model/authorPositionCount.ts
model/authorSummaryStats.ts
@@ -126,9 +130,7 @@ model/hEUWebLink.ts
model/hTTPValidationError.ts
model/idTokenMetadata.ts
model/inseAccountManagementModelOrganizationProfile.ts
model/inseModelsOpenalexWorkPageWorkPage.ts
model/inseOrganizationManagementModelOrganizationProfile.ts
model/inseWorksV2ModelWorkPage.ts
model/institution.ts
model/institutionFunderSummary.ts
model/institutionGeo.ts
@@ -136,6 +138,7 @@ model/institutionIds.ts
model/institutionInformation.ts
model/institutionNetworkNode.ts
model/institutionPage.ts
model/institutionPageV2.ts
model/institutionsListResponse.ts
model/ipcClassification.ts
model/keywordEntry.ts
@@ -202,6 +205,7 @@ model/topicHeatmap.ts
model/topicHeatmapField.ts
model/topicHeatmapValue.ts
model/topicIds.ts
model/topicPageV2.ts
model/topicSubfield.ts
model/topicYearlyData.ts
model/topics.ts
@@ -240,6 +244,8 @@ model/workIds.ts
model/workKeyword.ts
model/workMeshInner.ts
model/workNetworkNode.ts
model/workPage.ts
model/workPageV2.ts
model/workPrimaryCategory.ts
model/workSortBy.ts
model/workSustainableDevelopmentGoalsInner.ts
+7 -1
View File
@@ -1,5 +1,7 @@
export * from './auth.service';
import { AuthService } from './auth.service';
export * from './authorsV2.service';
import { AuthorsV2Service } from './authorsV2.service';
export * from './bookmarks.service';
import { BookmarksService } from './bookmarks.service';
export * from './companyConnections.service';
@@ -12,6 +14,8 @@ export * from './iNSEService.service';
import { INSEServiceService } from './iNSEService.service';
export * from './institutions.service';
import { InstitutionsService } from './institutions.service';
export * from './institutionsV2.service';
import { InstitutionsV2Service } from './institutionsV2.service';
export * from './keywords.service';
import { KeywordsService } from './keywords.service';
export * from './news.service';
@@ -28,10 +32,12 @@ export * from './projects.service';
import { ProjectsService } from './projects.service';
export * from './topics.service';
import { TopicsService } from './topics.service';
export * from './topicsV2.service';
import { TopicsV2Service } from './topicsV2.service';
export * from './universityRankings.service';
import { UniversityRankingsService } from './universityRankings.service';
export * from './works.service';
import { WorksService } from './works.service';
export * from './worksV2.service';
import { WorksV2Service } from './worksV2.service';
export const APIS = [AuthService, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, UniversityRankingsService, WorksService, WorksV2Service];
export const APIS = [AuthService, AuthorsV2Service, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, InstitutionsV2Service, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, TopicsV2Service, UniversityRankingsService, WorksService, WorksV2Service];
+158
View File
@@ -0,0 +1,158 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { AuthorPage } from '../model/authorPage';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root'
})
export class AuthorsV2Service extends BaseService {
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
super(basePath, configuration);
}
/**
* Returns a paginated list of authors for a given search term based on their display name.
* @endpoint get /api/v2/authors/autocomplete/selector
* @param query A search term to filter authors by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public autocompleteAuthorsForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<AuthorPage>;
public autocompleteAuthorsForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<AuthorPage>>;
public autocompleteAuthorsForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<AuthorPage>>;
public autocompleteAuthorsForSelector(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/authors/autocomplete/selector`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<AuthorPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a paginated list of authors for a given list of author IDs.
* @endpoint get /api/v2/authors/authors/id
* @param authorIds A list of author IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<AuthorPage>;
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<AuthorPage>>;
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<AuthorPage>>;
public getAuthorsByIds(authorIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (authorIds) {
authorIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'author_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/authors/authors/id`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<AuthorPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
@@ -0,0 +1,158 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { InstitutionPageV2 } from '../model/institutionPageV2';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root'
})
export class InstitutionsV2Service extends BaseService {
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
super(basePath, configuration);
}
/**
* Returns a list of institutions based on a search term for autocomplete functionality.
* @endpoint get /api/v2/institutions/autocomplete/selector
* @param query A search term to filter institutions by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInstitutionAutocompleteForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InstitutionPageV2>;
public getInstitutionAutocompleteForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InstitutionPageV2>>;
public getInstitutionAutocompleteForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InstitutionPageV2>>;
public getInstitutionAutocompleteForSelector(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/institutions/autocomplete/selector`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<InstitutionPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a list of institutions based on their IDs.
* @endpoint get /api/v2/institutions/ids
* @param institutionIds A list of institution IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InstitutionPageV2>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InstitutionPageV2>>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InstitutionPageV2>>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (institutionIds) {
institutionIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'institution_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/institutions/ids`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<InstitutionPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
+158
View File
@@ -0,0 +1,158 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { TopicPageV2 } from '../model/topicPageV2';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root'
})
export class TopicsV2Service extends BaseService {
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
super(basePath, configuration);
}
/**
* Returns a paginated list of topics for a given search term based on their display name.
* @endpoint get /api/v2/topics/autocomplete/selector
* @param query A search term to filter topics by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public autocompleteTopicsForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TopicPageV2>;
public autocompleteTopicsForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TopicPageV2>>;
public autocompleteTopicsForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TopicPageV2>>;
public autocompleteTopicsForSelector(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/topics/autocomplete/selector`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<TopicPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a paginated list of topics for a given list of topic IDs.
* @endpoint get /api/v2/topics/topics/id
* @param topicIds A list of topic IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTopicsByIds(topicIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TopicPageV2>;
public getTopicsByIds(topicIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TopicPageV2>>;
public getTopicsByIds(topicIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TopicPageV2>>;
public getTopicsByIds(topicIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (topicIds) {
topicIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'topic_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/topics/topics/id`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<TopicPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
+6 -6
View File
@@ -19,14 +19,14 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { InseModelsOpenalexWorkPageWorkPage } from '../model/inseModelsOpenalexWorkPageWorkPage';
// @ts-ignore
import { TopicCount } from '../model/topicCount';
// @ts-ignore
import { TopicsByTime } from '../model/topicsByTime';
// @ts-ignore
import { Work } from '../model/work';
// @ts-ignore
import { WorkPage } from '../model/workPage';
// @ts-ignore
import { WorksListResponse } from '../model/worksListResponse';
// @ts-ignore
@@ -115,9 +115,9 @@ export class WorksService extends BaseService {
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InseModelsOpenalexWorkPageWorkPage>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InseModelsOpenalexWorkPageWorkPage>>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InseModelsOpenalexWorkPageWorkPage>>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPage>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPage>>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPage>>;
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (authorId === null || authorId === undefined) {
throw new Error('Required parameter authorId was null or undefined when calling getAuthorWorks.');
@@ -188,7 +188,7 @@ export class WorksService extends BaseService {
let localVarPath = `/api/works/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<InseModelsOpenalexWorkPageWorkPage>('get', `${basePath}${localVarPath}`,
return this.httpClient.request<WorkPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
+10 -372
View File
@@ -16,28 +16,20 @@ import { HttpClient, HttpHeaders, HttpParams,
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { Author } from '../model/author';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { InseWorksV2ModelWorkPage } from '../model/inseWorksV2ModelWorkPage';
// @ts-ignore
import { Institution } from '../model/institution';
// @ts-ignore
import { SortDirection } from '../model/sortDirection';
// @ts-ignore
import { Topic } from '../model/topic';
// @ts-ignore
import { WorkClassification } from '../model/workClassification';
// @ts-ignore
import { WorkClassificationMergePage } from '../model/workClassificationMergePage';
// @ts-ignore
import { WorkClassificationPage } from '../model/workClassificationPage';
// @ts-ignore
import { WorkSortBy } from '../model/workSortBy';
import { WorkPageV2 } from '../model/workPageV2';
// @ts-ignore
import { WorkTopic } from '../model/workTopic';
import { WorkSortBy } from '../model/workSortBy';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -55,63 +47,6 @@ export class WorksV2Service extends BaseService {
super(basePath, configuration);
}
/**
* Returns a list of authors based on a search term for autocomplete functionality.
* @endpoint get /api/v2/works/authors/autocomplete
* @param query A search term to filter authors by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAuthorAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<Author>>;
public getAuthorAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<Author>>>;
public getAuthorAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<Author>>>;
public getAuthorAutocomplete(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/authors/autocomplete`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<Author>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a paginated list of works for a given author based on their ID.
* @endpoint get /api/v2/works/author/{raw_oa_author_id}
@@ -129,9 +64,9 @@ export class WorksV2Service extends BaseService {
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InseWorksV2ModelWorkPage>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InseWorksV2ModelWorkPage>>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InseWorksV2ModelWorkPage>>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPageV2>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPageV2>>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPageV2>>;
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPage.');
@@ -206,125 +141,7 @@ export class WorksV2Service extends BaseService {
let localVarPath = `/api/v2/works/author/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<InseWorksV2ModelWorkPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a list of authors based on their IDs.
* @endpoint get /api/v2/works/authors/search
* @param authorIds A list of author IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<Author>>;
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<Author>>>;
public getAuthorsByIds(authorIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<Author>>>;
public getAuthorsByIds(authorIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (authorIds) {
authorIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'author_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/authors/search`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<Author>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a list of institutions based on a search term for autocomplete functionality.
* @endpoint get /api/v2/works/institutions/autocomplete
* @param query A search term to filter institutions by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInstitutionAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<Institution>>;
public getInstitutionAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<Institution>>>;
public getInstitutionAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<Institution>>>;
public getInstitutionAutocomplete(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/institutions/autocomplete`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<Institution>>('get', `${basePath}${localVarPath}`,
return this.httpClient.request<WorkPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
@@ -355,9 +172,9 @@ export class WorksV2Service extends BaseService {
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InseWorksV2ModelWorkPage>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InseWorksV2ModelWorkPage>>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InseWorksV2ModelWorkPage>>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPageV2>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPageV2>>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPageV2>>;
public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (rawOaInstitutionId === null || rawOaInstitutionId === undefined) {
throw new Error('Required parameter rawOaInstitutionId was null or undefined when calling getInstitutionWorkPage.');
@@ -432,125 +249,7 @@ export class WorksV2Service extends BaseService {
let localVarPath = `/api/v2/works/institution/${this.configuration.encodeParam({name: "rawOaInstitutionId", value: rawOaInstitutionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<InseWorksV2ModelWorkPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a list of institutions based on their IDs.
* @endpoint get /api/v2/works/institutions/search
* @param institutionIds A list of institution IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<Institution>>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<Institution>>>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<Institution>>>;
public getInstitutionsByIds(institutionIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (institutionIds) {
institutionIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'institution_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/institutions/search`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<Institution>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns a list of work topics based on a search term for autocomplete functionality.
* @endpoint get /api/v2/works/topics/autocomplete
* @param query A search term to filter topics by (partial matches allowed).
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTopicAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<Topic>>;
public getTopicAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<Topic>>>;
public getTopicAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<Topic>>>;
public getTopicAutocomplete(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>query, 'query');
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/topics/autocomplete`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<Topic>>('get', `${basePath}${localVarPath}`,
return this.httpClient.request<WorkPageV2>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
@@ -753,65 +452,4 @@ export class WorksV2Service extends BaseService {
);
}
/**
* Returns a list of work topics based on their IDs.
* @endpoint get /api/v2/works/topics/search
* @param topicIds A list of topic IDs to retrieve.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getWorkTopicsByIds(topicIds?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<WorkTopic>>;
public getWorkTopicsByIds(topicIds?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<WorkTopic>>>;
public getWorkTopicsByIds(topicIds?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<WorkTopic>>>;
public getWorkTopicsByIds(topicIds?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (topicIds) {
topicIds.forEach((element) => {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>element, 'topic_ids');
})
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/v2/works/topics/search`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<WorkTopic>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
+31
View File
@@ -0,0 +1,31 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { Author } from './author';
export interface AuthorPage {
/**
* The elements of the page.
*/
elements?: Array<Author>;
/**
* The page number. (0-based)
*/
page?: number;
/**
* The page size in elements.
*/
size?: number;
/**
* The total number of elements.
*/
total?: number;
}
@@ -0,0 +1,31 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { Institution } from './institution';
export interface InstitutionPageV2 {
/**
* The elements of the page.
*/
elements?: Array<Institution>;
/**
* The page number. (0-based)
*/
page?: number;
/**
* The page size in elements.
*/
size?: number;
/**
* The total number of elements.
*/
total?: number;
}
+5 -2
View File
@@ -8,6 +8,7 @@ export * from './authorAffiliationsInner';
export * from './authorCountsByYearInner';
export * from './authorIds';
export * from './authorNetworkNode';
export * from './authorPage';
export * from './authorParsedLongestName';
export * from './authorPositionCount';
export * from './authorSummaryStats';
@@ -98,9 +99,7 @@ export * from './hEUWebLink';
export * from './hTTPValidationError';
export * from './idTokenMetadata';
export * from './inseAccountManagementModelOrganizationProfile';
export * from './inseModelsOpenalexWorkPageWorkPage';
export * from './inseOrganizationManagementModelOrganizationProfile';
export * from './inseWorksV2ModelWorkPage';
export * from './institution';
export * from './institutionFunderSummary';
export * from './institutionGeo';
@@ -108,6 +107,7 @@ export * from './institutionIds';
export * from './institutionInformation';
export * from './institutionNetworkNode';
export * from './institutionPage';
export * from './institutionPageV2';
export * from './institutionsListResponse';
export * from './ipcClassification';
export * from './keywordEntry';
@@ -173,6 +173,7 @@ export * from './topicHeatmap';
export * from './topicHeatmapField';
export * from './topicHeatmapValue';
export * from './topicIds';
export * from './topicPageV2';
export * from './topicSubfield';
export * from './topicYearlyData';
export * from './topics';
@@ -211,6 +212,8 @@ export * from './workIds';
export * from './workKeyword';
export * from './workMeshInner';
export * from './workNetworkNode';
export * from './workPage';
export * from './workPageV2';
export * from './workPrimaryCategory';
export * from './workSortBy';
export * from './workSustainableDevelopmentGoalsInner';
+31
View File
@@ -0,0 +1,31 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { Topic } from './topic';
export interface TopicPageV2 {
/**
* The elements of the page.
*/
elements?: Array<Topic>;
/**
* The page number. (0-based)
*/
page?: number;
/**
* The page size in elements.
*/
size?: number;
/**
* The total number of elements.
*/
total?: number;
}
@@ -10,7 +10,7 @@
import { Work } from './work';
export interface InseModelsOpenalexWorkPageWorkPage {
export interface WorkPage {
/**
* Total number of works matching the query
*/
@@ -10,7 +10,7 @@
import { Work } from './work';
export interface InseWorksV2ModelWorkPage {
export interface WorkPageV2 {
/**
* The elements of the page.
*/
+4 -4
View File
@@ -385,8 +385,8 @@ export const routes: Routes = [
),
runGuardsAndResolvers: 'always',
resolve: {
selectedTopics: selectedTopicsResolver,
selectedInstitutions: selectedInstitutionsResolver,
selectedTopicsPage: selectedTopicsResolver,
selectedInstitutionsPage: selectedInstitutionsResolver,
authorWorkPage: workPageResolver,
authorWorkClassificationMergePage: authorWorkClassificationPageResolver,
},
@@ -511,8 +511,8 @@ export const routes: Routes = [
(mod) => mod.InstitutionPublicationsComponent,
),
resolve: {
selectedAuthors: selectedAuthorsResolver,
selectedTopics: selectedTopicsResolver,
selectedAuthorsPage: selectedAuthorsResolver,
selectedTopicsPage: selectedTopicsResolver,
institutionWorkPage: workPageResolver,
},
data: {
@@ -1,7 +1,7 @@
<div class="content">
<app-publication-filter
[selectedAuthors]="selectedAuthors()"
[selectedTopics]="selectedTopics()"
[selectedAuthorsPage]="selectedAuthorsPage()"
[selectedTopicsPage]="selectedTopicsPage()"
[showInstitutionFilter]="false" />
<app-publication-table
@@ -1,6 +1,6 @@
import { Component, computed, input } from '@angular/core';
import { PublicationTableComponent } from '../../shared/ui/publication-table/publication-table.component';
import { Author, InseWorksV2ModelWorkPage, WorkTopic } from '../../api';
import { Author, AuthorPage, TopicPageV2, WorkPageV2, WorkTopic } from '../../api';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
@@ -15,9 +15,9 @@ import { PublicationFilterComponent } from '../../shared/ui/publication-filters/
styleUrl: './institution-publications.component.scss',
})
export class InstitutionPublicationsComponent {
institutionWorkPage = input.required<InseWorksV2ModelWorkPage>();
selectedAuthors = input.required<Array<Author>>();
selectedTopics = input.required<Array<WorkTopic>>();
institutionWorkPage = input.required<WorkPageV2>();
selectedAuthorsPage = input.required<AuthorPage>();
selectedTopicsPage = input.required<TopicPageV2>();
total = computed(() => this.institutionWorkPage().total ?? 0);
}
@@ -58,8 +58,8 @@
<div class="publication-list">
<app-publication-filter
[selectedTopics]="selectedTopics()"
[selectedInstitutions]="selectedInstitutions()"
[selectedTopicsPage]="selectedTopicsPage()"
[selectedInstitutionsPage]="selectedInstitutionsPage()"
[showAuthorFilter]="false" />
<app-publication-table
@@ -1,12 +1,14 @@
import { Component, computed, effect, input } from '@angular/core';
import {
InseWorksV2ModelWorkPage,
WorkPageV2,
Author,
WorkTopic,
WorkPrimaryCategory,
WorkClassificationMerge,
WorkClassificationMergePage,
InstitutionPageV2,
TopicPageV2,
} from '../../api';
import { NgxEchartsDirective } from 'ngx-echarts';
import * as echarts from 'echarts/core';
@@ -60,12 +62,12 @@ interface YearlyPurposeCounts {
styleUrl: './person-publications.component.scss',
})
export class PersonPublicationsComponent {
authorWorkPage = input.required<InseWorksV2ModelWorkPage>();
authorWorkPage = input.required<WorkPageV2>();
total = computed(() => this.authorWorkPage().total ?? 0);
elements = computed(() => this.authorWorkPage().elements ?? []);
selectedInstitutions = input.required<Array<Author>>();
selectedTopics = input.required<Array<WorkTopic>>();
selectedInstitutionsPage = input.required<InstitutionPageV2>();
selectedTopicsPage = input.required<TopicPageV2>();
authorWorkClassificationMergePage =
input.required<WorkClassificationMergePage>();
@@ -1,8 +1,8 @@
import { ResolveFn } from '@angular/router';
import { Author, WorksV2Service } from '../api';
import { Author, AuthorPage, AuthorsV2Service, WorksV2Service } from '../api';
import { inject } from '@angular/core';
export const selectedAuthorsResolver: ResolveFn<Array<Author>> = (
export const selectedAuthorsResolver: ResolveFn<AuthorPage> = (
route,
state,
) => {
@@ -11,10 +11,10 @@ export const selectedAuthorsResolver: ResolveFn<Array<Author>> = (
const authorIds = route.queryParamMap.getAll(authorIdQueryParamKey);
if (authorIds.length === 0) {
return [];
return { elements: [] };
}
return inject(WorksV2Service).getAuthorsByIds(
return inject(AuthorsV2Service).getAuthorsByIds(
authorIds.map((id) => id.trim()).filter((id) => id.length > 0),
);
};
@@ -1,8 +1,8 @@
import { inject } from '@angular/core';
import { ResolveFn } from '@angular/router';
import { Institution, WorksV2Service } from '../api';
import { InstitutionPageV2, InstitutionsV2Service } from '../api';
export const selectedInstitutionsResolver: ResolveFn<Array<Institution>> = (
export const selectedInstitutionsResolver: ResolveFn<InstitutionPageV2> = (
route,
state,
) => {
@@ -10,11 +10,8 @@ export const selectedInstitutionsResolver: ResolveFn<Array<Institution>> = (
(route.data['institutionIdQueryParamKey'] as string) || 'institutionId';
const institutionIds = route.queryParamMap.getAll(institutionIdQueryParamKey);
if (institutionIds.length === 0) {
return [];
}
return inject(WorksV2Service).getInstitutionsByIds(
return inject(InstitutionsV2Service).getInstitutionsByIds(
institutionIds.map((id) => id.trim()).filter((id) => id.length > 0),
);
};
@@ -1,20 +1,14 @@
import { inject } from '@angular/core';
import { ResolveFn } from '@angular/router';
import { WorksV2Service, WorkTopic } from '../api';
import { TopicPageV2, TopicsV2Service } from '../api';
export const selectedTopicsResolver: ResolveFn<Array<WorkTopic>> = (
route,
state,
) => {
export const selectedTopicsResolver: ResolveFn<TopicPageV2> = (route, state) => {
const topicIdQueryParamKey =
(route.data['topicIdQueryParamKey'] as string) || 'topicId';
const topicIds = route.queryParamMap.getAll(topicIdQueryParamKey);
if (topicIds.length === 0) {
return [];
}
return inject(WorksV2Service).getWorkTopicsByIds(
return inject(TopicsV2Service).getTopicsByIds(
topicIds.map((id) => id.trim()).filter((id) => id.length > 0),
);
};
@@ -4,7 +4,7 @@ import {
RouterStateSnapshot,
} from '@angular/router';
import {
InseWorksV2ModelWorkPage,
WorkPageV2,
SortDirection,
WorkSortBy,
WorksV2Service,
@@ -31,7 +31,7 @@ export const workQueryParamKeys = {
sortDirection: 'sort_direction',
} as const;
export const workPageResolver: ResolveFn<InseWorksV2ModelWorkPage> = (
export const workPageResolver: ResolveFn<WorkPageV2> = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
) => {
@@ -1,8 +1,15 @@
import { Component, computed, input } from '@angular/core';
import { SearchableTopicSelectComponent } from '../searchable-topic-select/searchable-topic-select.component';
import { SearchableYearSelectComponent } from '../searchable-year-select/searchable-year-select.component';
import { Author, Institution, Topic } from '../../../api';
import { ActivatedRoute, Router } from '@angular/router';
import {
Author,
AuthorPage,
Institution,
InstitutionPageV2,
Topic,
TopicPageV2,
} from '../../../api';
import { Router } from '@angular/router';
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
import { toSignal } from '@angular/core/rxjs-interop';
import { SearchableInstitutionSelectComponent } from '../searchable-institution-select/searchable-institution-select.component';
@@ -47,9 +54,18 @@ import { MatIconModule } from '@angular/material/icon';
export class PublicationFilterComponent {
constructor(private readonly router: Router) {}
selectedAuthors = input<Author[]>([]);
selectedTopics = input<Topic[]>([]);
selectedInstitutions = input<Institution[]>([]);
selectedAuthorsPage = input<AuthorPage>();
selectedAuthors = computed<Author[]>(
() => this.selectedAuthorsPage()?.elements || [],
);
selectedTopicsPage = input<TopicPageV2>();
selectedTopics = computed<Topic[]>(
() => this.selectedTopicsPage()?.elements || [],
);
selectedInstitutionsPage = input<InstitutionPageV2>();
selectedInstitutions = computed<Institution[]>(
() => this.selectedInstitutionsPage()?.elements || [],
);
showTitleFilter = input<boolean>(true);
showYearFilter = input<boolean>(true);
@@ -96,6 +112,17 @@ export class PublicationFilterComponent {
return author ? author.display_name : value;
},
},
{
id: 'institutions',
queryParamKey: workQueryParamKeys.institutionId,
icon: 'business',
valueFormatter: (value: string) => {
const institution = this.selectedInstitutions().find(
(i) => i.id === value,
);
return institution ? institution.display_name : value;
},
},
{
id: 'topics',
queryParamKey: workQueryParamKeys.topicId,
@@ -15,7 +15,7 @@ import {
} from '../data-table/data-table.component';
import {
DehydratedAuthor,
InseWorksV2ModelWorkPage,
WorkPageV2,
Institution,
Work,
WorkClassification,
@@ -53,7 +53,7 @@ import { WorkPrimaryCategoryPipe } from '../../pipes/work-primary-category.pipe'
styleUrl: './publication-table.component.scss',
})
export class PublicationTableComponent implements OnInit {
page = input.required<InseWorksV2ModelWorkPage>();
page = input.required<WorkPageV2>();
authorFilterEnabled = input<boolean>(false);
institutionFilterEnabled = input<boolean>(false);
@@ -1,5 +1,5 @@
import { Component, inject, input, output } from '@angular/core';
import { Author, WorksV2Service } from '../../../api';
import { Author, AuthorPage, AuthorsV2Service } from '../../../api';
import { Observable } from 'rxjs';
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
@@ -10,15 +10,15 @@ import { SearchableSelectComponent } from '../searchable-select/searchable-selec
styleUrl: './searchable-author-select.component.scss',
})
export class SearchableAuthorSelectComponent {
private readonly worksV2Service = inject(WorksV2Service);
private readonly authorsV2Service = inject(AuthorsV2Service);
label = input<string>('Authoren');
selectedAuthors = input.required<Author[]>();
handleAuthorSelectChange = output<Author>();
fetchAuthors = (searchTerm: string): Observable<Author[]> => {
return this.worksV2Service.getAuthorAutocomplete(searchTerm);
fetchAuthors = (searchTerm: string): Observable<AuthorPage> => {
return this.authorsV2Service.autocompleteAuthorsForSelector(searchTerm);
};
getAuthorLabel = (author: Author): string => {
@@ -1,5 +1,5 @@
import { Component, inject, input, output } from '@angular/core';
import { Institution, WorksV2Service } from '../../../api';
import { Institution, InstitutionsV2Service, TopicPageV2 } from '../../../api';
import { Observable } from 'rxjs';
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
@@ -10,15 +10,17 @@ import { SearchableSelectComponent } from '../searchable-select/searchable-selec
styleUrl: './searchable-institution-select.component.scss',
})
export class SearchableInstitutionSelectComponent {
private readonly worksV2Service = inject(WorksV2Service);
private readonly institutionsV2Service = inject(InstitutionsV2Service);
label = input<string>('Institutionen');
selectedInstitutions = input.required<Institution[]>();
handleInstitutionSelectChange = output<Institution>();
fetchInstitutions = (searchTerm: string): Observable<Institution[]> => {
return this.worksV2Service.getInstitutionAutocomplete(searchTerm);
fetchInstitutions = (searchTerm: string): Observable<TopicPageV2> => {
return this.institutionsV2Service.getInstitutionAutocompleteForSelector(
searchTerm,
);
};
getInstitutionLabel = (institution: Institution): string => {
@@ -24,6 +24,12 @@ export const findLanguageById = (id: string): Language | undefined => {
return languages.find((language) => language.code === id);
};
type LanguagePage = {
elements?: Language[];
page?: number;
size?: number;
total?: number;
};
@Component({
selector: 'app-searchable-language-select',
imports: [SearchableSelectComponent],
@@ -36,13 +42,13 @@ export class SearchableLanguageSelectComponent {
handleLanguageSelectChange = output<Language>();
fetchLanguages = (searchTerm: string): Observable<Language[]> => {
return new Observable<Language[]>((observer) => {
observer.next(
languages.filter((language) =>
fetchLanguages = (searchTerm: string): Observable<LanguagePage> => {
return new Observable<LanguagePage>((observer) => {
observer.next({
elements: languages.filter((language) =>
language.name.toLowerCase().includes(searchTerm.toLowerCase()),
),
);
});
observer.complete();
});
};
@@ -52,7 +52,7 @@
</mat-optgroup>
}
<mat-optgroup [label]="fetchedLabel()">
@for (element of fetchedElements(); track getSelectValue()(element)) {
@for (element of fetchedElements().elements; track getSelectValue()(element)) {
<mat-option [value]="element">
{{ getSelectLabel()(element) }}
@if (getSelectDescription()) {
@@ -24,6 +24,13 @@ import {
} from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
type Page<T> = {
elements?: T[];
page?: number;
size?: number;
total?: number;
};
@Component({
selector: 'app-searchable-select',
imports: [
@@ -43,7 +50,7 @@ export class SearchableSelectComponent<T> {
_elements = computed<T[]>(() => {
const predefined = this.selectedElements();
const fetched = this.fetchedElements();
return [...predefined, ...fetched];
return [...predefined, ...fetched.elements!];
});
isLoading = signal<boolean>(false);
@@ -51,8 +58,8 @@ export class SearchableSelectComponent<T> {
label = input.required<string>();
selectedLabel = input<string>('Ausgewählt');
fetchedLabel = input<string>('Verfügbar');
fetchElements = input<(searchTerm: string) => Observable<T[]>>();
fetchedElements = signal<T[]>([]);
fetchElements = input<(searchTerm: string) => Observable<Page<T>>>();
fetchedElements = signal<Page<T>>({ elements: [] });
selectedElements = input<T[]>([]);
getSelectLabel = input.required<(element: T) => string>();
getSelectValue = input.required<(element: T) => string>();
@@ -72,9 +79,9 @@ export class SearchableSelectComponent<T> {
switchMap((term) => {
const fetchFn = this.fetchElements();
if (!fetchFn) {
return of([] as T[]);
return of({ elements: [] } as Page<T>);
}
return fetchFn(term).pipe(catchError(() => of([] as T[])));
return fetchFn(term).pipe(catchError(() => of({ elements: [] } as Page<T>)));
}),
tap(() => this.isLoading.set(false)),
takeUntilDestroyed(this.destroyRef),
@@ -89,6 +96,6 @@ export class SearchableSelectComponent<T> {
_clearSearchValue(): void {
this.searchValue = '';
this.fetchedElements.set([]);
this.fetchedElements.set({ elements: [] });
}
}
@@ -1,6 +1,6 @@
import { Component, inject, input, output } from '@angular/core';
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
import { Topic, WorksV2Service } from '../../../api';
import { Topic, TopicPageV2, TopicsV2Service } from '../../../api';
import { Observable } from 'rxjs';
@Component({
@@ -10,15 +10,15 @@ import { Observable } from 'rxjs';
styleUrl: './searchable-topic-select.component.scss',
})
export class SearchableTopicSelectComponent {
private readonly worksV2Service = inject(WorksV2Service);
private readonly topicsV2Service = inject(TopicsV2Service);
label = input<string>('Themen');
selectedTopics = input.required<Topic[]>();
handleTopicSelectChange = output<Topic>();
fetchTopics = (searchTerm: string): Observable<Topic[]> => {
return this.worksV2Service.getTopicAutocomplete(searchTerm);
fetchTopics = (searchTerm: string): Observable<TopicPageV2> => {
return this.topicsV2Service.autocompleteTopicsForSelector(searchTerm);
};
getTopicLabel = (topic: Topic): string => {
@@ -33,6 +33,13 @@ export const findWorkTypeById = (id: string): WorkType | undefined => {
return workTypes.find((workType) => workType.id === id);
};
type WorkTypePage = {
elements?: WorkType[];
page?: number;
size?: number;
total?: number;
};
@Component({
selector: 'app-searchable-work-type-select',
imports: [SearchableSelectComponent],
@@ -45,13 +52,13 @@ export class SearchableWorkTypeSelectComponent {
handleWorkTypeSelectChange = output<WorkType>();
fetchWorkTypes = (searchTerm: string): Observable<WorkType[]> => {
return new Observable<WorkType[]>((observer) => {
observer.next(
workTypes.filter((workType) =>
fetchWorkTypes = (searchTerm: string): Observable<WorkTypePage> => {
return new Observable<WorkTypePage>((observer) => {
observer.next({
elements: workTypes.filter((workType) =>
workType.name.toLowerCase().includes(searchTerm.toLowerCase()),
),
);
});
observer.complete();
});
};
@@ -2,6 +2,13 @@ import { Component, input, output } from '@angular/core';
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
import { Observable } from 'rxjs';
type YearPage = {
elements?: number[];
page?: number;
size?: number;
total?: number;
};
@Component({
selector: 'app-searchable-year-select',
imports: [SearchableSelectComponent],
@@ -16,16 +23,16 @@ export class SearchableYearSelectComponent {
handleYearSelectChange = output<number>();
fetchYears = (searchTerm: string): Observable<number[]> => {
fetchYears = (searchTerm: string): Observable<YearPage> => {
const years: number[] = [];
for (let year = this.endYear(); year >= this.startYear(); year--) {
years.push(year);
}
return new Observable<number[]>((observer) => {
observer.next(
years.filter((year) => year.toString().includes(searchTerm)),
);
return new Observable<YearPage>((observer) => {
observer.next({
elements: years.filter((year) => year.toString().includes(searchTerm)),
});
observer.complete();
});
};