ravendb
Version:
RavenDB client for Node.js
62 lines • 2.12 kB
JavaScript
import { throwError } from "../../../Exceptions/index.js";
import { RavenCommand } from "../../../Http/RavenCommand.js";
import { HeadersBuilder } from "../../../Utility/HttpUtil.js";
import { RaftIdGenerator } from "../../../Utility/RaftIdGenerator.js";
export class PutServerWideAnalyzersOperation {
_analyzersToAdd;
constructor(...analyzersToAdd) {
if (!analyzersToAdd || analyzersToAdd.length === 0) {
throwError("InvalidArgumentException", "AnalyzersToAdd cannot be null or empty");
}
this._analyzersToAdd = analyzersToAdd;
}
getCommand(conventions) {
return new PutServerWideAnalyzersCommand(conventions, this._analyzersToAdd);
}
get resultType() {
return "CommandResult";
}
}
class PutServerWideAnalyzersCommand extends RavenCommand {
_analyzersToAdd;
constructor(conventions, analyzersToAdd) {
super();
if (!conventions) {
throwError("InvalidArgumentException", "Conventions cannot be null");
}
if (!analyzersToAdd) {
throwError("InvalidArgumentException", "Analyzers to add cannot be null");
}
this._analyzersToAdd = [];
for (const analyzerDefinition of analyzersToAdd) {
if (!analyzerDefinition.name) {
throwError("InvalidArgumentException", "Name cannot be null");
}
this._analyzersToAdd.push(conventions.objectMapper.toObjectLiteral(analyzerDefinition));
}
}
createRequest(node) {
const uri = node.url + "/admin/analyzers";
const headers = 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.newId();
}
}
//# sourceMappingURL=PutServerWideAnalyzersOperation.js.map