@kth/ladok-mellanlager-client 0.0.2

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.
Files changed (53) hide show
  1. package/README.md +11 -0
  2. package/dist/__generated__/ladok-mellanlagring.d.ts +1328 -0
  3. package/dist/__generated__/ladok-mellanlagring.js +7 -0
  4. package/dist/__generated__/ladok-mellanlagring.js.map +1 -0
  5. package/dist/helpers/createOpenApiClient.d.ts +3 -0
  6. package/dist/helpers/createOpenApiClient.js +36 -0
  7. package/dist/helpers/createOpenApiClient.js.map +1 -0
  8. package/dist/helpers/getAuthToken.d.ts +8 -0
  9. package/dist/helpers/getAuthToken.js +68 -0
  10. package/dist/helpers/getAuthToken.js.map +1 -0
  11. package/dist/helpers/mapResponse.d.ts +9 -0
  12. package/dist/helpers/mapResponse.js +44 -0
  13. package/dist/helpers/mapResponse.js.map +1 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.js +72 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/types/attribut.d.ts +15 -0
  18. package/dist/types/attribut.js +3 -0
  19. package/dist/types/attribut.js.map +1 -0
  20. package/dist/types/endpoints/planForUtbildning.d.ts +2 -0
  21. package/dist/types/endpoints/planForUtbildning.js +3 -0
  22. package/dist/types/endpoints/planForUtbildning.js.map +1 -0
  23. package/dist/types/endpoints/planForUtbildningUtbildningsinstans.d.ts +4 -0
  24. package/dist/types/endpoints/planForUtbildningUtbildningsinstans.js +3 -0
  25. package/dist/types/endpoints/planForUtbildningUtbildningsinstans.js.map +1 -0
  26. package/dist/types/endpoints/sokKursTillfalle.d.ts +49 -0
  27. package/dist/types/endpoints/sokKursTillfalle.js +3 -0
  28. package/dist/types/endpoints/sokKursTillfalle.js.map +1 -0
  29. package/dist/types/endpoints/sokUtbildningsInstans.d.ts +31 -0
  30. package/dist/types/endpoints/sokUtbildningsInstans.js +3 -0
  31. package/dist/types/endpoints/sokUtbildningsInstans.js.map +1 -0
  32. package/dist/types/endpoints/utbildningsinstans.d.ts +1 -0
  33. package/dist/types/endpoints/utbildningsinstans.js +3 -0
  34. package/dist/types/endpoints/utbildningsinstans.js.map +1 -0
  35. package/dist/types/endpoints/utbildningstillfalle.d.ts +1 -0
  36. package/dist/types/endpoints/utbildningstillfalle.js +3 -0
  37. package/dist/types/endpoints/utbildningstillfalle.js.map +1 -0
  38. package/dist/types/index.d.ts +11 -0
  39. package/dist/types/index.js +28 -0
  40. package/dist/types/index.js.map +1 -0
  41. package/dist/types/ladokMellanlagerApiClient.d.ts +27 -0
  42. package/dist/types/ladokMellanlagerApiClient.js +3 -0
  43. package/dist/types/ladokMellanlagerApiClient.js.map +1 -0
  44. package/dist/types/ladokMellanlagerApiClientConfig.d.ts +8 -0
  45. package/dist/types/ladokMellanlagerApiClientConfig.js +3 -0
  46. package/dist/types/ladokMellanlagerApiClientConfig.js.map +1 -0
  47. package/dist/types/plan.d.ts +10 -0
  48. package/dist/types/plan.js +3 -0
  49. package/dist/types/plan.js.map +1 -0
  50. package/dist/types/response.d.ts +38 -0
  51. package/dist/types/response.js +3 -0
  52. package/dist/types/response.js.map +1 -0
  53. package/package.json +33 -0
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by openapi-typescript.
4
+ * Do not make direct changes to the file.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=ladok-mellanlagring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ladok-mellanlagring.js","sourceRoot":"","sources":["../../src/__generated__/ladok-mellanlagring.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,3 @@
1
+ import { LadokMellanlagerApiClientConfig } from "../types";
2
+ import { paths } from "../__generated__/ladok-mellanlagring";
3
+ export declare const createOpenApiClient: (config: LadokMellanlagerApiClientConfig) => import("openapi-fetch").Client<paths, `${string}/${string}`>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.createOpenApiClient = void 0;
16
+ const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
17
+ const getAuthToken_1 = require("./getAuthToken");
18
+ const createOpenApiClient = (config) => {
19
+ const client = (0, openapi_fetch_1.default)({ baseUrl: config.baseUrl });
20
+ const authMiddleware = {
21
+ onRequest(_a) {
22
+ return __awaiter(this, arguments, void 0, function* ({ request }) {
23
+ const accessToken = yield (0, getAuthToken_1.getAccessToken)(config);
24
+ if (!accessToken)
25
+ throw new Error("no accesstoken");
26
+ request.headers.set("Ocp-Apim-Subscription-Key", config.ocpApimSubscriptionKey);
27
+ request.headers.set("Authorization", `Bearer ${accessToken}`);
28
+ return request;
29
+ });
30
+ },
31
+ };
32
+ client.use(authMiddleware);
33
+ return client;
34
+ };
35
+ exports.createOpenApiClient = createOpenApiClient;
36
+ //# sourceMappingURL=createOpenApiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOpenApiClient.js","sourceRoot":"","sources":["../../src/helpers/createOpenApiClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAAyD;AAEzD,iDAAgD;AAGzC,MAAM,mBAAmB,GAAG,CACjC,MAAuC,EACvC,EAAE;IACF,MAAM,MAAM,GAAG,IAAA,uBAAY,EAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,MAAM,cAAc,GAAe;QAC3B,SAAS;iEAAC,EAAE,OAAO,EAAE;gBACzB,MAAM,WAAW,GAAG,MAAM,IAAA,6BAAc,EAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,CAAC,WAAW;oBAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAEpD,OAAO,CAAC,OAAO,CAAC,GAAG,CACjB,2BAA2B,EAC3B,MAAM,CAAC,sBAAsB,CAC9B,CAAC;gBACF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;gBAC9D,OAAO,OAAO,CAAC;YACjB,CAAC;SAAA;KACF,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B"}
@@ -0,0 +1,8 @@
1
+ type Config = {
2
+ tokenUrl: string;
3
+ clientId: string;
4
+ clientSecret: string;
5
+ scope: string;
6
+ };
7
+ declare const getAccessToken: (tokenConfig: Config) => Promise<string | null>;
8
+ export { getAccessToken };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /* eslint-disable no-use-before-define */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getAccessToken = void 0;
14
+ // TODO(Ladok-POC): use MSAL lib? https://github.com/KTH/ug-rest-api-helper/blob/main/tokenCall.js
15
+ const GRANT_TYPE = "client_credentials";
16
+ const CONTENT_TYPE = "application/x-www-form-urlencoded";
17
+ const JWT_PAYLOAD_INDEX = 1;
18
+ // token attribute to store to avoid recalling authentication call if it's not expired
19
+ let token = null;
20
+ /**
21
+ * @returns false if there is a currently valid token. True otherwise.
22
+ */
23
+ const isTokenExpired = () => {
24
+ if (token) {
25
+ return getCurrentTimestampInSeconds() > getExpirationTimestamp(token);
26
+ }
27
+ return true;
28
+ };
29
+ const getCurrentTimestampInSeconds = () => Math.floor(Date.now() / 1000);
30
+ /**
31
+ * Decodes and returns the payload of the given JWT as JSON object according to https://jwt.io/
32
+ * @param {string} accessToken
33
+ * @returns JSON representation of the JWT's payload
34
+ */
35
+ const decodeJWTokenPayload = (accessToken) => {
36
+ const tokenParts = accessToken.split(".");
37
+ return JSON.parse(Buffer.from(tokenParts[JWT_PAYLOAD_INDEX], "base64").toString());
38
+ };
39
+ const getExpirationTimestamp = (accessToken) => {
40
+ const { exp } = decodeJWTokenPayload(accessToken);
41
+ return exp;
42
+ };
43
+ const getNewToken = (_a) => __awaiter(void 0, [_a], void 0, function* ({ tokenUrl, clientId, clientSecret, scope, }) {
44
+ const data = {
45
+ grant_type: GRANT_TYPE,
46
+ client_id: clientId,
47
+ client_secret: clientSecret,
48
+ scope,
49
+ };
50
+ const urlEncodedData = new URLSearchParams(Object.entries(data)).toString();
51
+ const jwtTokenResponse = yield fetch(tokenUrl, {
52
+ method: "POST",
53
+ body: urlEncodedData,
54
+ headers: {
55
+ "Content-Type": CONTENT_TYPE,
56
+ },
57
+ });
58
+ const result = yield jwtTokenResponse.json();
59
+ return result.access_token;
60
+ });
61
+ const getAccessToken = (tokenConfig) => __awaiter(void 0, void 0, void 0, function* () {
62
+ if (isTokenExpired()) {
63
+ token = yield getNewToken(tokenConfig);
64
+ }
65
+ return token;
66
+ });
67
+ exports.getAccessToken = getAccessToken;
68
+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,UAAU;QACtB,SAAS,EAAE,QAAQ;QACnB,aAAa,EAAE,YAAY;QAC3B,KAAK;KACN,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC5E,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;QAC7C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE;YACP,cAAc,EAAE,YAAY;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,CAAC;IAE7C,OAAO,MAAM,CAAC,YAAY,CAAC;AAC7B,CAAC,CAAA,CAAC;AAEF,MAAM,cAAc,GAAG,CAAO,WAAmB,EAAE,EAAE;IACnD,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,KAAK,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAEO,wCAAc"}
@@ -0,0 +1,9 @@
1
+ import { MellanlagringResponse, MellanlagringSearchResponse } from "../types";
2
+ type ResponseData = {
3
+ data?: unknown;
4
+ error?: unknown;
5
+ response: Response;
6
+ };
7
+ export declare const mapResponse: <T>({ data, error, response, }: ResponseData) => MellanlagringResponse<T>;
8
+ export declare const mapSearchResponse: <TResponse>({ data, error, response, }: ResponseData) => MellanlagringSearchResponse<TResponse>;
9
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapSearchResponse = exports.mapResponse = void 0;
4
+ const createOkResponseInfo = (response, rest) => {
5
+ return Object.assign({ type: "success", responseInfo: {
6
+ apiError: false,
7
+ statusCode: response.status,
8
+ statusText: response.statusText,
9
+ } }, rest);
10
+ };
11
+ const createErrorResponse = (response, msg) => {
12
+ return {
13
+ type: "error",
14
+ responseInfo: {
15
+ apiError: true,
16
+ statusCode: response.status,
17
+ statusText: response.statusText,
18
+ message: msg !== null && msg !== void 0 ? msg : "An unknown error occured when performing the request",
19
+ },
20
+ };
21
+ };
22
+ const mapResponse = ({ data, error, response, }) => {
23
+ if (error) {
24
+ return createErrorResponse(response);
25
+ }
26
+ else {
27
+ return createOkResponseInfo(response, { data: data });
28
+ }
29
+ };
30
+ exports.mapResponse = mapResponse;
31
+ const mapSearchResponse = ({ data, error, response, }) => {
32
+ if (error) {
33
+ return createErrorResponse(response);
34
+ }
35
+ else if (!Array.isArray(data)) {
36
+ return createErrorResponse(response);
37
+ }
38
+ else {
39
+ const [searchMeta, ...items] = data;
40
+ return createOkResponseInfo(response, { searchMeta, items });
41
+ }
42
+ };
43
+ exports.mapSearchResponse = mapSearchResponse;
44
+ //# sourceMappingURL=mapResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapResponse.js","sourceRoot":"","sources":["../../src/helpers/mapResponse.ts"],"names":[],"mappings":";;;AAEA,MAAM,oBAAoB,GAAG,CAAI,QAAkB,EAAE,IAAO,EAAE,EAAE;IAC9D,OAAO,gBACL,IAAI,EAAE,SAAS,EACf,YAAY,EAAE;YACZ,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;SAChC,IACE,IAAI,CACC,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,QAAkB,EAAE,GAAY,EAAE,EAAE;IAC/D,OAAO;QACL,IAAI,EAAE,OAAO;QACb,YAAY,EAAE;YACZ,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO,EAAE,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,sDAAsD;SACvE;KACO,CAAC;AACb,CAAC,CAAC;AAQK,MAAM,WAAW,GAAG,CAAI,EAC7B,IAAI,EACJ,KAAK,EACL,QAAQ,GACK,EAA4B,EAAE;IAC3C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,OAAO,oBAAoB,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAS,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB;AAEK,MAAM,iBAAiB,GAAG,CAAY,EAC3C,IAAI,EACJ,KAAK,EACL,QAAQ,GACK,EAA0C,EAAE;IACzD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC;QACpC,OAAO,oBAAoB,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B"}
@@ -0,0 +1,3 @@
1
+ import { LadokMellanlagerApiClient, LadokMellanlagerApiClientConfig } from "./types";
2
+ export declare const createClient: (config: LadokMellanlagerApiClientConfig) => LadokMellanlagerApiClient;
3
+ export * from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.createClient = void 0;
27
+ const createOpenApiClient_1 = require("./helpers/createOpenApiClient");
28
+ const mapResponse_1 = require("./helpers/mapResponse");
29
+ const createClient = (config) => {
30
+ const openApiClient = (0, createOpenApiClient_1.createOpenApiClient)(config);
31
+ return {
32
+ sokKursTillfalle: (query) => __awaiter(void 0, void 0, void 0, function* () {
33
+ const data = yield openApiClient.GET("/sokKurstillfalle", {
34
+ params: { query },
35
+ });
36
+ return (0, mapResponse_1.mapSearchResponse)(data);
37
+ }),
38
+ sokUtbildningsInstans: (query) => __awaiter(void 0, void 0, void 0, function* () {
39
+ const data = yield openApiClient.GET("/sokUtbildningsinstans", {
40
+ params: { query },
41
+ });
42
+ return (0, mapResponse_1.mapSearchResponse)(data);
43
+ }),
44
+ utbildningsinstans: (uid) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const res = yield openApiClient.GET("/utbildningsinstans/{uid}", {
46
+ params: { path: { uid } },
47
+ });
48
+ return (0, mapResponse_1.mapResponse)(res);
49
+ }),
50
+ utbildningstillfalle: (uid) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const res = yield openApiClient.GET("/utbildningstillfalle/{uid}", {
52
+ params: { path: { uid } },
53
+ });
54
+ return (0, mapResponse_1.mapResponse)(res);
55
+ }),
56
+ planForUtbildning: (uid) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const res = yield openApiClient.GET("/plan_for_utbildning/{uid}", {
58
+ params: { path: { uid } },
59
+ });
60
+ return (0, mapResponse_1.mapResponse)(res);
61
+ }),
62
+ planForUtbildningUtbildningsinstans: (uid) => __awaiter(void 0, void 0, void 0, function* () {
63
+ const res = yield openApiClient.GET("/plan_for_utbildning/utbildningsinstans/{uid}", {
64
+ params: { path: { uid } },
65
+ });
66
+ return (0, mapResponse_1.mapResponse)(res);
67
+ }),
68
+ };
69
+ };
70
+ exports.createClient = createClient;
71
+ __exportStar(require("./types"), exports);
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAoE;AACpE,uDAAuE;AAahE,MAAM,YAAY,GAAG,CAC1B,MAAuC,EACZ,EAAE;IAC7B,MAAM,aAAa,GAAG,IAAA,yCAAmB,EAAC,MAAM,CAAC,CAAC;IAElD,OAAO;QACL,gBAAgB,EAAE,CAAO,KAAK,EAAE,EAAE;YAChC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,mBAAmB,EAAE;gBACxD,MAAM,EAAE,EAAE,KAAK,EAAE;aAClB,CAAC,CAAC;YACH,OAAO,IAAA,+BAAiB,EAAuB,IAAI,CAAC,CAAC;QACvD,CAAC,CAAA;QACD,qBAAqB,EAAE,CAAO,KAAK,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,wBAAwB,EAAE;gBAC7D,MAAM,EAAE,EAAE,KAAK,EAAE;aAClB,CAAC,CAAC;YACH,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p: string;
3
+ Kod: string;
4
+ Uid?: string;
5
+ };
6
+ export type Attributvarde = {
7
+ Attributdefinition?: Attributdefinition;
8
+ Varden?: string[];
9
+ GrupperadeVarden?: {
10
+ Varden: {
11
+ Attributdefinition: Attributdefinition;
12
+ Varden: string[];
13
+ }[];
14
+ }[];
15
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=attribut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribut.js","sourceRoot":"","sources":["../../src/types/attribut.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { Plan } from "../plan";
2
+ export type PlanForUtbildning = Plan;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=planForUtbildning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planForUtbildning.js","sourceRoot":"","sources":["../../../src/types/endpoints/planForUtbildning.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { Plan } from "../plan";
2
+ export type PlanForUtbildning_Utbildningsinstans = {
3
+ PlanerForUtbildning: Plan[];
4
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=planForUtbildningUtbildningsinstans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planForUtbildningUtbildningsinstans.js","sourceRoot":"","sources":["../../../src/types/endpoints/planForUtbildningUtbildningsinstans.ts"],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ import { Attributvarde } from "../attribut";
2
+ export type SokKursTillfalleItem = {
3
+ tillfalle_uid: string;
4
+ instans_uid: string;
5
+ Attributvarden: Attributvarde[];
6
+ instans: {
7
+ Attributvarden: Attributvarde[];
8
+ };
9
+ Tillfallesperioder: [
10
+ {
11
+ ForstaRegistreringsdatum: string;
12
+ ForstaUndervisningsdatum: string;
13
+ Omfattningsvarde: number;
14
+ SistaRegistreringsdatum: string;
15
+ SistaUndervisningsdatum: string;
16
+ }
17
+ ];
18
+ index: {
19
+ "utbildning.attribut.kod": string;
20
+ "utbildning.attribut.svensk.benamning": string;
21
+ "utbildning.attribut.engelsk.benamning": string;
22
+ "utbildningstyp.kod": string;
23
+ "utbildningstyp.grundtyp": string;
24
+ "utbildningstyp.id": string;
25
+ "utbildning.attribut.undervisningssprak.kod": string;
26
+ "utbildning.attribut.organisation.kod": string;
27
+ "utbildning.attribut.startperiod.kod": string;
28
+ "utbildning.attribut.omfattning": string;
29
+ "utbildning.attribut.studieort.kod": string;
30
+ "utbildning.attribut.amnesgrupp.kod": string;
31
+ "utbildning.attribut.amnesord.kod": string;
32
+ "utbildning.attribut.undervisningstid.kod": string;
33
+ "utbildning.attribut.undervisningsform.kod": string;
34
+ "utbildning.attribut.betygsskala.kod": string;
35
+ "utbildning.attribut.huvudomrade.kod": string;
36
+ versionsnummer: string;
37
+ avvecklad: string;
38
+ Tillstand: "";
39
+ "sammanslagen_tillfallesperiod.start.dag": string;
40
+ "utbildning.uid": string;
41
+ "versionsnummer.max": string;
42
+ kodEllerBenamning: string;
43
+ "instansutbildningstyp.kod": string;
44
+ "instansutbildningstyp.grundtyp": string;
45
+ "instansutbildningstyp.id": string;
46
+ "instansutbildning.attribut.organisation.kod": string;
47
+ "instansversionsnummer.max": string;
48
+ };
49
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=sokKursTillfalle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sokKursTillfalle.js","sourceRoot":"","sources":["../../../src/types/endpoints/sokKursTillfalle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { Attributvarde } from "../attribut";
2
+ export type SokUtbildningsInstansItem = {
3
+ instans_uid?: string;
4
+ Attributvarden: Attributvarde[];
5
+ index: {
6
+ "utbildning.attribut.kod": string;
7
+ "utbildning.attribut.engelsk.benamning": string;
8
+ "utbildning.attribut.svensk.benamning": string;
9
+ "utbildningstyp.kod": string;
10
+ "utbildningstyp.grundtyp": string;
11
+ "utbildningstyp.id": string;
12
+ "utbildning.attribut.undervisningssprak.kod": string;
13
+ "utbildning.attribut.organisation.kod": string;
14
+ "utbildning.attribut.startperiod.kod": string;
15
+ "utbildning.attribut.omfattning": string;
16
+ "utbildning.attribut.studieort.kod": string;
17
+ "utbildning.attribut.amnesgrupp.kod": string;
18
+ "utbildning.attribut.amnesord.kod": string;
19
+ "utbildning.attribut.undervisningstid.kod": string;
20
+ "utbildning.attribut.undervisningsform.kod": string;
21
+ versionsnummer: string;
22
+ avvecklad: string;
23
+ "sammanslagen_tillfallesperiod.start.dag": string;
24
+ "utbildning.uid": string;
25
+ "versionsnummer.max": string;
26
+ kodEllerBenamning: string;
27
+ "utbildning.attribut.betygsskala.kod": string;
28
+ "utbildning.attribut.huvudomrade.kod": string;
29
+ Tillstand: string;
30
+ };
31
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=sokUtbildningsInstans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sokUtbildningsInstans.js","sourceRoot":"","sources":["../../../src/types/endpoints/sokUtbildningsInstans.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type Utbildningsinstans = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utbildningsinstans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utbildningsinstans.js","sourceRoot":"","sources":["../../../src/types/endpoints/utbildningsinstans.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type Utbildningstillfalle = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utbildningstillfalle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utbildningstillfalle.js","sourceRoot":"","sources":["../../../src/types/endpoints/utbildningstillfalle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export * from "./ladokMellanlagerApiClientConfig";
2
+ export * from "./ladokMellanlagerApiClient";
3
+ export * from "./endpoints/sokUtbildningsInstans";
4
+ export * from "./endpoints/sokKursTillfalle";
5
+ export * from "./endpoints/planForUtbildning";
6
+ export * from "./endpoints/planForUtbildningUtbildningsinstans";
7
+ export * from "./endpoints/utbildningsinstans";
8
+ export * from "./endpoints/utbildningstillfalle";
9
+ export * from "./attribut";
10
+ export * from "./plan";
11
+ export * from "./response";
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ladokMellanlagerApiClientConfig"), exports);
18
+ __exportStar(require("./ladokMellanlagerApiClient"), exports);
19
+ __exportStar(require("./endpoints/sokUtbildningsInstans"), exports);
20
+ __exportStar(require("./endpoints/sokKursTillfalle"), exports);
21
+ __exportStar(require("./endpoints/planForUtbildning"), exports);
22
+ __exportStar(require("./endpoints/planForUtbildningUtbildningsinstans"), exports);
23
+ __exportStar(require("./endpoints/utbildningsinstans"), exports);
24
+ __exportStar(require("./endpoints/utbildningstillfalle"), exports);
25
+ __exportStar(require("./attribut"), exports);
26
+ __exportStar(require("./plan"), exports);
27
+ __exportStar(require("./response"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,8DAA4C;AAE5C,oEAAkD;AAClD,+DAA6C;AAC7C,gEAA8C;AAC9C,kFAAgE;AAChE,iEAA+C;AAC/C,mEAAiD;AAEjD,6CAA2B;AAC3B,yCAAuB;AAEvB,6CAA2B"}
@@ -0,0 +1,27 @@
1
+ import { operations } from "../__generated__/ladok-mellanlagring";
2
+ import { PlanForUtbildning } from "./endpoints/planForUtbildning";
3
+ import { PlanForUtbildning_Utbildningsinstans } from "./endpoints/planForUtbildningUtbildningsinstans";
4
+ import { SokKursTillfalleItem } from "./endpoints/sokKursTillfalle";
5
+ import { SokUtbildningsInstansItem } from "./endpoints/sokUtbildningsInstans";
6
+ import { Utbildningsinstans } from "./endpoints/utbildningsinstans";
7
+ import { Utbildningstillfalle } from "./endpoints/utbildningstillfalle";
8
+ import { MellanlagringResponse, MellanlagringSearchResponse } from "./response";
9
+ /**
10
+ * Client with one function per endpoint in Ladok mellanlagring API.
11
+ * The functions name should be the same as the path for the endpoint.
12
+ *
13
+ * Response for all functions is either of type MellanlagringResponse<TResponse> or
14
+ * MellanlagringSearchResponse<TResponse> where <TResponse> is type for the specific
15
+ * endpoint.
16
+ *
17
+ * Types for args should if possible be extracted from openapi generated types
18
+ * (e.g. operations["<endpoint>"]["parameters"]["query"])
19
+ */
20
+ export interface LadokMellanlagerApiClient {
21
+ sokKursTillfalle(args: operations["sokKursTillfälle"]["parameters"]["query"]): Promise<MellanlagringSearchResponse<SokKursTillfalleItem>>;
22
+ sokUtbildningsInstans(args: operations["sokUtbildningsInstans"]["parameters"]["query"]): Promise<MellanlagringSearchResponse<SokUtbildningsInstansItem>>;
23
+ utbildningsinstans(uid: string): Promise<MellanlagringResponse<Utbildningsinstans>>;
24
+ utbildningstillfalle(uid: string): Promise<MellanlagringResponse<Utbildningstillfalle>>;
25
+ planForUtbildning(uid: string): Promise<MellanlagringResponse<PlanForUtbildning>>;
26
+ planForUtbildningUtbildningsinstans(uid: string): Promise<MellanlagringResponse<PlanForUtbildning_Utbildningsinstans>>;
27
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ladokMellanlagerApiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ladokMellanlagerApiClient.js","sourceRoot":"","sources":["../../src/types/ladokMellanlagerApiClient.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export interface LadokMellanlagerApiClientConfig {
2
+ baseUrl: string;
3
+ tokenUrl: string;
4
+ clientId: string;
5
+ clientSecret: string;
6
+ scope: string;
7
+ ocpApimSubscriptionKey: string;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ladokMellanlagerApiClientConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ladokMellanlagerApiClientConfig.js","sourceRoot":"","sources":["../../src/types/ladokMellanlagerApiClientConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { Attributvarde } from "./attribut";
2
+ export type Plan = {
3
+ AktuellaAttributvarden: Attributvarde[];
4
+ BeslutsinformationForPlan: unknown;
5
+ GiltigFran: string;
6
+ OvergripandeBeslutForPlan: unknown;
7
+ Tillstand: "EJ_BESLUTAD" | "BORTTAGEN" | "BESLUTAD" | string;
8
+ Uid: string;
9
+ UtbildningsinstansUID: string;
10
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/types/plan.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ type SearchMeta = {
2
+ pageResultSize: number;
3
+ requestCharge: number;
4
+ elapsedTime: number;
5
+ continuationToken?: string;
6
+ };
7
+ type ResponseInfoShared = {
8
+ statusCode: number;
9
+ statusText: string;
10
+ };
11
+ export type ResponseInfoOk = ResponseInfoShared & {
12
+ apiError: false;
13
+ };
14
+ export type ResponseInfoError = ResponseInfoShared & {
15
+ apiError: true;
16
+ message: string;
17
+ };
18
+ export type ResponseInfo = ResponseInfoOk | ResponseInfoError;
19
+ export type MellanlagringResponse<TData> = {
20
+ type: "success";
21
+ responseInfo: ResponseInfoOk;
22
+ data: TData;
23
+ } | {
24
+ type: "error";
25
+ responseInfo: ResponseInfoError;
26
+ data?: undefined;
27
+ };
28
+ export type MellanlagringSearchResponse<TData> = {
29
+ type: "success";
30
+ responseInfo: ResponseInfoOk;
31
+ searchMeta: SearchMeta;
32
+ items: TData[];
33
+ } | {
34
+ type: "error";
35
+ responseInfo: ResponseInfoError;
36
+ items?: undefined;
37
+ };
38
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=response.js.map