UNPKG

ravendb

Version:
57 lines 1.88 kB
import { throwError } from "../../../Exceptions/index.js"; import { RavenCommand } from "../../../Http/RavenCommand.js"; import { RaftIdGenerator } from "../../../Utility/RaftIdGenerator.js"; export class PutServerWideSortersOperation { _sortersToAdd; constructor(...sortersToAdd) { if (!sortersToAdd || sortersToAdd.length === 0) { throwError("InvalidArgumentException", "SortersToAdd cannot be null or empty"); } this._sortersToAdd = sortersToAdd; } getCommand(conventions) { return new PutServerWideSortersCommand(conventions, this._sortersToAdd); } get resultType() { return "CommandResult"; } } class PutServerWideSortersCommand extends RavenCommand { _sortersToAdd; constructor(conventions, sortersToAdd) { super(); if (!conventions) { throwError("InvalidArgumentException", "Conventions cannot be null"); } if (!sortersToAdd) { throwError("InvalidArgumentException", "SortersToAdd cannot be null"); } this._sortersToAdd = sortersToAdd.map(x => { if (!x.name) { 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.newId(); } } //# sourceMappingURL=PutServerWideSortersOperation.js.map