@studyportals/search-api-interface 1.0.0-beta.0

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.
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ **/bin/**
package/.eslintrc.yml ADDED
@@ -0,0 +1,4 @@
1
+ extends: ./node_modules/@studyportals/code-style/.eslintrc.js
2
+
3
+ rules:
4
+ eol-last: 2
package/bin/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { DegreeTypeEnum } from "./src/DegreeTypeEnum";
2
+ import { IOrganisationSearchResponse } from "./src/IOrganisationSearchResponse";
3
+ import { SearchApiOrganisationClient } from "./src/SearchApiOrganisationClient";
4
+ export { SearchApiOrganisationClient, IOrganisationSearchResponse, DegreeTypeEnum };
package/bin/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DegreeTypeEnum = exports.SearchApiOrganisationClient = void 0;
4
+ const DegreeTypeEnum_1 = require("./src/DegreeTypeEnum");
5
+ Object.defineProperty(exports, "DegreeTypeEnum", { enumerable: true, get: function () { return DegreeTypeEnum_1.DegreeTypeEnum; } });
6
+ const SearchApiOrganisationClient_1 = require("./src/SearchApiOrganisationClient");
7
+ Object.defineProperty(exports, "SearchApiOrganisationClient", { enumerable: true, get: function () { return SearchApiOrganisationClient_1.SearchApiOrganisationClient; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAQrD,+FARQ,+BAAc,OAQR;AANf,mFAAgF;AAG/E,4GAHQ,yDAA2B,OAGR"}
@@ -0,0 +1,7 @@
1
+ export declare enum DegreeTypeEnum {
2
+ MASTER = 0,
3
+ BACHELOR = 1,
4
+ PHD = 2,
5
+ DISTANCE_LEARNING = 3,
6
+ SHORT_COURSES = 4
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DegreeTypeEnum = void 0;
4
+ var DegreeTypeEnum;
5
+ (function (DegreeTypeEnum) {
6
+ DegreeTypeEnum[DegreeTypeEnum["MASTER"] = 0] = "MASTER";
7
+ DegreeTypeEnum[DegreeTypeEnum["BACHELOR"] = 1] = "BACHELOR";
8
+ DegreeTypeEnum[DegreeTypeEnum["PHD"] = 2] = "PHD";
9
+ DegreeTypeEnum[DegreeTypeEnum["DISTANCE_LEARNING"] = 3] = "DISTANCE_LEARNING";
10
+ DegreeTypeEnum[DegreeTypeEnum["SHORT_COURSES"] = 4] = "SHORT_COURSES";
11
+ })(DegreeTypeEnum = exports.DegreeTypeEnum || (exports.DegreeTypeEnum = {}));
12
+ //# sourceMappingURL=DegreeTypeEnum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DegreeTypeEnum.js","sourceRoot":"","sources":["../../src/DegreeTypeEnum.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAMX;AAND,WAAY,cAAc;IACzB,uDAAU,CAAA;IACV,2DAAY,CAAA;IACZ,iDAAO,CAAA;IACP,6EAAqB,CAAA;IACrB,qEAAiB,CAAA;AAClB,CAAC,EANW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAMzB"}
@@ -0,0 +1,5 @@
1
+ export interface IOrganisationSearchResponse<T> {
2
+ readonly result: readonly T[];
3
+ readonly hitsTotal: number;
4
+ readonly hitsTotalRelation: "more than" | "exactly";
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IOrganisationSearchResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IOrganisationSearchResponse.js","sourceRoot":"","sources":["../../src/IOrganisationSearchResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare class SearchApiClientBase {
2
+ private readonly domain;
3
+ private readonly apiUriBase;
4
+ constructor(domain: string, apiUriBase: string);
5
+ protected constructUri(relativeUri: string): string;
6
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchApiClientBase = void 0;
4
+ class SearchApiClientBase {
5
+ constructor(domain, apiUriBase) {
6
+ this.domain = domain;
7
+ this.apiUriBase = apiUriBase;
8
+ }
9
+ constructUri(relativeUri) {
10
+ return `${this.apiUriBase}/${this.domain}${relativeUri}`;
11
+ }
12
+ }
13
+ exports.SearchApiClientBase = SearchApiClientBase;
14
+ //# sourceMappingURL=SearchApiClientBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchApiClientBase.js","sourceRoot":"","sources":["../../src/SearchApiClientBase.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAmB;IAC/B,YAAoC,MAAc,EAChC,UAAkB;QADA,WAAM,GAAN,MAAM,CAAQ;QAChC,eAAU,GAAV,UAAU,CAAQ;IAEpC,CAAC;IAES,YAAY,CAAC,WAAmB;QACzC,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;IAC1D,CAAC;CACD;AATD,kDASC"}
@@ -0,0 +1,10 @@
1
+ import { SearchApiClientBase } from "./SearchApiClientBase";
2
+ import { IRequestSender, ISuperAgentRequestFactory } from "@studyportals/mb-platform-http-requests";
3
+ import { IOrganisationCard } from "@studyportals/domain-client";
4
+ import { IOrganisationSearchResponse } from "./IOrganisationSearchResponse";
5
+ export declare class SearchApiOrganisationClient extends SearchApiClientBase {
6
+ private readonly requestFactory;
7
+ private readonly requestSender;
8
+ constructor(apiUriBase: string, requestFactory: ISuperAgentRequestFactory, requestSender: IRequestSender);
9
+ searchCards(filters: any, resultCount: number, resultOffset: number): Promise<IOrganisationSearchResponse<IOrganisationCard>>;
10
+ }
@@ -0,0 +1,29 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SearchApiOrganisationClient = void 0;
13
+ const SearchApiClientBase_1 = require("./SearchApiClientBase");
14
+ class SearchApiOrganisationClient extends SearchApiClientBase_1.SearchApiClientBase {
15
+ constructor(apiUriBase, requestFactory, requestSender) {
16
+ super("organisations", apiUriBase);
17
+ this.requestFactory = requestFactory;
18
+ this.requestSender = requestSender;
19
+ }
20
+ searchCards(filters, resultCount, resultOffset) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const request = this.requestFactory.get(this.constructUri("search"))
23
+ .query(Object.assign(Object.assign({}, filters), { resultCount, resultOffset }));
24
+ return yield this.requestSender.sendAndExtractBody(request);
25
+ });
26
+ }
27
+ }
28
+ exports.SearchApiOrganisationClient = SearchApiOrganisationClient;
29
+ //# sourceMappingURL=SearchApiOrganisationClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchApiOrganisationClient.js","sourceRoot":"","sources":["../../src/SearchApiOrganisationClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA4D;AAK5D,MAAa,2BAA4B,SAAQ,yCAAmB;IAKnE,YAAmB,UAAkB,EACpC,cAAyC,EACzC,aAA6B;QAE7B,KAAK,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAEnC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,CAAC;IAEY,WAAW,CAAC,OAAY,EAAE,WAAmB,EAAE,YAAoB;;YAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;iBAClE,KAAK,iCAAM,OAAO,KAAE,WAAW,EAAE,YAAY,IAAG,CAAC;YAEnD,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAiD,OAAO,CAAC,CAAC;QAC7G,CAAC;KAAA;CACD;AArBD,kEAqBC"}
package/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { DegreeTypeEnum } from "./src/DegreeTypeEnum";
2
+ import { IOrganisationSearchResponse } from "./src/IOrganisationSearchResponse";
3
+ import { SearchApiOrganisationClient } from "./src/SearchApiOrganisationClient";
4
+
5
+ export {
6
+ SearchApiOrganisationClient,
7
+ IOrganisationSearchResponse,
8
+
9
+ DegreeTypeEnum
10
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@studyportals/search-api-interface",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Typescript library containing resources that facilitate integration with SearchApi",
5
+ "main": "bin/index.js",
6
+ "scripts": {
7
+ "compile": "rm -fR bin && npx tsc",
8
+ "deploy-patch": "npm version patch && npm run deploy",
9
+ "deploy-minor": "npm version minor && npm run deploy",
10
+ "deploy-major": "npm version major && npm run deploy",
11
+ "deploy-prerelease": "npm version prerelease && npm run deploy-beta",
12
+ "deploy-beta": "npm run prepare-deployment && npm publish ./bin --tag beta",
13
+ "deploy": "npm run prepare-deployment && npm publish ./bin",
14
+ "lint": "eslint . --ext .ts",
15
+ "lint:fix": "eslint . --ext .ts --fix"
16
+ },
17
+ "author": "Seal Team Six",
18
+ "license": "BSD-3-Clause",
19
+ "devDependencies": {
20
+ "@studyportals/code-style": "^1.7.0",
21
+ "@types/superagent": "^4.1.15",
22
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
23
+ "@typescript-eslint/parser": "^5.27.0",
24
+ "eslint": "^8.17.0",
25
+ "typescript": "^4.7.3",
26
+ "typescript-transform-paths": "^3.4.6"
27
+ },
28
+ "dependencies": {}
29
+ }
@@ -0,0 +1,7 @@
1
+ export enum DegreeTypeEnum {
2
+ MASTER = 0,
3
+ BACHELOR = 1,
4
+ PHD = 2,
5
+ DISTANCE_LEARNING = 3,
6
+ SHORT_COURSES = 4,
7
+ }
@@ -0,0 +1,5 @@
1
+ export interface IOrganisationSearchResponse<T> {
2
+ readonly result: readonly T[];
3
+ readonly hitsTotal: number;
4
+ readonly hitsTotalRelation: "more than" | "exactly";
5
+ }
@@ -0,0 +1,10 @@
1
+ export class SearchApiClientBase {
2
+ public constructor(private readonly domain: string,
3
+ private readonly apiUriBase: string
4
+ ) {
5
+ }
6
+
7
+ protected constructUri(relativeUri: string): string {
8
+ return `${this.apiUriBase}/${this.domain}${relativeUri}`;
9
+ }
10
+ }
@@ -0,0 +1,27 @@
1
+ import { SearchApiClientBase } from "./SearchApiClientBase";
2
+ import { IRequestSender, ISuperAgentRequestFactory } from "@studyportals/mb-platform-http-requests";
3
+ import { IOrganisationCard } from "@studyportals/domain-client";
4
+ import { IOrganisationSearchResponse } from "./IOrganisationSearchResponse";
5
+
6
+ export class SearchApiOrganisationClient extends SearchApiClientBase {
7
+
8
+ private readonly requestFactory: ISuperAgentRequestFactory;
9
+ private readonly requestSender: IRequestSender;
10
+
11
+ public constructor(apiUriBase: string,
12
+ requestFactory: ISuperAgentRequestFactory,
13
+ requestSender: IRequestSender
14
+ ) {
15
+ super("organisations", apiUriBase);
16
+
17
+ this.requestFactory = requestFactory;
18
+ this.requestSender = requestSender;
19
+ }
20
+
21
+ public async searchCards(filters: any, resultCount: number, resultOffset: number): Promise<IOrganisationSearchResponse<IOrganisationCard>> {
22
+ const request = this.requestFactory.get(this.constructUri("search"))
23
+ .query({ ...filters, resultCount, resultOffset });
24
+
25
+ return await this.requestSender.sendAndExtractBody<IOrganisationSearchResponse<IOrganisationCard>>(request);
26
+ }
27
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "bin",
4
+ "declaration": true,
5
+ "rootDirs": [
6
+ "./"
7
+ ],
8
+ "moduleResolution": "node",
9
+ "alwaysStrict": true,
10
+ "strictNullChecks": true,
11
+ "allowJs": false,
12
+ "allowUnreachableCode": false,
13
+ "allowUnusedLabels": false,
14
+ "noUnusedLocals": false,
15
+ "noUnusedParameters": false,
16
+ "noFallthroughCasesInSwitch": true,
17
+ "noImplicitAny": true,
18
+ "noImplicitReturns": true,
19
+ "noImplicitThis": true,
20
+ "sourceMap": true,
21
+ "target": "ES6",
22
+ "module": "commonjs",
23
+ "experimentalDecorators": true,
24
+ "paths": {
25
+ "@/*": [
26
+ "./*"
27
+ ]
28
+ },
29
+ "plugins": [
30
+ {
31
+ "transform": "typescript-transform-paths"
32
+ },
33
+ {
34
+ "transform": "typescript-transform-paths",
35
+ "afterDeclarations": true
36
+ }
37
+ ]
38
+ },
39
+ "typeRoots": [
40
+ "node_modules/@types/"
41
+ ],
42
+ "exclude": [
43
+ "node_modules",
44
+ "bin",
45
+ ".vscode"
46
+ ]
47
+ }