UNPKG

ravendb

Version:
57 lines 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PutSortersOperation = 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 PutSortersOperation { _sortersToAdd; constructor(...sortersToAdd) { if (!sortersToAdd || !sortersToAdd.length) { (0, index_js_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_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"); } if (sortersToAdd.some(x => !x)) { (0, index_js_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_js_1.RaftIdGenerator.newId(); } } //# sourceMappingURL=PutSortersOperation.js.map