ravendb
Version:
RavenDB client for Node.js
61 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PutServerWideSortersOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const RaftIdGenerator_js_1 = require("../../../Utility/RaftIdGenerator.js");
class PutServerWideSortersOperation {
_sortersToAdd;
constructor(...sortersToAdd) {
if (!sortersToAdd || sortersToAdd.length === 0) {
(0, index_js_1.throwError)("InvalidArgumentException", "SortersToAdd cannot be null or empty");
}
this._sortersToAdd = sortersToAdd;
}
getCommand(conventions) {
return new PutServerWideSortersCommand(conventions, this._sortersToAdd);
}
get resultType() {
return "CommandResult";
}
}
exports.PutServerWideSortersOperation = PutServerWideSortersOperation;
class PutServerWideSortersCommand extends RavenCommand_js_1.RavenCommand {
_sortersToAdd;
constructor(conventions, sortersToAdd) {
super();
if (!conventions) {
(0, index_js_1.throwError)("InvalidArgumentException", "Conventions cannot be null");
}
if (!sortersToAdd) {
(0, index_js_1.throwError)("InvalidArgumentException", "SortersToAdd cannot be null");
}
this._sortersToAdd = sortersToAdd.map(x => {
if (!x.name) {
(0, index_js_1.throwError)("InvalidArgumentException", "Sorter name cannot be null");
}
return conventions.objectMapper.toObjectLiteral(x);
});
}
createRequest(node) {
const uri = node.url + "/admin/sorters";
const headers = this._headers()
.typeAppJson().build();
const body = this._serializer.serialize({
Sorters: this._sortersToAdd
});
return {
uri,
method: "PUT",
headers,
body
};
}
get isReadRequest() {
return false;
}
getRaftUniqueRequestId() {
return RaftIdGenerator_js_1.RaftIdGenerator.newId();
}
}
//# sourceMappingURL=PutServerWideSortersOperation.js.map