UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

224 lines 10.8 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 } from "rxjs"; import { ApiResponseData } from "../../../models/api-response-data"; import { Endpoint } from "../../endpoint"; import { KeywordsResponse } from "../../../models/admin/keywords-response"; import { MembersResponse } from "../../../models/admin/members-response"; import { ProjectResponse } from "../../../models/admin/project-response"; import { ProjectRestrictedViewSettingsResponse } from "../../../models/admin/project-restricted-view-settings-response"; import { ProjectsResponse } from "../../../models/admin/projects-response"; /** * An endpoint for working with Knora projects. * @deprecated Use open API docs instead * @category Endpoint Admin */ var ProjectsEndpointAdmin = /** @class */ (function (_super) { __extends(ProjectsEndpointAdmin, _super); function ProjectsEndpointAdmin() { return _super !== null && _super.apply(this, arguments) || this; } /** * Returns a list of all projects. */ ProjectsEndpointAdmin.prototype.getProjects = function () { var _this = this; return this.httpGet("", undefined).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a project. * * @param project The project to be created. */ ProjectsEndpointAdmin.prototype.createProject = function (project) { var _this = this; return this.httpPost("", this.jsonConvert.serializeObject(project), undefined, undefined).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets all the unique keywords for all projects. */ ProjectsEndpointAdmin.prototype.getKeywords = function () { var _this = this; return this.httpGet("/Keywords").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, KeywordsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets all the keywords for a project. * * @param iri The IRI of the project. */ ProjectsEndpointAdmin.prototype.getProjectKeywords = function (iri) { var _this = this; return this.httpGet("/iri/" + encodeURIComponent(iri) + "/Keywords").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, KeywordsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a project. * * @param iri The IRI of the project to be updated. * @param projectInfo The project info to be updated. */ ProjectsEndpointAdmin.prototype.updateProject = function (iri, projectInfo) { var _this = this; return this.httpPut("/iri/" + encodeURIComponent(iri), this.jsonConvert.serializeObject(projectInfo)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a project. This method does not actually delete a project, but sets the status to false. * * @param iri The project IRI. */ ProjectsEndpointAdmin.prototype.deleteProject = function (iri) { var _this = this; return this.httpDelete("/iri/" + encodeURIComponent(iri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a project by a property. * * @param property The name of the property by which the project is identified. * @param value The value of the property by which the project is identified. */ ProjectsEndpointAdmin.prototype.getProject = function (property, value) { var _this = this; return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value), undefined).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a project by IRI. * * @param iri The IRI of the project. */ ProjectsEndpointAdmin.prototype.getProjectByIri = function (iri) { return this.getProject("iri", iri); }; /** * Gets a project by shortname. * * @param shortname The shortname of the project. */ ProjectsEndpointAdmin.prototype.getProjectByShortname = function (shortname) { return this.getProject("shortname", shortname); }; /** * Gets a project by shortcode. * * @param shortcode The shortcode of the project. */ ProjectsEndpointAdmin.prototype.getProjectByShortcode = function (shortcode) { return this.getProject("shortcode", shortcode); }; /** * Gets a project's members by a property. * * @param property The name of the property by which the project is identified. * @param value The value of the property by which the project is identified. */ ProjectsEndpointAdmin.prototype.getProjectMembers = function (property, value) { var _this = this; return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/members").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, MembersResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets the members of a project by IRI. * * @param iri The IRI of the project. */ ProjectsEndpointAdmin.prototype.getProjectMembersByIri = function (iri) { return this.getProjectMembers("iri", iri); }; /** * Gets a project's members by shortname. * * @param shortname The shortname of the project. */ ProjectsEndpointAdmin.prototype.getProjectMembersByShortname = function (shortname) { return this.getProjectMembers("shortname", shortname); }; /** * Gets a project's members by shortcode. * * @param shortcode The shortcode of the project. */ ProjectsEndpointAdmin.prototype.getProjectMembersByShortcode = function (shortcode) { return this.getProjectMembers("shortcode", shortcode); }; /** * Gets a project's admin members by a property. * * @param property The name of the property by which the project is identified. * @param value The value of the property by which the project is identified. */ ProjectsEndpointAdmin.prototype.getProjectAdminMembers = function (property, value) { var _this = this; return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/admin-members").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, MembersResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets the admin members of a project by IRI. * * @param iri The IRI of the project. */ ProjectsEndpointAdmin.prototype.getProjectAdminMembersByIri = function (iri) { return this.getProjectAdminMembers("iri", iri); }; /** * Gets a project's admin members by shortname. * * @param shortname The shortname of the project. */ ProjectsEndpointAdmin.prototype.getProjectAdminMembersByShortname = function (shortname) { return this.getProjectAdminMembers("shortname", shortname); }; /** * Gets a project's admin members by shortcode. * * @param shortcode The shortcode of the project. */ ProjectsEndpointAdmin.prototype.getProjectAdminMembersByShortcode = function (shortcode) { return this.getProjectAdminMembers("shortcode", shortcode); }; /** * Gets a project's restricted view settings by a property. * * @param property The name of the property by which the project is identified. * @param value The value of the property by which the project is identified. */ ProjectsEndpointAdmin.prototype.getProjectRestrictedViewSettings = function (property, value) { var _this = this; return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/RestrictedViewSettings").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectRestrictedViewSettingsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a project's restricted view settings by IRI. * * @param iri The IRI of the project. */ ProjectsEndpointAdmin.prototype.getProjectRestrictedViewSettingByIri = function (iri) { return this.getProjectRestrictedViewSettings("iri", iri); }; /** * Gets a project's restricted view settings by shortname. * * @param shortname The shortname of the project. */ ProjectsEndpointAdmin.prototype.getProjectRestrictedViewSettingByShortname = function (shortname) { return this.getProjectRestrictedViewSettings("shortname", shortname); }; /** * Gets a project's restricted view settings by shortcode. * * @param shortcode The shortcode of the project. */ ProjectsEndpointAdmin.prototype.getProjectRestrictedViewSettingByShortcode = function (shortcode) { return this.getProjectRestrictedViewSettings("shortcode", shortcode); }; return ProjectsEndpointAdmin; }(Endpoint)); export { ProjectsEndpointAdmin }; //# sourceMappingURL=projects-endpoint-admin.js.map