From 9a3b5b2aa31d24de8487f944226398e1e4267e6e Mon Sep 17 00:00:00 2001 From: Karl Andin Date: Fri, 6 Dec 2024 16:09:36 +0100 Subject: [PATCH 1/3] feat(KUI-1640): switch to install om-kursen-ladok-client from npm. --- package-lock.json | 53 +++++++++++++------ package.json | 2 +- server/apiCalls/ladokApi.js | 2 +- .../controllers/__tests__/courseCtrl.test.js | 2 +- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ff254b8..05753c56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@kth/kth-node-web-common": "^9.3.1", "@kth/log": "^4.0.7", "@kth/monitor": "^4.3.1", + "@kth/om-kursen-ladok-client": "^1.0.5", "@kth/server": "^4.1.0", "@kth/session": "^3.0.9", "@kth/style": "^1.4.2", @@ -34,7 +35,6 @@ "kth-node-i18n": "^1.0.18", "kth-node-redis": "^3.3.0", "kth-style": "^10.3.3", - "om-kursen-ladok-client": "file:../studadm-om-kursen-packages/packages/om-kursen-ladok-client", "react": "^18.3.1", "react-data-table-component": "^7.6.2", "react-dom": "^18.3.1", @@ -89,18 +89,6 @@ "node": "18" } }, - "../studadm-om-kursen-packages/packages/ladok-mellanlager-client": { - "version": "0.0.1", - "extraneous": true, - "hasInstallScript": true - }, - "../studadm-om-kursen-packages/packages/om-kursen-ladok-client": { - "version": "0.0.1", - "dependencies": { - "ladok-attributvarde-utils": "file:../ladok-attributvarde-utils", - "ladok-mellanlager-client": "file:../ladok-mellanlager-client" - } - }, "node_modules/@adobe/css-tools": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz", @@ -3512,6 +3500,19 @@ "locale": "^0.1.0" } }, + "node_modules/@kth/ladok-attributvarde-utils": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@kth/ladok-attributvarde-utils/-/ladok-attributvarde-utils-0.0.8.tgz", + "integrity": "sha512-nTKhshyBSiryNz2V81HHN79vkRaJwtTq1A2/Nbbfv53JV5d8NGCTcvmMSMVy1TdGunKE0TL7QrfFSq9IFaYacw==" + }, + "node_modules/@kth/ladok-mellanlager-client": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@kth/ladok-mellanlager-client/-/ladok-mellanlager-client-0.0.4.tgz", + "integrity": "sha512-osDlbtJ9E0aGPkxwodYXotlnBMTSGiYTVAv9zSWfNVd4GwAqkCTd8VvK7MD3AgGy6eqc0FHQF0/mVeaBM9w/Og==", + "dependencies": { + "openapi-fetch": "^0.13.0" + } + }, "node_modules/@kth/log": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/@kth/log/-/log-4.0.7.tgz", @@ -3531,6 +3532,15 @@ "@kth/log": "^4.0.7" } }, + "node_modules/@kth/om-kursen-ladok-client": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@kth/om-kursen-ladok-client/-/om-kursen-ladok-client-1.0.5.tgz", + "integrity": "sha512-nduL1lQ07N45kveA7ntOXVXP0T0ghP0r46Wid8XB/X6AW91+L5jHpeBuY7jvrKFqgJ36VE0Fk0lqiqOaTQ0vLg==", + "dependencies": { + "@kth/ladok-attributvarde-utils": "0.0.8", + "@kth/ladok-mellanlager-client": "0.0.4" + } + }, "node_modules/@kth/server": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@kth/server/-/server-4.1.0.tgz", @@ -14659,10 +14669,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/om-kursen-ladok-client": { - "resolved": "../studadm-om-kursen-packages/packages/om-kursen-ladok-client", - "link": true - }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -14709,6 +14715,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/openapi-fetch": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/openapi-fetch/-/openapi-fetch-0.13.3.tgz", + "integrity": "sha512-M1THnPkNOXUPsQKZfqunhW/wqH8l3/W3Vlj4lemQynf4mTaTwBTvL2pgjBe0zerL/GFT5ttCHu9fYvanUI3tOw==", + "dependencies": { + "openapi-typescript-helpers": "^0.0.15" + } + }, + "node_modules/openapi-typescript-helpers": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.15.tgz", + "integrity": "sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==" + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", diff --git a/package.json b/package.json index 4b2d7a1a..f15c61a6 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@kth/kth-node-web-common": "^9.3.1", "@kth/log": "^4.0.7", "@kth/monitor": "^4.3.1", + "@kth/om-kursen-ladok-client": "^1.0.5", "@kth/server": "^4.1.0", "@kth/session": "^3.0.9", "@kth/style": "^1.4.2", @@ -51,7 +52,6 @@ "kth-node-i18n": "^1.0.18", "kth-node-redis": "^3.3.0", "kth-style": "^10.3.3", - "om-kursen-ladok-client": "file:../studadm-om-kursen-packages/packages/om-kursen-ladok-client", "react": "^18.3.1", "react-data-table-component": "^7.6.2", "react-dom": "^18.3.1", diff --git a/server/apiCalls/ladokApi.js b/server/apiCalls/ladokApi.js index 484e476a..cd9398c1 100644 --- a/server/apiCalls/ladokApi.js +++ b/server/apiCalls/ladokApi.js @@ -1,6 +1,6 @@ 'use strict' -const { createApiClient } = require('om-kursen-ladok-client') +const { createApiClient } = require('@kth/om-kursen-ladok-client') const serverConfig = require('../configuration').server async function getCourseAndActiveRounds(courseCode, language) { diff --git a/server/controllers/__tests__/courseCtrl.test.js b/server/controllers/__tests__/courseCtrl.test.js index c94b1087..da32204d 100644 --- a/server/controllers/__tests__/courseCtrl.test.js +++ b/server/controllers/__tests__/courseCtrl.test.js @@ -33,7 +33,7 @@ jest.mock('@kth/kth-node-web-common/lib/language', () => ({ jest.mock('kth-node-express-routing', () => ({ getPaths: jest.fn(() => applicationPaths), })) -jest.mock('om-kursen-ladok-client', () => ({ +jest.mock('@kth/om-kursen-ladok-client', () => ({ createApiClient: () => ({ getLatestCourseVersion: () => mockedLadokData.mockedLadokCourseVersion, getActiveCourseRounds: () => mockedLadokData.mockedLadokRounds, From ebd02c5f4a82f9f94bca158854b67251951a1ac3 Mon Sep 17 00:00:00 2001 From: Karl Andin Date: Fri, 6 Dec 2024 16:10:08 +0100 Subject: [PATCH 2/3] fix(KUI-1640): fix some bugs when data is missing for a round. --- server/apiCalls/getFilteredData.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/apiCalls/getFilteredData.js b/server/apiCalls/getFilteredData.js index 6494f9c4..d7e0fda5 100644 --- a/server/apiCalls/getFilteredData.js +++ b/server/apiCalls/getFilteredData.js @@ -139,15 +139,15 @@ function _getRound(koppsRoundObject = {}, ladokRound, language = 'sv') { round_start_date: getDateFormat(parseOrSetEmpty(ladokRound.forstaUndervisningsdatum.date, language), language), round_end_date: getDateFormat(parseOrSetEmpty(ladokRound.sistaUndervisningsdatum.date, language), language), round_target_group: parseOrSetEmpty(ladokRound.malgrupp, language), - round_tutoring_form: ladokRound.undervisningsform.code, - round_tutoring_time: ladokRound.undervisningstid.code, + round_tutoring_form: parseOrSetEmpty(ladokRound.undervisningsform?.code, language), + round_tutoring_time: parseOrSetEmpty(ladokRound.undervisningstid?.code, language), round_tutoring_language: parseOrSetEmpty(ladokRound.undervisningssprak?.name, language), - round_course_place: parseOrSetEmpty(ladokRound.studieort.name, language), + round_course_place: parseOrSetEmpty(ladokRound.studieort?.name, language), round_short_name: parseOrSetEmpty(ladokRound.kortnamn, language), round_application_code: parseOrSetEmpty(ladokRound.tillfalleskod, language), - round_study_pace: parseOrSetEmpty(ladokRound.studietakt.takt, language), - round_course_term: parseSemesterIntoYearSemesterNumberArray(ladokRound.startperiod.inDigits), - round_funding_type: parseOrSetEmpty(ladokRound.finansieringsform.code, language), + round_study_pace: parseOrSetEmpty(ladokRound.studietakt?.takt, language), + round_course_term: parseSemesterIntoYearSemesterNumberArray(ladokRound.startperiod?.inDigits), + round_funding_type: parseOrSetEmpty(ladokRound.finansieringsform?.code, language), round_seats: _parseRoundSeatsMsg( parseOrSetEmpty(ladokRound.utbildningsplatser, language, true), From 4ba79e37955f547e138cc36c76b5a409f8206afc Mon Sep 17 00:00:00 2001 From: Karl Andin Date: Fri, 6 Dec 2024 16:10:49 +0100 Subject: [PATCH 3/3] chore(deps): npm audit fix --- package-lock.json | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 05753c56..4376a660 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7074,10 +7074,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "license": "MIT", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -8998,10 +8997,9 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", - "license": "MIT", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -9022,7 +9020,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -9037,6 +9035,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express-handlebars": { @@ -14955,10 +14957,9 @@ "license": "ISC" }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", - "license": "MIT" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, "node_modules/path-type": { "version": "4.0.0",