UNPKG

ravendb

Version:
72 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SetIndexPriorityCommand = exports.SetIndexesPriorityOperation = void 0; const TypeUtil_js_1 = require("../../../Utility/TypeUtil.js"); 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 SetIndexesPriorityOperation { _parameters; constructor(paramsOrIndexName, priority) { if (TypeUtil_js_1.TypeUtil.isString(paramsOrIndexName)) { const indexName = paramsOrIndexName; if (!indexName) { (0, index_js_1.throwError)("InvalidArgumentException", "IndexName cannot be null."); } this._parameters = { indexNames: [indexName], priority }; } else { const parameters = paramsOrIndexName; if (!parameters) { (0, index_js_1.throwError)("InvalidArgumentException", "Parameters cannot be null."); } if (!parameters.indexNames || !parameters.indexNames.length) { (0, index_js_1.throwError)("InvalidArgumentException", "IndexNames cannot be null or empty."); } this._parameters = parameters; } } getCommand(conventions) { return new SetIndexPriorityCommand(conventions, this._parameters); } get resultType() { return "CommandResult"; } } exports.SetIndexesPriorityOperation = SetIndexesPriorityOperation; class SetIndexPriorityCommand extends RavenCommand_js_1.RavenCommand { _parameters; constructor(conventions, parameters) { super(); if (!conventions) { (0, index_js_1.throwError)("InvalidArgumentException", "Conventions cannot be null"); } if (!parameters) { (0, index_js_1.throwError)("InvalidArgumentException", "Parameters cannot be null"); } this._parameters = conventions.objectMapper.toObjectLiteral(parameters); } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/indexes/set-priority"; const body = this._serializer.serialize(this._parameters); const headers = this._headers() .typeAppJson().build(); return { uri, method: "POST", body, headers }; } get isReadRequest() { return false; } getRaftUniqueRequestId() { return RaftIdGenerator_js_1.RaftIdGenerator.newId(); } } exports.SetIndexPriorityCommand = SetIndexPriorityCommand; //# sourceMappingURL=SetIndexesPriorityOperation.js.map