@dasch-swiss/dsp-js
Version:
JavaScript library that handles API requests to Knora
59 lines • 2.15 kB
JavaScript
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 { map } from "rxjs";
import { GenericCache } from "./GenericCache";
/**
* Caches user information obtained from Knora.
*/
var UserCache = /** @class */ (function (_super) {
__extends(UserCache, _super);
function UserCache(knoraApiConnection) {
var _this = _super.call(this) || this;
_this.knoraApiConnection = knoraApiConnection;
return _this;
}
/**
* Gets a user identified by its Iri.
*
* @param iri the Iri identifying the user.
*/
UserCache.prototype.getUser = function (iri) {
return this.getItem(iri);
};
/**
* Public method to access the reloadItem method
*
* @param key the id of the information to be returned.
* @return the item
*/
UserCache.prototype.reloadCachedItem = function (key) {
return this.reloadItem(key);
};
UserCache.prototype.requestItemFromKnora = function (key, isDependency) {
return this.knoraApiConnection.admin.usersEndpoint.getUser("iri", key).pipe(map(function (response) {
return [response.body];
}));
};
UserCache.prototype.getKeyOfItem = function (item) {
return item.user.id;
};
UserCache.prototype.getDependenciesOfItem = function (item) {
return [];
};
return UserCache;
}(GenericCache));
export { UserCache };
//# sourceMappingURL=UserCache.js.map