@knora/api
Version:
JavaScript library that handles API requests to Knora
222 lines • 11.2 kB
JavaScript
"use strict";
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var operators_1 = require("rxjs/operators");
var api_response_data_1 = require("../../../models/api-response-data");
var endpoint_1 = require("../../endpoint");
var keywords_response_1 = require("../../../models/admin/keywords-response");
var members_response_1 = require("../../../models/admin/members-response");
var project_response_1 = require("../../../models/admin/project-response");
var project_restricted_view_settings_response_1 = require("../../../models/admin/project-restricted-view-settings-response");
var projects_response_1 = require("../../../models/admin/projects-response");
/**
* An endpoint for working with Knora projects.
*/
var ProjectsEndpoint = /** @class */ (function (_super) {
__extends(ProjectsEndpoint, _super);
function ProjectsEndpoint() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Returns a list of all projects.
*/
ProjectsEndpoint.prototype.getProjects = function () {
var _this = this;
return this.httpGet("").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, projects_response_1.ProjectsResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Creates a project.
*
* @param project The project to be created.
*/
ProjectsEndpoint.prototype.createProject = function (project) {
var _this = this;
return this.httpPost("", this.jsonConvert.serializeObject(project)).pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, project_response_1.ProjectResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets all the unique keywords for all projects.
*/
ProjectsEndpoint.prototype.getKeywords = function () {
var _this = this;
return this.httpGet("/Keywords").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, keywords_response_1.KeywordsResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets all the keywords for a project.
*
* @param iri The IRI of the project.
*/
ProjectsEndpoint.prototype.getProjectKeywords = function (iri) {
var _this = this;
return this.httpGet("/iri/" + encodeURIComponent(iri) + "/Keywords").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, keywords_response_1.KeywordsResponse, _this.jsonConvert); }), operators_1.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.
*/
ProjectsEndpoint.prototype.updateProject = function (iri, projectInfo) {
var _this = this;
return this.httpPut("/iri/" + encodeURIComponent(iri), this.jsonConvert.serializeObject(projectInfo)).pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, project_response_1.ProjectResponse, _this.jsonConvert); }), operators_1.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.
*/
ProjectsEndpoint.prototype.deleteProject = function (iri) {
var _this = this;
return this.httpDelete("/iri/" + encodeURIComponent(iri)).pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, project_response_1.ProjectResponse, _this.jsonConvert); }), operators_1.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.
*/
ProjectsEndpoint.prototype.getProject = function (property, value) {
var _this = this;
return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value)).pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, project_response_1.ProjectResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets a project by IRI.
*
* @param iri The IRI of the project.
*/
ProjectsEndpoint.prototype.getProjectByIri = function (iri) {
return this.getProject("iri", iri);
};
/**
* Gets a project by shortname.
*
* @param shortname The shortname of the project.
*/
ProjectsEndpoint.prototype.getProjectByShortname = function (shortname) {
return this.getProject("shortname", shortname);
};
/**
* Gets a project by shortcode.
*
* @param shortcode The shortcode of the project.
*/
ProjectsEndpoint.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.
*/
ProjectsEndpoint.prototype.getProjectMembers = function (property, value) {
var _this = this;
return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/members").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, members_response_1.MembersResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets the members of a project by IRI.
*
* @param iri The IRI of the project.
*/
ProjectsEndpoint.prototype.getProjectMembersByIri = function (iri) {
return this.getProjectMembers("iri", iri);
};
/**
* Gets a project's members by shortname.
*
* @param shortname The shortname of the project.
*/
ProjectsEndpoint.prototype.getProjectMembersByShortname = function (shortname) {
return this.getProjectMembers("shortname", shortname);
};
/**
* Gets a project's members by shortcode.
*
* @param shortcode The shortcode of the project.
*/
ProjectsEndpoint.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.
*/
ProjectsEndpoint.prototype.getProjectAdminMembers = function (property, value) {
var _this = this;
return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/admin-members").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, members_response_1.MembersResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets the admin members of a project by IRI.
*
* @param iri The IRI of the project.
*/
ProjectsEndpoint.prototype.getProjectAdminMembersByIri = function (iri) {
return this.getProjectAdminMembers("iri", iri);
};
/**
* Gets a project's admin members by shortname.
*
* @param shortname The shortname of the project.
*/
ProjectsEndpoint.prototype.getProjectAdminMembersByShortname = function (shortname) {
return this.getProjectAdminMembers("shortname", shortname);
};
/**
* Gets a project's admin members by shortcode.
*
* @param shortcode The shortcode of the project.
*/
ProjectsEndpoint.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.
*/
ProjectsEndpoint.prototype.getProjectRestrictedViewSettings = function (property, value) {
var _this = this;
return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value) + "/RestrictedViewSettings").pipe(operators_1.map(function (ajaxResponse) { return api_response_data_1.ApiResponseData.fromAjaxResponse(ajaxResponse, project_restricted_view_settings_response_1.ProjectRestrictedViewSettingsResponse, _this.jsonConvert); }), operators_1.catchError(function (error) { return _this.handleError(error); }));
};
/**
* Gets a project's restricted view settings by IRI.
*
* @param iri The IRI of the project.
*/
ProjectsEndpoint.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.
*/
ProjectsEndpoint.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.
*/
ProjectsEndpoint.prototype.getProjectRestrictedViewSettingByShortcode = function (shortcode) {
return this.getProjectRestrictedViewSettings("shortcode", shortcode);
};
return ProjectsEndpoint;
}(endpoint_1.Endpoint));
exports.ProjectsEndpoint = ProjectsEndpoint;
//# sourceMappingURL=projects-endpoint.js.map