diff --git a/package-lock.json b/package-lock.json index 0599281..756f38f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,8 @@ "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/swagger": "^7.3.1", + "axios": "^1.6.8", + "dotenv": "^16.4.5", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1" }, @@ -2884,8 +2886,17 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } }, "node_modules/babel-jest": { "version": "29.7.0", @@ -3488,7 +3499,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3761,7 +3771,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -3844,6 +3853,17 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -4591,6 +4611,25 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", @@ -4661,7 +4700,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -6998,6 +7036,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -10945,8 +10988,17 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "requires": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } }, "babel-jest": { "version": "29.7.0", @@ -11366,7 +11418,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -11561,8 +11612,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, "depd": { "version": "2.0.0", @@ -11620,6 +11670,11 @@ "esutils": "^2.0.2" } }, + "dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==" + }, "eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -12202,6 +12257,11 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" + }, "foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", @@ -12257,7 +12317,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -13976,6 +14035,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/package.json b/package.json index 82e0fb2..91eb9cc 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/swagger": "^7.3.1", + "axios": "^1.6.8", + "dotenv": "^16.4.5", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1" }, diff --git a/src/app.module.ts b/src/app.module.ts index 31e9c85..29b2456 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,11 +1,22 @@ import { Module } from "@nestjs/common"; -import { AppController } from "./controller/app.controller"; -import { AppService } from "./service/app.service"; +import { ManifestController, ReconciliationController } from "./controller"; +import { ManifestService, ReconciliationService } from "./service"; +import { ArtsdataService } from "./service/artsdata"; +import { HttpService } from "./service/http"; @Module({ imports: [], - controllers: [AppController], - providers: [AppService] + controllers: [ + ManifestController, + ReconciliationController + ], + providers: [ + ManifestService, + ReconciliationService, + ArtsdataService, + HttpService + + ] }) export class AppModule { } diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000..c14b306 --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1 @@ +export * from './system.config'; diff --git a/src/config/system.config.ts b/src/config/system.config.ts new file mode 100644 index 0000000..80d2922 --- /dev/null +++ b/src/config/system.config.ts @@ -0,0 +1,8 @@ +import * as dotenv from "dotenv"; + +dotenv.config(); +const { env } = process; + +export const ARTSDATA: { ENDPOINT: string } = { + ENDPOINT: env.ARTSDATA_ENDPOINT || "https://db.artsdata.ca/" +}; diff --git a/src/constant/recon-queries.constants.ts b/src/constant/recon-queries.constants.ts new file mode 100644 index 0000000..99f27bf --- /dev/null +++ b/src/constant/recon-queries.constants.ts @@ -0,0 +1,42 @@ +export const QUERIES = { + + RECONCILITAION_QUERY:` + PREFIX luc: + PREFIX rdfs: + PREFIX schema: + SELECT + ?originalUri + ?score (sample(?names) as ?name) + (sample(?disambiguatingDescriptions) as ?disambiguatingDescription) + ?type + ?typeLabel + WHERE { + values ?query { "QUERY_PLACE_HOLDER" } + values ?type { TYPE_PLACE_HOLDER } + + ?originalUri a ?type ; + luc:Name ?query; + rdfs:label ?names ; + luc:score ?score . + FILTER (STRSTARTS(STR(?originalUri),"http://kg.artsdata.ca/resource/K" )) + + OPTIONAL { + ?originalUri schema:disambiguatingDescription ?disambiguatingDescriptions . + } + + OPTIONAL { + ?type rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") + } + + OPTIONAL { + ?type rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") + } + + BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?typeLabel) + + } GROUP BY ?originalUri ?score ?type ?typeLabel + ` + + + +}; diff --git a/src/controller/app.controller.spec.ts b/src/controller/app.controller.spec.ts deleted file mode 100644 index f334082..0000000 --- a/src/controller/app.controller.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from '../service/app.service'; -import * as MANIFEST from "../constant/manifest.constant.json"; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return Service Manifest', () => { - expect(appController.getServiceManifest()).toBe(MANIFEST); - }); - }); -}); diff --git a/src/controller/index.ts b/src/controller/index.ts new file mode 100644 index 0000000..bd7a6af --- /dev/null +++ b/src/controller/index.ts @@ -0,0 +1,2 @@ +export * from "./manifest" +export * from "./recon" diff --git a/src/controller/manifest/index.ts b/src/controller/manifest/index.ts new file mode 100644 index 0000000..b4b7cb4 --- /dev/null +++ b/src/controller/manifest/index.ts @@ -0,0 +1 @@ +export * from "./manifest.controller" \ No newline at end of file diff --git a/src/controller/manifest/manifest.controller.spec.ts b/src/controller/manifest/manifest.controller.spec.ts new file mode 100644 index 0000000..ffbbe1e --- /dev/null +++ b/src/controller/manifest/manifest.controller.spec.ts @@ -0,0 +1,23 @@ +import { Test, TestingModule } from "@nestjs/testing"; +import { ManifestController } from "./manifest.controller"; +import * as MANIFEST from "../../constant/manifest.constant.json"; +import { ManifestService } from "../../service"; + +describe('ManifestController', () => { + let manifestController: ManifestController; + + beforeEach(async () => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [ManifestController], + providers: [ManifestService] + }).compile(); + + manifestController = app.get(ManifestController); + }); + + describe("manifest", () => { + it("should return Service Manifest", () => { + expect(manifestController.getServiceManifest()).toBe(MANIFEST); + }); + }); +}); diff --git a/src/controller/app.controller.ts b/src/controller/manifest/manifest.controller.ts similarity index 65% rename from src/controller/app.controller.ts rename to src/controller/manifest/manifest.controller.ts index a304f5f..1fed288 100644 --- a/src/controller/app.controller.ts +++ b/src/controller/manifest/manifest.controller.ts @@ -1,12 +1,12 @@ import { Controller, Get } from "@nestjs/common"; -import { AppService } from "../service/app.service"; +import { ManifestService } from "../../service/manifest/manifest.service"; import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { ServiceManifestResponse } from "../dto/manifest.dto"; +import { ServiceManifestResponse } from "../../dto/manifest.dto"; @Controller() @ApiTags("APIs") -export class AppController { - constructor(private readonly appService: AppService) { +export class ManifestController { + constructor(private readonly appService: ManifestService) { } @Get() diff --git a/src/controller/recon/index.ts b/src/controller/recon/index.ts new file mode 100644 index 0000000..ed8a5c6 --- /dev/null +++ b/src/controller/recon/index.ts @@ -0,0 +1 @@ +export * from "./recon.controller" diff --git a/src/controller/recon/recon.controller.ts b/src/controller/recon/recon.controller.ts new file mode 100644 index 0000000..ca7596b --- /dev/null +++ b/src/controller/recon/recon.controller.ts @@ -0,0 +1,37 @@ +import { Controller, Get, Query } from "@nestjs/common"; +import { ApiOperation, ApiQuery, ApiResponse, ApiTags } from "@nestjs/swagger"; +import { ReconciliationResponse } from "../../dto"; +import { ReconciliationService } from "../../service"; +import { ReconciliationTypesEnum } from "../../enum"; + +@Controller() +@ApiTags("APIs") +export class ReconciliationController { + constructor(private readonly _reconciliationService: ReconciliationService) { + } + + @Get("/recon") + @ApiOperation({ summary: "Reconcile" }) + @ApiResponse({ status: 200, type: ReconciliationResponse, isArray: true, description: "Reconciliation response" }) + @ApiResponse({ status: 500, description: "Internal server error" }) + @ApiQuery({ + name: "name", + description: "Name of the entity to reconcile", + required: true, + explode: false, + type: String + }) + @ApiQuery({ + name: "type", + description: "Type of the entity to reconcile", + required: true, + explode: false, + enum: Object.values(ReconciliationTypesEnum) + }) + async reconcile( + @Query("name") name: string, + @Query("type") type: string + ): Promise { + return await this._reconciliationService.reconcile(name, type); + } +} diff --git a/src/dto/index.ts b/src/dto/index.ts new file mode 100644 index 0000000..ce144b0 --- /dev/null +++ b/src/dto/index.ts @@ -0,0 +1,3 @@ +export * from "./manifest.dto"; +export * from "./recon.dto"; + diff --git a/src/dto/recon.dto.ts b/src/dto/recon.dto.ts new file mode 100644 index 0000000..1ee378e --- /dev/null +++ b/src/dto/recon.dto.ts @@ -0,0 +1,31 @@ +import { ApiProperty } from "@nestjs/swagger"; + +class ReconciliationType { + @ApiProperty() + id: string; + @ApiProperty() + name: string; +} + +export class ReconciliationResponse { + @ApiProperty() + id: string; + @ApiProperty() + name: string; + @ApiProperty() + disambiguatingDescription: string; + @ApiProperty({ type: [ReconciliationType] }) + type: ReconciliationType[]; + @ApiProperty() + score: number; + @ApiProperty() + match: boolean; +} + +export class ReconciliationRequest { + @ApiProperty() + query: string; + @ApiProperty() + type: string; + +} \ No newline at end of file diff --git a/src/enum/index.ts b/src/enum/index.ts new file mode 100644 index 0000000..a10dcfd --- /dev/null +++ b/src/enum/index.ts @@ -0,0 +1,2 @@ +export * from './reconciliation-types.enum' + diff --git a/src/enum/reconciliation-types.enum.ts b/src/enum/reconciliation-types.enum.ts new file mode 100644 index 0000000..6f85d45 --- /dev/null +++ b/src/enum/reconciliation-types.enum.ts @@ -0,0 +1,6 @@ +export enum ReconciliationTypesEnum { + EVENT = "schema:Event", + PLACE = "schema:Place", + PERSON = "schema:Person", + ORGANIZATION = "schema:Organization" +} \ No newline at end of file diff --git a/src/helper/reconciliation-service.helper.ts b/src/helper/reconciliation-service.helper.ts new file mode 100644 index 0000000..0423644 --- /dev/null +++ b/src/helper/reconciliation-service.helper.ts @@ -0,0 +1,20 @@ +import { ReconciliationResponse } from "../dto"; + +export class ReconciliationServiceHelper { + + static formatReconciliationResponse(sparqlResponse: any): ReconciliationResponse[] { + + return sparqlResponse?.results?.bindings?.map((binding: any) => { + + const result = new ReconciliationResponse(); + result.id = binding["originalUri"].value; + result.disambiguatingDescription = binding["disambiguatingDescription"]?.value; + result.name = binding["name"]?.value; + result.score = binding["score"]?.value; + result.match = binding["score"]?.value >= 10; + result.type = [{ id: binding["type"]?.value, name: binding["typeLabel"]?.value }]; + return result; + }); + + } +} \ No newline at end of file diff --git a/src/service/app.service.ts b/src/service/app.service.ts deleted file mode 100644 index 4d224ef..0000000 --- a/src/service/app.service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Injectable } from "@nestjs/common"; -import * as MANIFEST from "../constant/manifest.constant.json"; -import { ServiceManifestResponse } from "../dto/manifest.dto"; - -@Injectable() -export class AppService { - getServiceManifest(): ServiceManifestResponse { - return MANIFEST; - } -} diff --git a/src/service/artsdata/artsdata.service.ts b/src/service/artsdata/artsdata.service.ts new file mode 100644 index 0000000..8c9ddf2 --- /dev/null +++ b/src/service/artsdata/artsdata.service.ts @@ -0,0 +1,30 @@ +import { Injectable } from "@nestjs/common"; +import { ARTSDATA } from "../../config"; +import { QUERIES } from "../../constant/recon-queries.constants"; +import { HttpService } from "../http"; +import { ReconciliationServiceHelper } from "../../helper/reconciliation-service.helper"; +import { ReconciliationResponse } from "../../dto"; + +@Injectable() +export class ArtsdataService { + + constructor(private readonly httpService: HttpService) { + } + + _getArtsdataEndPoint(): string { + const sparqlEndpoint = new URL("repositories/artsdata", ARTSDATA.ENDPOINT); + return sparqlEndpoint.toString(); + } + + async getReconciliationResult(name: string, type: string): Promise { + const sparqlEndpoint = this._getArtsdataEndPoint(); + const rawSparqlQuery = QUERIES.RECONCILITAION_QUERY + .replace("QUERY_PLACE_HOLDER", name) + .replace("TYPE_PLACE_HOLDER", type); + const sparqlQuery = "query=" + encodeURIComponent(rawSparqlQuery); + const response = await this.httpService.postRequest(sparqlEndpoint, sparqlQuery); + return ReconciliationServiceHelper.formatReconciliationResponse(response); + } + + +} diff --git a/src/service/artsdata/index.ts b/src/service/artsdata/index.ts new file mode 100644 index 0000000..18954ac --- /dev/null +++ b/src/service/artsdata/index.ts @@ -0,0 +1 @@ +export * from "./artsdata.service" diff --git a/src/service/http/http.service.ts b/src/service/http/http.service.ts new file mode 100644 index 0000000..6a6047f --- /dev/null +++ b/src/service/http/http.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from "@nestjs/common"; +import axios from "axios"; + +@Injectable() +export class HttpService { + async postRequest(url: string, query: string): Promise { + const response = await axios.post( + url, + query, + // "query=PREFIX+luc%3A+%3Chttp%3A%2F%2Fwww.ontotext.com%2Fowlim%2Flucene%23%3E%0A++++++++PREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A++++++++PREFIX+schema%3A+%3Chttp%3A%2F%2Fschema.org%2F%3E%0A++++++++SELECT+%0A++++++++++++++%3ForiginalUri%0A++++++++++++++%3Fscore+(sample(%3Fnames)+as+%3Fname)%0A++++++++++++++(sample(%3FdisambiguatingDescriptions)+as+%3FdisambiguatingDescription)+%0A++++++++WHERE+%7B%0A++++++++++++++values+%3Fquery+%7B+%22Taurey+Butler%22+%7D%0A++++++++++++++values+%3Ftype+%7B+schema%3APerson+%7D%0A++++%0A++++++++%3ForiginalUri+a+%3Ftype+%3B+%0A+++++++++++++++++++++luc%3AName+%3Fquery%3B%0A+++++++++++++++++++++rdfs%3Alabel+%3Fnames+%3B%0A+++++++++++++++++++++luc%3Ascore+%3Fscore+.%0A++++++++%0A++++++++OPTIONAL+%7B%0A++++++++++++++++++%3ForiginalUri++schema%3AdisambiguatingDescription+%3FdisambiguatingDescriptions+.%0A++++++++%7D%0A++++%0A++++++++FILTER+(STRSTARTS(STR(%3ForiginalUri)%2C%22http%3A%2F%2Fkg.artsdata.ca%2Fresource%2FK%22+))%0A++++++++%7D+GROUP+BY+%3ForiginalUri+%3Fscore&infer=true&sameAs=true&limit=1001&offset=0", + { + headers: { + "Accept": "application/x-sparqlstar-results+json, application/sparql-results+json;q=0.9, */*;q=0.8", + "Origin": "https://db.artsdata.ca", + "Referer": "https://db.artsdata.ca/" + } + } + ); + return response?.data + } + + + +} diff --git a/src/service/http/index.ts b/src/service/http/index.ts new file mode 100644 index 0000000..573da8c --- /dev/null +++ b/src/service/http/index.ts @@ -0,0 +1 @@ +export * from "./http.service" diff --git a/src/service/index.ts b/src/service/index.ts new file mode 100644 index 0000000..bd7a6af --- /dev/null +++ b/src/service/index.ts @@ -0,0 +1,2 @@ +export * from "./manifest" +export * from "./recon" diff --git a/src/service/manifest/index.ts b/src/service/manifest/index.ts new file mode 100644 index 0000000..dc3c238 --- /dev/null +++ b/src/service/manifest/index.ts @@ -0,0 +1 @@ +export * from "./manifest.service" diff --git a/src/service/manifest/manifest.service.ts b/src/service/manifest/manifest.service.ts new file mode 100644 index 0000000..9901603 --- /dev/null +++ b/src/service/manifest/manifest.service.ts @@ -0,0 +1,10 @@ +import { Injectable } from "@nestjs/common"; +import * as MANIFEST from "../../constant/manifest.constant.json"; +import { ServiceManifestResponse } from "../../dto/manifest.dto"; + +@Injectable() +export class ManifestService { + getServiceManifest(): ServiceManifestResponse { + return MANIFEST; + } +} diff --git a/src/service/recon/index.ts b/src/service/recon/index.ts new file mode 100644 index 0000000..21bfe85 --- /dev/null +++ b/src/service/recon/index.ts @@ -0,0 +1 @@ +export * from "./recon.service" diff --git a/src/service/recon/recon.service.ts b/src/service/recon/recon.service.ts new file mode 100644 index 0000000..7c4e396 --- /dev/null +++ b/src/service/recon/recon.service.ts @@ -0,0 +1,14 @@ +import { Injectable } from "@nestjs/common"; +import { ArtsdataService } from "../artsdata"; +import { ReconciliationResponse } from "../../dto"; + +@Injectable() +export class ReconciliationService { + + constructor(private readonly _artsdataService: ArtsdataService) { + } + + async reconcile(name: string, type: string): Promise { + return this._artsdataService.getReconciliationResult(name, type); + } +} diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index 50cda62..80b7f5c 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -3,7 +3,7 @@ import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; import { AppModule } from './../src/app.module'; -describe('AppController (e2e)', () => { +describe('ManifestController (e2e)', () => { let app: INestApplication; beforeEach(async () => {