diffusion
Version:
Diffusion JavaScript client
86 lines (85 loc) • 3.31 kB
JavaScript
;
/**
* @module Services.FetchQuery
*/
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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchQuerySerialiser = exports.FetchQuerySerialiserClass = void 0;
var Codec = require("./../../io/codec");
var LEESS = require("./../../serialisers/long-encoded-enum-set-serialiser");
var serialiser_1 = require("./../../serialisers/serialiser");
var topic_selector_serialiser_1 = require("./../../topics/topic-selector-serialiser");
/**
* Write a {@link Limit} to the stream
*
* @param bos the output stream
* @param value the {@link Limit} to be written
*/
function writeLimit(bos, limit) {
if (limit === undefined) {
Codec.writeByte(bos, 0);
}
else {
Codec.writeByte(bos, 1);
Codec.writeString(bos, limit.path);
Codec.writeBoolean(bos, limit.includesPath);
}
}
/**
* Write a {@link FetchRange} to the stream
*
* @param bos the output stream
* @param value the {@link FetchRange} to be written
*/
function writeRange(bos, range) {
writeLimit(bos, range.from);
writeLimit(bos, range.to);
}
/**
* Serialiser for {@link FetchQuery}
*/
var FetchQuerySerialiserClass = /** @class */ (function (_super) {
__extends(FetchQuerySerialiserClass, _super);
function FetchQuerySerialiserClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Write a {@link FetchQuery} to the stream
*
* @param bos the output stream
* @param value the {@link FetchQuery} to be written
*/
FetchQuerySerialiserClass.prototype.write = function (bos, value) {
topic_selector_serialiser_1.TopicSelectorSerialiser.write(bos, value.selector);
writeRange(bos, value.range);
LEESS.write(bos, value.topicTypes);
Codec.writeBoolean(bos, value.withValues);
Codec.writeBoolean(bos, value.withProperties);
Codec.writeInt32(bos, value.limit);
Codec.writeInt32(bos, value.maximumResultSize);
Codec.writeInt32(bos, value.deepBranchDepth);
Codec.writeInt32(bos, value.deepBranchLimit);
Codec.writeBoolean(bos, value.withUnpublishedDelayedTopics);
Codec.writeBoolean(bos, value.withSizes);
};
return FetchQuerySerialiserClass;
}(serialiser_1.AbstractSerialiser));
exports.FetchQuerySerialiserClass = FetchQuerySerialiserClass;
/**
* The {@link FetchRequestSerialiser} singleton
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.FetchQuerySerialiser = new FetchQuerySerialiserClass();