@kth/om-kursen-ladok-client 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { LadokMellanlagerApiClient, PeriodItem, SokUtbildningsTillfalleItem, SokUtbildningsTillfalleSlimItem } from '@kth/ladok-mellanlager-client';
|
|
2
2
|
import { PartOfProgramme } from '../mapPartOfProgramme';
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to get a list of educational instances (utbildningstillfällen) with
|
|
5
|
+
* some information (courseCode, swedish and english name) for the parent educational version.
|
|
6
|
+
*
|
|
7
|
+
* Because the endpoint utbildningstillfalle(Slim) does not include data from the version ("instans"),
|
|
8
|
+
* we have to first get the version UID, then query the search endpoint to find the educational instance with
|
|
9
|
+
* version information.
|
|
10
|
+
*
|
|
11
|
+
* @param utbildningsTillfalleUIDs
|
|
12
|
+
* @param ladokClient
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchEducationalInstancesWithVersionInfo: (utbildningsTillfalleUIDs: string[], ladokClient: LadokMellanlagerApiClient) => Promise<SokUtbildningsTillfalleSlimItem[]>;
|
|
3
16
|
export declare const processProgrammes: (programmeInstances: SokUtbildningsTillfalleItem[] | SokUtbildningsTillfalleSlimItem[], courseInstance: SokUtbildningsTillfalleItem | SokUtbildningsTillfalleSlimItem, periodItems: PeriodItem[], ladokClient: LadokMellanlagerApiClient, specialisationInstance?: SokUtbildningsTillfalleItem | SokUtbildningsTillfalleSlimItem) => Promise<PartOfProgramme[]>;
|
|
4
17
|
export declare const getPartOfProgrammes: (courseInstances: SokUtbildningsTillfalleItem[] | SokUtbildningsTillfalleSlimItem[], periodItems: PeriodItem[], ladokClient: LadokMellanlagerApiClient) => Promise<Record<string, PartOfProgramme[]>>;
|
|
@@ -9,29 +9,52 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getPartOfProgrammes = exports.processProgrammes = void 0;
|
|
12
|
+
exports.getPartOfProgrammes = exports.processProgrammes = exports.fetchEducationalInstancesWithVersionInfo = void 0;
|
|
13
13
|
const ladok_attributvarde_utils_1 = require("@kth/ladok-attributvarde-utils");
|
|
14
14
|
const mapPartOfProgramme_1 = require("../mapPartOfProgramme");
|
|
15
15
|
const studyYearUtil_1 = require("./studyYearUtil");
|
|
16
|
+
const getAllEntitiesByUseOfContinuation_1 = require("./getAllEntitiesByUseOfContinuation");
|
|
17
|
+
const responseUtils_1 = require("./responseUtils");
|
|
18
|
+
const queryConstants_1 = require("../queryConstants");
|
|
16
19
|
const extractUIDsByEducationType = (structureRefs, educationTypeID) => structureRefs.filter(x => x.UtbildningstypID == educationTypeID).map(x => x.UtbildningsattributbasUID);
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Utility function to get a list of educational instances (utbildningstillfällen) with
|
|
22
|
+
* some information (courseCode, swedish and english name) for the parent educational version.
|
|
23
|
+
*
|
|
24
|
+
* Because the endpoint utbildningstillfalle(Slim) does not include data from the version ("instans"),
|
|
25
|
+
* we have to first get the version UID, then query the search endpoint to find the educational instance with
|
|
26
|
+
* version information.
|
|
27
|
+
*
|
|
28
|
+
* @param utbildningsTillfalleUIDs
|
|
29
|
+
* @param ladokClient
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
const fetchEducationalInstancesWithVersionInfo = (utbildningsTillfalleUIDs, ladokClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
33
|
const results = yield Promise.all(utbildningsTillfalleUIDs.map((uid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
var _a
|
|
20
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
// 1. Query educationalInstance endpoint to get parent educationalVersion UID
|
|
36
|
+
const instanceWithoutVersionInfo = (_a = (yield ladokClient.utbildningstillfalleSlim(uid, {
|
|
21
37
|
attributVarden: 'utbildningsinstans.uid',
|
|
22
38
|
})).data) === null || _a === void 0 ? void 0 : _a.Attributvarden;
|
|
23
|
-
const versionUID = (0, ladok_attributvarde_utils_1.extractString)(
|
|
39
|
+
const versionUID = (0, ladok_attributvarde_utils_1.extractString)(instanceWithoutVersionInfo || [], 'utbildningsinstans.uid');
|
|
24
40
|
if (!versionUID)
|
|
25
41
|
return null;
|
|
26
|
-
|
|
42
|
+
// 2. Query search educationalInstance endpoint to get all educationalInstances for parent educationalVersion
|
|
43
|
+
const result = yield (0, getAllEntitiesByUseOfContinuation_1.getAllEntitiesByUseOfContinuation)(ladokClient.sokUtbildningsTillfalleSlim, {
|
|
27
44
|
utbildningsinstansUid: versionUID,
|
|
28
45
|
attributVarden: 'utbildning.attribut.startperiod',
|
|
29
46
|
instansAttributVarden: 'utbildning.attribut.kod,utbildning.attribut.svensk.benamning, utbildning.attribut.engelsk.benamning',
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
baraSistaVersion: 'false',
|
|
48
|
+
antalTraffar: queryConstants_1.MAX_ANTAL_TRAFFAR,
|
|
49
|
+
});
|
|
50
|
+
const allEntities = (0, responseUtils_1.throwIfContinuationError)(result);
|
|
51
|
+
// 3. Find the educationalInstance we are interested in
|
|
52
|
+
const instanceWithVersionInfo = allEntities.find(x => x.tillfalle_uid === uid);
|
|
53
|
+
return instanceWithVersionInfo !== null && instanceWithVersionInfo !== void 0 ? instanceWithVersionInfo : null;
|
|
32
54
|
})));
|
|
33
55
|
return results.filter((item) => Boolean(item));
|
|
34
56
|
});
|
|
57
|
+
exports.fetchEducationalInstancesWithVersionInfo = fetchEducationalInstancesWithVersionInfo;
|
|
35
58
|
const processProgrammes = (programmeInstances, courseInstance, periodItems, ladokClient, specialisationInstance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
59
|
return (yield Promise.all(programmeInstances.map((programmeInstance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
60
|
var _a, _b;
|
|
@@ -53,8 +76,9 @@ const processSpecialisations = (specialisationInstances, courseInstance, periodI
|
|
|
53
76
|
return [];
|
|
54
77
|
const structureRefs = ((_a = (yield ladokClient.strukturListaInnehaller(specialisationInstance.tillfalle_uid)).data) === null || _a === void 0 ? void 0 : _a.Strukturreferenser) ||
|
|
55
78
|
[];
|
|
79
|
+
// Here we assume that structureRefs only contain references to one ProgrammeInstance
|
|
56
80
|
const [firstProgrammeInstanceUID] = extractUIDsByEducationType(structureRefs, ladok_attributvarde_utils_1.EducationalTypeID.Programme);
|
|
57
|
-
const programmeInstances = yield
|
|
81
|
+
const programmeInstances = yield (0, exports.fetchEducationalInstancesWithVersionInfo)([firstProgrammeInstanceUID], ladokClient);
|
|
58
82
|
return (0, exports.processProgrammes)(programmeInstances, courseInstance, periodItems, ladokClient, specialisationInstance);
|
|
59
83
|
})))).flat();
|
|
60
84
|
});
|
|
@@ -73,8 +97,8 @@ const getPartOfProgramme = (courseInstance, periodItems, ladokClient) => __await
|
|
|
73
97
|
const structureRefs = ((_a = (yield ladokClient.strukturListaInnehaller(courseInstance.tillfalle_uid)).data) === null || _a === void 0 ? void 0 : _a.Strukturreferenser) || [];
|
|
74
98
|
const specialisationInstanceUIDs = extractUIDsByEducationType(structureRefs, ladok_attributvarde_utils_1.EducationalTypeID.Specialisation);
|
|
75
99
|
const programmeInstanceUIDs = extractUIDsByEducationType(structureRefs, ladok_attributvarde_utils_1.EducationalTypeID.Programme);
|
|
76
|
-
const specialisationInstances = (yield
|
|
77
|
-
const programmeInstances = (yield
|
|
100
|
+
const specialisationInstances = (yield (0, exports.fetchEducationalInstancesWithVersionInfo)(specialisationInstanceUIDs, ladokClient)) || [];
|
|
101
|
+
const programmeInstances = (yield (0, exports.fetchEducationalInstancesWithVersionInfo)(programmeInstanceUIDs, ladokClient)) || [];
|
|
78
102
|
const specialisationParts = yield processSpecialisations(specialisationInstances, courseInstance, periodItems, ladokClient);
|
|
79
103
|
const programmeParts = yield (0, exports.processProgrammes)(programmeInstances, courseInstance, periodItems, ladokClient);
|
|
80
104
|
const uniquePartOfProgrammes = removeDuplicateParts([...specialisationParts, ...programmeParts]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partOfProgrammeUtil.js","sourceRoot":"","sources":["../../src/utils/partOfProgrammeUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAiF;
|
|
1
|
+
{"version":3,"file":"partOfProgrammeUtil.js","sourceRoot":"","sources":["../../src/utils/partOfProgrammeUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAiF;AASjF,8DAA2E;AAC3E,mDAAmD;AACnD,2FAAuF;AACvF,mDAA0D;AAC1D,sDAAqD;AAErD,MAAM,0BAA0B,GAAG,CAAC,aAAiC,EAAE,eAAkC,EAAE,EAAE,CAC3G,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAA;AAExG;;;;;;;;;;;GAWG;AACI,MAAM,wCAAwC,GAAG,CACtD,wBAAkC,EAClC,WAAsC,EACtC,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,wBAAwB,CAAC,GAAG,CAAC,CAAM,GAAG,EAAC,EAAE;;QACvC,6EAA6E;QAC7E,MAAM,0BAA0B,GAAG,MAAA,CACjC,MAAM,WAAW,CAAC,wBAAwB,CAAC,GAAG,EAAE;YAC9C,cAAc,EAAE,wBAAwB;SACzC,CAAC,CACH,CAAC,IAAI,0CAAE,cAAc,CAAA;QAEtB,MAAM,UAAU,GAAG,IAAA,yCAAa,EAAC,0BAA0B,IAAI,EAAE,EAAE,wBAAwB,CAAC,CAAA;QAC5F,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAA;QAE5B,6GAA6G;QAC7G,MAAM,MAA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,EACX,WAAW,CACZ,CAAA;IACD,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,EAAC,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;IAE5G,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,CAAC,GAAG,mBAAmB,EAAE,GAAG,cAAc,CAAC,CAAC,CAAA;IAEhG,OAAO,sBAAsB,CAAA;AAC/B,CAAC,CAAA,CAAA;AAEM,MAAM,mBAAmB,GAAG,CACjC,eAAkF,EAClF,WAAyB,EACzB,WAAsC,EACtC,EAAE;IACF,MAAM,gBAAgB,GAAsC,EAAE,CAAA;IAE9D,MAAM,OAAO,CAAC,GAAG,CACf,eAAe,CAAC,GAAG,CAAC,CAAM,cAAc,EAAC,EAAE;QACzC,gBAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,MAAM,kBAAkB,CACvE,cAAc,EACd,WAAW,EACX,WAAW,CACZ,CAAA;IACH,CAAC,CAAA,CAAC,CACH,CAAA;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA,CAAA;AAlBY,QAAA,mBAAmB,uBAkB/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kth/om-kursen-ladok-client",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Om kursen specific logic and mappings, uses both @kth/ladok-mellanlager-client and @kth/ladok-attributevarde-utils.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@kth/ladok-attributvarde-utils": "1.0.4",
|
|
25
|
-
"@kth/ladok-mellanlager-client": "1.
|
|
25
|
+
"@kth/ladok-mellanlager-client": "1.2.0",
|
|
26
26
|
"date-fns": "^4.1.0",
|
|
27
27
|
"showdown": "^2.1.0"
|
|
28
28
|
}
|