@jorsek/ezd-client
Version:
53 lines • 2.48 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const Resource_1 = require("./Resource");
class Contribute extends Resource_1.Resource {
initContribution(template_path) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.axios.post("/content/v1/initContribution", {}, { params: { "template_uri": template_path } });
const uuid = response.data.initContribution.resourceUUID;
if (uuid) {
this._resource_uuid = uuid;
}
else {
console.log("OH NO!");
}
return this._resource_uuid;
});
}
resource_uuid() {
return this._resource_uuid;
}
commit(_doc_id) {
this.axios.get("/content/v1/commitContribution", { params: { resourceUUID: this.resource_uuid() } });
}
cancel(_doc_id) {
console.log(`THIS IS THE DOC ID: ${_doc_id}`);
this.axios.get("/content/v1/cancelContribution", { params: { resourceUUID: _doc_id } });
}
templates() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.config.get()).templates;
});
}
getContributions() {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.axios.get("/content/v1/contributions");
// TODO: validate this response once API is written in java, not xquery
// xquery returns null instead of empty array
// xwquery also returns single object instead of array of 1
const return_me = response.data ? response.data["resources"] ? response.data["resources"] : [] : [];
return Array.isArray(return_me) ? return_me : [return_me];
});
}
}
exports.Contribute = Contribute;
//# sourceMappingURL=Contribute.js.map
;