ravendb
Version:
RavenDB client for Node.js
66 lines • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PutServerWideAnalyzersOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const HttpUtil_js_1 = require("../../../Utility/HttpUtil.js");
const RaftIdGenerator_js_1 = require("../../../Utility/RaftIdGenerator.js");
class PutServerWideAnalyzersOperation {
_analyzersToAdd;
constructor(...analyzersToAdd) {
if (!analyzersToAdd || analyzersToAdd.length === 0) {
(0, index_js_1.throwError)("InvalidArgumentException", "AnalyzersToAdd cannot be null or empty");
}
this._analyzersToAdd = analyzersToAdd;
}
getCommand(conventions) {
return new PutServerWideAnalyzersCommand(conventions, this._analyzersToAdd);
}
get resultType() {
return "CommandResult";
}
}
exports.PutServerWideAnalyzersOperation = PutServerWideAnalyzersOperation;
class PutServerWideAnalyzersCommand extends RavenCommand_js_1.RavenCommand {
_analyzersToAdd;
constructor(conventions, analyzersToAdd) {
super();
if (!conventions) {
(0, index_js_1.throwError)("InvalidArgumentException", "Conventions cannot be null");
}
if (!analyzersToAdd) {
(0, index_js_1.throwError)("InvalidArgumentException", "Analyzers to add cannot be null");
}
this._analyzersToAdd = [];
for (const analyzerDefinition of analyzersToAdd) {
if (!analyzerDefinition.name) {
(0, index_js_1.throwError)("InvalidArgumentException", "Name cannot be null");
}
this._analyzersToAdd.push(conventions.objectMapper.toObjectLiteral(analyzerDefinition));
}
}
createRequest(node) {
const uri = node.url + "/admin/analyzers";
const headers = HttpUtil_js_1.HeadersBuilder
.create()
.typeAppJson()
.build();
const body = this._serializer
.serialize({
Analyzers: this._analyzersToAdd
});
return {
uri,
method: "PUT",
headers,
body
};
}
get isReadRequest() {
return false;
}
getRaftUniqueRequestId() {
return RaftIdGenerator_js_1.RaftIdGenerator.newId();
}
}
//# sourceMappingURL=PutServerWideAnalyzersOperation.js.map