@configurator/ravendb
Version:
RavenDB client for Node.js
48 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetDatabaseTopologyCommand = void 0;
const RavenCommand_1 = require("../../Http/RavenCommand");
const ServerNode_1 = require("../../Http/ServerNode");
const Topology_1 = require("../../Http/Topology");
class GetDatabaseTopologyCommand extends RavenCommand_1.RavenCommand {
constructor(debugTag, applicationIdentifier) {
super();
this._debugTag = debugTag;
this._applicationIdentifier = applicationIdentifier;
this.timeout = 15000;
}
createRequest(node) {
let uri = `${node.url}/topology?name=${node.database}`;
if (node.url.toLowerCase().indexOf(".fiddler") !== -1) {
uri += "&localUrl=" + encodeURIComponent(node.url);
}
if (this._debugTag) {
uri += "&" + this._debugTag;
}
if (this._applicationIdentifier) {
uri += "&applicationIdentifier=" + this._urlEncode(this._applicationIdentifier);
}
return { uri };
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
return;
}
let body = null;
const rawTpl = await this._pipeline()
.collectBody(_ => body = _)
.parseJsonSync()
.objectKeysTransform("camel")
.process(bodyStream);
const nodes = rawTpl.nodes
? rawTpl.nodes.map(x => Object.assign(new ServerNode_1.ServerNode(), x))
: null;
this.result = new Topology_1.Topology(rawTpl.etag, nodes);
return body;
}
get isReadRequest() {
return true;
}
}
exports.GetDatabaseTopologyCommand = GetDatabaseTopologyCommand;
//# sourceMappingURL=GetDatabaseTopologyCommand.js.map