diff --git a/api/src/core/adapters/hal/HalAPI/getDomains.ts b/api/src/core/adapters/hal/HalAPI/getDomains.ts new file mode 100644 index 00000000..62771fb7 --- /dev/null +++ b/api/src/core/adapters/hal/HalAPI/getDomains.ts @@ -0,0 +1,48 @@ +import fetch from "node-fetch"; +import { HalAPIDomain, HalFetchError } from "./type"; + +export async function getAllDomains(): Promise { + // Get all domains + const url = "http://api.archives-ouvertes.fr/ref/domain/?fl=*"; + + const res = await fetch(url).catch(err => { + console.error(err); + throw new HalFetchError(undefined); + }); + + if (res.status === 429) { + await new Promise(resolve => setTimeout(resolve, 100)); + return getAllDomains(); + } + + if (res.status === 404) { + throw new HalFetchError(res.status); + } + + const json = await res.json(); + + return json.response.docs; +} + +export async function getDomainByCode(code: string): Promise { + // Get domain using code + const url = `http://api.archives-ouvertes.fr/ref/domain/?q=code_s:${code}&fl=*`; + + const res = await fetch(url).catch(err => { + console.error(err); + throw new HalFetchError(undefined); + }); + + if (res.status === 429) { + await new Promise(resolve => setTimeout(resolve, 100)); + return getDomainByCode(code); + } + + if (res.status === 404) { + throw new HalFetchError(res.status); + } + + const json = await res.json(); + + return json.response.docs[0]; +} diff --git a/api/src/core/adapters/hal/getHalSoftware.ts b/api/src/core/adapters/hal/HalAPI/getHalSoftware.ts similarity index 57% rename from api/src/core/adapters/hal/getHalSoftware.ts rename to api/src/core/adapters/hal/HalAPI/getHalSoftware.ts index 56192e12..189fd120 100644 --- a/api/src/core/adapters/hal/getHalSoftware.ts +++ b/api/src/core/adapters/hal/HalAPI/getHalSoftware.ts @@ -1,40 +1,9 @@ -import memoize from "memoizee"; import fetch from "node-fetch"; -import { SoftwareExternalData, GetSoftwareExternalData } from "../../ports/GetSoftwareExternalData"; -import { - HalRawSoftware, - halSoftwareFieldsToReturnAsString, - rawHalSoftwareToSoftwareExternalData -} from "./halRawSoftware"; +import { halSoftwareFieldsToReturnAsString } from "../halRawSoftware"; +import { HalFetchError, HalRawSoftware } from "./type"; // HAL documentation is here : https://api.archives-ouvertes.fr/docs/search -export const getHalSoftware: GetSoftwareExternalData = memoize( - async (halDocId): Promise => { - const halRawSoftware = await fetchHalSoftwareById(halDocId).catch(error => { - if (!(error instanceof HalFetchError)) throw error; - if (error.status === 404 || error.status === undefined) return; - throw error; - }); - - if (halRawSoftware === undefined) return; - if (halRawSoftware.docType_s !== "SOFTWARE") return; - - return rawHalSoftwareToSoftwareExternalData(halRawSoftware); - }, - { - "promise": true, - "maxAge": 3 * 3600 * 1000 - } -); - -export class HalFetchError extends Error { - constructor(public readonly status: number | undefined) { - super(`Hal fetch error status: ${status}`); - Object.setPrototypeOf(this, new.target.prototype); - } -} - export async function fetchHalSoftwareById(halDocid: string): Promise { const res = await fetch( `https://api.archives-ouvertes.fr/search/?q=docid:${halDocid}&wt=json&fl=${halSoftwareFieldsToReturnAsString}&sort=docid%20asc` diff --git a/api/src/core/adapters/hal/HalAPI/index.ts b/api/src/core/adapters/hal/HalAPI/index.ts new file mode 100644 index 00000000..8fb11a6f --- /dev/null +++ b/api/src/core/adapters/hal/HalAPI/index.ts @@ -0,0 +1,13 @@ +import { getAllDomains, getDomainByCode } from "./getDomains"; +import { fetchHalSoftwareById, fetchHalSoftwares } from "./getHalSoftware"; + +export const halAPIGateway = { + software: { + getById: fetchHalSoftwareById, + getAll: fetchHalSoftwares + }, + domain: { + getByCode: getDomainByCode, + gelAll: getAllDomains + } +}; diff --git a/api/src/core/adapters/hal/HalAPI/type.ts b/api/src/core/adapters/hal/HalAPI/type.ts new file mode 100644 index 00000000..c38b29f9 --- /dev/null +++ b/api/src/core/adapters/hal/HalAPI/type.ts @@ -0,0 +1,170 @@ +export class HalFetchError extends Error { + constructor(public readonly status: number | undefined) { + super(`Hal fetch error status: ${status}`); + Object.setPrototypeOf(this, new.target.prototype); + } +} + +export type HalRawSoftware = { + // the following fields are the ones that we use + docid: string; + title_s: string[]; + en_title_s?: string[]; + fr_title_s?: string[]; + abstract_s?: string[]; + en_abstract_s?: string[]; + fr_abstract_s?: string[]; + uri_s: string; + openAccess_bool: boolean; + docType_s: string; + label_bibtex: string; + + // The following is the complete list of fields that could be returned by the HAL API + + // label_s: string; + // citationRef_s: string; + // citationFull_s: string; + // label_endnote: string; + // label_coins: string; + domainAllCode_s: string[]; + // level0_domain_s: string[]; + // domain_s: string[]; + // level1_domain_s: string[]; + // fr_domainAllCodeLabel_fs?: string[]; + // en_domainAllCodeLabel_fs?: string[]; + // es_domainAllCodeLabel_fs: string[]; + // eu_domainAllCodeLabel_fs: string[]; + // primaryDomain_s: string; + // en_keyword_s?: string[]; + keyword_s: string[]; + // fr_keyword_s?: string[]; + // authIdFormPerson_s: string[]; + authIdForm_i: number[]; + // authLastName_s: string[]; + // authFirstName_s: string[]; + // authMiddleName_s: string[]; + authFullName_s: string[]; + // authLastNameFirstName_s: string[]; + // authIdLastNameFirstName_fs: string[]; + // authFullNameIdFormPerson_fs: string[]; + // authAlphaLastNameFirstNameId_fs: string[]; + // authIdFullName_fs: string[]; + // authFullNameId_fs: string[]; + // authQuality_s: string[]; + // authFullNameFormIDPersonIDIDHal_fs: string[]; + // authFullNamePersonIDIDHal_fs: string[]; + // authIdHalFullName_fs: string[]; + // authFullNameIdHal_fs: string[]; + // authAlphaLastNameFirstNameIdHal_fs: string[]; + // authLastNameFirstNameIdHalPersonid_fs: string[]; + // authIdHasPrimaryStructure_fs: string[]; + authIdHal_s: string[]; + // structPrimaryHasAuthId_fs: string[]; + // structPrimaryHasAuthIdHal_fs: string[]; + // structPrimaryHasAlphaAuthId_fs: string[]; + // structPrimaryHasAlphaAuthIdHal_fs: string[]; + // structPrimaryHasAlphaAuthIdHalPersonid_fs: string[]; + // authIdHasStructure_fs: string[]; + // structHasAuthId_fs: string[]; + // structHasAuthIdHal_fs: string[]; + // structHasAuthIdHalPersonid_s: string[]; + // structHasAlphaAuthId_fs: string[]; + // structHasAlphaAuthIdHal_fs: string[]; + // structHasAlphaAuthIdHalPersonid_fs: string[]; + // instStructId_i: number[]; + // instStructIdName_fs: string[]; + // instStructNameId_fs: string[]; + // instStructName_fs: string[]; + // instStructName_s: string[]; + // instStructAddress_s: string; + // instStructCountry_s: string; + // instStructType_s: string; + // instStructValid_s: string; + // structId_i: number[]; + // structIdName_fs: string[]; + // structNameId_fs: string[]; + // structName_fs: string[]; + // structName_s: string; + // structAddress_s: string; + // structCountry_s: string; + // structType_s: string; + // structValid_s: string; + // contributorId_i: number; + // contributorFullName_s: string; + // contributorIdFullName_fs: string; + // contributorFullNameId_fs: string; + // language_s: string[]; + // halId_s: string; + // version_i: number; + // status_i: number; + // instance_s: string; + // sid_i: number; + // submitType_s: string; + // docSubType_s: string; + // oldDocType_s: string; + // thumbId_i: number; + // selfArchiving_bool: boolean; + // authorityInstitution_s: string[]; + // reportType_s: string; + // inPress_bool: boolean; + modifiedDate_tdate: string; + // modifiedDate_s: string; + // modifiedDateY_i: number; + // modifiedDateM_i: number; + // modifiedDateD_i: number; + // submittedDate_tdate: string; + // submittedDate_s: string; + // submittedDateY_i: number; + // submittedDateM_i: number; + // submittedDateD_i: number; + // releasedDate_tdate: string; + // releasedDate_s: string; + // releasedDateY_i: number; + // releasedDateM_i: number; + // releasedDateD_i: number; + // producedDate_tdate: string; + // producedDate_s: string; + // producedDateY_i: number; + // producedDateM_i: number; + // producedDateD_i: number; + // publicationDate_tdate: string; + // publicationDate_s: string; + // publicationDateY_i: number; + // publicationDateM_i: number; + // publicationDateD_i: number; + // owners_i: number[]; + // collId_i: number[]; + // collName_s: string[]; + // collCode_s: string[]; + // collCategory_s: string[]; + // collIdName_fs: string[]; + // collNameId_fs: string[]; + // collCodeName_fs: string[]; + // collCategoryCodeName_fs: string[]; + // collNameCode_fs: string[]; + // fileMain_s: string; + // files_s: string[]; + // fileType_s: string[]; + // _version_: bigint; + // dateLastIndexed_tdate: string; + // label_xml: string; + softCodeRepository_s: string[]; + // softDevelopmentStatus_s: string[]; + softPlatform_s: string[]; + softProgrammingLanguage_s: string[]; + // softRuntimePlatform_s: string[]; + softVersion_s: string[]; + licence_s: string[]; +}; + +export type HalAPIDomain = { + docid: number; + haveNext_bool: boolean; + code_s: string; + en_domain_s: string; + fr_domain_s: string; + label_s: string; + _version_: number; + dateLastIndexed_tdate: string; // ISO date + level_i: number; +}; diff --git a/api/src/core/adapters/hal/getHalSoftware.test.ts b/api/src/core/adapters/hal/getHalSoftware.test.ts index ce6d409c..70e3df59 100644 --- a/api/src/core/adapters/hal/getHalSoftware.test.ts +++ b/api/src/core/adapters/hal/getHalSoftware.test.ts @@ -1,6 +1,6 @@ import { describe, it } from "vitest"; import { expectToEqual } from "../../../tools/test.helpers"; -import { getHalSoftware } from "./getHalSoftware"; +import { getHalSoftware } from "./getSoftwareFromHal"; import { getHalSoftwareOptions } from "./getHalSoftwareOptions"; describe("HAL", () => { @@ -34,7 +34,7 @@ describe("HAL", () => { "softwareVersion": undefined, "keywords": undefined, "programmingLanguages": undefined, - "applicationCategories": ["info"], + "applicationCategories": ["Computer Science [cs]"], "publicationTime": new Date(1561566581000) }); }); diff --git a/api/src/core/adapters/hal/getHalSoftwareOptions.ts b/api/src/core/adapters/hal/getHalSoftwareOptions.ts index 35d6a728..5c1ee65c 100644 --- a/api/src/core/adapters/hal/getHalSoftwareOptions.ts +++ b/api/src/core/adapters/hal/getHalSoftwareOptions.ts @@ -1,6 +1,7 @@ import fetch from "node-fetch"; import type { GetSoftwareExternalDataOptions } from "../../ports/GetSoftwareExternalDataOptions"; -import { HalRawSoftware, halSoftwareFieldsToReturnAsString, rawHalSoftwareToExternalOption } from "./halRawSoftware"; +import { halSoftwareFieldsToReturnAsString, rawHalSoftwareToExternalOption } from "./halRawSoftware"; +import { HalRawSoftware } from "./HalAPI/type"; // HAL documentation is here : https://api.archives-ouvertes.fr/docs/search diff --git a/api/src/core/adapters/hal/getSoftwareFromHal.ts b/api/src/core/adapters/hal/getSoftwareFromHal.ts new file mode 100644 index 00000000..55aff5f4 --- /dev/null +++ b/api/src/core/adapters/hal/getSoftwareFromHal.ts @@ -0,0 +1,67 @@ +import memoize from "memoizee"; +import { GetSoftwareExternalData, SoftwareExternalData } from "../../ports/GetSoftwareExternalData"; +import { fetchHalSoftwareById } from "./HalAPI/getHalSoftware"; +import { parseBibliographicFields } from "./parseBibliographicFields"; +import { halAPIGateway } from "./HalAPI"; +import { HalFetchError } from "./HalAPI/type"; + +export const getHalSoftware: GetSoftwareExternalData = memoize( + async (halDocId): Promise => { + const halRawSoftware = await fetchHalSoftwareById(halDocId).catch(error => { + if (!(error instanceof HalFetchError)) throw error; + if (error.status === 404 || error.status === undefined) return; + throw error; + }); + + if (halRawSoftware === undefined) return; + if (halRawSoftware.docType_s !== "SOFTWARE") return; + + const bibliographicReferences = parseBibliographicFields(halRawSoftware.label_bibtex); + const license = bibliographicReferences?.license?.join(", "); + + const sciencesCategories = await Promise.all( + halRawSoftware.domainAllCode_s.map(async (code: string): Promise => { + const domain = await halAPIGateway.domain.getByCode(code); + return domain.en_domain_s; + }) + ); + + return { + externalId: halRawSoftware.docid, + externalDataOrigin: "HAL", + developers: halRawSoftware.authFullName_s.map((fullname: string, index: number) => { + return { + "id": halRawSoftware?.authIdHal_s?.[index] ?? halRawSoftware.authIdForm_i[index].toString(), + "name": fullname + }; + }), + label: { + "en": halRawSoftware?.en_title_s?.[0] ?? halRawSoftware?.title_s?.[0] ?? "-", + "fr": halRawSoftware?.fr_title_s?.[0] ?? halRawSoftware.en_title_s?.[0] // TODO pourquoi en anglais et pas défault ? + }, + description: { + "en": halRawSoftware?.en_abstract_s?.[0] ?? halRawSoftware.abstract_s?.[0] ?? "-", + "fr": halRawSoftware?.fr_abstract_s?.[0] ?? halRawSoftware.en_abstract_s?.[0] // TODO pourquoi en anglais et pas défault ? + }, + isLibreSoftware: halRawSoftware.openAccess_bool, + // Optionnal + logoUrl: undefined, + framaLibreId: undefined, + websiteUrl: halRawSoftware.uri_s, + sourceUrl: halRawSoftware?.softCodeRepository_s?.[0], + documentationUrl: undefined, // TODO no info about documentation in HAL check on SWH or Repo ? + license, + softwareVersion: halRawSoftware?.softVersion_s?.[0], + keywords: halRawSoftware?.keyword_s, + programmingLanguages: halRawSoftware?.softProgrammingLanguage_s, + applicationCategories: sciencesCategories, + publicationTime: halRawSoftware?.modifiedDate_tdate + ? new Date(halRawSoftware?.modifiedDate_tdate) + : undefined + }; + }, + { + "promise": true, + "maxAge": 3 * 3600 * 1000 + } +); diff --git a/api/src/core/adapters/hal/halRawSoftware.ts b/api/src/core/adapters/hal/halRawSoftware.ts index 61b1c233..82c8efc5 100644 --- a/api/src/core/adapters/hal/halRawSoftware.ts +++ b/api/src/core/adapters/hal/halRawSoftware.ts @@ -1,6 +1,7 @@ -import { Language, SoftwareExternalData } from "../../ports/GetSoftwareExternalData"; +import { Language } from "../../ports/GetSoftwareExternalData"; import { SoftwareExternalDataOption } from "../../ports/GetSoftwareExternalDataOptions"; import { SoftwareFormData, SoftwareType } from "../../usecases/readWriteSillData"; +import { HalRawSoftware } from "./HalAPI/type"; import { parseBibliographicFields } from "./parseBibliographicFields"; const halSoftwareFieldsToReturn: (keyof HalRawSoftware)[] = [ @@ -30,43 +31,6 @@ const halSoftwareFieldsToReturn: (keyof HalRawSoftware)[] = [ export const halSoftwareFieldsToReturnAsString = halSoftwareFieldsToReturn.join(","); -export const rawHalSoftwareToSoftwareExternalData = (halSoftware: HalRawSoftware): SoftwareExternalData => { - const bibliographicReferences = parseBibliographicFields(halSoftware.label_bibtex); - const license = bibliographicReferences?.license?.join(", "); - - return { - externalId: halSoftware.docid, - externalDataOrigin: "HAL", - developers: halSoftware.authFullName_s.map((fullname, index) => { - return { - "id": halSoftware?.authIdHal_s?.[index] ?? halSoftware.authIdForm_i[index].toString(), - "name": fullname - }; - }), - label: { - "en": halSoftware?.en_title_s?.[0] ?? halSoftware?.title_s?.[0] ?? "-", - "fr": halSoftware?.fr_title_s?.[0] ?? halSoftware.en_title_s?.[0] // TODO pourquoi en anglais et pas défault ? - }, - description: { - "en": halSoftware?.en_abstract_s?.[0] ?? halSoftware.abstract_s?.[0] ?? "-", - "fr": halSoftware?.fr_abstract_s?.[0] ?? halSoftware.en_abstract_s?.[0] // TODO pourquoi en anglais et pas défault ? - }, - isLibreSoftware: halSoftware.openAccess_bool, - // Optionnal - logoUrl: undefined, - framaLibreId: undefined, - websiteUrl: halSoftware.uri_s, - sourceUrl: halSoftware?.softCodeRepository_s?.[0], - documentationUrl: undefined, // TODO no info about documentation in HAL check on SWH or Repo ? - license, - softwareVersion: halSoftware?.softVersion_s?.[0], - keywords: halSoftware?.keyword_s, - programmingLanguages: halSoftware?.softProgrammingLanguage_s, - applicationCategories: halSoftware?.domainAllCode_s, - publicationTime: halSoftware?.modifiedDate_tdate ? new Date(halSoftware?.modifiedDate_tdate) : undefined - }; -}; - export const rawHalSoftwareToExternalOption = (language: Language) => (halSoftware: HalRawSoftware): SoftwareExternalDataOption => { @@ -91,158 +55,6 @@ export const rawHalSoftwareToExternalOption = }; }; -export type HalRawSoftware = { - // the following fields are the ones that we use - docid: string; - title_s: string[]; - en_title_s?: string[]; - fr_title_s?: string[]; - abstract_s?: string[]; - en_abstract_s?: string[]; - fr_abstract_s?: string[]; - uri_s: string; - openAccess_bool: boolean; - docType_s: string; - label_bibtex: string; - - // The following is the complete list of fields that could be returned by the HAL API - - // label_s: string; - // citationRef_s: string; - // citationFull_s: string; - // label_endnote: string; - // label_coins: string; - domainAllCode_s: string[]; - // level0_domain_s: string[]; - // domain_s: string[]; - // level1_domain_s: string[]; - // fr_domainAllCodeLabel_fs?: string[]; - // en_domainAllCodeLabel_fs?: string[]; - // es_domainAllCodeLabel_fs: string[]; - // eu_domainAllCodeLabel_fs: string[]; - // primaryDomain_s: string; - // en_keyword_s?: string[]; - keyword_s: string[]; - // fr_keyword_s?: string[]; - // authIdFormPerson_s: string[]; - authIdForm_i: number[]; - // authLastName_s: string[]; - // authFirstName_s: string[]; - // authMiddleName_s: string[]; - authFullName_s: string[]; - // authLastNameFirstName_s: string[]; - // authIdLastNameFirstName_fs: string[]; - // authFullNameIdFormPerson_fs: string[]; - // authAlphaLastNameFirstNameId_fs: string[]; - // authIdFullName_fs: string[]; - // authFullNameId_fs: string[]; - // authQuality_s: string[]; - // authFullNameFormIDPersonIDIDHal_fs: string[]; - // authFullNamePersonIDIDHal_fs: string[]; - // authIdHalFullName_fs: string[]; - // authFullNameIdHal_fs: string[]; - // authAlphaLastNameFirstNameIdHal_fs: string[]; - // authLastNameFirstNameIdHalPersonid_fs: string[]; - // authIdHasPrimaryStructure_fs: string[]; - authIdHal_s: string[]; - // structPrimaryHasAuthId_fs: string[]; - // structPrimaryHasAuthIdHal_fs: string[]; - // structPrimaryHasAlphaAuthId_fs: string[]; - // structPrimaryHasAlphaAuthIdHal_fs: string[]; - // structPrimaryHasAlphaAuthIdHalPersonid_fs: string[]; - // authIdHasStructure_fs: string[]; - // structHasAuthId_fs: string[]; - // structHasAuthIdHal_fs: string[]; - // structHasAuthIdHalPersonid_s: string[]; - // structHasAlphaAuthId_fs: string[]; - // structHasAlphaAuthIdHal_fs: string[]; - // structHasAlphaAuthIdHalPersonid_fs: string[]; - // instStructId_i: number[]; - // instStructIdName_fs: string[]; - // instStructNameId_fs: string[]; - // instStructName_fs: string[]; - // instStructName_s: string[]; - // instStructAddress_s: string; - // instStructCountry_s: string; - // instStructType_s: string; - // instStructValid_s: string; - // structId_i: number[]; - // structIdName_fs: string[]; - // structNameId_fs: string[]; - // structName_fs: string[]; - // structName_s: string; - // structAddress_s: string; - // structCountry_s: string; - // structType_s: string; - // structValid_s: string; - // contributorId_i: number; - // contributorFullName_s: string; - // contributorIdFullName_fs: string; - // contributorFullNameId_fs: string; - // language_s: string[]; - // halId_s: string; - // version_i: number; - // status_i: number; - // instance_s: string; - // sid_i: number; - // submitType_s: string; - // docSubType_s: string; - // oldDocType_s: string; - // thumbId_i: number; - // selfArchiving_bool: boolean; - // authorityInstitution_s: string[]; - // reportType_s: string; - // inPress_bool: boolean; - modifiedDate_tdate: string; - // modifiedDate_s: string; - // modifiedDateY_i: number; - // modifiedDateM_i: number; - // modifiedDateD_i: number; - // submittedDate_tdate: string; - // submittedDate_s: string; - // submittedDateY_i: number; - // submittedDateM_i: number; - // submittedDateD_i: number; - // releasedDate_tdate: string; - // releasedDate_s: string; - // releasedDateY_i: number; - // releasedDateM_i: number; - // releasedDateD_i: number; - // producedDate_tdate: string; - // producedDate_s: string; - // producedDateY_i: number; - // producedDateM_i: number; - // producedDateD_i: number; - // publicationDate_tdate: string; - // publicationDate_s: string; - // publicationDateY_i: number; - // publicationDateM_i: number; - // publicationDateD_i: number; - // owners_i: number[]; - // collId_i: number[]; - // collName_s: string[]; - // collCode_s: string[]; - // collCategory_s: string[]; - // collIdName_fs: string[]; - // collNameId_fs: string[]; - // collCodeName_fs: string[]; - // collCategoryCodeName_fs: string[]; - // collNameCode_fs: string[]; - // fileMain_s: string; - // files_s: string[]; - // fileType_s: string[]; - // _version_: bigint; - // dateLastIndexed_tdate: string; - // label_xml: string; - softCodeRepository_s: string[]; - // softDevelopmentStatus_s: string[]; - softPlatform_s: string[]; - softProgrammingLanguage_s: string[]; - // softRuntimePlatform_s: string[]; - softVersion_s: string[]; - licence_s: string[]; -}; - const stringOfArrayIncluded = (stringArray: Array, text: string): boolean => { return stringArray.some((arg: string) => { return text.includes(arg); diff --git a/api/src/core/adapters/hal/index.ts b/api/src/core/adapters/hal/index.ts index ac783cf0..c4bc85de 100644 --- a/api/src/core/adapters/hal/index.ts +++ b/api/src/core/adapters/hal/index.ts @@ -1,7 +1,7 @@ -import { fetchHalSoftwares } from "./getHalSoftware"; +import { getHalSoftware } from "./getSoftwareFromHal"; -export const halAPIGateway = { - software: { - getAll: fetchHalSoftwares +export const halAdapter = { + softwareExternalData: { + getByHalId: getHalSoftware } }; diff --git a/api/src/core/bootstrap.ts b/api/src/core/bootstrap.ts index d3328876..9a985e6c 100644 --- a/api/src/core/bootstrap.ts +++ b/api/src/core/bootstrap.ts @@ -9,7 +9,7 @@ import { getServiceProviders } from "./adapters/getServiceProviders"; import { createGetSoftwareLatestVersion } from "./adapters/getSoftwareLatestVersion"; import { getWikidataSoftware } from "./adapters/wikidata/getWikidataSoftware"; import { getWikidataSoftwareOptions } from "./adapters/wikidata/getWikidataSoftwareOptions"; -import { getHalSoftware } from "./adapters/hal/getHalSoftware"; +import { halAdapter } from "./adapters/hal"; import { getHalSoftwareOptions } from "./adapters/hal/getHalSoftwareOptions"; import { createKeycloakUserApi, type KeycloakUserApiParams } from "./adapters/userApi"; import type { ComptoirDuLibreApi } from "./ports/ComptoirDuLibreApi"; @@ -166,7 +166,7 @@ function getSoftwareExternalDataFunctions(externalSoftwareDataOrigin: ExternalDa case "HAL": return { "getSoftwareExternalDataOptions": getHalSoftwareOptions, - "getSoftwareExternalData": getHalSoftware + "getSoftwareExternalData": halAdapter.softwareExternalData.getByHalId }; default: const unreachableCase: never = externalSoftwareDataOrigin; diff --git a/api/src/core/usecases/importFromSource.ts b/api/src/core/usecases/importFromSource.ts index a5ab5f22..4e75cec4 100644 --- a/api/src/core/usecases/importFromSource.ts +++ b/api/src/core/usecases/importFromSource.ts @@ -1,5 +1,5 @@ import { DbApiV2 } from "../ports/DbApiV2"; -import { halAPIGateway } from "../adapters/hal"; +import { halAPIGateway } from "../adapters/hal/HalAPI"; import { halRawSoftwareToSoftwareForm } from "../adapters/hal/halRawSoftware"; export const importFromHALSource: (dbApi: DbApiV2) => (agentEmail: string) => Promise[]> = ( diff --git a/api/src/rpc/start.ts b/api/src/rpc/start.ts index 31bd462d..1464ade3 100644 --- a/api/src/rpc/start.ts +++ b/api/src/rpc/start.ts @@ -9,7 +9,7 @@ import { assert } from "tsafe/assert"; import { bootstrapCore } from "../core"; import { Database } from "../core/adapters/dbApi/kysely/kysely.database"; import { createPgDialect } from "../core/adapters/dbApi/kysely/kysely.dialect"; -import { getHalSoftware } from "../core/adapters/hal/getHalSoftware"; +import { halAdapter } from "../core/adapters/hal"; import { getHalSoftwareOptions } from "../core/adapters/hal/getHalSoftwareOptions"; import { getWikidataSoftware } from "../core/adapters/wikidata/getWikidataSoftware"; import { getWikidataSoftwareOptions } from "../core/adapters/wikidata/getWikidataSoftwareOptions"; @@ -181,7 +181,7 @@ function getSoftwareExternalDataFunctions(externalSoftwareDataOrigin: ExternalDa case "HAL": return { "getSoftwareExternalDataOptions": getHalSoftwareOptions, - "getSoftwareExternalData": getHalSoftware + "getSoftwareExternalData": halAdapter.softwareExternalData.getByHalId }; default: const unreachableCase: never = externalSoftwareDataOrigin;