UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

69 lines 2.93 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { catchError, map, mergeMap } from "rxjs"; import { ListNodeV2 } from "../../../models/v2/lists/list-node-v2"; import { Endpoint } from "../../endpoint"; var jsonld = require("jsonld/dist/jsonld.js"); /** * Handles requests to the lists route of the Knora API. * * @category Endpoint V2 */ var ListsEndpointV2 = /** @class */ (function (_super) { __extends(ListsEndpointV2, _super); function ListsEndpointV2() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get a specific list node. * * @param nodeIri the Ir of the list node to be fetched. */ ListsEndpointV2.prototype.getNode = function (nodeIri) { var _this = this; // TODO: Do not hard-code the URL and http call params, generate this from Knora return this.httpGet("/node/" + encodeURIComponent(nodeIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (res) { return _this.jsonConvert.deserialize(res, ListNodeV2); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Get an entire list. * * @param rootNodeIri the list's root node Iri. */ ListsEndpointV2.prototype.getList = function (rootNodeIri) { var _this = this; // TODO: Do not hard-code the URL and http call params, generate this from Knora return this.httpGet("/lists/" + encodeURIComponent(rootNodeIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (res) { return _this.jsonConvert.deserialize(res, ListNodeV2); }), catchError(function (error) { return _this.handleError(error); })); }; return ListsEndpointV2; }(Endpoint)); export { ListsEndpointV2 }; //# sourceMappingURL=lists-endpoint-v2.js.map