diffusion
Version:
Diffusion JavaScript client
108 lines (107 loc) • 4.71 kB
JavaScript
;
/**
* @module diffusion.topics
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchRequest = void 0;
var topic_type_1 = require("./topic-type");
/**
* A parameterised query that can be used to search the topic tree.
*
* A new request can be created using the {@link Session.fetchRequest fetchRequest}
* method and modified to specify a range of topics and/or
* various levels of detail. The request can then be issued to the server
* using the {@link FetchRequest.fetch fetch} method
* supplying a topic selector which specifies the selection of topics.
* The results are returned via a {@link Result}.
*
* As a minimum, the path and type of each selected topic will be returned.
* It is also possible to request that the topic {@link withValues values}
* and/or {@link withProperties properties} are returned.
*
* If values are selected then the topic types selected are naturally
* constrained by the provided `dataType` argument. So if
* {@link DataTypes.string} is specified, only {@link TopicTypeEnum.STRING
* STRING} topics will be selected. However, if {@link DataTypes.json} is
* specified, all types compatible with {@link JSON} will be selected
* including {@link TopicTypeEnum.STRING STRING}, {@link TopicTypeEnum.INT64 INT64}
* and {@link TopicTypeEnum.DOUBLE DOUBLE}. See
* {@link DataType.canReadAs} for the class hierarchy of types.
*
* To select topic types when
* values are not required, or to further constrain the selection when
* values are required, it is also possible to specify exactly which
* {@link TopicTypeEnum topic types} to select.
*
* The topics selected by the topic selector can be further restricted by
* range. A range is defined by a start path and an end path, and contains
* all paths in-between in path order. Given a topic tree containing the
* topics:
*
* ```
* a, a/b, a/c, a/c/x, a/c/y, a/d, a/e, b, b/a/x, b/b/x, c
* ```
*
* The range from `a/c/y` to `b/a/x` includes the topics with paths:
*
* ```
* a/c/x, a/c/y, a/d, a/e, b, b/a/x
* ```
*
* The start point of a range can be specified using {@link from} or
* {@link after} and an end point using {@link to} or
* {@link before}. {@link from} and {@link to} include any
* topic with the specified path in the selection, whereas {@link after}
* and {@link before} are non-inclusive and useful for paging
* through a potentially large range of topics. If no start point is
* specified, the start point is assumed to be the first topic of the topic
* tree, ordered by path name. Similarly, if no end point is specified, the
* end point is the last topic of the topic tree.
*
* A limit on the number of results returned can be specified using
* {@link first}. This is advisable if the result set could
* potentially be large. The number of results returned is also limited by
* the session's maximum message size – see {@link maximumResultSize}. The
* result indicates whether the results have been limited via the
* {@link FetchResult.hasMore hasMore} method. If `hasMore()`
* returns `true`, further results can be retrieved by modifying the original
* query to request results {@link after} the last path received.
*
* By default, results are returned in path order, earliest path first,
* starting from the beginning of any range specified. It is also possible
* to request results from the end of the range indicated by specifying a
* limit to the number of results using {@link last}. This method
* complements {@link first}, returning up to the specified number of
* results from the end of the range, but in reverse path order. This is
* useful for paging backwards through a range of topics.
*
* It can be useful to explore an unknown topic tree in a breadth-first
* manner rather than the path order. This can be achieved using
* {@link limitDeepBranches}.
*
* FetchRequest instances are immutable and can be safely shared and reused.
*
* @since 6.2
*/
var FetchRequest = /** @class */ (function () {
function FetchRequest() {
}
/**
* Return a set of all topic types that can be fetched.
*
* @returns the topic types that can be fetched by a FetchRequest
*/
FetchRequest.getAllTypes = function () {
return new Set([
topic_type_1.TopicTypeEnum.JSON,
topic_type_1.TopicTypeEnum.BINARY,
topic_type_1.TopicTypeEnum.RECORD_V2,
topic_type_1.TopicTypeEnum.DOUBLE,
topic_type_1.TopicTypeEnum.INT64,
topic_type_1.TopicTypeEnum.STRING,
topic_type_1.TopicTypeEnum.TIME_SERIES
]);
};
return FetchRequest;
}());
exports.FetchRequest = FetchRequest;