UNPKG

@configurator/ravendb

Version:
55 lines 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PutSortersOperation = void 0; const Exceptions_1 = require("../../../Exceptions"); const RavenCommand_1 = require("../../../Http/RavenCommand"); const RaftIdGenerator_1 = require("../../../Utility/RaftIdGenerator"); class PutSortersOperation { constructor(...sortersToAdd) { if (!sortersToAdd || !sortersToAdd.length) { (0, Exceptions_1.throwError)("InvalidArgumentException", "SortersToAdd cannot be null or empty"); } this._sortersToAdd = sortersToAdd; } get resultType() { return "CommandResult"; } getCommand(conventions) { return new PutSortersCommand(conventions, this._sortersToAdd); } } exports.PutSortersOperation = PutSortersOperation; class PutSortersCommand extends RavenCommand_1.RavenCommand { constructor(conventions, sortersToAdd) { super(); if (!conventions) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Conventions cannot be null"); } if (!sortersToAdd) { (0, Exceptions_1.throwError)("InvalidArgumentException", "SortersToAdd cannot be null"); } if (sortersToAdd.findIndex(x => !x) > -1) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Sorter cannot be null"); } this._sortersToAdd = sortersToAdd; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/admin/sorters"; const body = this._serializer.serialize({ sorters: this._sortersToAdd }); return { uri, method: "PUT", headers: this._headers().typeAppJson().build(), body }; } get isReadRequest() { return false; } getRaftUniqueRequestId() { return RaftIdGenerator_1.RaftIdGenerator.newId(); } } //# sourceMappingURL=PutSortersOperation.js.map