jinaga
Version:
Data management for web and mobile applications.
52 lines • 2.46 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpNetwork = void 0;
const description_1 = require("../specification/description");
class HttpNetwork {
constructor(webClient) {
this.webClient = webClient;
}
feeds(start, specification) {
return __awaiter(this, void 0, void 0, function* () {
const declarationString = (0, description_1.describeDeclaration)(start, specification.given.map(g => g.label));
const specificationString = (0, description_1.describeSpecification)(specification, 0);
const request = `${declarationString}\n${specificationString}`;
const response = yield this.webClient.feeds(request);
return response.feeds;
});
}
fetchFeed(feed, bookmark) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.webClient.feed(feed, bookmark);
return response;
});
}
streamFeed(feed, bookmark, onResponse, onError, feedRefreshIntervalSeconds) {
return this.webClient.streamFeed(feed, bookmark, (response) => __awaiter(this, void 0, void 0, function* () {
yield onResponse(response.references, response.bookmark);
}), onError, feedRefreshIntervalSeconds);
}
load(factReferences) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.webClient.load({
references: factReferences
});
const envelopes = response.facts.map(fact => ({
fact,
signatures: []
}));
return envelopes;
});
}
}
exports.HttpNetwork = HttpNetwork;
//# sourceMappingURL=httpNetwork.js.map