@softvision/webpdf-wsclient-typescript
Version:
A simplified and optimized API client library for the webPDF server
66 lines • 2.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestWebServiceDocumentState = void 0;
const exception_1 = require("../../../exception");
class RestWebServiceDocumentState {
constructor(documentFile, documentManager) {
this.historyMap = new Map();
this._documentFile = documentFile;
this._documentManager = documentManager;
}
getDocumentId() {
return this.getDocumentFile().documentId;
}
getDocumentFile() {
return this._documentFile;
}
setDocumentFile(documentFile) {
this._documentFile = documentFile;
}
getHistory() {
return Array.from(this.historyMap.values());
}
setHistory(historyEntries) {
this.historyMap.clear();
for (let historyEntry of historyEntries) {
this.updateHistoryEntry(historyEntry);
}
}
getHistoryEntry(historyId) {
if (!this.historyMap.has(historyId)) {
throw new exception_1.ClientResultException(exception_1.WsclientErrors.INVALID_HISTORY_DATA);
}
return this.historyMap.get(historyId);
}
updateHistoryEntry(historyEntry) {
let historyId = historyEntry.id;
if (historyEntry.active) {
for (let entry of this.historyMap.values()) {
entry.active = false;
}
}
this.historyMap.set(historyId, historyEntry);
}
lastHistory() {
if (this.historyMap.size === 0) {
throw new exception_1.ClientResultException(exception_1.WsclientErrors.INVALID_HISTORY_DATA);
}
return Array.from(this.historyMap.values()).pop();
}
getHistorySize() {
return this.historyMap.size;
}
activeHistory() {
if (this.historyMap.size === 0) {
throw new exception_1.ClientResultException(exception_1.WsclientErrors.INVALID_HISTORY_DATA);
}
return Array.from(this.historyMap.values()).find((entry) => {
return entry.active === true;
});
}
getDocumentManager() {
return this._documentManager;
}
}
exports.RestWebServiceDocumentState = RestWebServiceDocumentState;
//# sourceMappingURL=RestWebServiceDocumentState.js.map