diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 31224394f4a3..b14aca08a2c2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -142,7 +142,7 @@ codemagic.yaml /libs/api/domains/user-profile/ @island-is/hugsmidjan @island-is/juni @island-is/aranja /libs/api/domains/passport/ @island-is/hugsmidjan /libs/api/domains/vehicles/ @island-is/hugsmidjan -/libs/api/domains/university-of-iceland/ @island-is/hugsmidjan +/libs/api/domains/university-careers/ @island-is/hugsmidjan /libs/api/domains/regulations/ @island-is/hugsmidjan /libs/api/domains/regulations-admin/ @island-is/hugsmidjan /libs/api/domains/rights-portal @island-is/hugsmidjan @@ -176,7 +176,7 @@ codemagic.yaml /libs/clients/passports/ @island-is/hugsmidjan /libs/clients/p-card/ @island-is/hugsmidjan /libs/clients/assets/ @island-is/hugsmidjan -/libs/clients/university-of-iceland/ @island-is/hugsmidjan +/libs/clients/university-careers/ @island-is/hugsmidjan /libs/clients/regulations-admin/ @island-is/hugsmidjan /libs/clients/inna/ @island-is/hugsmidjan /libs/clients/hms-loans/ @island-is/hugsmidjan @@ -191,7 +191,6 @@ codemagic.yaml /libs/portals/admin/air-discount-scheme @island-is/hugsmidjan /libs/application/templates/official-journal-of-iceland/ @island-is/hugsmidjan /libs/application/template-api-modules/src/lib/modules/templates/official-journal-of-iceland/ @island-is/hugsmidjan - /libs/application/templates/data-protection-complaint/ @island-is/norda /libs/application/templates/institution-collaboration/ @island-is/norda @island-is/fuglar /libs/application/templates/login-service/ @island-is/norda @@ -213,7 +212,7 @@ codemagic.yaml /libs/clients/rsk/company-registry @island-is/norda /libs/clients/althingi-ombudsman/ @island-is/norda /libs/api/domains/company-registry @island-is/norda -/libs/clients/icelandic-health-insurance/health-insurance/ @island-is/norda @island-is/norda +/libs/clients/icelandic-health-insurance/health-insurance/ @island-is/norda /libs/clients/data-protection-complaint/ @island-is/norda /libs/clients/fishing-license/ @island-is/norda /libs/api/domains/fishing-license/ @island-is/norda diff --git a/apps/api/infra/api.ts b/apps/api/infra/api.ts index 9069c630683a..dd247b6a50d1 100644 --- a/apps/api/infra/api.ts +++ b/apps/api/infra/api.ts @@ -44,6 +44,7 @@ import { SocialInsuranceAdministration, IntellectualProperties, Inna, + UniversityCareers, OfficialJournalOfIceland, } from '../../../infra/src/dsl/xroad' @@ -412,6 +413,7 @@ export const serviceSetup = (services: { ChargeFjsV2, EnergyFunds, UniversityOfIceland, + UniversityCareers, WorkMachines, IcelandicGovernmentInstitutionVacancies, RskProcuring, diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 0adf72ca48bf..141d3f2ae31e 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -67,7 +67,6 @@ import { StatisticsModule } from '@island.is/api/domains/statistics' import { SyslumennModule } from '@island.is/api/domains/syslumenn' import { TransportAuthorityApiModule } from '@island.is/api/domains/transport-authority' import { UniversityGatewayApiModule } from '@island.is/api/domains/university-gateway' -import { UniversityOfIcelandModule } from '@island.is/api/domains/university-of-iceland' import { UserProfileModule } from '@island.is/api/domains/user-profile' import { VehiclesModule } from '@island.is/api/domains/vehicles' import { @@ -96,6 +95,7 @@ import { FirearmLicenseClientConfig } from '@island.is/clients/firearm-license' import { FishingLicenseClientConfig } from '@island.is/clients/fishing-license' import { FiskistofaClientConfig } from '@island.is/clients/fiskistofa' import { AircraftRegistryClientConfig } from '@island.is/clients/aircraft-registry' +import { UniversityCareersModule } from '@island.is/api/domains/university-careers' import { UserNotificationClientConfig } from '@island.is/clients/user-notification' import { HealthDirectorateClientConfig, @@ -134,14 +134,14 @@ import { ShipRegistryClientConfig } from '@island.is/clients/ship-registry' import { SignatureCollectionClientConfig } from '@island.is/clients/signature-collection' import { SyslumennClientConfig } from '@island.is/clients/syslumenn' import { HuntingLicenseClientConfig } from '@island.is/clients/hunting-license' -import { UniversityOfIcelandClientConfig } from '@island.is/clients/university-of-iceland' -import { DocumentsClientV2Config } from '@island.is/clients/documents-v2' import { VehiclesClientConfig } from '@island.is/clients/vehicles' import { WorkMachinesClientConfig } from '@island.is/clients/work-machines' import { CmsModule, PowerBiConfig } from '@island.is/cms' import { CmsTranslationsModule } from '@island.is/cms-translations' import { FileStorageConfig } from '@island.is/file-storage' import { AuditModule } from '@island.is/nest/audit' +import { DocumentsClientV2Config } from '@island.is/clients/documents-v2' + import { ConfigModule, DownloadServiceConfig, @@ -170,6 +170,13 @@ import { GraphqlOptionsFactory } from './graphql-options.factory' import { GraphQLConfig } from './graphql.config' import { HealthController } from './health.controller' import { DocumentClientConfig } from '@island.is/clients/documents' +import { + AgriculturalUniversityOfIcelandCareerClientConfig, + UniversityOfIcelandCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + HolarUniversityCareerClientConfig, + BifrostUniversityCareerClientConfig, +} from '@island.is/clients/university-careers' import { HousingBenefitsConfig } from '@island.is/clients/hms-housing-benefits' import { UserProfileClientConfig } from '@island.is/clients/user-profile' @@ -270,6 +277,7 @@ const environment = getConfig ShipRegistryModule, IntellectualPropertiesModule, StatisticsModule, + UniversityCareersModule, OfficialJournalOfIcelandModule, CompanyRegistryModule, IcelandicNamesModule.register({ @@ -306,7 +314,6 @@ const environment = getConfig MortgageCertificateModule, TransportAuthorityApiModule, EnergyFundsServiceModule, - UniversityOfIcelandModule, WorkMachinesModule, AdministrationOfOccupationalSafetyAndHealthModule, UniversityGatewayApiModule, @@ -376,7 +383,6 @@ const environment = getConfig CommunicationsConfig, HealthDirectorateClientConfig, OfficialJournalOfIcelandClientConfig, - UniversityOfIcelandClientConfig, InnaClientConfig, SessionsApiClientConfig, AuthAdminApiClientConfig, @@ -389,6 +395,11 @@ const environment = getConfig ShipRegistryClientConfig, HousingBenefitCalculatorClientConfig, MMSClientConfig, + AgriculturalUniversityOfIcelandCareerClientConfig, + UniversityOfIcelandCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + HolarUniversityCareerClientConfig, + BifrostUniversityCareerClientConfig, StatisticsClientConfig, SignatureCollectionClientConfig, UniversityGatewayApiClientConfig, diff --git a/apps/download-service/infra/download-service.ts b/apps/download-service/infra/download-service.ts index f85510e11405..307b7fa416fb 100644 --- a/apps/download-service/infra/download-service.ts +++ b/apps/download-service/infra/download-service.ts @@ -5,6 +5,7 @@ import { Education, Finance, HealthInsurance, + UniversityCareers, UniversityOfIceland, Vehicles, WorkMachines, @@ -49,6 +50,7 @@ export const serviceSetup = (services: { HealthInsurance, Vehicles, UniversityOfIceland, + UniversityCareers, WorkMachines, Education, ) diff --git a/apps/download-service/src/app/app.module.ts b/apps/download-service/src/app/app.module.ts index e5e7e4e266e3..ce7ffc49d213 100644 --- a/apps/download-service/src/app/app.module.ts +++ b/apps/download-service/src/app/app.module.ts @@ -31,9 +31,13 @@ import { VehiclesClientModule, } from '@island.is/clients/vehicles' import { - UniversityOfIcelandClientConfig, - UniversityOfIcelandClientModule, -} from '@island.is/clients/university-of-iceland' + AgriculturalUniversityOfIcelandCareerClientConfig, + BifrostUniversityCareerClientConfig, + HolarUniversityCareerClientConfig, + UniversityCareersClientModule, + UniversityOfAkureyriCareerClientConfig, + UniversityOfIcelandCareerClientConfig, +} from '@island.is/clients/university-careers' import { RegulationsClientConfig, RegulationsClientModule, @@ -73,11 +77,11 @@ import { DocumentsClientModule, FinanceClientModule, VehiclesClientModule, - UniversityOfIcelandClientModule, RegulationsAdminClientModule, RegulationsClientModule, WorkMachinesClientModule, DistrictCommissionersLicensesClientModule, + UniversityCareersClientModule, MMSClientModule, RightsPortalClientModule, ConfigModule.forRoot({ @@ -87,7 +91,11 @@ import { IdsClientConfig, XRoadConfig, VehiclesClientConfig, - UniversityOfIcelandClientConfig, + UniversityOfIcelandCareerClientConfig, + AgriculturalUniversityOfIcelandCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, + HolarUniversityCareerClientConfig, + BifrostUniversityCareerClientConfig, RegulationsAdminClientConfig, RegulationsClientConfig, WorkMachinesClientConfig, diff --git a/apps/download-service/src/app/modules/education-documents/education-document.controller.ts b/apps/download-service/src/app/modules/education-documents/education-document.controller.ts index 7bba08d14a54..516ad2cdcdac 100644 --- a/apps/download-service/src/app/modules/education-documents/education-document.controller.ts +++ b/apps/download-service/src/app/modules/education-documents/education-document.controller.ts @@ -11,10 +11,6 @@ import { ApiOkResponse } from '@nestjs/swagger' import { Response } from 'express' import { ApiScope } from '@island.is/auth/scopes' import type { User } from '@island.is/auth-nest-tools' -import { - NemandiFerillFerillFileTranscriptGetLocaleEnum, - UniversityOfIcelandService, -} from '@island.is/clients/university-of-iceland' import { CurrentUser, IdsUserGuard, @@ -23,17 +19,23 @@ import { } from '@island.is/auth-nest-tools' import { AuditService } from '@island.is/nest/audit' import { GetEducationGraduationDocumentDto } from './dto/getEducationGraduationDocument' +import { + UniversityCareersClientService, + UniversityIdShort, +} from '@island.is/clients/university-careers' +import { Locale } from '@island.is/shared/types' +import { UniversityShortIdMap } from '@island.is/clients/university-careers' @UseGuards(IdsUserGuard, ScopesGuard) @Scopes(ApiScope.education) @Controller('education') export class EducationController { constructor( - private readonly universityOfIcelandApi: UniversityOfIcelandService, + private readonly universitiesApi: UniversityCareersClientService, private readonly auditService: AuditService, ) {} - @Post('/graduation/:lang/:trackNumber') + @Post('/graduation/:lang/:university/:trackNumber') @Header('Content-Type', 'application/pdf') @ApiOkResponse({ content: { 'application/pdf': {} }, @@ -43,7 +45,9 @@ export class EducationController { async getEducationGraduationPDF( @Param('trackNumber') trackNumber: string, @Param('lang') lang: string, - @CurrentUser() user: User, + @Param('university') uni: UniversityIdShort, + @CurrentUser() + user: User, @Body() resource: GetEducationGraduationDocumentDto, @Res() res: Response, ) { @@ -52,17 +56,18 @@ export class EducationController { authorization: `Bearer ${resource.__accessToken}`, } - const documentResponse = await this.universityOfIcelandApi.studentCareerPDF( + const documentResponse = await this.universitiesApi.getStudentTrackPdf( authUser, parseInt(trackNumber), - lang as NemandiFerillFerillFileTranscriptGetLocaleEnum, + UniversityShortIdMap[uni], + lang as Locale, ) if (documentResponse) { this.auditService.audit({ - action: 'getVehicleHistoryPdf', + action: 'getStudentTrackEducationGraduationPdf', auth: user, - resources: trackNumber, + resources: `${trackNumber}/${lang}/${uni}`, }) const contentArrayBuffer = await documentResponse.arrayBuffer() @@ -71,7 +76,7 @@ export class EducationController { res.header('Content-length', buffer.length.toString()) res.header( 'Content-Disposition', - `inline; filename=${user.nationalId}-brautskraning-${trackNumber}.pdf`, + `inline; filename=${user.nationalId}-skoli-${UniversityShortIdMap[uni]}-brautskraning-${trackNumber}.pdf`, ) res.header('Content-Type: application/pdf') res.header('Pragma: no-cache') diff --git a/charts/islandis/values.dev.yaml b/charts/islandis/values.dev.yaml index 5990971c1ebc..ced4f134b03e 100644 --- a/charts/islandis/values.dev.yaml +++ b/charts/islandis/values.dev.yaml @@ -326,9 +326,11 @@ api: USER_NOTIFICATION_API_URL: 'http://web-user-notification.user-notification.svc.cluster.local' USER_PROFILE_CLIENT_URL: 'http://web-service-portal-api.service-portal.svc.cluster.local' XROAD_ADR_MACHINE_LICENSE_PATH: 'IS-DEV/GOV/10013/Vinnueftirlitid-Protected/rettindi-token-v1' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1' XROAD_AIRCRAFT_REGISTRY_PATH: 'IS-DEV/GOV/10017/Samgongustofa-Protected/Loftfaraskra-V1' XROAD_BASE_PATH: 'http://securityserver.dev01.devland.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.dev01.devland.is/r1/IS-DEV' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1' XROAD_CHARGE_FJS_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/chargeFJS_v2' XROAD_CHARGE_FJS_V2_TIMEOUT: '20000' XROAD_CLIENT_ID: 'IS-DEV/GOV/10000/island-is-client' @@ -355,6 +357,7 @@ api: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS-DEV/GOV/10033/HMS-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS-DEV/GOV/10033/HMS-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_HOUSING_BENEFIT_CALCULATOR_PATH: 'IS-DEV/GOV/10033/HMS-Protected/calc-v1' XROAD_HUNTING_LICENSE_PATH: 'IS-DEV/GOV/10009/Umhverfisstofnun-Protected/api' XROAD_ICELANDIC_GOVERNMENT_INSTITUTION_VACANCIES_PATH: 'IS-DEV/GOV/10021/FJS-Protected/recruitment-v1' @@ -383,6 +386,7 @@ api: XROAD_TLS_BASE_PATH: 'https://securityserver.dev01.devland.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.dev01.devland.is/r1/IS-DEV' XROAD_TR_PATH: 'IS-DEV/GOV/10008/TR-Protected/external-v1' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1' XROAD_VEHICLES_MILEAGE_PATH: 'IS-DEV/GOV/10017/Samgongustofa-Protected/Vehicle-Mileagereading-V1' XROAD_VEHICLES_PATH: 'IS-DEV/GOV/10017/Samgongustofa-Protected/Mitt-Svaedi-V1' @@ -1164,8 +1168,10 @@ download-service: NODE_OPTIONS: '--max-old-space-size=460' REGULATIONS_ADMIN_URL: 'http://web-regulations-admin-backend.regulations-admin.svc.cluster.local' SERVERSIDE_FEATURES_ON: '' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1' XROAD_BASE_PATH: 'http://securityserver.dev01.devland.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.dev01.devland.is/r1/IS-DEV' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1' XROAD_CLIENT_ID: 'IS-DEV/GOV/10000/island-is-client' XROAD_FINANCES_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeIsland' XROAD_FINANCES_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeServicesFJS_v2' @@ -1174,10 +1180,12 @@ download-service: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS-DEV/GOV/10033/HMS-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS-DEV/GOV/10033/HMS-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_MMS_GRADE_SERVICE_ID: 'IS-DEV/EDU/10020/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS-DEV/EDU/10020/MMS-Protected/license-api-v1' XROAD_TLS_BASE_PATH: 'https://securityserver.dev01.devland.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.dev01.devland.is/r1/IS-DEV' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1' XROAD_VEHICLES_PATH: 'IS-DEV/GOV/10017/Samgongustofa-Protected/Mitt-Svaedi-V1' XROAD_WORK_MACHINE_LICENSE_PATH: 'IS-DEV/GOV/10013/Vinnueftirlitid-Protected/vinnuvelar-token' diff --git a/charts/islandis/values.prod.yaml b/charts/islandis/values.prod.yaml index 91f2601d331a..7a800d466b76 100644 --- a/charts/islandis/values.prod.yaml +++ b/charts/islandis/values.prod.yaml @@ -316,9 +316,11 @@ api: USER_NOTIFICATION_API_URL: 'http://web-user-notification.user-notification.svc.cluster.local' USER_PROFILE_CLIENT_URL: 'http://web-service-portal-api.service-portal.svc.cluster.local' XROAD_ADR_MACHINE_LICENSE_PATH: 'IS/GOV/4201810439/Vinnueftirlitid-Protected/rettindi-token-v1' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS/EDU/4112043590/LBHI-Protected/brautskraning-v1' XROAD_AIRCRAFT_REGISTRY_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Loftfaraskra-V1' XROAD_BASE_PATH: 'http://securityserver.island.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.island.is/r1/IS' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS/EDU/5502690239/Bifrost-Protected/brautskraning-v1' XROAD_CHARGE_FJS_V2_PATH: 'IS/GOV/5402697509/FJS-Public/chargeFJS_v2' XROAD_CHARGE_FJS_V2_TIMEOUT: '20000' XROAD_CLIENT_ID: 'IS/GOV/5501692829/island-is-client' @@ -345,6 +347,7 @@ api: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS/GOV/5812191480/Husnaeds-og-mannvirkjastofnun-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS/GOV/5812191480/Husnaeds-og-mannvirkjastofnun-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS/EDU/5001694359/Holar-Protected/brautskraning-v1' XROAD_HOUSING_BENEFIT_CALCULATOR_PATH: 'IS/GOV/5812191480/Husnaeds-og-mannvirkjastofnun-Protected/calc-v1' XROAD_HUNTING_LICENSE_PATH: 'IS/GOV/7010022880/Umhverfisstofnun-Protected/api' XROAD_ICELANDIC_GOVERNMENT_INSTITUTION_VACANCIES_PATH: 'IS/GOV/5402697509/FJS-Protected/recruitment-v1' @@ -373,6 +376,7 @@ api: XROAD_TLS_BASE_PATH: 'https://securityserver.island.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.island.is/r1/IS' XROAD_TR_PATH: 'IS/GOV/5012130120/TR-Protected/external-v1' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS/EDU/5206871229/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS/EDU/6001692039/HI-Protected/brautskraning-v1' XROAD_VEHICLES_MILEAGE_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Vehicle-Mileagereading-V1' XROAD_VEHICLES_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Mitt-Svaedi-V1' @@ -1159,8 +1163,10 @@ download-service: NODE_OPTIONS: '--max-old-space-size=460' REGULATIONS_ADMIN_URL: 'http://web-regulations-admin-backend.regulations-admin.svc.cluster.local' SERVERSIDE_FEATURES_ON: 'driving-license-use-v1-endpoint-for-v2-comms' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS/EDU/4112043590/LBHI-Protected/brautskraning-v1' XROAD_BASE_PATH: 'http://securityserver.island.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.island.is/r1/IS' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS/EDU/5502690239/Bifrost-Protected/brautskraning-v1' XROAD_CLIENT_ID: 'IS/GOV/5501692829/island-is-client' XROAD_FINANCES_PATH: 'IS/GOV/5402697509/FJS-Public/financeIsland' XROAD_FINANCES_V2_PATH: 'IS/GOV/5402697509/FJS-Public/financeServicesFJS_v2' @@ -1169,10 +1175,12 @@ download-service: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS/GOV/5812191480/Husnaeds-og-mannvirkjastofnun-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS/GOV/5812191480/Husnaeds-og-mannvirkjastofnun-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS/EDU/5001694359/Holar-Protected/brautskraning-v1' XROAD_MMS_GRADE_SERVICE_ID: 'IS/EDU/5708150320/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS/EDU/5708150320/MMS-Protected/license-api-v1' XROAD_TLS_BASE_PATH: 'https://securityserver.island.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.island.is/r1/IS' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS/EDU/5206871229/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS/EDU/6001692039/HI-Protected/brautskraning-v1' XROAD_VEHICLES_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Mitt-Svaedi-V1' XROAD_WORK_MACHINE_LICENSE_PATH: 'IS/GOV/4201810439/Vinnueftirlitid-Protected/vinnuvelar-token' diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index 8a9b62f718c5..7f0a0f5ba957 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -326,9 +326,11 @@ api: USER_NOTIFICATION_API_URL: 'http://web-user-notification.user-notification.svc.cluster.local' USER_PROFILE_CLIENT_URL: 'http://web-service-portal-api.service-portal.svc.cluster.local' XROAD_ADR_MACHINE_LICENSE_PATH: 'IS-TEST/GOV/4201810439/Vinnueftirlitid-Protected/rettindi-token-v1' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1' XROAD_AIRCRAFT_REGISTRY_PATH: 'IS-DEV/GOV/10017/Samgongustofa-Protected/Loftfaraskra-V1' XROAD_BASE_PATH: 'http://securityserver.staging01.devland.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.staging01.devland.is/r1/IS-TEST' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1' XROAD_CHARGE_FJS_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/chargeFJS_v2' XROAD_CHARGE_FJS_V2_TIMEOUT: '20000' XROAD_CLIENT_ID: 'IS-TEST/GOV/5501692829/island-is-client' @@ -355,6 +357,7 @@ api: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS-TEST/GOV/5812191480/HMS-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS-TEST/GOV/5812191480/HMS-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_HOUSING_BENEFIT_CALCULATOR_PATH: 'IS-TEST/GOV/5812191480/HMS-Protected/calc-v1' XROAD_HUNTING_LICENSE_PATH: 'IS-DEV/GOV/10009/Umhverfisstofnun-Protected/api' XROAD_ICELANDIC_GOVERNMENT_INSTITUTION_VACANCIES_PATH: 'IS-DEV/GOV/10021/FJS-Protected/recruitment-v1' @@ -383,6 +386,7 @@ api: XROAD_TLS_BASE_PATH: 'https://securityserver.staging01.devland.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.staging01.devland.is/r1/IS-TEST' XROAD_TR_PATH: 'IS-TEST/GOV/5012130120/TR-Protected/external-v1' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1' XROAD_VEHICLES_MILEAGE_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Vehicle-Mileagereading-V1' XROAD_VEHICLES_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Mitt-Svaedi-V1' @@ -1034,8 +1038,10 @@ download-service: NODE_OPTIONS: '--max-old-space-size=460' REGULATIONS_ADMIN_URL: 'http://web-regulations-admin-backend.regulations-admin.svc.cluster.local' SERVERSIDE_FEATURES_ON: '' + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1' XROAD_BASE_PATH: 'http://securityserver.staging01.devland.is' XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.staging01.devland.is/r1/IS-TEST' + XROAD_BIFROST_UNIVERSITY_PATH: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1' XROAD_CLIENT_ID: 'IS-TEST/GOV/5501692829/island-is-client' XROAD_FINANCES_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeIsland' XROAD_FINANCES_V2_PATH: 'IS-DEV/GOV/10021/FJS-Public/financeServicesFJS_v2' @@ -1044,10 +1050,12 @@ download-service: XROAD_HEALTH_INSURANCE_WSDLURL: 'https://test-huld.sjukra.is/islandrg?wsdl' XROAD_HMS_HOUSING_BENEFITS_PATH: 'IS-TEST/GOV/5812191480/HMS-Protected/husbot-v1' XROAD_HMS_LOANS_PATH: 'IS-TEST/GOV/5812191480/HMS-Protected/libra-v1' + XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_MMS_GRADE_SERVICE_ID: 'IS-TEST/EDU/5708150320/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS-TEST/EDU/5708150320/MMS-Protected/license-api-v1' XROAD_TLS_BASE_PATH: 'https://securityserver.staging01.devland.is' XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.staging01.devland.is/r1/IS-TEST' + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1' XROAD_UNIVERSITY_OF_ICELAND_PATH: 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1' XROAD_VEHICLES_PATH: 'IS/GOV/5405131040/Samgongustofa-Protected/Mitt-Svaedi-V1' XROAD_WORK_MACHINE_LICENSE_PATH: 'IS-TEST/GOV/4201810439/Vinnueftirlitid-Protected/vinnuvelar-token' diff --git a/infra/src/dsl/xroad.ts b/infra/src/dsl/xroad.ts index c51578c65704..3c2d33496adf 100644 --- a/infra/src/dsl/xroad.ts +++ b/infra/src/dsl/xroad.ts @@ -344,6 +344,31 @@ export const UniversityOfIceland = new XroadConf({ }, }) +export const UniversityCareers = new XroadConf({ + env: { + XROAD_UNIVERSITY_OF_AKUREYRI_PATH: { + dev: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1', + staging: 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1', + prod: 'IS/EDU/5206871229/UNAK-Protected/brautskraning-v1', + }, + XROAD_AGRICULTURAL_UNIVERSITY_OF_ICELAND_PATH: { + dev: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1', + staging: 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1', + prod: 'IS/EDU/4112043590/LBHI-Protected/brautskraning-v1', + }, + XROAD_BIFROST_UNIVERSITY_PATH: { + dev: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1', + staging: 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1', + prod: 'IS/EDU/5502690239/Bifrost-Protected/brautskraning-v1', + }, + XROAD_HOLAR_UNIVERSITY_PATH: { + dev: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1', + staging: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1', + prod: 'IS/EDU/5001694359/Holar-Protected/brautskraning-v1', + }, + }, +}) + export const Education = new XroadConf({ env: { XROAD_MMS_LICENSE_SERVICE_ID: { diff --git a/libs/api/domains/university-of-iceland/.eslintrc.json b/libs/api/domains/university-careers/.eslintrc.json similarity index 100% rename from libs/api/domains/university-of-iceland/.eslintrc.json rename to libs/api/domains/university-careers/.eslintrc.json diff --git a/libs/api/domains/university-careers/README.md b/libs/api/domains/university-careers/README.md new file mode 100644 index 000000000000..5a3f35d484f4 --- /dev/null +++ b/libs/api/domains/university-careers/README.md @@ -0,0 +1,7 @@ +# api-domains-university-careers + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test api-domains-university-careers` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/api/domains/university-careers/jest.config.ts b/libs/api/domains/university-careers/jest.config.ts new file mode 100644 index 000000000000..44761516a9ee --- /dev/null +++ b/libs/api/domains/university-careers/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'api-domains-university-careers', + preset: '../../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../../../coverage/libs/api/domains/university-careers', +} diff --git a/libs/api/domains/university-careers/project.json b/libs/api/domains/university-careers/project.json new file mode 100644 index 000000000000..0b4b0604f897 --- /dev/null +++ b/libs/api/domains/university-careers/project.json @@ -0,0 +1,30 @@ +{ + "name": "api-domains-university-careers", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/api/domains/university-careers/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/api/domains/university-careers/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/api/domains/university-careers/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": ["lib:api", "scope:api"] +} diff --git a/libs/api/domains/university-careers/src/index.ts b/libs/api/domains/university-careers/src/index.ts new file mode 100644 index 000000000000..86ee82e0893d --- /dev/null +++ b/libs/api/domains/university-careers/src/index.ts @@ -0,0 +1 @@ +export * from './lib/universityCareers.module' diff --git a/libs/api/domains/university-careers/src/lib/dto/studentInfo.input.ts b/libs/api/domains/university-careers/src/lib/dto/studentInfo.input.ts new file mode 100644 index 000000000000..dfe52ba0253e --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/dto/studentInfo.input.ts @@ -0,0 +1,12 @@ +import { UniversityId } from '@island.is/clients/university-careers' +import { Field, InputType, registerEnumType } from '@nestjs/graphql' +import { IsString } from 'class-validator' + +registerEnumType(UniversityId, { name: 'UniversityCareersUniversityId' }) + +@InputType('UniversityCareersStudentInfoInput') +export class StudentInfoInput { + @Field() + @IsString() + locale!: string +} diff --git a/libs/api/domains/university-careers/src/lib/dto/studentInfoByUniversity.input.ts b/libs/api/domains/university-careers/src/lib/dto/studentInfoByUniversity.input.ts new file mode 100644 index 000000000000..37d0997db610 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/dto/studentInfoByUniversity.input.ts @@ -0,0 +1,18 @@ +import { UniversityId } from '@island.is/clients/university-careers' +import { Field, InputType } from '@nestjs/graphql' +import { IsEnum, IsNumber, IsString } from 'class-validator' + +@InputType('UniversityCareersStudentInfoByUniversityInput') +export class StudentInfoByUniversityInput { + @Field(() => UniversityId) + @IsEnum(UniversityId) + universityId!: UniversityId + + @Field() + @IsNumber() + trackNumber!: number + + @Field() + @IsString() + locale!: string +} diff --git a/libs/api/domains/university-careers/src/lib/mapper.ts b/libs/api/domains/university-careers/src/lib/mapper.ts new file mode 100644 index 000000000000..a170fa20e102 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/mapper.ts @@ -0,0 +1,95 @@ +import { + StudentTrackDto, + StudentTrackOverviewDto, +} from '@island.is/clients/university-careers' +import { isDefined } from '@island.is/shared/utils' +import { StudentTrack } from './models/studentTrack.model' +import { StudentTrackTranscript } from './models/studentTrackTranscript.model' +import { Institution } from './models/institution.model' +import { InstitutionProps } from './universityCareers.types' + +export const mapToStudent = ( + data: StudentTrackDto, + institution: InstitutionProps, +): StudentTrackTranscript | null => { + if ( + !data || + !data?.name || + !data?.graduationDate || + !data?.trackNumber || + !data?.school || + !data?.faculty || + !data?.studyProgram || + !data?.degree + ) { + return null + } + + let institutionMapped: Institution | undefined + + if (data.institution?.id) { + institutionMapped = { + id: data.institution.id, + shortId: data.institution.idShort, + displayName: institution.displayName, + logoUrl: institution.logoUrl, + } + } else { + institutionMapped = institution + } + + return { + name: data.name, + trackNumber: data.trackNumber, + institution: institutionMapped, + school: data.school, + faculty: data.faculty, + studyProgram: data.studyProgram, + degree: data.degree, + graduationDate: data.graduationDate.toISOString(), + } +} + +export const mapToStudentTrackModel = ( + data: StudentTrackOverviewDto, + institution: InstitutionProps, +): StudentTrack | null => { + if ( + !data.transcript || + !data?.body?.description || + !data?.body?.footer || + !data?.body?.unconfirmedData + ) { + return null + } + + const transcript = mapToStudent(data.transcript, institution) + + if (!transcript) { + return null + } + + return { + transcript, + files: + data.files + ?.map((d) => { + if (!d.type || !d.locale || !d.displayName || !d.fileName) { + return null + } + + return { + type: d.type, + locale: d.locale, + displayName: d.displayName, + fileName: d.fileName, + } + }) + .filter(isDefined) ?? [], + metadata: { + description: data?.body?.description, + footer: data?.body?.footer, + unconfirmedData: data?.body?.unconfirmedData, + }, + } +} diff --git a/libs/api/domains/university-careers/src/lib/models/institution.model.ts b/libs/api/domains/university-careers/src/lib/models/institution.model.ts new file mode 100644 index 000000000000..f244087c285e --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/institution.model.ts @@ -0,0 +1,20 @@ +import { + UniversityId, + UniversityIdShort, +} from '@island.is/clients/university-careers' +import { ObjectType, Field } from '@nestjs/graphql' + +@ObjectType('UniversityCareersInstitution') +export class Institution { + @Field(() => UniversityId) + id!: UniversityId + + @Field(() => String) + shortId!: UniversityIdShort + + @Field(() => String, { nullable: true }) + displayName?: string + + @Field(() => String, { nullable: true }) + logoUrl?: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentFile.model.ts b/libs/api/domains/university-careers/src/lib/models/studentFile.model.ts new file mode 100644 index 000000000000..25ee567492ba --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentFile.model.ts @@ -0,0 +1,16 @@ +import { ObjectType, Field } from '@nestjs/graphql' + +@ObjectType('UniversityCareersStudentFile') +export class StudentFile { + @Field(() => String) + type!: string + + @Field(() => String) + locale!: string + + @Field(() => String) + displayName!: string + + @Field(() => String) + fileName!: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrack.model.ts b/libs/api/domains/university-careers/src/lib/models/studentTrack.model.ts new file mode 100644 index 000000000000..06e707c8bc92 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrack.model.ts @@ -0,0 +1,21 @@ +import { ObjectType, Field } from '@nestjs/graphql' +import { StudentTrackMetadata } from './studentTrackMetadata' +import { StudentFile } from './studentFile.model' +import { StudentTrackTranscript } from './studentTrackTranscript.model' + +@ObjectType('UniversityCareersStudentTrack') +export class StudentTrack { + @Field(() => StudentTrackTranscript) + transcript!: StudentTrackTranscript + + @Field(() => [StudentFile], { + description: 'Extra info about any available files for download', + }) + files!: StudentFile[] + + @Field(() => StudentTrackMetadata) + metadata!: StudentTrackMetadata + + @Field(() => String, { nullable: true }) + downloadServiceURL?: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrackHistory.model.ts b/libs/api/domains/university-careers/src/lib/models/studentTrackHistory.model.ts new file mode 100644 index 000000000000..93bd4968b8b8 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrackHistory.model.ts @@ -0,0 +1,8 @@ +import { Field, ObjectType } from '@nestjs/graphql' +import { StudentTrackTranscriptResult } from './studentTrackTranscriptResult.model' + +@ObjectType('UniversityCareersStudentTrackHistory') +export class StudentTrackHistory { + @Field(() => [StudentTrackTranscriptResult]) + trackResults!: Array +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrackMetadata.ts b/libs/api/domains/university-careers/src/lib/models/studentTrackMetadata.ts new file mode 100644 index 000000000000..eb41db8582c8 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrackMetadata.ts @@ -0,0 +1,13 @@ +import { ObjectType, Field } from '@nestjs/graphql' + +@ObjectType('UniversityCareersStudentTrackMetadata') +export class StudentTrackMetadata { + @Field(() => String) + description!: string + + @Field(() => String) + footer!: string + + @Field(() => String, { nullable: true }) + unconfirmedData?: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrackTranscript.model.ts b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscript.model.ts new file mode 100644 index 000000000000..468dd44118ad --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscript.model.ts @@ -0,0 +1,32 @@ +import { ObjectType, Field } from '@nestjs/graphql' +import { Institution } from './institution.model' + +@ObjectType('UniversityCareersStudentTrackTranscript') +export class StudentTrackTranscript { + @Field(() => String) + name!: string + + @Field(() => String, { nullable: true }) + nationalId?: string + + @Field(() => String) + graduationDate!: string + + @Field(() => Number) + trackNumber!: number + + @Field(() => Institution) + institution!: Institution + + @Field(() => String) + school!: string + + @Field(() => String) + faculty!: string + + @Field(() => String) + studyProgram!: string + + @Field(() => String) + degree!: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptError.model.ts b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptError.model.ts new file mode 100644 index 000000000000..af510322bee3 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptError.model.ts @@ -0,0 +1,11 @@ +import { UniversityId } from '@island.is/clients/university-careers' +import { Field, ObjectType } from '@nestjs/graphql' + +@ObjectType('UniversityCareersStudentTrackTranscriptError') +export class StudentTrackTranscriptError { + @Field(() => UniversityId) + university!: UniversityId + + @Field({ nullable: true, description: 'The error, raw' }) + error?: string +} diff --git a/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptResult.model.ts b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptResult.model.ts new file mode 100644 index 000000000000..f61f35f82895 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/models/studentTrackTranscriptResult.model.ts @@ -0,0 +1,18 @@ +import { createUnionType } from '@nestjs/graphql' +import { StudentTrackTranscript } from './studentTrackTranscript.model' +import { StudentTrackTranscriptError } from './studentTrackTranscriptError.model' + +export const StudentTrackTranscriptResult = createUnionType({ + name: 'UniversityCareersStudentTrackTranscriptResult', + types: () => [StudentTrackTranscript, StudentTrackTranscriptError] as const, + resolveType(value) { + if (value.error) { + return StudentTrackTranscriptError + } + if (value.trackNumber) { + return StudentTrackTranscript + } + + return null + }, +}) diff --git a/libs/api/domains/university-careers/src/lib/universityCareers.module.ts b/libs/api/domains/university-careers/src/lib/universityCareers.module.ts new file mode 100644 index 000000000000..d0a656140b96 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/universityCareers.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common' +import { UniversityCareersClientModule } from '@island.is/clients/university-careers' +import { UniversityCareersResolver } from './universityCareers.resolver' +import { CmsModule } from '@island.is/cms' +import { UniversityCareersService } from './universityCareers.service' +import { FeatureFlagModule } from '@island.is/nest/feature-flags' + +@Module({ + providers: [UniversityCareersResolver, UniversityCareersService], + imports: [UniversityCareersClientModule, CmsModule, FeatureFlagModule], +}) +export class UniversityCareersModule {} diff --git a/libs/api/domains/university-careers/src/lib/universityCareers.resolver.ts b/libs/api/domains/university-careers/src/lib/universityCareers.resolver.ts new file mode 100644 index 000000000000..497d0e39d122 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/universityCareers.resolver.ts @@ -0,0 +1,78 @@ +import { Args, Query, Resolver } from '@nestjs/graphql' +import { Inject, UseGuards } from '@nestjs/common' +import { Audit } from '@island.is/nest/audit' +import { + CurrentUser, + IdsUserGuard, + Scopes, + ScopesGuard, +} from '@island.is/auth-nest-tools' +import type { User } from '@island.is/auth-nest-tools' +import { ApiScope } from '@island.is/auth/scopes' +import { DownloadServiceConfig } from '@island.is/nest/config' +import type { ConfigType } from '@island.is/nest/config' +import { StudentInfoByUniversityInput } from './dto/studentInfoByUniversity.input' +import { Locale } from '@island.is/shared/types' +import { StudentTrack } from './models/studentTrack.model' +import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' +import { StudentInfoInput } from './dto/studentInfo.input' +import { UniversityCareersService } from './universityCareers.service' +import { StudentTrackHistory } from './models/studentTrackHistory.model' + +@UseGuards(IdsUserGuard, ScopesGuard) +@Scopes(ApiScope.internal) +@Resolver(() => StudentTrackHistory) +@Audit({ namespace: '@island.is/api/university-careers' }) +export class UniversityCareersResolver { + constructor( + private service: UniversityCareersService, + @Inject(DownloadServiceConfig.KEY) + private readonly downloadServiceConfig: ConfigType< + typeof DownloadServiceConfig + >, + @Inject(LOGGER_PROVIDER) private readonly logger: Logger, + ) {} + + @Query(() => StudentTrackHistory, { + name: 'universityCareersStudentTrackHistory', + }) + @Audit() + async studentTrackHistory( + @CurrentUser() user: User, + @Args('input') input: StudentInfoInput, + ): Promise { + return await this.service.getStudentTrackHistory( + user, + input.locale as Locale, + ) + } + + @Query(() => StudentTrack, { + name: 'universityCareersStudentTrack', + nullable: true, + }) + @Audit() + async studentTrack( + @Args('input') input: StudentInfoByUniversityInput, + @CurrentUser() user: User, + ): Promise { + if (!input.trackNumber) { + return null + } + const student = await this.service.getStudentTrack( + user, + input.universityId, + input.trackNumber, + input.locale as Locale, + ) + + if (!student) { + return null + } + + return { + ...student, + downloadServiceURL: `${this.downloadServiceConfig.baseUrl}/download/v1/education/graduation/`, + } + } +} diff --git a/libs/api/domains/university-careers/src/lib/universityCareers.service.ts b/libs/api/domains/university-careers/src/lib/universityCareers.service.ts new file mode 100644 index 000000000000..cde05c603d8f --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/universityCareers.service.ts @@ -0,0 +1,182 @@ +import { User } from '@island.is/auth-nest-tools' +import { FetchError } from '@island.is/clients/middlewares' +import { + StudentTrackDto, + UniversityCareersClientService, + UniversityId, +} from '@island.is/clients/university-careers' +import { CmsContentfulService } from '@island.is/cms' +import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' +import { FeatureFlagService, Features } from '@island.is/nest/feature-flags' +import { Locale } from '@island.is/shared/types' +import { isDefined } from '@island.is/shared/utils' +import { Inject, Injectable } from '@nestjs/common' +import { mapToStudent, mapToStudentTrackModel } from './mapper' +import { StudentTrack } from './models/studentTrack.model' +import { StudentTrackHistory } from './models/studentTrackHistory.model' +import { StudentTrackTranscript } from './models/studentTrackTranscript.model' +import { StudentTrackTranscriptError } from './models/studentTrackTranscriptError.model' +import { StudentTrackTranscriptResult } from './models/studentTrackTranscriptResult.model' +import { UniversityContentfulReferenceIds } from './universityCareers.types' +import { UniversityIdMap } from '@island.is/clients/university-careers' + +const LOG_CATEGORY = 'university-careers-api' +const FEATURE_FLAGS: Record, Features> = { + unak: Features.isUniversityOfAkureyriEnabled, + lbhi: Features.isAgriculturalUniversityOfIcelandEnabled, + bifrost: Features.isBifrostUniversityEnabled, + holar: Features.isHolarUniversityEnabled, +} + +@Injectable() +export class UniversityCareersService { + constructor( + private universityCareers: UniversityCareersClientService, + private readonly cmsContentfulService: CmsContentfulService, + private readonly featureFlagService: FeatureFlagService, + @Inject(LOGGER_PROVIDER) private readonly logger: Logger, + ) {} + + private getContentfulOrganizations = async (locale: Locale) => { + const universityIds = Object.values(UniversityId) + const referenceIds = universityIds.map( + (id) => UniversityContentfulReferenceIds[id], + ) + + //Get all organizations now -> fewer contentful calls + return this.cmsContentfulService.getOrganizations({ + lang: locale, + referenceIdentifiers: referenceIds, + }) + } + + async getStudentTrackHistory( + user: User, + locale: Locale, + ): Promise { + let normalizedResults: Array = [] + + const organizations = await this.getContentfulOrganizations(locale) + //parallel execution + await Promise.all( + Object.values(UniversityId).map(async (uni) => { + const org = organizations.items.find( + (o) => + o.referenceIdentifier === UniversityContentfulReferenceIds[uni], + ) + if (!org) { + this.logger.warning('Invalid institution for student track history', { + university: uni, + }) + normalizedResults.push({ + university: uni, + error: JSON.stringify(new Error('Invalid institution')), + }) + return + } + + const data = await this.getStudentTrackHistoryByUniversity( + user, + uni, + locale, + org.title, + org.logo?.url, + ) + + if (!data) { + this.logger.debug('No data found') + return + } + + if (Array.isArray(data)) { + normalizedResults = normalizedResults.concat(data) + } else { + normalizedResults.push(data) + } + }), + ) + + return { + trackResults: normalizedResults, + } + } + + async getStudentTrackHistoryByUniversity( + user: User, + university: UniversityId, + locale: Locale, + institutionTitle?: string, + institutionLogoUrl?: string, + ): Promise< + Array | StudentTrackTranscriptError | null + > { + // TODO: REMOVE FEATURE FLAG LOGIC WHEN FULLY TESTED + if (university !== 'hi') { + const isUniversityAllowed = await this.featureFlagService.getValue( + FEATURE_FLAGS[university], + false, + user, + ) + if (!isUniversityAllowed) { + return null + } + } + const data: Array | StudentTrackTranscriptError | null = + await this.universityCareers + .getStudentTrackHistory(user, university, locale) + .catch((e: Error | FetchError) => { + return { university, error: JSON.stringify(e) } + }) + + if (Array.isArray(data)) { + return data + .map((d) => + mapToStudent(d, { + id: university, + shortId: UniversityIdMap[university], + displayName: institutionTitle ?? '', + logoUrl: institutionLogoUrl, + }), + ) + .filter(isDefined) + } + + return data + } + + async getStudentTrack( + user: User, + university: UniversityId, + trackNumber: number, + locale: Locale, + ): Promise { + const data = await this.universityCareers.getStudentTrack( + user, + trackNumber, + university, + locale, + ) + + if (!data?.transcript) { + this.logger.debug('No transcript data found', { + category: LOG_CATEGORY, + university, + }) + return null + } + + const organization = + await this.cmsContentfulService.getOrganizationByReferenceId( + UniversityContentfulReferenceIds[university], + locale, + ) + return ( + mapToStudentTrackModel(data, { + id: university, + shortId: UniversityIdMap[university], + displayName: organization.title, + logoUrl: organization.logo?.url, + }) ?? null + ) + } +} diff --git a/libs/api/domains/university-careers/src/lib/universityCareers.types.ts b/libs/api/domains/university-careers/src/lib/universityCareers.types.ts new file mode 100644 index 000000000000..bb564e7b75b1 --- /dev/null +++ b/libs/api/domains/university-careers/src/lib/universityCareers.types.ts @@ -0,0 +1,19 @@ +import { + UniversityId, + UniversityIdShort, +} from '@island.is/clients/university-careers' + +export interface InstitutionProps { + id: UniversityId + shortId: UniversityIdShort + displayName: string + logoUrl?: string +} + +export const UniversityContentfulReferenceIds: Record = { + unak: '02210', + bifrost: 'bifrost-university', + holar: '17217', + lbhi: '17216', + hi: '17201', +} diff --git a/libs/api/domains/university-careers/tsconfig.json b/libs/api/domains/university-careers/tsconfig.json new file mode 100644 index 000000000000..4022fd4d0ad7 --- /dev/null +++ b/libs/api/domains/university-careers/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/api/domains/university-careers/tsconfig.lib.json b/libs/api/domains/university-careers/tsconfig.lib.json new file mode 100644 index 000000000000..e6b77320ab6a --- /dev/null +++ b/libs/api/domains/university-careers/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "declaration": true, + "types": ["node"], + "target": "es2021", + "strictNullChecks": true, + "noImplicitAny": true, + "strictBindCallApply": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/libs/api/domains/university-careers/tsconfig.spec.json b/libs/api/domains/university-careers/tsconfig.spec.json new file mode 100644 index 000000000000..6668655fc397 --- /dev/null +++ b/libs/api/domains/university-careers/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/libs/api/domains/university-of-iceland/.babelrc b/libs/api/domains/university-of-iceland/.babelrc deleted file mode 100644 index b63f0528f976..000000000000 --- a/libs/api/domains/university-of-iceland/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nrwl/js/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/api/domains/university-of-iceland/README.md b/libs/api/domains/university-of-iceland/README.md deleted file mode 100644 index 88a1839b5221..000000000000 --- a/libs/api/domains/university-of-iceland/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# API Domains University of Iceland - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test api-domains-university-of-iceland` to execute the unit tests via [Jest](https://jestjs.io). - -## Running lint - -Run `nx lint api-domains-university-of-iceland` to execute the lint via [ESLint](https://eslint.org/). diff --git a/libs/api/domains/university-of-iceland/jest.config.ts b/libs/api/domains/university-of-iceland/jest.config.ts deleted file mode 100644 index 569200f6d159..000000000000 --- a/libs/api/domains/university-of-iceland/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'api-domains-university-of-iceland', - preset: '../../../../jest.preset.js', - globals: {}, - testEnvironment: 'node', - transform: { - '^.+\\.[tj]sx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: - '../../../../coverage/libs/api/domains/university-of-iceland', -} diff --git a/libs/api/domains/university-of-iceland/project.json b/libs/api/domains/university-of-iceland/project.json deleted file mode 100644 index 30557be0d3ba..000000000000 --- a/libs/api/domains/university-of-iceland/project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "api-domains-university-of-iceland", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/api/domains/university-of-iceland/src", - "projectType": "library", - "targets": { - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/api/domains/university-of-iceland/**/*.ts"] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": [ - "{workspaceRoot}/coverage/libs/api/domains/university-of-iceland" - ], - "options": { - "jestConfig": "libs/api/domains/university-of-iceland/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": ["lib:api", "scope:api"] -} diff --git a/libs/api/domains/university-of-iceland/src/index.ts b/libs/api/domains/university-of-iceland/src/index.ts deleted file mode 100644 index f00aea34cd08..000000000000 --- a/libs/api/domains/university-of-iceland/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './lib/universityOfIceland.resolver' -export * from './lib/universityOfIceland.module' diff --git a/libs/api/domains/university-of-iceland/src/lib/dto/studentInfo.input.ts b/libs/api/domains/university-of-iceland/src/lib/dto/studentInfo.input.ts deleted file mode 100644 index d8421997f869..000000000000 --- a/libs/api/domains/university-of-iceland/src/lib/dto/studentInfo.input.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Field, InputType } from '@nestjs/graphql' -import { IsNumber, IsOptional, IsString } from 'class-validator' - -@InputType('UniversityOfIcelandStudentInfoInput') -export class StudentInfoInput { - @Field({ nullable: true }) - @IsNumber() - @IsOptional() - trackNumber?: number - - @Field() - @IsString() - locale!: string -} diff --git a/libs/api/domains/university-of-iceland/src/lib/models/studentInfo.model.ts b/libs/api/domains/university-of-iceland/src/lib/models/studentInfo.model.ts deleted file mode 100644 index 9cad288a2cae..000000000000 --- a/libs/api/domains/university-of-iceland/src/lib/models/studentInfo.model.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Field, ObjectType } from '@nestjs/graphql' - -@ObjectType('UniversityOfIcelandInstitution') -export class Institution { - @Field(() => String) - id!: string - - @Field(() => String) - displayName!: string -} -@ObjectType('UniversityOfIcelandStudentDescription') -export class StudentDescription { - @Field(() => String) - description!: string - - @Field(() => String) - footer!: string - - @Field(() => String, { nullable: true }) - unconfirmedData?: string -} - -@ObjectType('UniversityOfIcelandStudent') -export class Student { - @Field(() => String) - name!: string - - @Field(() => String, { nullable: true }) - nationalId?: string - - @Field(() => String) - graduationDate!: string - - @Field(() => Number) - trackNumber!: number - - @Field(() => Institution, { nullable: true }) - institution?: Institution - - @Field(() => String) - school!: string - - @Field(() => String) - faculty!: string - - @Field(() => String) - studyProgram!: string - - @Field(() => String) - degree!: string -} -@ObjectType('UniversityOfIcelandStudentTrack') -export class StudentTrackModel { - @Field(() => Student) - transcript!: Student - - @Field(() => [StudentFiles]) - files!: StudentFiles[] - - @Field(() => StudentDescription) - body!: StudentDescription - - @Field(() => String, { nullable: true }) - downloadServiceURL?: string -} - -@ObjectType('UniversityOfIcelandStudentInfo') -export class StudentInfo { - @Field(() => [Student], { nullable: true }) - transcripts?: Student[] - @Field(() => StudentTrackModel, { nullable: true }) - track?: StudentTrackModel -} -@ObjectType('UniversityOfIcelandStudentFiles') -export class StudentFiles { - @Field(() => String) - type!: string - - @Field(() => String) - locale!: string - - @Field(() => String) - displayName!: string - - @Field(() => String) - fileName!: string -} diff --git a/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.module.ts b/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.module.ts deleted file mode 100644 index 0f6bf10ca04e..000000000000 --- a/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common' -import { UniversityOfIcelandClientModule } from '@island.is/clients/university-of-iceland' -import { UniversityOfIcelandResolver } from './universityOfIceland.resolver' - -@Module({ - providers: [UniversityOfIcelandResolver], - imports: [UniversityOfIcelandClientModule], -}) -export class UniversityOfIcelandModule {} diff --git a/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.resolver.ts b/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.resolver.ts deleted file mode 100644 index 57662378e9a3..000000000000 --- a/libs/api/domains/university-of-iceland/src/lib/universityOfIceland.resolver.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { Args, Query, ResolveField, Resolver } from '@nestjs/graphql' - -import { Inject, UseGuards } from '@nestjs/common' -import { Audit } from '@island.is/nest/audit' - -import { - CurrentUser, - IdsUserGuard, - Scopes, - ScopesGuard, -} from '@island.is/auth-nest-tools' -import type { User } from '@island.is/auth-nest-tools' -import { - UniversityOfIcelandService, - NemandiGetLocaleEnum, - NemandiFerillFerillGetLocaleEnum, -} from '@island.is/clients/university-of-iceland' -import { ApiScope } from '@island.is/auth/scopes' -import { DownloadServiceConfig } from '@island.is/nest/config' -import type { ConfigType } from '@island.is/nest/config' -import { StudentInfoInput } from './dto/studentInfo.input' -import { - StudentInfo, - Student, - StudentTrackModel, -} from './models/studentInfo.model' - -@UseGuards(IdsUserGuard, ScopesGuard) -@Scopes(ApiScope.internal) -@Resolver(() => StudentInfo) -@Audit({ namespace: '@island.is/api/university-of-iceland' }) -export class UniversityOfIcelandResolver { - constructor( - private universityOfIcelandApi: UniversityOfIcelandService, - @Inject(DownloadServiceConfig.KEY) - private readonly downloadServiceConfig: ConfigType< - typeof DownloadServiceConfig - >, - ) {} - - @Query(() => StudentInfo, { - name: 'universityOfIcelandStudentInfo', - nullable: true, - }) - @Audit() - async studentInfo( - @CurrentUser() user: User, - @Args('input') input: StudentInfoInput, - ): Promise { - const data = await this.universityOfIcelandApi.studentInfo( - user, - input.locale as NemandiGetLocaleEnum, - ) - return { - transcripts: data?.transcripts as Array, - } - } - - @ResolveField('track', () => StudentTrackModel, { nullable: true }) - @Audit() - async resolveTrack( - @Args('input') input: StudentInfoInput, - @CurrentUser() user: User, - ): Promise { - if (!input.trackNumber) { - return null - } - const data = (await this.universityOfIcelandApi.studentCareer( - user, - input.trackNumber, - input.locale as NemandiFerillFerillGetLocaleEnum, - )) as StudentTrackModel - - if (!data || !data.transcript) { - return null - } - - const transcriptData = { - ...data.transcript, - graduationDate: data.transcript.graduationDate, - } - return { - transcript: transcriptData, - files: data.files, - body: data.body, - downloadServiceURL: `${this.downloadServiceConfig.baseUrl}/download/v1/education/graduation/`, - } - } -} diff --git a/libs/api/domains/university-of-iceland/tsconfig.json b/libs/api/domains/university-of-iceland/tsconfig.json deleted file mode 100644 index 26b7b4afd192..000000000000 --- a/libs/api/domains/university-of-iceland/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/api/domains/university-of-iceland/tsconfig.lib.json b/libs/api/domains/university-of-iceland/tsconfig.lib.json deleted file mode 100644 index 17fdb8a339a4..000000000000 --- a/libs/api/domains/university-of-iceland/tsconfig.lib.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/api/domains/university-of-iceland/tsconfig.spec.json b/libs/api/domains/university-of-iceland/tsconfig.spec.json deleted file mode 100644 index ef88b556acb9..000000000000 --- a/libs/api/domains/university-of-iceland/tsconfig.spec.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "**/*.test.ts", - "**/*.spec.ts", - "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts", - "jest.config.ts" - ] -} diff --git a/libs/clients/university-of-iceland/.eslintrc.json b/libs/clients/university-careers/.eslintrc.json similarity index 100% rename from libs/clients/university-of-iceland/.eslintrc.json rename to libs/clients/university-careers/.eslintrc.json diff --git a/libs/clients/university-careers/README.md b/libs/clients/university-careers/README.md new file mode 100644 index 000000000000..3ca5f3945bb4 --- /dev/null +++ b/libs/clients/university-careers/README.md @@ -0,0 +1,7 @@ +# clients-university-careers + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test clients-university-careers` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/clients/university-careers/jest.config.ts b/libs/clients/university-careers/jest.config.ts new file mode 100644 index 000000000000..9b8740dba7f6 --- /dev/null +++ b/libs/clients/university-careers/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'clients-university-careers', + preset: '../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../../coverage/libs/clients/university-careers', +} diff --git a/libs/clients/university-careers/project.json b/libs/clients/university-careers/project.json new file mode 100644 index 000000000000..93674067ed9c --- /dev/null +++ b/libs/clients/university-careers/project.json @@ -0,0 +1,62 @@ +{ + "name": "clients-university-careers", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/clients/university-careers/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/clients/university-careers/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/clients/university-careers/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "update-openapi-document": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "curl -H \"X-Road-Client: $XROAD_CLIENT_ID\" http://localhost:8081/r1/IS-DEV/EDU/10055/Holar-Protected/getOpenAPI?serviceCode=brautskraning-v1 > src/lib/clients/holar-university/clientConfig.yaml", + "curl -H \"X-Road-Client: $XROAD_CLIENT_ID\" http://localhost:8081/r1/IS-DEV/EDU/10056/LBHI-Protected/getOpenAPI?serviceCode=brautskraning-v1 > src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml", + "curl -H \"X-Road-Client: $XROAD_CLIENT_ID\" http://localhost:8081/r1/IS-DEV/EDU/10057/Bifrost-Protected/getOpenAPI?serviceCode=brautskraning-v1 > src/lib/clients/bifrost-university/clientConfig.yaml", + "curl -H \"X-Road-Client: $XROAD_CLIENT_ID\" http://localhost:8081/r1/IS-DEV/EDU/10010/HI-Protected/getOpenAPI?serviceCode=brautskraning-v1 > src/lib/clients/university-of-iceland/clientConfig.yaml", + "curl -H \"X-Road-Client: $XROAD_CLIENT_ID\" http://localhost:8081/r1/IS-DEV/EDU/10054/UNAK-Protected/getOpenAPI?serviceCode=brautskraning-v1 > src/lib/clients/university-of-akureyri/clientConfig.yaml", + "prettier --write src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml", + "prettier --write src/lib/clients/holar-university/clientConfig.yaml", + "prettier --write src/lib/clients/bifrost-university/clientConfig.yaml", + "prettier --write src/lib/clients/university-of-akureyri/clientConfig.yaml", + "prettier --write src/lib/clients/university-of-iceland/clientConfig.yaml" + ], + "parallel": false, + "cwd": "libs/clients/university-careers" + } + }, + "codegen/backend-client": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "yarn openapi-generator -o libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/gen/fetch -i libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml", + "yarn openapi-generator -o libs/clients/university-careers/src/lib/clients/holar-university/gen/fetch -i libs/clients/university-careers/src/lib/clients/holar-university/clientConfig.yaml", + "yarn openapi-generator -o libs/clients/university-careers/src/lib/clients/bifrost-university/gen/fetch -i libs/clients/university-careers/src/lib/clients/bifrost-university/clientConfig.yaml", + "yarn openapi-generator -o libs/clients/university-careers/src/lib/clients/university-of-akureyri/gen/fetch -i libs/clients/university-careers/src/lib/clients/university-of-akureyri/clientConfig.yaml", + "yarn openapi-generator -o libs/clients/university-careers/src/lib/clients/university-of-iceland/gen/fetch -i libs/clients/university-careers/src/lib/clients/university-of-iceland/clientConfig.yaml" + ] + }, + "outputs": ["{projectRoot}/gen/fetch"] + } + }, + "tags": ["lib:client", "scope:client"] +} diff --git a/libs/clients/university-careers/src/index.ts b/libs/clients/university-careers/src/index.ts new file mode 100644 index 000000000000..1dfa04dd1619 --- /dev/null +++ b/libs/clients/university-careers/src/index.ts @@ -0,0 +1,16 @@ +export * from './lib/universityCareers.module' +export * from './lib/universityCareers.service' +export { + UniversityId, + UniversityIdShort, + UniversityIdMap, + UniversityShortIdMap, +} from './lib/universityCareers.types' +export { + UniversityOfIcelandCareerClientConfig, + AgriculturalUniversityOfIcelandCareerClientConfig, + HolarUniversityCareerClientConfig, + BifrostUniversityCareerClientConfig, + UniversityOfAkureyriCareerClientConfig, +} from './lib/clients' +export * from './lib/dto' diff --git a/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.config.ts b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.config.ts new file mode 100644 index 000000000000..103815c77353 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.config.ts @@ -0,0 +1,8 @@ +import { clientConfigFactory } from '../../configFactory' + +export const AgriculturalUniversityOfIcelandCareerClientConfig = + clientConfigFactory( + 'AGRICULTURAL_UNIVERSITY_OF_ICELAND', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1', + ) diff --git a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.provider.ts b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.provider.ts similarity index 59% rename from libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.provider.ts rename to libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.provider.ts index 209fe65604b9..d7569e46843d 100644 --- a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.provider.ts +++ b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.provider.ts @@ -1,50 +1,49 @@ -import { Configuration, StudentTranscriptApi } from '../../gen/fetch' -import { Provider } from '@nestjs/common' +import { createEnhancedFetch } from '@island.is/clients/middlewares' import { ConfigType, - XRoadConfig, - LazyDuringDevScope, IdsClientConfig, + LazyDuringDevScope, + XRoadConfig, } from '@island.is/nest/config' -import { UniversityOfIcelandClientConfig } from './universityOfIcelandClient.config' -import { createEnhancedFetch } from '@island.is/clients/middlewares' +import { AgriculturalUniversityOfIcelandCareerClientConfig } from './agriculturalUniversityOfIcelandCareerClient.config' +import { Configuration, StudentTranscriptApi } from './gen/fetch' -export const UniversityOfIcelandApiProvider: Provider = { +export const AgriculturalUniversityOfIcelandCareerClientProvider = { provide: StudentTranscriptApi, scope: LazyDuringDevScope, useFactory: ( xroadConfig: ConfigType, - config: ConfigType, + config: ConfigType< + typeof AgriculturalUniversityOfIcelandCareerClientConfig + >, idsClientConfig: ConfigType, ) => new StudentTranscriptApi( new Configuration({ fetchApi: createEnhancedFetch({ + name: 'clients-university-careers-agricultural-university-of-iceland', + organizationSlug: 'landbunadarhaskoli-islands', logErrorResponseBody: true, - name: 'clients-university-of-iceland', - organizationSlug: 'haskoli-islands', - timeout: config.fetch.timeout, autoAuth: idsClientConfig.isConfigured ? { mode: 'tokenExchange', issuer: idsClientConfig.issuer, clientId: idsClientConfig.clientId, clientSecret: idsClientConfig.clientSecret, - scope: config.fetch.scope, + scope: config.scope, } : undefined, }), - basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xRoadServicePath}`, + basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xroadPath}`, headers: { 'X-Road-Client': xroadConfig.xRoadClient, Accept: 'application/json', - 'Content-Type': 'application/json', }, }), ), inject: [ XRoadConfig.KEY, - UniversityOfIcelandClientConfig.KEY, + AgriculturalUniversityOfIcelandCareerClientConfig.KEY, IdsClientConfig.KEY, ], } diff --git a/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.service.ts b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.service.ts new file mode 100644 index 000000000000..103815c77353 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.service.ts @@ -0,0 +1,8 @@ +import { clientConfigFactory } from '../../configFactory' + +export const AgriculturalUniversityOfIcelandCareerClientConfig = + clientConfigFactory( + 'AGRICULTURAL_UNIVERSITY_OF_ICELAND', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10056/LBHI-Protected/brautskraning-v1', + ) diff --git a/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml new file mode 100644 index 000000000000..c30664950245 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/clientConfig.yaml @@ -0,0 +1,203 @@ +--- +openapi: '3.0.3' +info: + title: 'Útskriftargögn nemenda' + version: '1.0.0' + contact: + email: 'help@hi.is' +servers: + - url: '/api/vottord/brautskraning' + - url: '/api/vottord/brautskraning' +paths: + /nemandi: + get: + summary: 'Listi yfir ferla sem nemandi hefur brauskrást af' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'transcripts' + properties: + transcripts: + type: 'array' + items: + $ref: '#/components/schemas/studentTrack' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: 'Nemandi hefur enga brautskráða ferla' + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}: + get: + summary: + "Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskrá\ + ningaryfirliti" + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'studentTrackOverview' + properties: + transcript: + type: 'object' + $ref: '#/components/schemas/studentTrack' + files: + type: 'array' + items: + $ref: '#/components/schemas/studentFile' + body: + type: 'object' + properties: + description: + type: 'string' + description: 'Texti fyrir ofan transcript' + example: 'Námsferilsyfirlit ekki til prentunar á pappír...' + footer: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Ef upplýsingar hér eru ekki réttar...' + unconfirmed_data: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Óstaðfest gögn hafið samband við...' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}/file/transcript: + get: + summary: 'Skilar útskriftargögnum á pdf formi' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'PDF skjal' + content: + application/pdf: + schema: + type: 'string' + format: 'binary' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' +components: + schemas: + studentTrack: + type: 'object' + properties: + name: + type: 'string' + description: 'Fullt nafn leyfisbréfshafa' + example: 'Gervimaður Finnland' + nationalId: + type: 'string' + description: 'National ID number' + example: '0101302209' + graduationDate: + type: 'string' + description: 'ISO 8601 date' + example: '2021-11-24' + trackNumber: + type: 'integer' + description: 'Númer á feril nemenda, hlaupdandi tala frá 1' + example: 4 + institution: + type: 'object' + properties: + id: + type: 'string' + example: 'hi' + displayName: + type: 'string' + example: 'Háskóli Íslands' + school: + type: 'string' + description: 'Svið sem nemandi er skráður á ferlinum' + example: 'Félagsvísindasvið' + faculty: + type: 'string' + description: 'Deild sem er skráð á ferilinn' + example: 'Lagadeild' + studyProgram: + type: 'string' + description: 'Námsleið sem nemandinn er skráð á ferilinn' + example: 'Lögfræði' + programId: + type: 'string' + description: '6 stafa ID á námsleið' + example: '123456' + degree: + type: 'string' + description: 'Námsgráða' + example: 'BA' + studentFile: + type: 'object' + properties: + type: + type: 'string' + description: 'TODO' + example: 'transcript' + locale: + type: 'string' + description: 'Tungumál fyrir file' + example: 'is' + displayName: + type: 'string' + description: 'TODO' + example: 'Námsferilsyfirlit með brautskráningu' + fileName: + type: 'string' + description: 'TODO' + example: 'utskriftaryfirlit-0101302209.pdf' + parameters: + locale: + name: 'locale' + in: 'query' + schema: + type: 'string' + enum: + - 'is' + - 'en' + default: 'is' + ferill: + in: 'path' + name: 'ferill' + schema: + type: 'integer' + required: true + description: 'Ferilsnúmer nemenda' + securitySchemes: + bearerAuth: + type: 'http' + scheme: 'bearer' + bearerFormat: 'JWT' +security: + - bearerAuth: [] diff --git a/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/index.ts b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/index.ts new file mode 100644 index 000000000000..ceb2cfa97f68 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/agricultural-university-of-iceland/index.ts @@ -0,0 +1,7 @@ +export { StudentTranscriptApi as LbhiApi } from './gen/fetch' +export { StudentTrackInstitution as LbhiStudentTrackInstitution } from './gen/fetch' +export { StudentTrack as LbhiStudentTrack } from './gen/fetch' +export { NemandiGetLocaleEnum as LbhiLocale } from './gen/fetch' +export { NemandiFerillFerillFileTranscriptGetLocaleEnum as LbhiTranscriptLocale } from './gen/fetch' +export { NemandiFerillFerillGetLocaleEnum as LbhiFerillLocale } from './gen/fetch' +export * from './agriculturalUniversityOfIcelandCareerClient.config' diff --git a/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.config.ts b/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.config.ts new file mode 100644 index 000000000000..b5bedafa1f3a --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.config.ts @@ -0,0 +1,7 @@ +import { clientConfigFactory } from '../../configFactory' + +export const BifrostUniversityCareerClientConfig = clientConfigFactory( + 'BIFROST_UNIVERSITY', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10057/Bifrost-Protected/brautskraning-v1', +) diff --git a/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.provider.ts b/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.provider.ts new file mode 100644 index 000000000000..7506e21290f2 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/bifrost-university/bifrostUniversityCareerClient.provider.ts @@ -0,0 +1,47 @@ +import { createEnhancedFetch } from '@island.is/clients/middlewares' +import { + ConfigType, + IdsClientConfig, + LazyDuringDevScope, + XRoadConfig, +} from '@island.is/nest/config' +import { BifrostUniversityCareerClientConfig } from './bifrostUniversityCareerClient.config' +import { Configuration, StudentTranscriptApi } from './gen/fetch' + +export const BifrostUniversityCareerClientProvider = { + provide: StudentTranscriptApi, + scope: LazyDuringDevScope, + useFactory: ( + xroadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => + new StudentTranscriptApi( + new Configuration({ + fetchApi: createEnhancedFetch({ + name: 'clients-university-careers-bifrost-university', + organizationSlug: 'bifrost', + logErrorResponseBody: true, + autoAuth: idsClientConfig.isConfigured + ? { + mode: 'tokenExchange', + issuer: idsClientConfig.issuer, + clientId: idsClientConfig.clientId, + clientSecret: idsClientConfig.clientSecret, + scope: config.scope, + } + : undefined, + }), + basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xroadPath}`, + headers: { + 'X-Road-Client': xroadConfig.xRoadClient, + Accept: 'application/json', + }, + }), + ), + inject: [ + XRoadConfig.KEY, + BifrostUniversityCareerClientConfig.KEY, + IdsClientConfig.KEY, + ], +} diff --git a/libs/clients/university-careers/src/lib/clients/bifrost-university/clientConfig.yaml b/libs/clients/university-careers/src/lib/clients/bifrost-university/clientConfig.yaml new file mode 100644 index 000000000000..c30664950245 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/bifrost-university/clientConfig.yaml @@ -0,0 +1,203 @@ +--- +openapi: '3.0.3' +info: + title: 'Útskriftargögn nemenda' + version: '1.0.0' + contact: + email: 'help@hi.is' +servers: + - url: '/api/vottord/brautskraning' + - url: '/api/vottord/brautskraning' +paths: + /nemandi: + get: + summary: 'Listi yfir ferla sem nemandi hefur brauskrást af' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'transcripts' + properties: + transcripts: + type: 'array' + items: + $ref: '#/components/schemas/studentTrack' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: 'Nemandi hefur enga brautskráða ferla' + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}: + get: + summary: + "Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskrá\ + ningaryfirliti" + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'studentTrackOverview' + properties: + transcript: + type: 'object' + $ref: '#/components/schemas/studentTrack' + files: + type: 'array' + items: + $ref: '#/components/schemas/studentFile' + body: + type: 'object' + properties: + description: + type: 'string' + description: 'Texti fyrir ofan transcript' + example: 'Námsferilsyfirlit ekki til prentunar á pappír...' + footer: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Ef upplýsingar hér eru ekki réttar...' + unconfirmed_data: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Óstaðfest gögn hafið samband við...' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}/file/transcript: + get: + summary: 'Skilar útskriftargögnum á pdf formi' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'PDF skjal' + content: + application/pdf: + schema: + type: 'string' + format: 'binary' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' +components: + schemas: + studentTrack: + type: 'object' + properties: + name: + type: 'string' + description: 'Fullt nafn leyfisbréfshafa' + example: 'Gervimaður Finnland' + nationalId: + type: 'string' + description: 'National ID number' + example: '0101302209' + graduationDate: + type: 'string' + description: 'ISO 8601 date' + example: '2021-11-24' + trackNumber: + type: 'integer' + description: 'Númer á feril nemenda, hlaupdandi tala frá 1' + example: 4 + institution: + type: 'object' + properties: + id: + type: 'string' + example: 'hi' + displayName: + type: 'string' + example: 'Háskóli Íslands' + school: + type: 'string' + description: 'Svið sem nemandi er skráður á ferlinum' + example: 'Félagsvísindasvið' + faculty: + type: 'string' + description: 'Deild sem er skráð á ferilinn' + example: 'Lagadeild' + studyProgram: + type: 'string' + description: 'Námsleið sem nemandinn er skráð á ferilinn' + example: 'Lögfræði' + programId: + type: 'string' + description: '6 stafa ID á námsleið' + example: '123456' + degree: + type: 'string' + description: 'Námsgráða' + example: 'BA' + studentFile: + type: 'object' + properties: + type: + type: 'string' + description: 'TODO' + example: 'transcript' + locale: + type: 'string' + description: 'Tungumál fyrir file' + example: 'is' + displayName: + type: 'string' + description: 'TODO' + example: 'Námsferilsyfirlit með brautskráningu' + fileName: + type: 'string' + description: 'TODO' + example: 'utskriftaryfirlit-0101302209.pdf' + parameters: + locale: + name: 'locale' + in: 'query' + schema: + type: 'string' + enum: + - 'is' + - 'en' + default: 'is' + ferill: + in: 'path' + name: 'ferill' + schema: + type: 'integer' + required: true + description: 'Ferilsnúmer nemenda' + securitySchemes: + bearerAuth: + type: 'http' + scheme: 'bearer' + bearerFormat: 'JWT' +security: + - bearerAuth: [] diff --git a/libs/clients/university-careers/src/lib/clients/bifrost-university/index.ts b/libs/clients/university-careers/src/lib/clients/bifrost-university/index.ts new file mode 100644 index 000000000000..c09480451b27 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/bifrost-university/index.ts @@ -0,0 +1,7 @@ +export { StudentTranscriptApi as BifrostApi } from './gen/fetch' +export { StudentTrackInstitution as BifrostStudentTrackInstitution } from './gen/fetch' +export { StudentTrack as BifrostStudentTrack } from './gen/fetch' +export { NemandiGetLocaleEnum as BifrostLocale } from './gen/fetch' +export { NemandiFerillFerillFileTranscriptGetLocaleEnum as BifrostTranscriptLocale } from './gen/fetch' +export { NemandiFerillFerillGetLocaleEnum as BifrostFerillLocale } from './gen/fetch' +export * from './bifrostUniversityCareerClient.config' diff --git a/libs/clients/university-careers/src/lib/clients/holar-university/clientConfig.yaml b/libs/clients/university-careers/src/lib/clients/holar-university/clientConfig.yaml new file mode 100644 index 000000000000..c30664950245 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/holar-university/clientConfig.yaml @@ -0,0 +1,203 @@ +--- +openapi: '3.0.3' +info: + title: 'Útskriftargögn nemenda' + version: '1.0.0' + contact: + email: 'help@hi.is' +servers: + - url: '/api/vottord/brautskraning' + - url: '/api/vottord/brautskraning' +paths: + /nemandi: + get: + summary: 'Listi yfir ferla sem nemandi hefur brauskrást af' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'transcripts' + properties: + transcripts: + type: 'array' + items: + $ref: '#/components/schemas/studentTrack' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: 'Nemandi hefur enga brautskráða ferla' + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}: + get: + summary: + "Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskrá\ + ningaryfirliti" + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'studentTrackOverview' + properties: + transcript: + type: 'object' + $ref: '#/components/schemas/studentTrack' + files: + type: 'array' + items: + $ref: '#/components/schemas/studentFile' + body: + type: 'object' + properties: + description: + type: 'string' + description: 'Texti fyrir ofan transcript' + example: 'Námsferilsyfirlit ekki til prentunar á pappír...' + footer: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Ef upplýsingar hér eru ekki réttar...' + unconfirmed_data: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Óstaðfest gögn hafið samband við...' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}/file/transcript: + get: + summary: 'Skilar útskriftargögnum á pdf formi' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'PDF skjal' + content: + application/pdf: + schema: + type: 'string' + format: 'binary' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' +components: + schemas: + studentTrack: + type: 'object' + properties: + name: + type: 'string' + description: 'Fullt nafn leyfisbréfshafa' + example: 'Gervimaður Finnland' + nationalId: + type: 'string' + description: 'National ID number' + example: '0101302209' + graduationDate: + type: 'string' + description: 'ISO 8601 date' + example: '2021-11-24' + trackNumber: + type: 'integer' + description: 'Númer á feril nemenda, hlaupdandi tala frá 1' + example: 4 + institution: + type: 'object' + properties: + id: + type: 'string' + example: 'hi' + displayName: + type: 'string' + example: 'Háskóli Íslands' + school: + type: 'string' + description: 'Svið sem nemandi er skráður á ferlinum' + example: 'Félagsvísindasvið' + faculty: + type: 'string' + description: 'Deild sem er skráð á ferilinn' + example: 'Lagadeild' + studyProgram: + type: 'string' + description: 'Námsleið sem nemandinn er skráð á ferilinn' + example: 'Lögfræði' + programId: + type: 'string' + description: '6 stafa ID á námsleið' + example: '123456' + degree: + type: 'string' + description: 'Námsgráða' + example: 'BA' + studentFile: + type: 'object' + properties: + type: + type: 'string' + description: 'TODO' + example: 'transcript' + locale: + type: 'string' + description: 'Tungumál fyrir file' + example: 'is' + displayName: + type: 'string' + description: 'TODO' + example: 'Námsferilsyfirlit með brautskráningu' + fileName: + type: 'string' + description: 'TODO' + example: 'utskriftaryfirlit-0101302209.pdf' + parameters: + locale: + name: 'locale' + in: 'query' + schema: + type: 'string' + enum: + - 'is' + - 'en' + default: 'is' + ferill: + in: 'path' + name: 'ferill' + schema: + type: 'integer' + required: true + description: 'Ferilsnúmer nemenda' + securitySchemes: + bearerAuth: + type: 'http' + scheme: 'bearer' + bearerFormat: 'JWT' +security: + - bearerAuth: [] diff --git a/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.config.ts b/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.config.ts new file mode 100644 index 000000000000..36be95344f7b --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.config.ts @@ -0,0 +1,7 @@ +import { clientConfigFactory } from '../../configFactory' + +export const HolarUniversityCareerClientConfig = clientConfigFactory( + 'HOLAR_UNIVERSITY', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1', +) diff --git a/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.provider.ts b/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.provider.ts new file mode 100644 index 000000000000..b1dc7d289d99 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/holar-university/holarUniversityCareerClient.provider.ts @@ -0,0 +1,47 @@ +import { createEnhancedFetch } from '@island.is/clients/middlewares' +import { + ConfigType, + IdsClientConfig, + LazyDuringDevScope, + XRoadConfig, +} from '@island.is/nest/config' +import { HolarUniversityCareerClientConfig } from './holarUniversityCareerClient.config' +import { Configuration, StudentTranscriptApi } from './gen/fetch' + +export const HolarUniversityCareerClientProvider = { + provide: StudentTranscriptApi, + scope: LazyDuringDevScope, + useFactory: ( + xroadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => + new StudentTranscriptApi( + new Configuration({ + fetchApi: createEnhancedFetch({ + name: 'clients-university-careers-holar-university', + organizationSlug: 'holaskoli-haskolinn-a-holum', + logErrorResponseBody: true, + autoAuth: idsClientConfig.isConfigured + ? { + mode: 'tokenExchange', + issuer: idsClientConfig.issuer, + clientId: idsClientConfig.clientId, + clientSecret: idsClientConfig.clientSecret, + scope: config.scope, + } + : undefined, + }), + basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xroadPath}`, + headers: { + 'X-Road-Client': xroadConfig.xRoadClient, + Accept: 'application/json', + }, + }), + ), + inject: [ + XRoadConfig.KEY, + HolarUniversityCareerClientConfig.KEY, + IdsClientConfig.KEY, + ], +} diff --git a/libs/clients/university-careers/src/lib/clients/holar-university/index.ts b/libs/clients/university-careers/src/lib/clients/holar-university/index.ts new file mode 100644 index 000000000000..faa7bf5c8f0b --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/holar-university/index.ts @@ -0,0 +1,7 @@ +export { StudentTranscriptApi as HolarApi } from './gen/fetch' +export { StudentTrackInstitution as HolarStudentTrackInstitution } from './gen/fetch' +export { StudentTrack as HolarStudentTrack } from './gen/fetch' +export { NemandiGetLocaleEnum as HolarLocale } from './gen/fetch' +export { NemandiFerillFerillFileTranscriptGetLocaleEnum as HolarTranscriptLocale } from './gen/fetch' +export { NemandiFerillFerillGetLocaleEnum as HolarFerillLocale } from './gen/fetch' +export * from './holarUniversityCareerClient.config' diff --git a/libs/clients/university-careers/src/lib/clients/index.ts b/libs/clients/university-careers/src/lib/clients/index.ts new file mode 100644 index 000000000000..f085e1bbc6c9 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/index.ts @@ -0,0 +1,5 @@ +export * from './bifrost-university' +export * from './holar-university' +export * from './agricultural-university-of-iceland' +export * from './university-of-akureyri' +export * from './university-of-iceland' diff --git a/libs/clients/university-careers/src/lib/clients/university-of-akureyri/clientConfig.yaml b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/clientConfig.yaml new file mode 100644 index 000000000000..c30664950245 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/clientConfig.yaml @@ -0,0 +1,203 @@ +--- +openapi: '3.0.3' +info: + title: 'Útskriftargögn nemenda' + version: '1.0.0' + contact: + email: 'help@hi.is' +servers: + - url: '/api/vottord/brautskraning' + - url: '/api/vottord/brautskraning' +paths: + /nemandi: + get: + summary: 'Listi yfir ferla sem nemandi hefur brauskrást af' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'transcripts' + properties: + transcripts: + type: 'array' + items: + $ref: '#/components/schemas/studentTrack' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: 'Nemandi hefur enga brautskráða ferla' + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}: + get: + summary: + "Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskrá\ + ningaryfirliti" + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'studentTrackOverview' + properties: + transcript: + type: 'object' + $ref: '#/components/schemas/studentTrack' + files: + type: 'array' + items: + $ref: '#/components/schemas/studentFile' + body: + type: 'object' + properties: + description: + type: 'string' + description: 'Texti fyrir ofan transcript' + example: 'Námsferilsyfirlit ekki til prentunar á pappír...' + footer: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Ef upplýsingar hér eru ekki réttar...' + unconfirmed_data: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Óstaðfest gögn hafið samband við...' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}/file/transcript: + get: + summary: 'Skilar útskriftargögnum á pdf formi' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'PDF skjal' + content: + application/pdf: + schema: + type: 'string' + format: 'binary' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' +components: + schemas: + studentTrack: + type: 'object' + properties: + name: + type: 'string' + description: 'Fullt nafn leyfisbréfshafa' + example: 'Gervimaður Finnland' + nationalId: + type: 'string' + description: 'National ID number' + example: '0101302209' + graduationDate: + type: 'string' + description: 'ISO 8601 date' + example: '2021-11-24' + trackNumber: + type: 'integer' + description: 'Númer á feril nemenda, hlaupdandi tala frá 1' + example: 4 + institution: + type: 'object' + properties: + id: + type: 'string' + example: 'hi' + displayName: + type: 'string' + example: 'Háskóli Íslands' + school: + type: 'string' + description: 'Svið sem nemandi er skráður á ferlinum' + example: 'Félagsvísindasvið' + faculty: + type: 'string' + description: 'Deild sem er skráð á ferilinn' + example: 'Lagadeild' + studyProgram: + type: 'string' + description: 'Námsleið sem nemandinn er skráð á ferilinn' + example: 'Lögfræði' + programId: + type: 'string' + description: '6 stafa ID á námsleið' + example: '123456' + degree: + type: 'string' + description: 'Námsgráða' + example: 'BA' + studentFile: + type: 'object' + properties: + type: + type: 'string' + description: 'TODO' + example: 'transcript' + locale: + type: 'string' + description: 'Tungumál fyrir file' + example: 'is' + displayName: + type: 'string' + description: 'TODO' + example: 'Námsferilsyfirlit með brautskráningu' + fileName: + type: 'string' + description: 'TODO' + example: 'utskriftaryfirlit-0101302209.pdf' + parameters: + locale: + name: 'locale' + in: 'query' + schema: + type: 'string' + enum: + - 'is' + - 'en' + default: 'is' + ferill: + in: 'path' + name: 'ferill' + schema: + type: 'integer' + required: true + description: 'Ferilsnúmer nemenda' + securitySchemes: + bearerAuth: + type: 'http' + scheme: 'bearer' + bearerFormat: 'JWT' +security: + - bearerAuth: [] diff --git a/libs/clients/university-careers/src/lib/clients/university-of-akureyri/index.ts b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/index.ts new file mode 100644 index 000000000000..c719ad501723 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/index.ts @@ -0,0 +1,7 @@ +export { StudentTranscriptApi as UnakApi } from './gen/fetch' +export { StudentTrackInstitution as UnakStudentTrackInstitution } from './gen/fetch' +export { StudentTrack as UnakStudentTrack } from './gen/fetch' +export { NemandiGetLocaleEnum as UnakLocale } from './gen/fetch' +export { NemandiFerillFerillFileTranscriptGetLocaleEnum as UnakTranscriptLocale } from './gen/fetch' +export { NemandiFerillFerillGetLocaleEnum as UnakFerillLocale } from './gen/fetch' +export * from './universityOfAkureyriCareerClient.config' diff --git a/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.config.ts b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.config.ts new file mode 100644 index 000000000000..85481c48950d --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.config.ts @@ -0,0 +1,7 @@ +import { clientConfigFactory } from '../../configFactory' + +export const UniversityOfAkureyriCareerClientConfig = clientConfigFactory( + 'UNIVERSITY_OF_AKUREYRI', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10054/UNAK-Protected/brautskraning-v1', +) diff --git a/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.provider.ts b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.provider.ts new file mode 100644 index 000000000000..4f795b4eb2bc --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-akureyri/universityOfAkureyriCareerClient.provider.ts @@ -0,0 +1,50 @@ +import { Configuration, StudentTranscriptApi } from './gen/fetch' +import { Provider } from '@nestjs/common' +import { UniversityOfAkureyriCareerClientConfig } from './universityOfAkureyriCareerClient.config' +import { + ConfigType, + XRoadConfig, + LazyDuringDevScope, + IdsClientConfig, +} from '@island.is/nest/config' +import { createEnhancedFetch } from '@island.is/clients/middlewares' + +export const UniversityOfAkureyriCareerClientProvider: Provider = + { + provide: StudentTranscriptApi, + scope: LazyDuringDevScope, + useFactory: ( + xroadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => + new StudentTranscriptApi( + new Configuration({ + fetchApi: createEnhancedFetch({ + logErrorResponseBody: true, + name: 'clients-university-careers-university-of-akureyri', + organizationSlug: 'haskolinn-a-akureyri', + autoAuth: idsClientConfig.isConfigured + ? { + mode: 'tokenExchange', + issuer: idsClientConfig.issuer, + clientId: idsClientConfig.clientId, + clientSecret: idsClientConfig.clientSecret, + scope: config.scope, + } + : undefined, + }), + basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xroadPath}`, + headers: { + 'X-Road-Client': xroadConfig.xRoadClient, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + }), + ), + inject: [ + XRoadConfig.KEY, + UniversityOfAkureyriCareerClientConfig.KEY, + IdsClientConfig.KEY, + ], + } diff --git a/libs/clients/university-careers/src/lib/clients/university-of-iceland/clientConfig.yaml b/libs/clients/university-careers/src/lib/clients/university-of-iceland/clientConfig.yaml new file mode 100644 index 000000000000..c30664950245 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-iceland/clientConfig.yaml @@ -0,0 +1,203 @@ +--- +openapi: '3.0.3' +info: + title: 'Útskriftargögn nemenda' + version: '1.0.0' + contact: + email: 'help@hi.is' +servers: + - url: '/api/vottord/brautskraning' + - url: '/api/vottord/brautskraning' +paths: + /nemandi: + get: + summary: 'Listi yfir ferla sem nemandi hefur brauskrást af' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'transcripts' + properties: + transcripts: + type: 'array' + items: + $ref: '#/components/schemas/studentTrack' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: 'Nemandi hefur enga brautskráða ferla' + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}: + get: + summary: + "Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskrá\ + ningaryfirliti" + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'Skilar lista af ferlum sem nemandi hefur útskrifast af' + content: + application/json: + schema: + type: 'object' + title: 'studentTrackOverview' + properties: + transcript: + type: 'object' + $ref: '#/components/schemas/studentTrack' + files: + type: 'array' + items: + $ref: '#/components/schemas/studentFile' + body: + type: 'object' + properties: + description: + type: 'string' + description: 'Texti fyrir ofan transcript' + example: 'Námsferilsyfirlit ekki til prentunar á pappír...' + footer: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Ef upplýsingar hér eru ekki réttar...' + unconfirmed_data: + type: 'string' + description: 'Texti fyrir neðan transcript' + example: 'Óstaðfest gögn hafið samband við...' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' + /nemandi/ferill/{ferill}/file/transcript: + get: + summary: 'Skilar útskriftargögnum á pdf formi' + tags: + - 'studentTranscript' + parameters: + - $ref: '#/components/parameters/ferill' + - $ref: '#/components/parameters/locale' + responses: + '200': + description: 'PDF skjal' + content: + application/pdf: + schema: + type: 'string' + format: 'binary' + '400': + description: 'Bad request. Invalid kennitala' + '404': + description: + "Nemandi hefur enga brautskráða ferla, ferill ekki til, er\ + \ ekki brautskráður fyrir feril." + '5XX': + description: 'Unexpected error.' +components: + schemas: + studentTrack: + type: 'object' + properties: + name: + type: 'string' + description: 'Fullt nafn leyfisbréfshafa' + example: 'Gervimaður Finnland' + nationalId: + type: 'string' + description: 'National ID number' + example: '0101302209' + graduationDate: + type: 'string' + description: 'ISO 8601 date' + example: '2021-11-24' + trackNumber: + type: 'integer' + description: 'Númer á feril nemenda, hlaupdandi tala frá 1' + example: 4 + institution: + type: 'object' + properties: + id: + type: 'string' + example: 'hi' + displayName: + type: 'string' + example: 'Háskóli Íslands' + school: + type: 'string' + description: 'Svið sem nemandi er skráður á ferlinum' + example: 'Félagsvísindasvið' + faculty: + type: 'string' + description: 'Deild sem er skráð á ferilinn' + example: 'Lagadeild' + studyProgram: + type: 'string' + description: 'Námsleið sem nemandinn er skráð á ferilinn' + example: 'Lögfræði' + programId: + type: 'string' + description: '6 stafa ID á námsleið' + example: '123456' + degree: + type: 'string' + description: 'Námsgráða' + example: 'BA' + studentFile: + type: 'object' + properties: + type: + type: 'string' + description: 'TODO' + example: 'transcript' + locale: + type: 'string' + description: 'Tungumál fyrir file' + example: 'is' + displayName: + type: 'string' + description: 'TODO' + example: 'Námsferilsyfirlit með brautskráningu' + fileName: + type: 'string' + description: 'TODO' + example: 'utskriftaryfirlit-0101302209.pdf' + parameters: + locale: + name: 'locale' + in: 'query' + schema: + type: 'string' + enum: + - 'is' + - 'en' + default: 'is' + ferill: + in: 'path' + name: 'ferill' + schema: + type: 'integer' + required: true + description: 'Ferilsnúmer nemenda' + securitySchemes: + bearerAuth: + type: 'http' + scheme: 'bearer' + bearerFormat: 'JWT' +security: + - bearerAuth: [] diff --git a/libs/clients/university-careers/src/lib/clients/university-of-iceland/index.ts b/libs/clients/university-careers/src/lib/clients/university-of-iceland/index.ts new file mode 100644 index 000000000000..e11d47298b6c --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-iceland/index.ts @@ -0,0 +1,7 @@ +export { StudentTranscriptApi as HIApi } from './gen/fetch' +export { StudentTrack as HIStudentTrack } from './gen/fetch' +export { StudentTrackInstitution as HIStudentTrackInstitution } from './gen/fetch' +export { NemandiGetLocaleEnum as HILocale } from './gen/fetch' +export { NemandiFerillFerillFileTranscriptGetLocaleEnum as HITranscriptLocale } from './gen/fetch' +export { NemandiFerillFerillGetLocaleEnum as HIFerillLocale } from './gen/fetch' +export * from './universityOfIcelandCareerClient.config' diff --git a/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.config.ts b/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.config.ts new file mode 100644 index 000000000000..ae6f0bb2fdf2 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.config.ts @@ -0,0 +1,7 @@ +import { clientConfigFactory } from '../../configFactory' + +export const UniversityOfIcelandCareerClientConfig = clientConfigFactory( + 'UNIVERSITY_OF_ICELAND', + ['@hi.is/brautskraningar'], + 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1', +) diff --git a/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.provider.ts b/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.provider.ts new file mode 100644 index 000000000000..9c2bbdcba7a8 --- /dev/null +++ b/libs/clients/university-careers/src/lib/clients/university-of-iceland/universityOfIcelandCareerClient.provider.ts @@ -0,0 +1,50 @@ +import { Configuration, StudentTranscriptApi } from './gen/fetch' +import { Provider } from '@nestjs/common' +import { UniversityOfIcelandCareerClientConfig } from './universityOfIcelandCareerClient.config' +import { + ConfigType, + XRoadConfig, + LazyDuringDevScope, + IdsClientConfig, +} from '@island.is/nest/config' +import { createEnhancedFetch } from '@island.is/clients/middlewares' + +export const UniversityOfIcelandCareerClientProvider: Provider = + { + provide: StudentTranscriptApi, + scope: LazyDuringDevScope, + useFactory: ( + xroadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => + new StudentTranscriptApi( + new Configuration({ + fetchApi: createEnhancedFetch({ + logErrorResponseBody: true, + name: 'clients-university-careers-university-of-iceland', + organizationSlug: 'haskoli-islands', + autoAuth: idsClientConfig.isConfigured + ? { + mode: 'tokenExchange', + issuer: idsClientConfig.issuer, + clientId: idsClientConfig.clientId, + clientSecret: idsClientConfig.clientSecret, + scope: config.scope, + } + : undefined, + }), + basePath: `${xroadConfig.xRoadBasePath}/r1/${config.xroadPath}`, + headers: { + 'X-Road-Client': xroadConfig.xRoadClient, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + }), + ), + inject: [ + XRoadConfig.KEY, + UniversityOfIcelandCareerClientConfig.KEY, + IdsClientConfig.KEY, + ], + } diff --git a/libs/clients/university-careers/src/lib/configFactory.ts b/libs/clients/university-careers/src/lib/configFactory.ts new file mode 100644 index 000000000000..52d1b80aa524 --- /dev/null +++ b/libs/clients/university-careers/src/lib/configFactory.ts @@ -0,0 +1,22 @@ +import { defineConfig } from '@island.is/nest/config' +import * as z from 'zod' +import { UniversityId } from './universityCareers.types' + +const schema = z.object({ + xroadPath: z.string(), + scope: z.array(z.string()), +}) + +export const clientConfigFactory = ( + universityIndex: keyof typeof UniversityId, + scope: Array, + backupXRoad?: string, +) => + defineConfig>({ + name: `${UniversityId[universityIndex]}CareerClientConfig`, + schema, + load: (env) => ({ + xroadPath: env.required(`XROAD_${universityIndex}_PATH`, backupXRoad), + scope, + }), + }) diff --git a/libs/clients/university-careers/src/lib/dto/index.ts b/libs/clients/university-careers/src/lib/dto/index.ts new file mode 100644 index 000000000000..1b554446f011 --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/index.ts @@ -0,0 +1,3 @@ +export { StudentTrackDto } from './studentTrackDto' +export { StudentTrackOverviewBodyDto } from './studentTrackOverviewBodyDto' +export { StudentTrackOverviewDto } from './studentTrackOverviewDto' diff --git a/libs/clients/university-careers/src/lib/dto/studentFileDto.ts b/libs/clients/university-careers/src/lib/dto/studentFileDto.ts new file mode 100644 index 000000000000..223fe2a96809 --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/studentFileDto.ts @@ -0,0 +1,6 @@ +export interface StudentFileDto { + type?: string + locale?: string + displayName?: string + fileName?: string +} diff --git a/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts b/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts new file mode 100644 index 000000000000..060df61ab33a --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/studentTrackDto.ts @@ -0,0 +1,49 @@ +import { + BifrostStudentTrack, + HolarStudentTrack, + LbhiStudentTrack, + UnakStudentTrack, + HIStudentTrack, +} from '../clients' +import { UniversityId } from '../universityCareers.types' +import { + StudentTrackInstitutionDto, + mapToStudentTrackInstitutionDto, +} from './studentTrackInstitutionDto' + +export interface StudentTrackDto { + name?: string + nationalId?: string + graduationDate?: Date + trackNumber?: number + institution?: StudentTrackInstitutionDto + school?: string + faculty?: string + studyProgram?: string + degree?: string +} + +export const mapToStudentTrackDto = ( + transcript: + | HolarStudentTrack + | LbhiStudentTrack + | BifrostStudentTrack + | UnakStudentTrack + | HIStudentTrack, + institutionId: UniversityId, +): StudentTrackDto | null => { + if (!transcript.graduationDate) { + return null + } + + const institution = mapToStudentTrackInstitutionDto( + institutionId, + transcript.institution, + ) + + return { + ...transcript, + institution, + graduationDate: new Date(transcript.graduationDate), + } +} diff --git a/libs/clients/university-careers/src/lib/dto/studentTrackInstitutionDto.ts b/libs/clients/university-careers/src/lib/dto/studentTrackInstitutionDto.ts new file mode 100644 index 000000000000..1d01dfa3b4d2 --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/studentTrackInstitutionDto.ts @@ -0,0 +1,34 @@ +import { + BifrostStudentTrackInstitution, + HIStudentTrackInstitution, + HolarStudentTrackInstitution, + LbhiStudentTrackInstitution, + UnakStudentTrackInstitution, +} from '../clients' +import { + UniversityId, + UniversityIdMap, + UniversityIdShort, +} from '../universityCareers.types' + +export interface StudentTrackInstitutionDto { + id: UniversityId + idShort: UniversityIdShort + displayName?: string +} + +export const mapToStudentTrackInstitutionDto = ( + institutionId: UniversityId, + institution?: + | HolarStudentTrackInstitution + | LbhiStudentTrackInstitution + | BifrostStudentTrackInstitution + | UnakStudentTrackInstitution + | HIStudentTrackInstitution, +): StudentTrackInstitutionDto | undefined => { + return { + ...institution, + id: institutionId, + idShort: UniversityIdMap[institutionId], + } +} diff --git a/libs/clients/university-careers/src/lib/dto/studentTrackOverviewBodyDto.ts b/libs/clients/university-careers/src/lib/dto/studentTrackOverviewBodyDto.ts new file mode 100644 index 000000000000..b1ad8f2efb4e --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/studentTrackOverviewBodyDto.ts @@ -0,0 +1,5 @@ +export interface StudentTrackOverviewBodyDto { + description?: string + footer?: string + unconfirmedData?: string +} diff --git a/libs/clients/university-careers/src/lib/dto/studentTrackOverviewDto.ts b/libs/clients/university-careers/src/lib/dto/studentTrackOverviewDto.ts new file mode 100644 index 000000000000..411b9e036a90 --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/studentTrackOverviewDto.ts @@ -0,0 +1,9 @@ +import { StudentFileDto } from './studentFileDto' +import { StudentTrackDto } from './studentTrackDto' +import { StudentTrackOverviewBodyDto } from './studentTrackOverviewBodyDto' + +export interface StudentTrackOverviewDto { + transcript?: StudentTrackDto + files?: Array + body?: StudentTrackOverviewBodyDto +} diff --git a/libs/clients/university-careers/src/lib/dto/universityDto.ts b/libs/clients/university-careers/src/lib/dto/universityDto.ts new file mode 100644 index 000000000000..4672f208fd2c --- /dev/null +++ b/libs/clients/university-careers/src/lib/dto/universityDto.ts @@ -0,0 +1,46 @@ +import { + LbhiApi, + UnakApi, + HolarApi, + BifrostApi, + HIApi, + UnakLocale, + LbhiLocale, + BifrostLocale, + HolarLocale, + HILocale, + UnakTranscriptLocale, + LbhiTranscriptLocale, + BifrostTranscriptLocale, + HolarTranscriptLocale, + HITranscriptLocale, + UnakFerillLocale, + LbhiFerillLocale, + BifrostFerillLocale, + HolarFerillLocale, + HIFerillLocale, +} from '../clients' + +export interface UniversityDto { + api: LbhiApi | UnakApi | HolarApi | BifrostApi | HIApi + locales: { + studentLocale: + | typeof UnakLocale + | typeof LbhiLocale + | typeof BifrostLocale + | typeof HolarLocale + | typeof HILocale + studentTranscriptLocale: + | typeof UnakTranscriptLocale + | typeof LbhiTranscriptLocale + | typeof BifrostTranscriptLocale + | typeof HolarTranscriptLocale + | typeof HITranscriptLocale + studentTrackLocale: + | typeof UnakFerillLocale + | typeof LbhiFerillLocale + | typeof BifrostFerillLocale + | typeof HolarFerillLocale + | typeof HIFerillLocale + } +} diff --git a/libs/clients/university-careers/src/lib/universityCareers.module.ts b/libs/clients/university-careers/src/lib/universityCareers.module.ts new file mode 100644 index 000000000000..859f35900ef2 --- /dev/null +++ b/libs/clients/university-careers/src/lib/universityCareers.module.ts @@ -0,0 +1,20 @@ +import { Module } from '@nestjs/common' +import { AgriculturalUniversityOfIcelandCareerClientProvider } from './clients/agricultural-university-of-iceland/agriculturalUniversityOfIcelandCareerClient.provider' +import { BifrostUniversityCareerClientProvider } from './clients/bifrost-university/bifrostUniversityCareerClient.provider' +import { HolarUniversityCareerClientProvider } from './clients/holar-university/holarUniversityCareerClient.provider' +import { UniversityOfAkureyriCareerClientProvider } from './clients/university-of-akureyri/universityOfAkureyriCareerClient.provider' +import { UniversityCareersClientService } from './universityCareers.service' +import { UniversityOfIcelandCareerClientProvider } from './clients/university-of-iceland/universityOfIcelandCareerClient.provider' + +@Module({ + providers: [ + AgriculturalUniversityOfIcelandCareerClientProvider, + BifrostUniversityCareerClientProvider, + HolarUniversityCareerClientProvider, + UniversityOfAkureyriCareerClientProvider, + UniversityOfIcelandCareerClientProvider, + UniversityCareersClientService, + ], + exports: [UniversityCareersClientService], +}) +export class UniversityCareersClientModule {} diff --git a/libs/clients/university-careers/src/lib/universityCareers.service.ts b/libs/clients/university-careers/src/lib/universityCareers.service.ts new file mode 100644 index 000000000000..738697d82a18 --- /dev/null +++ b/libs/clients/university-careers/src/lib/universityCareers.service.ts @@ -0,0 +1,172 @@ +import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools' +import { Inject, Injectable } from '@nestjs/common' +import { + BifrostApi, + BifrostFerillLocale, + BifrostLocale, + BifrostTranscriptLocale, + HIApi, + HIFerillLocale, + HILocale, + HITranscriptLocale, + HolarApi, + HolarFerillLocale, + HolarLocale, + HolarTranscriptLocale, + LbhiApi, + LbhiFerillLocale, + LbhiLocale, + LbhiTranscriptLocale, + UnakApi, + UnakFerillLocale, + UnakLocale, + UnakTranscriptLocale, +} from './clients' +import { StudentTrackDto, mapToStudentTrackDto } from './dto/studentTrackDto' +import { Locale } from '@island.is/shared/types' +import { UniversityId } from './universityCareers.types' +import { handle404 } from '@island.is/clients/middlewares' +import { isDefined } from '@island.is/shared/utils' +import { StudentTrackOverviewDto } from './dto/studentTrackOverviewDto' +import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' +import { UniversityDto } from './dto/universityDto' + +@Injectable() +export class UniversityCareersClientService { + constructor( + private readonly lbhiApi: LbhiApi, + private readonly unakApi: UnakApi, + private readonly holarApi: HolarApi, + private readonly bifrostApi: BifrostApi, + private readonly hiApi: HIApi, + @Inject(LOGGER_PROVIDER) private readonly logger: Logger, + ) {} + + private getApi = (type: UniversityId, user: User): UniversityDto => { + switch (type) { + case UniversityId.AGRICULTURAL_UNIVERSITY_OF_ICELAND: + return { + api: this.lbhiApi.withMiddleware(new AuthMiddleware(user as Auth)), + locales: { + studentLocale: LbhiLocale, + studentTranscriptLocale: LbhiTranscriptLocale, + studentTrackLocale: LbhiFerillLocale, + }, + } + case UniversityId.BIFROST_UNIVERSITY: + return { + api: this.bifrostApi.withMiddleware(new AuthMiddleware(user as Auth)), + locales: { + studentLocale: BifrostLocale, + studentTranscriptLocale: BifrostTranscriptLocale, + studentTrackLocale: BifrostFerillLocale, + }, + } + case UniversityId.HOLAR_UNIVERSITY: + return { + api: this.holarApi.withMiddleware(new AuthMiddleware(user as Auth)), + locales: { + studentLocale: HolarLocale, + studentTranscriptLocale: HolarTranscriptLocale, + studentTrackLocale: HolarFerillLocale, + }, + } + case UniversityId.UNIVERSITY_OF_AKUREYRI: + return { + api: this.unakApi.withMiddleware(new AuthMiddleware(user as Auth)), + locales: { + studentLocale: UnakLocale, + studentTranscriptLocale: UnakTranscriptLocale, + studentTrackLocale: UnakFerillLocale, + }, + } + case UniversityId.UNIVERSITY_OF_ICELAND: + return { + api: this.hiApi.withMiddleware(new AuthMiddleware(user as Auth)), + locales: { + studentLocale: HILocale, + studentTranscriptLocale: HITranscriptLocale, + studentTrackLocale: HIFerillLocale, + }, + } + } + } + + getStudentTrackHistory = async ( + user: User, + university: UniversityId, + locale?: Locale, + ): Promise | null> => { + const { api, locales } = this.getApi(university, user) + const data = await api + .nemandiGet({ + locale: + locale === 'en' ? locales.studentLocale.En : locales.studentLocale.Is, + }) + .catch(handle404) + + if (!data) { + return null + } + + const transcripts = + data.transcripts + ?.map((t) => mapToStudentTrackDto(t, university)) + .filter(isDefined) ?? [] + + if (!transcripts.length) { + this.logger.debug('No transcripts found for user', { + university, + }) + } + return transcripts + } + + getStudentTrack = async ( + user: User, + trackNumber: number, + university: UniversityId, + locale?: Locale, + ): Promise => { + const { api, locales } = this.getApi(university, user) + const data = await api + .nemandiFerillFerillGet({ + ferill: trackNumber, + locale: + locale === 'en' + ? locales.studentTrackLocale.En + : locales.studentTrackLocale.Is, + }) + .catch(handle404) + + if (!data) { + return null + } + + return { + transcript: data.transcript + ? mapToStudentTrackDto(data.transcript, university) ?? undefined + : undefined, + files: data.files?.map((d) => ({ ...d })), + body: { ...data.body }, + } + } + + getStudentTrackPdf = async ( + user: User, + trackNumber: number, + university: UniversityId, + locale?: Locale, + ): Promise => { + const { api, locales } = this.getApi(university, user) + return api + .nemandiFerillFerillFileTranscriptGet({ + ferill: trackNumber, + locale: + locale === 'en' + ? locales.studentTranscriptLocale.En + : locales.studentTranscriptLocale.Is, + }) + .catch(handle404) + } +} diff --git a/libs/clients/university-careers/src/lib/universityCareers.types.ts b/libs/clients/university-careers/src/lib/universityCareers.types.ts new file mode 100644 index 000000000000..5be7abdffa46 --- /dev/null +++ b/libs/clients/university-careers/src/lib/universityCareers.types.ts @@ -0,0 +1,83 @@ +import { z } from 'zod' +import { + UnakLocale, + LbhiLocale, + BifrostLocale, + HolarLocale, + HILocale, + BifrostFerillLocale, + BifrostTranscriptLocale, + HIFerillLocale, + HITranscriptLocale, + HolarFerillLocale, + HolarTranscriptLocale, + LbhiFerillLocale, + LbhiTranscriptLocale, + UnakFerillLocale, + UnakTranscriptLocale, + UnakApi, + BifrostApi, + HIApi, + HolarApi, + LbhiApi, +} from './clients' + +export const schema = z.object({ + xroadPath: z.string(), + scope: z.array(z.string()), +}) + +export enum UniversityId { + UNIVERSITY_OF_AKUREYRI = 'unak', + BIFROST_UNIVERSITY = 'bifrost', + HOLAR_UNIVERSITY = 'holar', + AGRICULTURAL_UNIVERSITY_OF_ICELAND = 'lbhi', + UNIVERSITY_OF_ICELAND = 'hi', +} + +export const UniversityShortIdMap: Record = { + unak: UniversityId.UNIVERSITY_OF_AKUREYRI, + bifrost: UniversityId.BIFROST_UNIVERSITY, + holar: UniversityId.HOLAR_UNIVERSITY, + lbhi: UniversityId.AGRICULTURAL_UNIVERSITY_OF_ICELAND, + hi: UniversityId.UNIVERSITY_OF_ICELAND, +} + +export const UniversityIdMap: Record = { + unak: 'unak', + bifrost: 'bifrost', + holar: 'holar', + lbhi: 'lbhi', + hi: 'hi', +} + +export type UniversityIdShort = 'unak' | 'bifrost' | 'holar' | 'lbhi' | 'hi' + +export type UniversityApi = LbhiApi | UnakApi | HolarApi | BifrostApi | HIApi + +export type UniversityLocales = { + studentLocale: StudentLocale + studentTransriptLocale: StudentTranscriptLocale + studentTrackLocale: StudentTrackLocale +} + +export type StudentLocale = + | typeof UnakLocale + | typeof LbhiLocale + | typeof BifrostLocale + | typeof HolarLocale + | typeof HILocale + +export type StudentTranscriptLocale = + | typeof UnakTranscriptLocale + | typeof LbhiTranscriptLocale + | typeof BifrostTranscriptLocale + | typeof HolarTranscriptLocale + | typeof HITranscriptLocale + +export type StudentTrackLocale = + | typeof UnakFerillLocale + | typeof LbhiFerillLocale + | typeof BifrostFerillLocale + | typeof HolarFerillLocale + | typeof HIFerillLocale diff --git a/libs/clients/university-careers/tsconfig.json b/libs/clients/university-careers/tsconfig.json new file mode 100644 index 000000000000..8122543a9ab0 --- /dev/null +++ b/libs/clients/university-careers/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/clients/university-careers/tsconfig.lib.json b/libs/clients/university-careers/tsconfig.lib.json new file mode 100644 index 000000000000..dbf54fd7d68c --- /dev/null +++ b/libs/clients/university-careers/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "types": ["node"], + "target": "es2021", + "strictNullChecks": true, + "noImplicitAny": true, + "strictBindCallApply": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/libs/clients/university-careers/tsconfig.spec.json b/libs/clients/university-careers/tsconfig.spec.json new file mode 100644 index 000000000000..69a251f328ce --- /dev/null +++ b/libs/clients/university-careers/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/libs/clients/university-of-iceland/.babelrc b/libs/clients/university-of-iceland/.babelrc deleted file mode 100644 index b63f0528f976..000000000000 --- a/libs/clients/university-of-iceland/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nrwl/js/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/clients/university-of-iceland/README.md b/libs/clients/university-of-iceland/README.md deleted file mode 100644 index 7377e85677b5..000000000000 --- a/libs/clients/university-of-iceland/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Clients University of Iceland - -This library was generated with [Nx](https://nx.dev). - -Display student career. - -## Running unit tests - -Run `nx test clients-university-of-iceland` to execute the unit tests via [Jest](https://jestjs.io). - -## Running lint - -Run `nx lint clients-university-of-iceland` to execute the lint via [ESLint](https://eslint.org/). - -## Regenerating the client: - -```sh -yarn nx run clients-university-of-iceland:codegen/backend-client -``` diff --git a/libs/clients/university-of-iceland/jest.config.ts b/libs/clients/university-of-iceland/jest.config.ts deleted file mode 100644 index bbbaa442dc92..000000000000 --- a/libs/clients/university-of-iceland/jest.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'clients-university-of-iceland', - preset: '../../../jest.preset.js', - globals: {}, - testEnvironment: 'node', - transform: { - '^.+\\.[tj]sx?$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../../coverage/libs/clients/university-of-iceland', -} diff --git a/libs/clients/university-of-iceland/project.json b/libs/clients/university-of-iceland/project.json deleted file mode 100644 index 6b7b9b09c8b5..000000000000 --- a/libs/clients/university-of-iceland/project.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "clients-university-of-iceland", - "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/clients/university-of-iceland/src", - "projectType": "library", - "targets": { - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/clients/university-of-iceland/**/*.ts"] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": [ - "{workspaceRoot}/coverage/libs/clients/university-of-iceland" - ], - "options": { - "jestConfig": "libs/clients/university-of-iceland/jest.config.ts", - "passWithNoTests": true - } - }, - "codegen/backend-client": { - "executor": "nx:run-commands", - "options": { - "command": "yarn openapi-generator -o libs/clients/university-of-iceland/gen/fetch -i libs/clients/university-of-iceland/src/clientConfig.yaml" - }, - "outputs": ["{projectRoot}/gen/fetch"] - }, - "update-openapi-document": { - "executor": "nx:run-commands", - "options": { - "command": "curl -H \"X-Road-Client: IS-DEV/GOV/10000/island-is-client\" http://localhost:8081/r1/IS-DEV/EDU/10010/HI-Protected/brautskraning-v1/openapi.yaml > src/clientConfig.yaml", - "parallel": false, - "cwd": "libs/clients/university-of-iceland" - } - } - }, - "tags": ["lib:client", "scope:client"] -} diff --git a/libs/clients/university-of-iceland/src/clientConfig.yaml b/libs/clients/university-of-iceland/src/clientConfig.yaml deleted file mode 100644 index 7c4d06413f2e..000000000000 --- a/libs/clients/university-of-iceland/src/clientConfig.yaml +++ /dev/null @@ -1,198 +0,0 @@ -openapi: 3.0.3 -info: - title: Útskriftargögn nemenda - version: 1.0.0 - contact: - email: help@hi.is -servers: - - url: https://ugla.{skoli}.is/api/vottord/brautskraning - variables: - skoli: - default: hi - enum: - - hi - - unak - - lbhi - - url: https://nokkvith.throun.hi.is/api/vottord/brautskraning -paths: - /nemandi: - get: - summary: Listi yfir ferla sem nemandi hefur brauskrást af - tags: - - studentTranscript - parameters: - - $ref: '#/components/parameters/locale' - responses: - 200: - description: Skilar lista af ferlum sem nemandi hefur útskrifast af - content: - application/json: - schema: - type: object - title: transcripts - properties: - transcripts: - type: array - items: - $ref: '#/components/schemas/studentTrack' - '400': - description: Bad request. Invalid kennitala - '404': - description: Nemandi hefur enga brautskráða ferla - '5XX': - description: Unexpected error. - /nemandi/ferill/{ferill}: - get: - summary: Ferill nemanda með brautskráningu, ásamt listi af fælum tengt brauskráningaryfirliti - tags: - - studentTranscript - parameters: - - $ref: '#/components/parameters/ferill' - - $ref: '#/components/parameters/locale' - responses: - 200: - description: Skilar lista af ferlum sem nemandi hefur útskrifast af - content: - application/json: - schema: - type: object - title: studentTrackOverview - properties: - transcript: - type: object - $ref: '#/components/schemas/studentTrack' - files: - type: array - items: - $ref: '#/components/schemas/studentFile' - body: - type: object - properties: - description: - type: string - description: Texti fyrir ofan transcript - example: 'Námsferilsyfirlit ekki til prentunar á pappír...' - footer: - type: string - description: Texti fyrir neðan transcript - example: 'Ef upplýsingar hér eru ekki réttar...' - unconfirmed_data: - type: string - description: Text when studentFile array is empty - example: 'Engar upplýsingar í boði á PDF formi ...' - '400': - description: Bad request. Invalid kennitala - '404': - description: Nemandi hefur enga brautskráða ferla, ferill ekki til, er ekki brautskráður fyrir feril. - '5XX': - description: Unexpected error. - /nemandi/ferill/{ferill}/file/transcript: - get: - summary: Skilar útskriftargögnum á pdf formi - tags: - - studentTranscript - parameters: - - $ref: '#/components/parameters/ferill' - - $ref: '#/components/parameters/locale' - responses: - '200': - description: PDF skjal - content: - application/pdf: - schema: - type: string - format: binary - '400': - description: Bad request. Invalid kennitala - '404': - description: Nemandi hefur enga brautskráða ferla, ferill ekki til, er ekki brautskráður fyrir feril. - '5XX': - description: Unexpected error. - -components: - schemas: - studentTrack: - type: object - properties: - name: - type: string - description: Fullt nafn leyfisbréfshafa - example: 'Gervimaður Finnland' - nationalId: - type: string - description: National ID number - example: '0101302209' - graduationDate: - type: string - description: ISO 8601 date - example: '2021-11-24' - trackNumber: - type: integer - description: Númer á feril nemenda, hlaupdandi tala frá 1 - example: 4 - institution: - type: object - properties: - id: - type: string - example: 'hi' - displayName: - type: string - example: 'Háskóli Íslands' - school: - type: string - description: Svið sem nemandi er skráður á ferlinum - example: 'Félagsvísindasvið' - faculty: - type: string - description: Deild sem er skráð á ferilinn - example: 'Lagadeild' - studyProgram: - type: string - description: Námsleið sem nemandinn er skráð á ferilinn - example: 'Lögfræði' - degree: - type: string - description: Námsgráða - example: 'BA' - studentFile: - type: object - properties: - type: - type: string - description: TODO - example: 'transcript' - locale: - type: string - description: Tungumál fyrir file - example: 'is' - displayName: - type: string - description: TODO - example: 'Námsferilsyfirlit með brautskráningu' - fileName: - type: string - description: TODO - example: 'utskriftaryfirlit-0101302209.pdf' - parameters: - locale: - name: locale - in: query - schema: - type: string - enum: ['is', 'en'] - default: 'is' - ferill: - in: path - name: ferill - schema: - type: integer - required: true - description: Ferilsnúmer nemenda - securitySchemes: - bearerAuth: - type: http - scheme: bearer - bearerFormat: JWT -security: - - bearerAuth: [] diff --git a/libs/clients/university-of-iceland/src/index.ts b/libs/clients/university-of-iceland/src/index.ts deleted file mode 100644 index 20252fc30242..000000000000 --- a/libs/clients/university-of-iceland/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { UniversityOfIcelandClientModule } from './lib/universityOfIcelandClient.module' -export { UniversityOfIcelandClientConfig } from './lib/universityOfIcelandClient.config' -export * from '../gen/fetch' -export { UniversityOfIcelandApiProvider } from './lib/universityOfIcelandClient.provider' -export { UniversityOfIcelandService } from './lib/universityOfIcelandClient.service' diff --git a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.config.ts b/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.config.ts deleted file mode 100644 index 9817d098e509..000000000000 --- a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { defineConfig } from '@island.is/nest/config' -import * as z from 'zod' - -const schema = z.object({ - xRoadServicePath: z.string(), - fetch: z.object({ - timeout: z.number().int(), - scope: z.array(z.string()), - }), -}) - -export const UniversityOfIcelandClientConfig = defineConfig< - z.infer ->({ - name: 'UniversityOfIcelandClient', - schema, - load(env) { - return { - xRoadServicePath: env.required( - 'XROAD_UNIVERSITY_OF_ICELAND_PATH', - 'IS-DEV/EDU/10010/HI-Protected/brautskraning-v1', - ), - fetch: { - timeout: 30000, - scope: ['@hi.is/brautskraningar'], - }, - } - }, -}) diff --git a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.module.ts b/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.module.ts deleted file mode 100644 index e6680df9cf53..000000000000 --- a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common' -import { UniversityOfIcelandApiProvider } from './universityOfIcelandClient.provider' -import { UniversityOfIcelandService } from './universityOfIcelandClient.service' - -@Module({ - providers: [UniversityOfIcelandApiProvider, UniversityOfIcelandService], - exports: [UniversityOfIcelandService], -}) -export class UniversityOfIcelandClientModule {} diff --git a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.service.ts b/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.service.ts deleted file mode 100644 index 16bd48fdc4cb..000000000000 --- a/libs/clients/university-of-iceland/src/lib/universityOfIcelandClient.service.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools' -import { Injectable } from '@nestjs/common' -import { - StudentTranscriptApi, - NemandiGetLocaleEnum, - Transcripts, - NemandiFerillFerillGetLocaleEnum, - StudentTrackOverview, - NemandiFerillFerillFileTranscriptGetLocaleEnum, -} from '../../gen/fetch' -import { handle404 } from '@island.is/clients/middlewares' - -@Injectable() -export class UniversityOfIcelandService { - constructor(private readonly universityOfIcelandApi: StudentTranscriptApi) {} - - private universityOfIcelandApiWithAuth = (user: User) => - this.universityOfIcelandApi.withMiddleware(new AuthMiddleware(user as Auth)) - - studentInfo = ( - user: User, - locale?: NemandiGetLocaleEnum, - ): Promise => - this.universityOfIcelandApiWithAuth(user) - .nemandiGet({ - locale: locale, - }) - .catch(handle404) - - studentCareer = ( - user: User, - trackNumber: number, - locale?: NemandiFerillFerillGetLocaleEnum, - ): Promise => - this.universityOfIcelandApiWithAuth(user) - .nemandiFerillFerillGet({ - ferill: trackNumber, - locale: locale, - }) - .catch(handle404) - - studentCareerPDF = ( - user: User, - trackNumber: number, - locale?: NemandiFerillFerillFileTranscriptGetLocaleEnum, - ): Promise => - this.universityOfIcelandApiWithAuth(user) - .nemandiFerillFerillFileTranscriptGet({ - ferill: trackNumber, - locale: locale, - }) - .catch(handle404) -} diff --git a/libs/clients/university-of-iceland/tsconfig.json b/libs/clients/university-of-iceland/tsconfig.json deleted file mode 100644 index 667a3463d1d1..000000000000 --- a/libs/clients/university-of-iceland/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/clients/university-of-iceland/tsconfig.lib.json b/libs/clients/university-of-iceland/tsconfig.lib.json deleted file mode 100644 index ff64bb51cff8..000000000000 --- a/libs/clients/university-of-iceland/tsconfig.lib.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/clients/university-of-iceland/tsconfig.spec.json b/libs/clients/university-of-iceland/tsconfig.spec.json deleted file mode 100644 index 83cd0e830ed2..000000000000 --- a/libs/clients/university-of-iceland/tsconfig.spec.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "**/*.test.ts", - "**/*.spec.ts", - "**/*.test.tsx", - "**/*.spec.tsx", - "**/*.test.js", - "**/*.spec.js", - "**/*.test.jsx", - "**/*.spec.jsx", - "**/*.d.ts", - "jest.config.ts" - ] -} diff --git a/libs/cms/src/lib/cms.contentful.service.ts b/libs/cms/src/lib/cms.contentful.service.ts index 3756be7f7b59..5e96083952f4 100644 --- a/libs/cms/src/lib/cms.contentful.service.ts +++ b/libs/cms/src/lib/cms.contentful.service.ts @@ -345,6 +345,25 @@ export class CmsContentfulService { ) } + async getOrganizationByReferenceId( + referenceId: string, + lang: string, + ): Promise { + const params = { + ['content_type']: 'organization', + include: 10, + 'fields.referenceIdentifier': referenceId, + } + + const result = await this.contentfulRepository + .getLocalizedEntries(lang, params) + .catch(errorHandler('getOrganization')) + + return ( + (result.items as types.IOrganization[]).map(mapOrganization)[0] ?? null + ) + } + async getOrganizationPage( slug: string, lang: string, diff --git a/libs/feature-flags/src/lib/features.ts b/libs/feature-flags/src/lib/features.ts index 13bfc550d19e..8a89f1f9d682 100644 --- a/libs/feature-flags/src/lib/features.ts +++ b/libs/feature-flags/src/lib/features.ts @@ -56,6 +56,12 @@ export enum Features { //Occupational License Health directorate fetch enabled occupationalLicensesV2 = 'isOccupationalLicensesV2Enabled', + //Possible universities + isUniversityOfAkureyriEnabled = 'isUniversityOfAkureyriEnabled', + isAgriculturalUniversityOfIcelandEnabled = 'isAgriculturalUniversityOfIcelandEnabled', + isBifrostUniversityEnabled = 'isBifrostUniversityEnabled', + isHolarUniversityEnabled = 'isHolarUniversityEnabled', + //License service new drivers license client enabled licenseServiceDrivingLicenseClient = 'isLicenseServiceDrivingLicenceClientV2Enabled', licenseServiceDrivingLicencePhotoCheckDisabled = 'isLicenseServiceDrivingLicencePhotoCheckDisabled', diff --git a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts index 42b14d567602..bf1b6c4d533d 100644 --- a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts +++ b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts @@ -17,7 +17,7 @@ export const avatar = style({ sm: { display: 'flex', width: 66, - height: 66, + //height: 66, }, }), }) diff --git a/libs/service-portal/core/src/lib/messages.ts b/libs/service-portal/core/src/lib/messages.ts index 483c4c87aafe..9685e92fa4a8 100644 --- a/libs/service-portal/core/src/lib/messages.ts +++ b/libs/service-portal/core/src/lib/messages.ts @@ -233,6 +233,15 @@ export const m = defineMessages({ id: 'service.portal:could-not-fetch', defaultMessage: 'Tókst ekki að sækja', }, + couldNotFetchAllItems: { + id: 'service.portal:could-not-fetch-all-items', + defaultMessage: 'Ekki tókst að sækja öll gögn', + }, + couldNotFetchAllItemsDetail: { + id: 'service.portal:could-not-fetch-all-items-detail', + defaultMessage: + 'Einhverjar tengingar virðast hafa rofnað svo ekki tókst að sækja gögn frá eftirfarandi aðilum: {arg}. Verið er að vinna í að lagfæra tenginuna.', + }, somethingWrong: { id: 'service.portal:something-went-wrong', defaultMessage: 'Eitthvað fór úrskeiðis', @@ -765,6 +774,10 @@ export const m = defineMessages({ id: 'service.portal:educationDegree', defaultMessage: 'Prófgráður', }, + noTranscriptForDownload: { + id: 'service.portal:educationCareerNoTranscriptForDownload', + defaultMessage: 'Námsmat ófáanlegt', + }, accessControl: { id: 'service.portal:accessControl', defaultMessage: 'Aðgangsstýring', diff --git a/libs/service-portal/documents/src/components/DocumentRenderer/DocumentRenderer.tsx b/libs/service-portal/documents/src/components/DocumentRenderer/DocumentRenderer.tsx index b0fb688b9847..e5a9761161ad 100644 --- a/libs/service-portal/documents/src/components/DocumentRenderer/DocumentRenderer.tsx +++ b/libs/service-portal/documents/src/components/DocumentRenderer/DocumentRenderer.tsx @@ -1,6 +1,5 @@ -import { DocumentDetails } from '@island.is/api/schema' import { HtmlDocument } from './HTMLDocument' -import { PdfDocWithModal, PdfDocument } from './PdfDocument' +import { PdfDocWithModal } from './PdfDocument' import { UrlDocument } from './UrlDocment' import NoPDF from '../NoPDF/NoPDF' import { messages } from '../../utils/messages' diff --git a/libs/service-portal/documents/src/components/NoPDF/EmptyImage.tsx b/libs/service-portal/documents/src/components/NoPDF/EmptyImage.tsx index c47ee2a171be..faad2a44663e 100644 --- a/libs/service-portal/documents/src/components/NoPDF/EmptyImage.tsx +++ b/libs/service-portal/documents/src/components/NoPDF/EmptyImage.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -export function EmptyImageSmall(props: React.SVGProps) { +export const EmptyImageSmall = (props: React.SVGProps) => { return ( { useNamespaces('sp.education-student-assessment') return ( diff --git a/libs/service-portal/education/src/lib/paths.ts b/libs/service-portal/education/src/lib/paths.ts index 59141bc119cb..e44fad7b8bb5 100644 --- a/libs/service-portal/education/src/lib/paths.ts +++ b/libs/service-portal/education/src/lib/paths.ts @@ -11,7 +11,7 @@ export enum EducationPaths { EducationHaskoli = '/menntun/haskoli', EducationHaskoliGraduation = '/menntun/haskoli/brautskraning', - EducationHaskoliGraduationDetail = '/menntun/haskoli/brautskraning/:id', + EducationHaskoliGraduationDetail = '/menntun/haskoli/brautskraning/:uni/:id', EducationDrivingLessons = '/menntun/okunam', } diff --git a/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.graphql b/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.graphql new file mode 100644 index 000000000000..bc575fc2e2cf --- /dev/null +++ b/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.graphql @@ -0,0 +1,27 @@ +query studentInfo($input: UniversityCareersStudentInfoInput!) { + universityCareersStudentTrackHistory(input: $input) { + __typename + trackResults { + ... on UniversityCareersStudentTrackTranscript { + name + nationalId + graduationDate + trackNumber + institution { + id + displayName + logoUrl + } + school + faculty + studyProgram + degree + } + ... on UniversityCareersStudentTrackTranscriptError { + __typename + university + error + } + } + } +} diff --git a/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.tsx b/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.tsx index 4d7c21ca2bf7..3711096c79b1 100644 --- a/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.tsx +++ b/libs/service-portal/education/src/screens/EducationGraduation/EducationGraduation.tsx @@ -1,6 +1,6 @@ import { defineMessage } from 'react-intl' -import { Box, Stack } from '@island.is/island-ui/core' +import { AlertMessage, Box, Stack } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' import { ActionCard, @@ -8,36 +8,23 @@ import { IntroHeader, m, } from '@island.is/service-portal/core' -import { Query } from '@island.is/api/schema' -import { gql, useQuery } from '@apollo/client' -import { GET_ORGANIZATIONS_QUERY } from '@island.is/service-portal/graphql' -import { getOrganizationLogoUrl } from '@island.is/shared/utils' +import { isDefined } from '@island.is/shared/utils' import { EducationPaths } from '../../lib/paths' import { Problem } from '@island.is/react-spa/shared' - -const GetStudentInfoQuery = gql` - query universityOfIcelandStudentInfo( - $input: UniversityOfIcelandStudentInfoInput! - ) { - universityOfIcelandStudentInfo(input: $input) { - transcripts { - degree - faculty - institution { - displayName - } - studyProgram - trackNumber - } - } - } -` +import { useStudentInfoQuery } from './EducationGraduation.generated' +import { + UniversityCareersStudentTrackTranscript, + UniversityCareersStudentTrackTranscriptError, +} from '@island.is/api/schema' +import { useOrganizations } from '@island.is/service-portal/graphql' +import { useMemo } from 'react' +import { mapUniversityToSlug } from '../../utils/mapUniversitySlug' export const EducationGraduation = () => { useNamespaces('sp.education-graduation') const { lang, formatMessage } = useLocale() - const { loading, error, data } = useQuery(GetStudentInfoQuery, { + const { loading, error, data } = useStudentInfoQuery({ variables: { input: { locale: lang, @@ -45,16 +32,34 @@ export const EducationGraduation = () => { }, }) - const { data: orgData } = useQuery(GET_ORGANIZATIONS_QUERY, { - variables: { - input: { - lang: lang, - }, - }, - }) - const organizations = orgData?.getOrganizations?.items || {} + const { data: organizations } = useOrganizations() + + const tracks: Array = + data?.universityCareersStudentTrackHistory?.trackResults + .filter((u) => u.__typename === 'UniversityCareersStudentTrackTranscript') + .filter(isDefined) + .map((u) => u as UniversityCareersStudentTrackTranscript) ?? [] + + const errors: Array = + useMemo(() => { + return ( + data?.universityCareersStudentTrackHistory?.trackResults + .filter( + (u) => + u.__typename === 'UniversityCareersStudentTrackTranscriptError', + ) + .filter(isDefined) + .map((u) => u as UniversityCareersStudentTrackTranscriptError) ?? [] + ) + }, [data?.universityCareersStudentTrackHistory.trackResults]) - const studentInfo = data?.universityOfIcelandStudentInfo?.transcripts || [] + const errorString = useMemo(() => { + return errors + .map((e) => mapUniversityToSlug(e.university)) + .map((e) => (organizations ?? []).find((o) => o.slug === e)?.title) + .filter(isDefined) + .join(', ') + }, [errors, organizations]) return ( @@ -66,12 +71,21 @@ export const EducationGraduation = () => { 'Hér getur þú fundið yfirlit yfir brautskráningar frá háskólanámi frá árinu 2015.', description: 'education graduation intro', })} - serviceProviderSlug={'haskoli-islands'} - serviceProviderTooltip={formatMessage(m.universityOfIcelandTooltip)} /> + {!!errors.length && !error && !loading && ( + + + + )} {error && !loading && } {loading && !error && } - {!loading && !error && studentInfo.length === 0 && ( + {!loading && !error && !tracks?.length && !errors?.length && ( { )} - {studentInfo.length > 0 && - studentInfo.map((item, index) => { + {!!tracks?.length && + tracks?.map((item, index) => { + if (!item.institution.id) { + return null + } return ( { useNamespaces('sp.education-graduation') - const { id } = useParams() as UseParams + const { id, uni } = useParams() as UseParams const { formatMessage, lang } = useLocale() - const { data, loading, error } = useQuery(GetStudentInfoQuery, { + const { data, loading, error } = useStudentTrackQuery({ variables: { input: { trackNumber: parseInt(id), locale: lang, + universityId: + mapSlugToUniversity(uni) ?? + UniversityCareersUniversityId.UNIVERSITY_OF_ICELAND, }, }, }) - const studentInfo = data?.universityOfIcelandStudentInfo?.track?.transcript - const text = data?.universityOfIcelandStudentInfo?.track?.body - const files = data?.universityOfIcelandStudentInfo?.track?.files + const studentInfo = data?.universityCareersStudentTrack?.transcript + const text = data?.universityCareersStudentTrack?.metadata + const files = data?.universityCareersStudentTrack?.files const downloadServiceURL = - data?.universityOfIcelandStudentInfo?.track?.downloadServiceURL + data?.universityCareersStudentTrack?.downloadServiceURL const graduationDate = studentInfo ? formatDate(studentInfo?.graduationDate) : undefined - const noFiles = files?.length === 0 + const filesAvailable = (files?.length ?? 0) > 0 return ( @@ -115,9 +78,12 @@ export const EducationGraduationDetail = () => { printHidden > {files && - files?.length > 0 && + filesAvailable && downloadServiceURL && - files?.map((item, index) => { + files.map((item, index) => { + const shortOrgId = + data.universityCareersStudentTrack?.transcript?.institution + ?.shortId return ( { iconType="outline" onClick={() => formSubmit( - `${downloadServiceURL}${item.locale}/${studentInfo?.trackNumber}`, + `${downloadServiceURL}${item.locale}/${ + shortOrgId ?? uni + }/${studentInfo?.trackNumber}`, ) } > @@ -140,30 +108,20 @@ export const EducationGraduationDetail = () => { ) })} - {noFiles ? ( - - {text?.unconfirmedData && ( - - )} - {text?.unconfirmedData || ''} + {!filesAvailable && !loading && ( + + - ) : undefined} + )} {error && !loading && } - {loading && !error && ( - - )} {!loading && !error && !studentInfo && ( { - {loading && !error && } {text?.footer} diff --git a/libs/service-portal/education/src/utils/mapUniversitySlug.ts b/libs/service-portal/education/src/utils/mapUniversitySlug.ts new file mode 100644 index 000000000000..7fecff474a0f --- /dev/null +++ b/libs/service-portal/education/src/utils/mapUniversitySlug.ts @@ -0,0 +1,73 @@ +import { UniversityCareersUniversityId } from '@island.is/api/schema' +import { OrganizationSlugType } from '@island.is/shared/constants' + +export type UniversitySlug = 'lbhi' | 'holar' | 'hi' | 'unak' | 'bifrost' + +const isUniversitySlug = (slug: string): slug is UniversitySlug => { + return ( + slug === 'lbhi' || + slug === 'holar' || + slug === 'hi' || + slug === 'unak' || + slug === 'bifrost' + ) +} + +export const mapUniversityToSlug = ( + university: UniversityCareersUniversityId, +): UniversitySlug => { + switch (university) { + case UniversityCareersUniversityId.AGRICULTURAL_UNIVERSITY_OF_ICELAND: + return 'lbhi' + case UniversityCareersUniversityId.HOLAR_UNIVERSITY: + return 'holar' + case UniversityCareersUniversityId.UNIVERSITY_OF_ICELAND: + return 'hi' + case UniversityCareersUniversityId.UNIVERSITY_OF_AKUREYRI: + return 'unak' + case UniversityCareersUniversityId.BIFROST_UNIVERSITY: + return 'bifrost' + } +} + +export const mapSlugToUniversity = ( + slug: string, +): UniversityCareersUniversityId | null => { + if (!isUniversitySlug(slug)) { + return null + } + + switch (slug) { + case 'lbhi': + return UniversityCareersUniversityId.AGRICULTURAL_UNIVERSITY_OF_ICELAND + case 'holar': + return UniversityCareersUniversityId.HOLAR_UNIVERSITY + case 'hi': + return UniversityCareersUniversityId.UNIVERSITY_OF_ICELAND + case 'unak': + return UniversityCareersUniversityId.UNIVERSITY_OF_AKUREYRI + case 'bifrost': + return UniversityCareersUniversityId.BIFROST_UNIVERSITY + } +} + +export const mapSlugToContentfulSlug = ( + slug: string, +): OrganizationSlugType | null => { + if (!isUniversitySlug(slug)) { + return null + } + + switch (slug) { + case 'lbhi': + return 'landbunadarhaskoli-islands' + case 'holar': + return 'holaskoli-haskolinn-a-holum' + case 'hi': + return 'haskoli-islands' + case 'unak': + return 'haskolinn-a-akureyri' + case 'bifrost': + return 'bifrost' + } +} diff --git a/libs/shared/constants/src/lib/organizationSlug.ts b/libs/shared/constants/src/lib/organizationSlug.ts index 8c9d706ac98c..0c7b88594183 100644 --- a/libs/shared/constants/src/lib/organizationSlug.ts +++ b/libs/shared/constants/src/lib/organizationSlug.ts @@ -6,6 +6,10 @@ */ export type OrganizationSlugType = | 'haskoli-islands' + | 'haskolinn-a-akureyri' + | 'holaskoli-haskolinn-a-holum' + | 'bifrost' + | 'landbunadarhaskoli-islands' | 'vinnueftirlitid' | 'thjodskra' | 'stafraent-island' diff --git a/tsconfig.base.json b/tsconfig.base.json index 9b5f735d3fd3..bd607497c348 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -228,12 +228,12 @@ "@island.is/api/domains/transport-authority": [ "libs/api/domains/transport-authority/src/index.ts" ], + "@island.is/api/domains/university-careers": [ + "libs/api/domains/university-careers/src/index.ts" + ], "@island.is/api/domains/university-gateway": [ "libs/api/domains/university-gateway/src/index.ts" ], - "@island.is/api/domains/university-of-iceland": [ - "libs/api/domains/university-of-iceland/src/index.ts" - ], "@island.is/api/domains/user-profile": [ "libs/api/domains/user-profile/src/index.ts" ], @@ -760,12 +760,12 @@ "@island.is/clients/university-application/university-of-iceland": [ "libs/clients/university-application/university-of-iceland/src/index.ts" ], + "@island.is/clients/university-careers": [ + "libs/clients/university-careers/src/index.ts" + ], "@island.is/clients/university-gateway-api": [ "libs/clients/university-gateway-api/src/index.ts" ], - "@island.is/clients/university-of-iceland": [ - "libs/clients/university-of-iceland/src/index.ts" - ], "@island.is/clients/user-notification": [ "libs/clients/user-notification/src/index.ts" ],